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