Merge branch 'dev'

This commit is contained in:
wangliwen 2022-10-20 11:51:38 +08:00
commit e83f712193
5 changed files with 214 additions and 0 deletions

View File

@ -641,4 +641,34 @@ public class ResourceController {
} }
@GetMapping("/getPraiseList")
@ApiOperation("获取好评榜")
@LogOperation("获取好评榜")
public Result getPraiseList() {
return new Result<>().ok(resourceService.getPraiseList());
}
@GetMapping("/getPopularList")
@ApiOperation("获取热门榜")
@LogOperation("获取热门榜")
public Result getPopularList() {
return new Result<>().ok(resourceService.getPopularList());
}
@GetMapping("/getStarList")
@ApiOperation("获取明星榜")
@LogOperation("获取明星榜")
public Result getStarList() {
return new Result<>().ok(resourceService.getStarList());
}
@GetMapping("/getPotentialList")
@ApiOperation("获取潜力榜")
@LogOperation("获取潜力榜")
public Result getPotentialList() {
return new Result<>().ok(resourceService.getPotentialList());
}
} }

View File

@ -197,4 +197,12 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
List<Map> selectCollectList(@Param("resourceType") String resourceType, @Param("attrType") String attrType); List<Map> selectCollectList(@Param("resourceType") String resourceType, @Param("attrType") String attrType);
List<Map> selectCollectResourceList(); List<Map> selectCollectResourceList();
List<Map> getPraiseList();
List<Map> getPopularList(@Param("startDate") String startDate);
List<Map> getPotentialList(@Param("halfMonthDay") String halfMonthDay, @Param("monthDay") String monthDay);
List<Map> getStarList();
} }

View File

@ -149,4 +149,12 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectCensusResourceTable(Map params); Object selectCensusResourceTable(Map params);
Object selectCensusApplyTable(Map params); Object selectCensusApplyTable(Map params);
Object getPraiseList();
Object getPopularList();
Object getStarList();
Object getPotentialList();
} }

View File

@ -1,5 +1,6 @@
package io.renren.modules.resource.service.impl; package io.renren.modules.resource.service.impl;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -2311,4 +2312,29 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
return new PageData(result, dtoList.size()); return new PageData(result, dtoList.size());
} }
@Override
public Object getPraiseList() {
return resourceDao.getPraiseList();
}
@Override
public Object getPopularList() {
String start = DateUtil.lastMonth().toDateStr() + " 00:00:00";
return resourceDao.getPopularList(start);
}
@Override
public Object getStarList() {
return resourceDao.getStarList();
}
@Override
public Object getPotentialList() {
String halfMonthDay = DateUtil.offsetDay(new Date(), -15).toDateStr() + " 00:00:00";
String monthDay = DateUtil.offsetDay(new Date(), -30).toDateStr() + " 00:00:00";
List<Map> potentialList = resourceDao.getPotentialList(halfMonthDay, monthDay);
return potentialList;
}
} }

View File

@ -1982,4 +1982,146 @@
GROUP BY tda.attr_value GROUP BY tda.attr_value
ORDER BY count DESC ORDER BY count DESC
</select> </select>
<select id="getPraiseList" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.NAME AS "resourceName",
IFNULL( AVG( trs.score ), 3 ) AS "score",
tdr.create_date AS "createDate"
FROM
tb_data_resource tdr LEFT JOIN
tb_resource_score trs ON tdr.id = trs.resource_id
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type IN('组件服务', '应用资源')
GROUP BY
resourceId
ORDER BY
score DESC, createDate
LIMIT 10
</select>
<select id="getPopularList" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.NAME AS "resourceName",
IFNULL(taa.applyCount, 0) AS "applyCount",
IFNULL(trc.collectCount, 0) AS "collectCount",
IFNULL(trb.browseCount, 0) AS "browseCount",
tdr.create_date
FROM
tb_data_resource tdr
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "applyCount" FROM t_ability_application WHERE 1 = 1 AND del_flag
= 0 AND create_date > #{startDate} GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN ( SELECT resource_id, COUNT( id ) AS "collectCount" FROM tb_resource_collection WHERE 1 = 1 AND
del_flag = 0 AND create_date > #{startDate} GROUP BY resource_id ) trc ON tdr.id = trc.resource_id
LEFT JOIN (SELECT resource_id, COUNT(id) AS "browseCount" FROM tb_resource_browse WHERE 1 = 1
AND create_date > #{startDate} GROUP BY resource_id) trb ON tdr.id = trb.resource_id
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type IN('组件服务', '应用资源')
ORDER BY
applyCount DESC,
collectCount DESC,
browseCount DESC,
tdr.create_date
LIMIT 10
</select>
<select id="getPotentialList" resultType="java.util.Map">
SELECT
tdr.id AS "resourceId",
tdr.`name` AS "resourceName",
IF(temp2.oneCount IS NULL, '1' , '0') AS "isNew",
IFNULL(temp1.halfCount, 0) AS "halfMonthCount",
IFNULL(temp2.oneCount, 0) AS "lastMonthCount",
(IFNULL(temp1.halfCount, 0) - IFNULL(temp2.oneCount, 0)) / IFNULL(temp2.oneCount, 0) AS "growthRate",
tdr.create_date
FROM
tb_data_resource tdr
LEFT JOIN (
SELECT
COUNT( id ) AS "halfCount",
resource_id
FROM
t_ability_application taa
WHERE
1 = 1
AND del_flag = 0
AND camera_list IS NULL
AND create_date >= #{halfMonthDay}
GROUP BY
resource_id
) temp1 ON tdr.id = temp1.resource_id
LEFT JOIN (
SELECT
COUNT( id ) AS "oneCount",
resource_id
FROM
t_ability_application taa
WHERE
1 = 1
AND del_flag = 0
AND camera_list IS NULL
AND #{halfMonthDay} > create_date AND create_date >= #{monthDay}
GROUP BY
resource_id
) temp2 ON tdr.id = temp2.resource_id
WHERE
1 = 1
AND tdr.del_flag = 0
AND tdr.type IN ('组件服务', '应用资源')
ORDER BY isNew DESC, halfMonthCount DESC, create_date DESC, growthRate DESC
LIMIT 10
</select>
<select id="getStarList" resultType="java.util.Map">
SELECT list.resourceId,
list.resourceName,
(list.applyNum + list.browseNum + list.collectNum + list.scoreNum) AS "fireNum",
list.create_date AS "createDate"
FROM (
SELECT
tdr.id AS "resourceId",
tdr.name AS "resourceName",
IFNULL((taa.count / temp1.maxApplyCount), 0) * 1.5 AS "applyNum",
IFNULL((trc.count / temp2.maxCopllectCount), 0) * 1 AS "collectNum",
IFNULL((trb.count / temp3.maxBrowseCount), 0) * 0.5 AS "browseNum",
IFNULL((trs.score / temp4.maxScore), 0 ) * 2 AS "scoreNum",
tdr.create_date
FROM
tb_data_resource tdr
LEFT JOIN (SELECT COUNT(id) AS "count", resource_id FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND camera_list IS NULL GROUP BY resource_id ) taa ON tdr.id = taa.resource_id
LEFT JOIN (SELECT COUNT(id) AS "count", resource_id FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id) trc
ON tdr.id = trc.resource_id
LEFT JOIN (SELECT COUNT(id) AS "count", resource_id FROM tb_resource_browse WHERE 1 = 1 GROUP BY resource_id) trb
ON tdr.id = trb.resource_id
LEFT JOIN (SELECT AVG(score) AS "score", resource_id FROM tb_resource_score WHERE 1 = 1 GROUP BY resource_id) trs
ON tdr.id = trs.resource_id
JOIN (SELECT IFNULL(MAX(count), 0) AS "maxApplyCount" FROM (SELECT COUNT(id) AS "count" FROM t_ability_application WHERE 1 = 1 AND del_flag = 0 AND camera_list IS NULL GROUP BY resource_id ) taa) temp1
JOIN (SELECT IFNULL(MAX(count), 0) AS "maxCopllectCount" FROM(SELECT COUNT(id) AS "count" FROM tb_resource_collection WHERE 1 = 1 AND del_flag = 0 GROUP BY resource_id)trc) temp2
JOIN (SELECT IFNULL(MAX(count), 0) AS "maxBrowseCount" FROM(SELECT COUNT(id) AS "count" FROM tb_resource_browse WHERE 1 = 1 GROUP BY resource_id) trb) temp3
JOIN (SELECT IFNULL(MAX(score), 0) AS "maxScore" FROM(SELECT AVG(score) AS "score" FROM tb_resource_score WHERE 1 = 1 GROUP BY resource_id) trs) temp4
WHERE 1 = 1
AND tdr.del_flag = 0
AND tdr.type IN ('组件服务', '应用资源')
)list
ORDER BY fireNum DESC, create_date DESC LIMIT 10
</select>
</mapper> </mapper>