Merge branch 'master' into docker_package

This commit is contained in:
wangliwen 2022-07-19 11:46:08 +08:00
commit 75e84b35d9
5 changed files with 71 additions and 3 deletions

View File

@ -14,6 +14,7 @@ import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel;
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.security.user.SecurityUser;
import io.renren.modules.security.user.UserDetail;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -57,12 +58,27 @@ public class ResourceBrowseController {
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "name", value = "关键字", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "type",value = "查询类型(组件服务 应用资源 知识库)", paramType = "query", dataType = "String"),
})
//@RequiresPermissions("resourceBrowse:resourcebrowse:page")
public Result<PageData<ResourceBrowseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
PageData<ResourceBrowseDTO> page = resourceBrowseService.page(params);
page.getList().forEach(item -> item.setResourceDTO(resourceService.get(item.getResourceId())));
return new Result<PageData<ResourceBrowseDTO>>().ok(page);
UserDetail user = SecurityUser.getUser();
if(user == null){
return new Result<>();
}else{
Long id = user.getId();
params.put("userId",id);
}
Integer page = Integer.parseInt(params.get("page").toString()) - 1;
Integer pageSize = Integer.parseInt(params.get("limit").toString());
params.put("pageNum",page);
params.put("pageSize",pageSize);
//PageData<ResourceBrowseDTO> page = resourceBrowseService.page(params);
PageData<ResourceBrowseDTO> pageData = resourceBrowseService.selectResourceBrowseByTypeAndUser(params);
pageData.getList().forEach(item -> item.setResourceDTO(resourceService.get(item.getResourceId())));
return new Result<PageData<ResourceBrowseDTO>>().ok(pageData);
}
@GetMapping("/select/{id}")

View File

@ -1,6 +1,7 @@
package io.renren.modules.resourceBrowse.dao;
import io.renren.common.dao.BaseDao;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -22,4 +23,7 @@ public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> {
Integer selectDayMax();
List<Map> selectDayList(@Param("startDate") String startDate,@Param("endDate") String endDate);
List<ResourceBrowseDTO> selectResourceBrowseByTypeAndUser(@Param("params") Map<String,Object> params);
Integer resourceBrowseDTOCount(@Param("params") Map<String,Object> params);
}

View File

@ -1,9 +1,13 @@
package io.renren.modules.resourceBrowse.service;
import io.renren.common.page.PageData;
import io.renren.common.service.CrudService;
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
import java.util.List;
import java.util.Map;
/**
* 浏览记录
*
@ -17,4 +21,6 @@ public interface ResourceBrowseService extends CrudService<ResourceBrowseEntity,
Object selectDayMax();
Object selectDayList(String startDate, String endDate);
PageData<ResourceBrowseDTO> selectResourceBrowseByTypeAndUser(Map<String,Object> map);
}

View File

@ -1,6 +1,7 @@
package io.renren.modules.resourceBrowse.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.page.PageData;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.utils.DateUtils;
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
@ -10,6 +11,7 @@ import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
import io.renren.modules.security.user.SecurityUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import java.util.*;
@ -75,4 +77,12 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao
}
return resultMap;
}
@Override
public PageData<ResourceBrowseDTO> selectResourceBrowseByTypeAndUser(Map<String, Object> map) {
Integer total = resourceBrowseDao.resourceBrowseDTOCount(map);
List<ResourceBrowseDTO> list = resourceBrowseDao.selectResourceBrowseByTypeAndUser(map);
PageData<ResourceBrowseDTO> pageData = new PageData<ResourceBrowseDTO>(list,total);
return pageData;
}
}

View File

@ -52,4 +52,36 @@
SUBSTR(create_date, 1, 10)
</select>
<select id="selectResourceBrowseByTypeAndUser" parameterType="java.util.Map" resultType="io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO">
SELECT a.* FROM tb_resource_browse a INNER JOIN tb_data_resource b ON a.resource_id = b.id
WHERE a.state = 0
<if test="params.type != null and params.type != ''">
AND b.type = #{params.type}
</if>
<if test="params.name != null and params.name != ''">
AND (b.name LIKE(CONCAT('%',CONCAT(trim(#{params.name}),'%'))) OR b.type LIKE(CONCAT('%',CONCAT(trim(#{params.name}),'%'))) OR b.description LIKE(CONCAT('%',CONCAT(trim(#{params.name}),'%'))))
</if>
AND b.del_flag = 0
<choose>
<when test="params.orderField != null and params.orderField != null and params.order != null and params.order != ''">
ORDER BY ${params.orderField} ${params.order}
</when>
<otherwise>
ORDER BY create_date desc
</otherwise>
</choose>
LIMIT ${params.pageNum}, ${params.pageSize}
</select>
<select id="resourceBrowseDTOCount" parameterType="java.util.Map" resultType="java.lang.Integer">
SELECT COUNT(a.id) AS total FROM tb_resource_browse a INNER JOIN tb_data_resource b ON a.resource_id = b.id
WHERE a.state = 0
<if test="params.type != null and params.type != ''">
AND b.type = #{params.type}
</if>
<if test="params.name != null and params.name != ''">
AND (b.name LIKE(CONCAT('%',CONCAT(trim(#{params.name}),'%'))) OR b.type LIKE(CONCAT('%',CONCAT(trim(#{params.name}),'%'))) OR b.description LIKE(CONCAT('%',CONCAT(trim(#{params.name}),'%'))))
</if>
AND b.del_flag = 0
</select>
</mapper>