字典类型内也返回对应字典值
This commit is contained in:
parent
23bd3c44a0
commit
b15402adad
|
@ -10,6 +10,7 @@ import io.renren.common.validator.group.DefaultGroup;
|
||||||
import io.renren.common.validator.group.UpdateGroup;
|
import io.renren.common.validator.group.UpdateGroup;
|
||||||
import io.renren.modules.sys.dto.SysDictTypeDTO;
|
import io.renren.modules.sys.dto.SysDictTypeDTO;
|
||||||
import io.renren.modules.sys.entity.DictType;
|
import io.renren.modules.sys.entity.DictType;
|
||||||
|
import io.renren.modules.sys.service.SysDictDataService;
|
||||||
import io.renren.modules.sys.service.SysDictTypeService;
|
import io.renren.modules.sys.service.SysDictTypeService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
@ -21,6 +22,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
|
@ -31,6 +33,8 @@ import java.util.Map;
|
||||||
public class SysDictTypeController {
|
public class SysDictTypeController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private SysDictTypeService sysDictTypeService;
|
private SysDictTypeService sysDictTypeService;
|
||||||
|
@Autowired
|
||||||
|
private SysDictDataService sysDictDataService;
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@ApiOperation("字典类型分页查询")
|
@ApiOperation("字典类型分页查询")
|
||||||
|
@ -41,13 +45,18 @@ public class SysDictTypeController {
|
||||||
@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 = "dictType", value = "字典类型", 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")
|
// @RequiresPermissions("sys:dict:page")
|
||||||
public Result<PageData<SysDictTypeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
public Result<PageData<SysDictTypeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params) {
|
||||||
//字典类型
|
//字典类型
|
||||||
PageData<SysDictTypeDTO> page = sysDictTypeService.page(params);
|
PageData<SysDictTypeDTO> 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<PageData<SysDictTypeDTO>>().ok(page);
|
return new Result<PageData<SysDictTypeDTO>>().ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,7 +66,7 @@ public class SysDictTypeController {
|
||||||
// @RequiresPermissions("sys:dict:info")
|
// @RequiresPermissions("sys:dict:info")
|
||||||
public Result<SysDictTypeDTO> get(@PathVariable("id") Long id) {
|
public Result<SysDictTypeDTO> get(@PathVariable("id") Long id) {
|
||||||
SysDictTypeDTO data = sysDictTypeService.get(id);
|
SysDictTypeDTO data = sysDictTypeService.get(id);
|
||||||
|
data.setSysDictDataDTOList(sysDictDataService.selectByDictTypeId(data.getId().toString()));
|
||||||
return new Result<SysDictTypeDTO>().ok(data);
|
return new Result<SysDictTypeDTO>().ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ import javax.validation.constraints.NotNull;
|
||||||
import javax.validation.constraints.Null;
|
import javax.validation.constraints.Null;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
|
@ -50,4 +51,9 @@ public class SysDictTypeDTO implements Serializable {
|
||||||
@ApiModelProperty(value = "更新时间")
|
@ApiModelProperty(value = "更新时间")
|
||||||
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
private Date updateDate;
|
private Date updateDate;
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "对应字典数据")
|
||||||
|
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
|
List<SysDictDataDTO> sysDictDataDTOList;
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ import io.renren.common.service.BaseService;
|
||||||
import io.renren.modules.sys.dto.SysDictDataDTO;
|
import io.renren.modules.sys.dto.SysDictDataDTO;
|
||||||
import io.renren.modules.sys.entity.SysDictDataEntity;
|
import io.renren.modules.sys.entity.SysDictDataEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,4 +23,6 @@ public interface SysDictDataService extends BaseService<SysDictDataEntity> {
|
||||||
|
|
||||||
void delete(Long[] ids);
|
void delete(Long[] ids);
|
||||||
|
|
||||||
|
List<SysDictDataDTO> selectByDictTypeId(String dictTypeId);
|
||||||
|
|
||||||
}
|
}
|
|
@ -14,7 +14,9 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典类型
|
* 字典类型
|
||||||
|
@ -75,4 +77,11 @@ public class SysDictDataServiceImpl extends BaseServiceImpl<SysDictDataDao, SysD
|
||||||
deleteBatchIds(Arrays.asList(ids));
|
deleteBatchIds(Arrays.asList(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SysDictDataDTO> selectByDictTypeId(String dictTypeId) {
|
||||||
|
QueryWrapper<SysDictDataEntity> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq("dict_type_id", dictTypeId);
|
||||||
|
return baseDao.selectList(wrapper).stream().map(index -> ConvertUtils.sourceToTarget(index, SysDictDataDTO.class)).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -43,10 +43,14 @@ public class SysDictTypeServiceImpl extends BaseServiceImpl<SysDictTypeDao, SysD
|
||||||
String dictType = (String) params.get("dictType");
|
String dictType = (String) params.get("dictType");
|
||||||
String dictName = (String) params.get("dictName");
|
String dictName = (String) params.get("dictName");
|
||||||
|
|
||||||
|
String dictLabel = (String) params.get("dictLabel");
|
||||||
|
String dictValue = (String) params.get("dictValue");
|
||||||
|
|
||||||
QueryWrapper<SysDictTypeEntity> wrapper = new QueryWrapper<>();
|
QueryWrapper<SysDictTypeEntity> wrapper = new QueryWrapper<>();
|
||||||
wrapper.like(StringUtils.isNotBlank(dictType), "dict_type", dictType);
|
wrapper.like(StringUtils.isNotBlank(dictType), "dict_type", dictType);
|
||||||
wrapper.like(StringUtils.isNotBlank(dictName), "dict_name", dictName);
|
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;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue