From b15402adad89ddf3c1b2a8c0e749a7f963a06d19 Mon Sep 17 00:00:00 2001 From: wangliwen Date: Sat, 29 Oct 2022 10:50:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=97=E5=85=B8=E7=B1=BB=E5=9E=8B=E5=86=85?= =?UTF-8?q?=E4=B9=9F=E8=BF=94=E5=9B=9E=E5=AF=B9=E5=BA=94=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sys/controller/SysDictTypeController.java | 15 ++++++++++++--- .../io/renren/modules/sys/dto/SysDictTypeDTO.java | 6 ++++++ .../modules/sys/service/SysDictDataService.java | 3 +++ .../sys/service/impl/SysDictDataServiceImpl.java | 9 +++++++++ .../sys/service/impl/SysDictTypeServiceImpl.java | 6 +++++- 5 files changed, 35 insertions(+), 4 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDictTypeController.java b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDictTypeController.java index 87ce47e5..f29104f0 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDictTypeController.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/controller/SysDictTypeController.java @@ -10,6 +10,7 @@ import io.renren.common.validator.group.DefaultGroup; import io.renren.common.validator.group.UpdateGroup; import io.renren.modules.sys.dto.SysDictTypeDTO; import io.renren.modules.sys.entity.DictType; +import io.renren.modules.sys.service.SysDictDataService; import io.renren.modules.sys.service.SysDictTypeService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -21,6 +22,7 @@ import springfox.documentation.annotations.ApiIgnore; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 字典类型 @@ -31,6 +33,8 @@ import java.util.Map; public class SysDictTypeController { @Autowired private SysDictTypeService sysDictTypeService; + @Autowired + private SysDictDataService sysDictDataService; @GetMapping("page") @ApiOperation("字典类型分页查询") @@ -41,13 +45,18 @@ public class SysDictTypeController { @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType = "String"), @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType = "String"), @ApiImplicitParam(name = "dictType", value = "字典类型", paramType = "query", dataType = "String"), - @ApiImplicitParam(name = "dictName", value = "字典名称", paramType = "query", dataType = "String") + @ApiImplicitParam(name = "dictName", value = "字典名称", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "dictLabel", value = "字典标签", paramType = "query", dataType = "String"), + @ApiImplicitParam(name = "dictValue", value = "字典值", paramType = "query", dataType = "String") }) // @RequiresPermissions("sys:dict:page") public Result> page(@ApiIgnore @RequestParam Map params) { //字典类型 PageData page = sysDictTypeService.page(params); - + page.setList(page.getList().stream().map(index -> { + index.setSysDictDataDTOList(sysDictDataService.selectByDictTypeId(index.getId().toString())); + return index; + }).collect(Collectors.toList())); // return new Result>().ok(page); } @@ -57,7 +66,7 @@ public class SysDictTypeController { // @RequiresPermissions("sys:dict:info") public Result get(@PathVariable("id") Long id) { SysDictTypeDTO data = sysDictTypeService.get(id); - + data.setSysDictDataDTOList(sysDictDataService.selectByDictTypeId(data.getId().toString())); return new Result().ok(data); } diff --git a/renren-admin/src/main/java/io/renren/modules/sys/dto/SysDictTypeDTO.java b/renren-admin/src/main/java/io/renren/modules/sys/dto/SysDictTypeDTO.java index eb7fd086..06cfbdba 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/dto/SysDictTypeDTO.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/dto/SysDictTypeDTO.java @@ -14,6 +14,7 @@ import javax.validation.constraints.NotNull; import javax.validation.constraints.Null; import java.io.Serializable; import java.util.Date; +import java.util.List; /** * 字典类型 @@ -50,4 +51,9 @@ public class SysDictTypeDTO implements Serializable { @ApiModelProperty(value = "更新时间") @JsonProperty(access = JsonProperty.Access.READ_ONLY) private Date updateDate; + + + @ApiModelProperty(value = "对应字典数据") + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + List sysDictDataDTOList; } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/SysDictDataService.java b/renren-admin/src/main/java/io/renren/modules/sys/service/SysDictDataService.java index d33b984b..cd835d9c 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/SysDictDataService.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/SysDictDataService.java @@ -5,6 +5,7 @@ import io.renren.common.service.BaseService; import io.renren.modules.sys.dto.SysDictDataDTO; import io.renren.modules.sys.entity.SysDictDataEntity; +import java.util.List; import java.util.Map; /** @@ -22,4 +23,6 @@ public interface SysDictDataService extends BaseService { void delete(Long[] ids); + List selectByDictTypeId(String dictTypeId); + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictDataServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictDataServiceImpl.java index d2a30383..e67c906e 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictDataServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictDataServiceImpl.java @@ -14,7 +14,9 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.util.Arrays; +import java.util.List; import java.util.Map; +import java.util.stream.Collectors; /** * 字典类型 @@ -75,4 +77,11 @@ public class SysDictDataServiceImpl extends BaseServiceImpl selectByDictTypeId(String dictTypeId) { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("dict_type_id", dictTypeId); + return baseDao.selectList(wrapper).stream().map(index -> ConvertUtils.sourceToTarget(index, SysDictDataDTO.class)).collect(Collectors.toList()); + } + } \ No newline at end of file diff --git a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictTypeServiceImpl.java b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictTypeServiceImpl.java index 4a949c3c..48776078 100644 --- a/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictTypeServiceImpl.java +++ b/renren-admin/src/main/java/io/renren/modules/sys/service/impl/SysDictTypeServiceImpl.java @@ -43,10 +43,14 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl wrapper = new QueryWrapper<>(); wrapper.like(StringUtils.isNotBlank(dictType), "dict_type", dictType); wrapper.like(StringUtils.isNotBlank(dictName), "dict_name", dictName); - + wrapper.exists(StringUtils.isNotBlank(dictLabel), String.format("SELECT 1 FROM sys_dict_data sdd WHERE sdd.dict_type_id = sys_dict_type.id AND sdd.dict_label LIKE CONCAT( '%', '%s', '%' ) ", dictLabel)); + wrapper.exists(StringUtils.isNotBlank(dictValue), String.format("SELECT 1 FROM sys_dict_data sdd WHERE sdd.dict_type_id = sys_dict_type.id AND sdd.dict_value =1", dictValue)); return wrapper; }