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

View File

@ -35,4 +35,6 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
@Param("pageSize") Integer pageSize, @Param("pageSize") Integer pageSize,
@Param("orderField")String orderField, @Param("orderField")String orderField,
@Param("orderType") String orderType); @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); Object selectMostPopular(JSONObject jsonObject);
void updateVisits(Long id); 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())); item.setInfoList(this.selectAttrsByResourceId(item.getId()));
}); });
resultPage.setRecords(resourceDTOS); resultPage.setRecords(resourceDTOS);
resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 1, 100000, orderField, orderType).size()); resultPage.setTotal(resourceDao.selectDTOPage(resourceDTO, 0, 100000, orderField, orderType).size());
} else { } else {
List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType); List<ResourceDTO> resourceDTOS = resourceDao.selectWithAttrs(resourceDTO, orderField, orderType);
int j = Math.min(pageNum * pageSize, resourceDTOS.size()); int j = Math.min(pageNum * pageSize, resourceDTOS.size());
@ -227,4 +227,17 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
.eq(ResourceEntity::getDelFlag, 0); .eq(ResourceEntity::getDelFlag, 0);
resourceDao.update(entity, updateWrapper); 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.resourceCar.service.ResourceCarService;
import io.renren.modules.security.user.SecurityUser; import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail; import io.renren.modules.security.user.UserDetail;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -43,8 +44,10 @@ public class ResourceCarServiceImpl extends CrudServiceImpl<ResourceCarDao, Reso
@Override @Override
public void deleteByIds(JSONObject jsonObject) { public void deleteByIds(JSONObject jsonObject) {
List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class); if (ObjectUtils.allNotNull(jsonObject.getJSONArray("ids"))) {
resourceCarDao.deleteByIds(ids); List<Long> ids = jsonObject.getJSONArray("ids").toJavaList(Long.class);
resourceCarDao.deleteByIds(ids);
}
} }
@Override @Override

View File

@ -254,4 +254,38 @@
ORDER BY ${orderField} ${orderType} ORDER BY ${orderField} ${orderType}
LIMIT ${pageNum}, ${pageSize} LIMIT ${pageNum}, ${pageSize}
</select> </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> </mapper>