1、修改个人中心-我的浏览接口
This commit is contained in:
parent
b23afc8029
commit
b3e4b77447
|
@ -14,6 +14,7 @@ import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
|
||||||
import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel;
|
import io.renren.modules.resourceBrowse.excel.ResourceBrowseExcel;
|
||||||
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
|
import io.renren.modules.resourceBrowse.service.ResourceBrowseService;
|
||||||
import io.renren.modules.security.user.SecurityUser;
|
import io.renren.modules.security.user.SecurityUser;
|
||||||
|
import io.renren.modules.security.user.UserDetail;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
import io.swagger.annotations.ApiImplicitParams;
|
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.LIMIT, value = "每页显示记录数", paramType = "query", required = true, dataType = "int"),
|
||||||
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"),
|
||||||
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", 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")
|
//@RequiresPermissions("resourceBrowse:resourcebrowse:page")
|
||||||
public Result<PageData<ResourceBrowseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
public Result<PageData<ResourceBrowseDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||||
PageData<ResourceBrowseDTO> page = resourceBrowseService.page(params);
|
UserDetail user = SecurityUser.getUser();
|
||||||
page.getList().forEach(item -> item.setResourceDTO(resourceService.get(item.getResourceId())));
|
if(user == null){
|
||||||
return new Result<PageData<ResourceBrowseDTO>>().ok(page);
|
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}")
|
@GetMapping("/select/{id}")
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package io.renren.modules.resourceBrowse.dao;
|
package io.renren.modules.resourceBrowse.dao;
|
||||||
|
|
||||||
import io.renren.common.dao.BaseDao;
|
import io.renren.common.dao.BaseDao;
|
||||||
|
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
|
||||||
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
|
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
@ -22,4 +23,7 @@ public interface ResourceBrowseDao extends BaseDao<ResourceBrowseEntity> {
|
||||||
Integer selectDayMax();
|
Integer selectDayMax();
|
||||||
|
|
||||||
List<Map> selectDayList(@Param("startDate") String startDate,@Param("endDate") String endDate);
|
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);
|
||||||
}
|
}
|
|
@ -1,9 +1,13 @@
|
||||||
package io.renren.modules.resourceBrowse.service;
|
package io.renren.modules.resourceBrowse.service;
|
||||||
|
|
||||||
|
import io.renren.common.page.PageData;
|
||||||
import io.renren.common.service.CrudService;
|
import io.renren.common.service.CrudService;
|
||||||
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
|
import io.renren.modules.resourceBrowse.dto.ResourceBrowseDTO;
|
||||||
import io.renren.modules.resourceBrowse.entity.ResourceBrowseEntity;
|
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 selectDayMax();
|
||||||
|
|
||||||
Object selectDayList(String startDate, String endDate);
|
Object selectDayList(String startDate, String endDate);
|
||||||
|
|
||||||
|
PageData<ResourceBrowseDTO> selectResourceBrowseByTypeAndUser(Map<String,Object> map);
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package io.renren.modules.resourceBrowse.service.impl;
|
package io.renren.modules.resourceBrowse.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
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.service.impl.CrudServiceImpl;
|
||||||
import io.renren.common.utils.DateUtils;
|
import io.renren.common.utils.DateUtils;
|
||||||
import io.renren.modules.resourceBrowse.dao.ResourceBrowseDao;
|
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 io.renren.modules.security.user.SecurityUser;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.security.core.parameters.P;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -75,4 +77,12 @@ public class ResourceBrowseServiceImpl extends CrudServiceImpl<ResourceBrowseDao
|
||||||
}
|
}
|
||||||
return resultMap;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -52,4 +52,36 @@
|
||||||
SUBSTR(create_date, 1, 10)
|
SUBSTR(create_date, 1, 10)
|
||||||
</select>
|
</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>
|
</mapper>
|
Loading…
Reference in New Issue