parent
b004dd4cb5
commit
db289ca6d3
@ -0,0 +1,39 @@
|
||||
package com.zh.project0512.controller.wxApp;
|
||||
|
||||
import com.zh.project0512.model.dto.RankListDTO;
|
||||
import com.zh.project0512.model.vo.RankListVo;
|
||||
import com.zh.project0512.service.IRankService;
|
||||
import com.zh.project0512.utils.result.ResultList;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 首页排行榜
|
||||
*/
|
||||
@Tag(name = "首页")
|
||||
@RestController
|
||||
@RequestMapping("/wxApp/ks")
|
||||
public class RankController {
|
||||
@Resource
|
||||
IRankService rankService;
|
||||
|
||||
/**
|
||||
* 查询排行榜列表
|
||||
* @param rankListDTO 排行列表DTO
|
||||
* @return 排行榜列表
|
||||
*/
|
||||
@Operation(summary = "排行列表")
|
||||
@PostMapping("/list")
|
||||
public ResultList<RankListVo> rankList(@Validated RankListDTO rankListDTO){
|
||||
return ResultList.success(rankService.rankList(rankListDTO),"请求成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.zh.project0512.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.zh.project0512.model.QywxDepartmentUserLink;
|
||||
import com.zh.project0512.model.Reference;
|
||||
import com.zh.project0512.model.dto.RankListDTO;
|
||||
import com.zh.project0512.model.vo.RankListVo;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface QywxDepartmentUserLinkMapper extends BaseMapper<QywxDepartmentUserLink> {
|
||||
List<RankListVo> rankListPage(IPage<Reference> page, @Param("ew") Wrapper<RankListDTO> queryWrapper);
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.zh.project0512.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 企业微信部门用户关联表
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class QywxDepartmentUserLink implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 用户主键id
|
||||
*/
|
||||
private Integer userId;
|
||||
/**
|
||||
* 部门主键id
|
||||
*/
|
||||
private Integer departmentId;
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.zh.project0512.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 排行列表 Vo
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class RankListVo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 标题
|
||||
*/
|
||||
private String title;
|
||||
/**
|
||||
* 副标题
|
||||
*/
|
||||
private String subtitle;
|
||||
/**
|
||||
* 传播值
|
||||
*/
|
||||
private int value;
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package com.zh.project0512.service;
|
||||
|
||||
import com.zh.project0512.model.dto.RankListDTO;
|
||||
import com.zh.project0512.model.vo.RankListVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IRankService {
|
||||
/**
|
||||
* 查询排行榜列表
|
||||
* @param rankListDTO 排行列表DTO
|
||||
* @return 排行列表 Vo
|
||||
*/
|
||||
List<RankListVo> rankList(RankListDTO rankListDTO);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.zh.project0512.serviceImpl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.zh.project0512.mapper.QywxDepartmentUserLinkMapper;
|
||||
import com.zh.project0512.model.dto.RankListDTO;
|
||||
import com.zh.project0512.model.vo.RankListVo;
|
||||
import com.zh.project0512.service.IRankService;
|
||||
import com.zh.project0512.utils.MybatisPlusUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class RankServiceImpl implements IRankService {
|
||||
@Resource
|
||||
QywxDepartmentUserLinkMapper qywxDepartmentUserLinkMapper;
|
||||
|
||||
@Override
|
||||
public List<RankListVo> rankList(RankListDTO rankListDTO) {
|
||||
QueryWrapper<RankListDTO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.groupBy("u.id");
|
||||
queryWrapper.orderByDesc("value");
|
||||
List<RankListVo> rankListVoList = qywxDepartmentUserLinkMapper.rankListPage(MybatisPlusUtil.SetNumPage(rankListDTO.getPageNum(), rankListDTO.getSize()),queryWrapper);
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zh.project0512.mapper.QywxDepartmentUserLinkMapper">
|
||||
<select id="rankListPage" resultType="com.zh.project0512.model.vo.RankListVo">
|
||||
select u.id,u.name as title,
|
||||
(sum(IFNULL(v.playNum,0))+sum(IFNULL(v.commendNum,0))+sum(IFNULL(v.collectionNum,0))+sum(IFNULL(v.commentNum,0))) as value
|
||||
from user as u
|
||||
LEFT JOIN video as v ON u.id = v.userId
|
||||
<if test='ew != null'>
|
||||
${ew.SqlSegment}
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in new issue