Merge remote-tracking branch 'origin/master'

This commit is contained in:
wangliwen 2022-04-28 21:35:38 +08:00
commit 7da01b64ad
6 changed files with 66 additions and 6 deletions

View File

@ -49,10 +49,8 @@ public class ResourceController {
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "creator", value = "创建者用户id", paramType = "query", dataType = "String")
})
//@RequiresPermissions("resource:resource:page")
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
//ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class);
//resourceService.pageWithAttrs(resourceDTO);
params.put("del_flag", 0);
PageData<ResourceDTO> page = resourceService.page(params);
page.getList().forEach(item -> {
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
@ -97,6 +95,13 @@ public class ResourceController {
return new Result<>().ok(resourceService.selectMostPopular(jsonObject));
}
@GetMapping("/selectRecommend")
@ApiOperation("根据用户查询推荐能力")
@LogOperation("根据用户查询推荐能力")
public Result selectRecommend() {
return new Result<>().ok(resourceService.selectRecommend());
}
@GetMapping("/updateVisits")
@ApiOperation("更新能力访问量")
@LogOperation("更新能力访问量")

View File

@ -35,4 +35,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
@Param("pageSize") Integer pageSize,
@Param("orderField")String orderField,
@Param("orderType") String orderType);
List<Map> selectApplyArea(Long userId);
}

View File

@ -35,4 +35,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
Object selectMostPopular(JSONObject jsonObject);
void updateVisits(Long id);
Object selectRecommend();
}

View File

@ -151,7 +151,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
item.setInfoList(this.selectAttrsByResourceId(item.getId()));
});
resultPage.setRecords(resourceDTOS);
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 1, 100000, orderField, orderType).size());
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size());
} else {
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
int j = Math.min(pageNum * pageSize, resourceDTOS.size());
@ -227,4 +227,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
.eq(ResourceEntity::getDelFlag, 0);
resourceDao.update(entity, updateWrapper);
}
@Override
public Object selectRecommend() {
Long userId = SecurityUser.getUser().getId();
//根据用户收藏和申请数据查出应用领域排名在根据应用领域查询热门能力推荐给用户
List<Map> applyAreaList = resourceDao.selectApplyArea(userId);
//1.没有收藏和申请过按最热能力选取
if (applyAreaList.isEmpty()) {
}
return null;
}
}

View File

@ -12,6 +12,7 @@ import io.renren.modules.resourceCar.entity.ResourceCarEntity;
import io.renren.modules.resourceCar.service.ResourceCarService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -43,8 +44,10 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
@Override
public void deleteByIds(JSONObject jsonObject) {
List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class);
resourceCarDao.deleteByIds(ids);
if (ObjectUtils.allNotNull(jsonObject.getJSONArray("ids"))) {
List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class);
resourceCarDao.deleteByIds(ids);
}
}
@Override

View File

@ -254,4 +254,38 @@
ORDER BY ${orderField} ${orderType}
LIMIT ${pageNum}, ${pageSize}
</select>
<select id="selectApplyArea" resultType="java.util.Map">
SELECT
*
FROM
(
SELECT
attr_value,
IFNULL( COUNT( trc.id ), 0 ) AS "colCount",
IFNULL( COUNT( taa.id ), 0 ) AS "aplCount",
(
IFNULL( COUNT( trc.id ), 0 ) + IFNULL( COUNT( taa.id ), 0 )) AS total
FROM
tb_data_attr tda
LEFT JOIN tb_resource_collection trc ON tda.data_resource_id = trc.resource_id
AND trc.del_flag = 0
AND trc.user_id = #{userId}
LEFT JOIN t_ability_application taa ON tda.data_resource_id = taa.resource_id
AND taa.del_flag = 0
AND taa.user_id = #{userId}
WHERE
1 = 1
AND tda.attr_type = '应用领域'
AND tda.del_flag = 0
AND ( attr_value != '' AND attr_value IS NOT NULL )
GROUP BY
attr_value
ORDER BY
total DESC
) temp
WHERE
temp.total != 0
</select>
</mapper>