门户查询最新及最热能力

This commit is contained in:
DingGang 2022-04-23 18:51:52 +08:00
parent d70cb67c06
commit c28ec496f1
5 changed files with 57 additions and 0 deletions

View File

@ -92,6 +92,21 @@ public class ResourceController {
return new Result<>().ok(resourceService.selectTotal());
}
@GetMapping("/selectNewest")
@ApiOperation("查询最新上架能力")
@LogOperation("查询最新上架能力")
public Result selectNewest(@RequestBody JSONObject jsonObject){
return new Result<>().ok(resourceService.selectNewest(jsonObject));
}
@GetMapping("/selectMostPopular")
@ApiOperation("查询热门能力")
@LogOperation("查询热门能力")
public Result selectMostPopular(@RequestBody JSONObject jsonObject){
return new Result<>().ok(resourceService.selectMostPopular(jsonObject));
}
@PostMapping("/insert")
@ApiOperation("保存")

View File

@ -23,4 +23,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO);
List<Map> selectTypeCount(Long deptId);
List<ResourceDTO> selectMostPopular();
}

View File

@ -34,4 +34,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
void getDevelopmentFile(HttpServletRequest request, HttpServletResponse response) throws Exception;
Object selectNewest(JSONObject jsonObject);
Object selectMostPopular(JSONObject jsonObject);
}

View File

@ -231,4 +231,19 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
System.err.println("获取开发指南成功!!!");
}
@Override
public Object selectNewest(JSONObject jsonObject) {
QueryWrapper<ResourceEntity> queryWrapper = new QueryWrapper<>();
queryWrapper.orderByDesc("create_date")
.eq(StringUtils.isNotBlank(jsonObject.getString("type")),"type", jsonObject.getString("type"));
return resourceDao.selectList(queryWrapper);
}
@Override
public Object selectMostPopular(JSONObject jsonObject) {
resourceDao.selectMostPopular();
return null;
}
}

View File

@ -132,4 +132,26 @@
group by type
order by type
</select>
<select id="selectMostPopular" resultType="io.renren.modules.resource.dto.ResourceDTO">
SELECT
tdr.id,
tdr.dept_id,
tdr.description,
tdr.downloads,
tdr.visits,
trs.score,
taa.applyCount,
(IFNULL(downloads, 0) + IFNULL(visits, 0) + IFNULL(trs.score, 0) + IFNULL(applyCount,0)) as total
FROM
tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, SUM( score ) AS "score" FROM tb_resource_score WHERE del_flag = 0 GROUP BY resource_id ) trs ON tdr.id = trs.resource_id
LEFT JOIN ( SELECT resource_id, COUNT(id) AS "applyCount" FROM t_ability_application WHERE del_flag = 0 GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
WHERE
1 = 1
AND tdr.id = trs.resource_id
AND tdr.del_flag = 0
ORDER BY downloads DESC
</select>
</mapper>