|
@@ -1,12 +1,18 @@
|
|
|
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.DictData;
|
|
|
+import com.persagy.dmp.dic.entity.DictData;
|
|
|
+import com.persagy.dmp.dic.entity.DictType;
|
|
|
+import com.persagy.dmp.dic.service.DictDataService;
|
|
|
+import com.persagy.dmp.rwd.basic.utils.QueryCriteriaHelper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
@@ -21,42 +27,48 @@ import java.util.List;
|
|
|
* @date:2021/6/10
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping(value = "/dic/dit/data")
|
|
|
+@RequestMapping(value = "/dic/dt/data")
|
|
|
public class DictDataController {
|
|
|
|
|
|
@Autowired
|
|
|
- private com.persagy.dmp.dic.service.DictDataService DictDataService;
|
|
|
+ private DictDataService service;
|
|
|
|
|
|
- @PostMapping("/create")
|
|
|
- public CommonResult<DictData> create(@RequestBody DictData DictData) {
|
|
|
- if(StrUtil.isBlank(DictData.getDictTypeId())){
|
|
|
+ @PostMapping("/query")
|
|
|
+ public CommonResult<PageList<DictData>> query(@RequestBody QueryCriteria criteria) {
|
|
|
+ if(criteria == null) {
|
|
|
throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
}
|
|
|
- DictData content = DictDataService.create(DictData);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ QueryWrapper<DictData> wrapper = new QueryWrapper<>();
|
|
|
+ // 转换查询条件
|
|
|
+ QueryCriteriaHelper.toWrapper(wrapper, criteria);
|
|
|
+ Page page = service.queryByCondition(QueryCriteriaHelper.toPage(criteria), wrapper);
|
|
|
+ return ResultHelper.multi(page.getRecords(), page.getTotal());
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/create")
|
|
|
+ public CommonResult<DictData> create(@RequestBody DictData vo){
|
|
|
+ vo = service.insert(vo);
|
|
|
+ return ResultHelper.single(vo);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/update")
|
|
|
- public CommonResult<DictData> update(@RequestBody DictData DictData) {
|
|
|
- if(StrUtil.isBlank(DictData.getDictTypeId())|| StrUtil.isBlank(DictData.getId()) ){
|
|
|
- throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
- }
|
|
|
- DictData content = DictDataService.update(DictData);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ public CommonResult<DictData> update(@RequestBody DictData vo){
|
|
|
+ vo = service.update(vo);
|
|
|
+ return ResultHelper.single(vo);
|
|
|
}
|
|
|
|
|
|
@PostMapping("/delete")
|
|
|
- public CommonResult<DictData> delete(@RequestBody DictData DictData) {
|
|
|
- if(StrUtil.isBlank(DictData.getDictTypeId()) || StrUtil.isBlank(DictData.getId()) ){
|
|
|
- throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
- }
|
|
|
- DictData content = DictDataService.delete(DictData);
|
|
|
- return ResultHelper.single(content);
|
|
|
+ public CommonResult<DictData> delete(@RequestBody DictData vo){
|
|
|
+ service.delete(vo);
|
|
|
+ return ResultHelper.success();
|
|
|
}
|
|
|
|
|
|
- @PostMapping("/query")
|
|
|
- public CommonResult<PageList<DictData>> query(@RequestBody DictData DictData) {
|
|
|
- List<DictData> content = DictDataService.query(DictData);
|
|
|
- return ResultHelper.multi(content);
|
|
|
+ @PostMapping("/result")
|
|
|
+ public CommonResult<PageList<DictData>> query(@RequestBody DictType dictType) {
|
|
|
+ if(dictType == null) {
|
|
|
+ throw new BusinessException(ResponseCode.A0400.getCode(), ResponseCode.A0400.getDesc());
|
|
|
+ }
|
|
|
+ List<DictData> dictDataList = service.queryData(dictType);
|
|
|
+ return ResultHelper.multi(dictDataList,dictDataList.size());
|
|
|
}
|
|
|
}
|