fix:修复数据字典(一级)Bug
This commit is contained in:
@@ -20,7 +20,7 @@ import javax.validation.Valid;
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/${restPath}/sys/dict")
|
||||
@Api(tags = {"Sys-数据字典设置"})
|
||||
@Api(tags = {"Sys-数据字典"})
|
||||
public class DictController {
|
||||
|
||||
@Resource
|
||||
@@ -32,7 +32,7 @@ public class DictController {
|
||||
@ApiOperation(value = "分页获取所有数据字典")
|
||||
@GetMapping("/page")
|
||||
public ResponseMessage page(@Valid DictQueryVo dictQueryVo) {
|
||||
return dictService.list(dictQueryVo);
|
||||
return dictService.pageByCondition(dictQueryVo);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.adc.da.sys.service;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.adc.da.eo.DictEntity;
|
||||
import com.adc.da.sys.util.BeanCopyUtils;
|
||||
import com.adc.da.sys.vo.DictQueryVo;
|
||||
@@ -21,7 +22,6 @@ import org.springframework.stereotype.Service;
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author ThinkBook
|
||||
@@ -37,13 +37,16 @@ public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity>
|
||||
private DictDao dictDao;
|
||||
|
||||
@Override
|
||||
public ResponseMessage list(DictQueryVo dictQueryVo) {
|
||||
public ResponseMessage pageByCondition(DictQueryVo dictQueryVo) {
|
||||
LambdaQueryWrapper<DictEntity> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.like(StrUtil.isNotBlank(dictQueryVo.getDicName()), DictEntity::getDicName, dictQueryVo.getDicName());
|
||||
wrapper.eq(StrUtil.isNotBlank(dictQueryVo.getDicCode()), DictEntity::getDicCode, dictQueryVo.getDicCode());
|
||||
wrapper.eq(DictEntity::getDelFlag, 0);
|
||||
wrapper.orderByAsc(DictEntity::getCreateTime);
|
||||
IPage<DictEntity> page = new Page<>(dictQueryVo.getPageNo(), dictQueryVo.getPageSize());
|
||||
page(page, wrapper);
|
||||
|
||||
IPage<DictVo> returnPage = new Page<>();
|
||||
Page returnPage = BeanCopyUtils.copyBean(page, Page.class);
|
||||
List<DictVo> dictVos = BeanCopyUtils.copyBeanList(page.getRecords(), DictVo.class);
|
||||
|
||||
returnPage.setRecords(dictVos);
|
||||
@@ -55,8 +58,9 @@ public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity>
|
||||
try {
|
||||
DictEntity dictEntity = new DictEntity();
|
||||
//字典编码不可变
|
||||
dictVo.setDicCode(null);
|
||||
BeanUtil.copyProperties(dictVo, dictEntity);
|
||||
dictEntity.setDicCode(null);
|
||||
dictEntity.setUpdateTime(new Date());
|
||||
dictDao.updateById(dictEntity);
|
||||
log.info("编辑数据字典{}成功", dictEntity.getDicName());
|
||||
return Result.success("编辑成功");
|
||||
@@ -75,6 +79,7 @@ public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity>
|
||||
|
||||
DictEntity dictEntity = new DictEntity();
|
||||
dictEntity.setId(id);
|
||||
dictEntity.setUpdateTime(new Date());
|
||||
dictEntity.setDelFlag(1);
|
||||
if (updateById(dictEntity)) {
|
||||
return Result.success("删除成功");
|
||||
@@ -98,6 +103,7 @@ public class DictServiceImpl extends ServiceImpl<DictDao, DictEntity>
|
||||
DictEntity dictEntity = BeanCopyUtils.copyBean(dictVo, DictEntity.class);
|
||||
dictEntity.setId(UUID.randomUUID10())
|
||||
.setCreateTime(new Date())
|
||||
.setUpdateTime(new Date())
|
||||
.setDelFlag(0);
|
||||
save(dictEntity);
|
||||
return Result.success("新增成功");
|
||||
|
||||
@@ -21,7 +21,7 @@ public interface IDictService extends IService<DictEntity> {
|
||||
* @param dictQueryVo
|
||||
* @return
|
||||
*/
|
||||
ResponseMessage list(DictQueryVo dictQueryVo);
|
||||
ResponseMessage pageByCondition(DictQueryVo dictQueryVo);
|
||||
|
||||
/**
|
||||
* 编辑字典
|
||||
|
||||
@@ -11,6 +11,16 @@ import javax.validation.constraints.NotNull;
|
||||
@Data
|
||||
public class DictQueryVo {
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dicName;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
private String dicCode;
|
||||
|
||||
/**
|
||||
* 页数
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user