编目管理接口,资源管理接口修改

This commit is contained in:
dinggang 2022-04-15 11:49:50 +08:00
parent c7e119ab1f
commit 5f2bd3aeab
5 changed files with 23 additions and 24 deletions

View File

@ -8,7 +8,6 @@ import io.renren.common.utils.Result;
import io.renren.common.validator.ValidatorUtils;
import io.renren.common.validator.group.AddGroup;
import io.renren.common.validator.group.DefaultGroup;
import io.renren.common.validator.group.UpdateGroup;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.service.ResourceService;
import io.swagger.annotations.Api;
@ -19,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
import java.util.Map;
/**
@ -58,10 +56,14 @@ public class ResourceController {
@PostMapping("/pageWithAttrs")
@ApiOperation("分页查询资源信息2")
//@ApiImplicitParams({
// @ApiImplicitParam(name = "name", value = "资源名称", paramType = "query", dataType="String") ,
// @ApiImplicitParam(name = "type", value = "资源类型", paramType = "query",required = true, dataType="String") ,
// @ApiImplicitParam(name = "infoList", value = "类型", paramType = "query", dataType="List")
//})
//@RequiresPermissions("resource:resource:page")
public Result pageWithAttrs(@RequestBody ResourceDTO resourceDTO){
return new Result<>().ok(resourceService.pageWithAttrs(resourceDTO));
public Result pageWithAttrs(@RequestBody JSONObject jsonObject){
return new Result<>().ok(resourceService.pageWithAttrs(jsonObject));
}
@GetMapping("/select/{id}")

View File

@ -7,7 +7,6 @@ import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
/**
* 资源表
@ -20,5 +19,5 @@ public interface ResourceDao extends BaseDao<ResourceEntity> {
Integer deleteByIds(@Param("ids") List<Long> idList);
List<ResourceDTO> selectWithAttrs(ResourceDTO resourceDTO);
List<ResourceDTO> selectWithAttrs(@Param("dto") ResourceDTO resourceDTO, @Param("pageNum") Integer pageNum, @Param("pageSize") Integer pageSize);
}

View File

@ -1,7 +1,6 @@
package io.renren.modules.resource.service;
import com.alibaba.fastjson.JSONObject;
import io.renren.common.page.PageData;
import io.renren.common.service.CrudService;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
@ -25,7 +24,7 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
ResourceDTO selectWithAttrs(Long id);
List<ResourceDTO> pageWithAttrs(ResourceDTO resourceDTO);
List<ResourceDTO> pageWithAttrs(JSONObject jsonObject);
List<AttrEntity> selectAttrsByResourceId(Long id);
}

View File

@ -1,26 +1,23 @@
package io.renren.modules.resource.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.common.constant.Constant;
import io.renren.modules.resource.dao.AttrDao;
import io.renren.modules.resource.dao.ResourceDao;
import io.renren.modules.resource.dto.ResourceDTO;
import io.renren.modules.resource.entity.AttrEntity;
import io.renren.modules.resource.entity.ResourceEntity;
import io.renren.modules.resource.service.ResourceService;
import io.renren.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -106,8 +103,12 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
}
@Override
public List<ResourceDTO> pageWithAttrs(ResourceDTO resourceDTO) {
return resourceDao.selectWithAttrs(resourceDTO);
public List<ResourceDTO> pageWithAttrs(JSONObject jsonObject) {
ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class);
Integer pageNum = jsonObject.getInteger("pageNum");
Integer pageSize = jsonObject.getInteger("pageSize");
return resourceDao.selectWithAttrs(resourceDTO, (pageNum - 1) * pageSize, pageSize);
}
@Override

View File

@ -85,12 +85,12 @@
tb_data_attr a
WHERE 1 = 1
and r.id = a.data_resource_id
and r.type = #{type}
and r.type = #{dto.type}
and r.del_flag = 0
<if test="name != null and name != ''" >
and r.name like CONCAT('%',#{name},'%')
<if test="dto.name != null and dto.name != ''" >
and r.name like CONCAT('%',#{dto.name},'%')
</if>
<if test="infoList.size > 0">
<if test="dto.infoList.size > 0">
AND
a.data_resource_id IN (
SELECT
@ -101,20 +101,18 @@
tb.data_resource_id
FROM
(
<foreach collection="infoList" item="item" separator="union all">
<foreach collection="dto.infoList" item="item" separator="union all">
SELECT data_resource_id FROM tb_data_attr
WHERE attr_type = #{item.attrType} AND attr_value = #{item.attrValue} and del_flag = 0
</foreach>
) tb
GROUP BY
tb.data_resource_id
HAVING
COUNT( tb.data_resource_id ) = ${infoList.size}
COUNT( tb.data_resource_id ) = ${dto.infoList.size}
ORDER BY
tb.data_resource_id ASC
limit #{pageNum} , #{pageSize}
) tmp)
) tmp) limit ${pageNum}, ${pageSize}
</if>
</select>