编目管理接口,资源管理接口修改
This commit is contained in:
parent
42b318b471
commit
c7e119ab1f
|
@ -16,5 +16,5 @@ public interface CategoryDao extends BaseDao<Category> {
|
|||
|
||||
Integer deleteByIds(@Param("ids") List<Long> idList);
|
||||
|
||||
List<Map> selectFilterCriterByTopCategory(String topCategoryName);
|
||||
List<Map> selectDictData(String linkValue);
|
||||
}
|
||||
|
|
|
@ -78,8 +78,20 @@ public class CategoryServiceImpl extends CrudServiceImpl<CategoryDao, Category,
|
|||
|
||||
@Override
|
||||
public List<Map> getAllFilterCriteriaByTopCategory(String topCategoryName) {
|
||||
//return categoryDao.selectFilterCriterByTopCategory(topCategoryName);
|
||||
return null;
|
||||
QueryWrapper<Category> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("root_category", topCategoryName)
|
||||
.eq("del_flag",0)
|
||||
.eq("is_link_to_dic", "true")
|
||||
.orderByAsc("xh");
|
||||
List<Category> categories = categoryDao.selectList(wrapper);
|
||||
ArrayList<Map> resultList = new ArrayList<>();
|
||||
categories.forEach(item -> {
|
||||
HashMap<String, Object> hashMap = new HashMap<>();
|
||||
hashMap.put("name", item.getName());
|
||||
hashMap.put("typeList", categoryDao.selectDictData(item.getLinkValue()));
|
||||
resultList.add(hashMap);
|
||||
});
|
||||
return resultList;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,19 +1,15 @@
|
|||
package io.renren.modules.resource.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.renren.common.annotation.LogOperation;
|
||||
import io.renren.common.constant.Constant;
|
||||
import io.renren.common.page.PageData;
|
||||
import io.renren.common.utils.ExcelUtils;
|
||||
import io.renren.common.utils.Result;
|
||||
import io.renren.common.validator.AssertUtils;
|
||||
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.excel.ResourceExcel;
|
||||
import io.renren.modules.resource.service.ResourceService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
|
@ -23,7 +19,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -40,23 +35,33 @@ public class ResourceController {
|
|||
@Autowired
|
||||
private ResourceService resourceService;
|
||||
|
||||
@PostMapping("/page")
|
||||
@GetMapping("/page")
|
||||
@ApiOperation("分页查询资源信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pageNum", value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
|
||||
@ApiImplicitParam(name = "pageSize", value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
|
||||
@ApiImplicitParam(name = "", value = "排序字段", paramType = "query", dataType="String") ,
|
||||
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") ,
|
||||
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
|
||||
@ApiImplicitParam(name = "type", value = "类型", paramType = "query",required = true, dataType="String") ,
|
||||
//@ApiImplicitParam(name = "name", 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")
|
||||
})
|
||||
//@RequiresPermissions("resource:resource:page")
|
||||
public Result<PageData<ResourceDTO>> page(@RequestBody JSONObject jsonObject){
|
||||
String pageNum = jsonObject.getString("pageNum");
|
||||
String pageSize = jsonObject.getString("pageSize");
|
||||
ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class);
|
||||
//PageData<ResourceDTO> page = resourceService.pageWithAttrs(params);
|
||||
public Result<PageData<ResourceDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||
//ResourceDTO resourceDTO = JSON.toJavaObject(jsonObject, ResourceDTO.class);
|
||||
//resourceService.pageWithAttrs(resourceDTO);
|
||||
PageData<ResourceDTO> page = resourceService.page(params);
|
||||
page.getList().forEach(item -> {
|
||||
item.setInfoList(resourceService.selectAttrsByResourceId(item.getId()));
|
||||
});
|
||||
return new Result<PageData<ResourceDTO>>().ok(page);
|
||||
}
|
||||
|
||||
//return new Result<PageData<ResourceDTO>>().ok(page);
|
||||
return null;
|
||||
@PostMapping("/pageWithAttrs")
|
||||
@ApiOperation("分页查询资源信息2")
|
||||
//@RequiresPermissions("resource:resource:page")
|
||||
public Result pageWithAttrs(@RequestBody ResourceDTO resourceDTO){
|
||||
|
||||
return new Result<>().ok(resourceService.pageWithAttrs(resourceDTO));
|
||||
}
|
||||
|
||||
@GetMapping("/select/{id}")
|
||||
|
@ -81,13 +86,13 @@ public class ResourceController {
|
|||
return new Result();
|
||||
}
|
||||
|
||||
@PutMapping
|
||||
@PutMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
@LogOperation("修改")
|
||||
//@RequiresPermissions("resource:resource:update")
|
||||
public Result update(@RequestBody ResourceDTO dto){
|
||||
//效验数据
|
||||
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
////效验数据
|
||||
//ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||
|
||||
resourceService.updateWithAttrs(dto);
|
||||
|
||||
|
|
|
@ -17,4 +17,5 @@ import java.util.List;
|
|||
public interface AttrDao extends BaseDao<AttrEntity> {
|
||||
|
||||
Integer delete4Resource(@Param("resourceIds") List<Long> idList);
|
||||
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
package io.renren.modules.resource.dao;
|
||||
|
||||
import io.renren.common.dao.BaseDao;
|
||||
import io.renren.modules.resource.dto.ResourceDTO;
|
||||
import io.renren.modules.resource.entity.ResourceEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 资源表
|
||||
|
@ -17,4 +19,6 @@ import java.util.List;
|
|||
public interface ResourceDao extends BaseDao<ResourceEntity> {
|
||||
|
||||
Integer deleteByIds(@Param("ids") List<Long> idList);
|
||||
|
||||
List<ResourceDTO> selectWithAttrs(ResourceDTO resourceDTO);
|
||||
}
|
|
@ -11,8 +11,8 @@ import java.util.Date;
|
|||
* @author dg
|
||||
* @since 1.0 2022-04-13
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
//@Data
|
||||
//@EqualsAndHashCode(callSuper=false)
|
||||
@TableName("tb_data_attr")
|
||||
public class AttrEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
@ -60,4 +60,136 @@ public class AttrEntity {
|
|||
private String note3;
|
||||
private String note4;
|
||||
private String note5;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getDataResourceId() {
|
||||
return dataResourceId;
|
||||
}
|
||||
|
||||
public void setDataResourceId(Long dataResourceId) {
|
||||
this.dataResourceId = dataResourceId;
|
||||
}
|
||||
|
||||
public String getAttrType() {
|
||||
return attrType;
|
||||
}
|
||||
|
||||
public void setAttrType(String attrType) {
|
||||
this.attrType = attrType;
|
||||
}
|
||||
|
||||
public String getAttrValue() {
|
||||
return attrValue;
|
||||
}
|
||||
|
||||
public void setAttrValue(String attrValue) {
|
||||
this.attrValue = attrValue;
|
||||
}
|
||||
|
||||
public Integer getDelFlag() {
|
||||
return delFlag;
|
||||
}
|
||||
|
||||
public void setDelFlag(Integer delFlag) {
|
||||
this.delFlag = delFlag;
|
||||
}
|
||||
|
||||
public Long getCreator() {
|
||||
return creator;
|
||||
}
|
||||
|
||||
public void setCreator(Long creator) {
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
public Date getCreateDate() {
|
||||
return createDate;
|
||||
}
|
||||
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public Long getUpdater() {
|
||||
return updater;
|
||||
}
|
||||
|
||||
public void setUpdater(Long updater) {
|
||||
this.updater = updater;
|
||||
}
|
||||
|
||||
public Date getUpdateDate() {
|
||||
return updateDate;
|
||||
}
|
||||
|
||||
public void setUpdateDate(Date updateDate) {
|
||||
this.updateDate = updateDate;
|
||||
}
|
||||
|
||||
public String getNote1() {
|
||||
return note1;
|
||||
}
|
||||
|
||||
public void setNote1(String note1) {
|
||||
this.note1 = note1;
|
||||
}
|
||||
|
||||
public String getNote2() {
|
||||
return note2;
|
||||
}
|
||||
|
||||
public void setNote2(String note2) {
|
||||
this.note2 = note2;
|
||||
}
|
||||
|
||||
public String getNote3() {
|
||||
return note3;
|
||||
}
|
||||
|
||||
public void setNote3(String note3) {
|
||||
this.note3 = note3;
|
||||
}
|
||||
|
||||
public String getNote4() {
|
||||
return note4;
|
||||
}
|
||||
|
||||
public void setNote4(String note4) {
|
||||
this.note4 = note4;
|
||||
}
|
||||
|
||||
public String getNote5() {
|
||||
return note5;
|
||||
}
|
||||
|
||||
public void setNote5(String note5) {
|
||||
this.note5 = note5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AttrEntity{" +
|
||||
"id=" + id +
|
||||
", dataResourceId=" + dataResourceId +
|
||||
", attrType='" + attrType + '\'' +
|
||||
", attrValue='" + attrValue + '\'' +
|
||||
", delFlag=" + delFlag +
|
||||
", creator=" + creator +
|
||||
", createDate=" + createDate +
|
||||
", updater=" + updater +
|
||||
", updateDate=" + updateDate +
|
||||
", note1='" + note1 + '\'' +
|
||||
", note2='" + note2 + '\'' +
|
||||
", note3='" + note3 + '\'' +
|
||||
", note4='" + note4 + '\'' +
|
||||
", note5='" + note5 + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -1,10 +1,14 @@
|
|||
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;
|
||||
import io.renren.modules.resource.entity.ResourceEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 资源表
|
||||
*
|
||||
|
@ -20,4 +24,8 @@ public interface ResourceService extends CrudService<ResourceEntity, ResourceDTO
|
|||
void updateWithAttrs(ResourceDTO dto);
|
||||
|
||||
ResourceDTO selectWithAttrs(Long id);
|
||||
|
||||
List<ResourceDTO> pageWithAttrs(ResourceDTO resourceDTO);
|
||||
|
||||
List<AttrEntity> selectAttrsByResourceId(Long id);
|
||||
}
|
|
@ -20,6 +20,7 @@ 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;
|
||||
|
||||
|
@ -41,8 +42,10 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
@Override
|
||||
public QueryWrapper<ResourceEntity> getWrapper(Map<String, Object> params){
|
||||
QueryWrapper<ResourceEntity> wrapper = new QueryWrapper<>();
|
||||
|
||||
|
||||
wrapper.eq("type", params.get("type").toString())
|
||||
.eq("del_flag", 0)
|
||||
//.like(StringUtils.isNotBlank(params.get("name").toString()),"name", params.get("name").toString())
|
||||
.orderByDesc("create_date");
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
@ -51,9 +54,11 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
public void insertWithAttrs(ResourceDTO dto) {
|
||||
ResourceEntity resourceEntity = new ResourceEntity();
|
||||
BeanUtils.copyProperties(dto, resourceEntity);
|
||||
Long resourceID = IdWorker.getId(resourceEntity);
|
||||
resourceEntity.setId(resourceID);
|
||||
resourceEntity.setDelFlag(0);
|
||||
resourceDao.insert(resourceEntity);
|
||||
Long resourceID = IdWorker.getId(resourceEntity);
|
||||
|
||||
List<AttrEntity> attrEntities= dto.getInfoList();
|
||||
attrEntities.forEach(item -> {
|
||||
item.setDelFlag(0);
|
||||
|
@ -97,6 +102,20 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
.eq("del_flag", 0);
|
||||
List<AttrEntity> attrEntities = attrDao.selectList(wrapper);
|
||||
resourceDTO.setInfoList(attrEntities);
|
||||
return null;
|
||||
return resourceDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceDTO> pageWithAttrs(ResourceDTO resourceDTO) {
|
||||
return resourceDao.selectWithAttrs(resourceDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AttrEntity> selectAttrsByResourceId(Long resourceId) {
|
||||
QueryWrapper<AttrEntity> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("data_resource_id", resourceId)
|
||||
.eq("del_flag", 0)
|
||||
.orderByDesc("attr_type");
|
||||
return attrDao.selectList(wrapper);
|
||||
}
|
||||
}
|
|
@ -66,3 +66,4 @@ mybatis-plus:
|
|||
cache-enabled: false
|
||||
call-setters-on-nulls: true
|
||||
jdbc-type-for-null: 'null'
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
|
|
@ -37,8 +37,12 @@
|
|||
order by xh
|
||||
</select>
|
||||
|
||||
<select id="selectFilterCriterByTopCategory" resultType="java.util.Map">
|
||||
select
|
||||
<select id="selectDictData" resultType="java.util.Map">
|
||||
select *
|
||||
from sys_dict_data
|
||||
where 1 = 1
|
||||
and dict_type_id = #{linkValue}
|
||||
order by sort
|
||||
</select>
|
||||
|
||||
<update id="deleteByIds">
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
set del_flag = 1,
|
||||
update_date = now()
|
||||
where 1 = 1
|
||||
and data_resourceId in
|
||||
and data_resource_id in
|
||||
<foreach collection="resourceIds" item="item" open="(" separator="," close=")">
|
||||
#{item}
|
||||
</foreach>
|
||||
|
|
|
@ -26,6 +26,45 @@
|
|||
<result property="note5" column="note5"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="resourceDTO" type="io.renren.modules.resource.dto.ResourceDTO">
|
||||
<result property="id" column="id"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="description" column="description"/>
|
||||
<result property="link" column="link"/>
|
||||
<result property="image" column="image"/>
|
||||
<result property="dataVolume" column="data_volume"/>
|
||||
<result property="visits" column="visits"/>
|
||||
<result property="downloads" column="downloads"/>
|
||||
<result property="score" column="score"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="createDate" column="create_date"/>
|
||||
<result property="updater" column="updater"/>
|
||||
<result property="updateDate" column="update_date"/>
|
||||
<result property="note1" column="note1"/>
|
||||
<result property="note2" column="note2"/>
|
||||
<result property="note3" column="note3"/>
|
||||
<result property="note4" column="note4"/>
|
||||
<result property="note5" column="note5"/>
|
||||
<collection property="infoList" javaType="List" ofType="attrEntity">
|
||||
<result property="id" column="id"/>
|
||||
<result property="dataResourceId" column="data_resource_id"/>
|
||||
<result property="attrType" column="attr_type"/>
|
||||
<result property="attrValue" column="attr_value"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="creator" column="creator"/>
|
||||
<result property="createDate" column="create_date"/>
|
||||
<result property="updater" column="updater"/>
|
||||
<result property="updateDate" column="update_date"/>
|
||||
<result property="note1" column="note1"/>
|
||||
<result property="note2" column="note2"/>
|
||||
<result property="note3" column="note3"/>
|
||||
<result property="note4" column="note4"/>
|
||||
<result property="note5" column="note5"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<update id="deleteByIds">
|
||||
update tb_data_resource
|
||||
set del_flag = 1,
|
||||
|
@ -37,4 +76,46 @@
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<select id="selectWithAttrs" resultMap="resourceDTO">
|
||||
SELECT
|
||||
r.*,
|
||||
a.*
|
||||
FROM
|
||||
tb_data_resource r,
|
||||
tb_data_attr a
|
||||
WHERE 1 = 1
|
||||
and r.id = a.data_resource_id
|
||||
and r.type = #{type}
|
||||
and r.del_flag = 0
|
||||
<if test="name != null and name != ''" >
|
||||
and r.name like CONCAT('%',#{name},'%')
|
||||
</if>
|
||||
<if test="infoList.size > 0">
|
||||
AND
|
||||
a.data_resource_id IN (
|
||||
SELECT
|
||||
data_resource_id
|
||||
FROM
|
||||
(
|
||||
SELECT
|
||||
tb.data_resource_id
|
||||
FROM
|
||||
(
|
||||
<foreach collection="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}
|
||||
ORDER BY
|
||||
tb.data_resource_id ASC
|
||||
limit #{pageNum} , #{pageSize}
|
||||
) tmp)
|
||||
</if>
|
||||
|
||||
</select>
|
||||
</mapper>
|
|
@ -15,7 +15,6 @@ import java.nio.charset.StandardCharsets;
|
|||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* XSS过滤处理
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue