|
@@ -1,17 +1,19 @@
|
|
|
package com.persagy.dmp.dic.controller;
|
|
|
|
|
|
-import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.persagy.dmp.basic.model.QueryCriteria;
|
|
|
import com.persagy.dmp.common.constant.ResponseCode;
|
|
|
import com.persagy.dmp.common.exception.BusinessException;
|
|
|
import com.persagy.dmp.common.model.response.CommonResult;
|
|
|
+import com.persagy.dmp.common.model.response.PageList;
|
|
|
import com.persagy.dmp.common.utils.ResultHelper;
|
|
|
import com.persagy.dmp.dic.entity.DictType;
|
|
|
import com.persagy.dmp.dic.service.DictTypeService;
|
|
|
+import com.persagy.dmp.rwd.basic.utils.QueryCriteriaHelper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import java.util.List;
|
|
|
-
|
|
|
/**
|
|
|
* 字典类型
|
|
|
* @author:linhuili
|
|
@@ -22,41 +24,35 @@ import java.util.List;
|
|
|
public class DictTypeController {
|
|
|
|
|
|
@Autowired
|
|
|
- private DictTypeService dictTypeService;
|
|
|
+ private DictTypeService service;
|
|
|
|
|
|
- @PostMapping("/create")
|
|
|
- public CommonResult<DictType> create(@RequestBody DictType dictType) {
|
|
|
- if(StrUtil.isBlank(dictType.getGroupCode())){
|
|
|
+ @PostMapping("/query")
|
|
|
+ public CommonResult<PageList<DictType>> query(@RequestBody QueryCriteria criteria) {
|
|
|
+ if(criteria == null) {
|
|
|
throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
}
|
|
|
- DictType content = dictTypeService.create(dictType);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ QueryWrapper<DictType> wrapper = new QueryWrapper<>();
|
|
|
+ // 转换查询条件
|
|
|
+ QueryCriteriaHelper.toWrapper(wrapper, criteria);
|
|
|
+ Page page = service.queryByCondition(QueryCriteriaHelper.toPage(criteria), wrapper);
|
|
|
+ return ResultHelper.multi(page.getRecords(), page.getTotal());
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/update")
|
|
|
- public CommonResult<DictType> update(@RequestBody DictType dictType) {
|
|
|
- if(StrUtil.isBlank(dictType.getGroupCode())|| StrUtil.isBlank(dictType.getId()) ){
|
|
|
- throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
- }
|
|
|
- DictType content = dictTypeService.update(dictType);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ @PostMapping("/create")
|
|
|
+ public CommonResult<DictType> create(@RequestBody DictType vo){
|
|
|
+ vo = service.insert(vo);
|
|
|
+ return ResultHelper.single(vo);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/delete")
|
|
|
- public CommonResult<DictType> delete(@RequestBody DictType dictType) {
|
|
|
- if(StrUtil.isBlank(dictType.getGroupCode()) || StrUtil.isBlank(dictType.getId()) ){
|
|
|
- throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
- }
|
|
|
- DictType content = dictTypeService.delete(dictType);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ @PostMapping("/update")
|
|
|
+ public CommonResult<DictType> update(@RequestBody DictType vo){
|
|
|
+ vo = service.update(vo);
|
|
|
+ return ResultHelper.single(vo);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/query")
|
|
|
- public CommonResult<List<DictType>> query(@RequestBody DictType dictType) {
|
|
|
- if(StrUtil.isBlank(dictType.getGroupCode())){
|
|
|
- throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
- }
|
|
|
- List<DictType> content = dictTypeService.query(dictType);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public CommonResult<DictType> delete(@RequestBody String id){
|
|
|
+ service.delete(id);
|
|
|
+ return ResultHelper.success();
|
|
|
}
|
|
|
}
|