From 2478796b737d88788e71b06744b4fb7cb4943b7e Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Fri, 1 Jul 2022 23:43:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=95=B0=E6=8D=AE=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E3=80=91=E6=96=B0=E5=A2=9E=E5=92=8C=E7=BC=96=E8=BE=91=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../eve/controller/SysDictTypeController.java | 10 +++++----- .../eve/eitity/dict/SysDictTypeMation.java | 1 + .../eve/service/SysDictTypeService.java | 2 +- .../service/impl/SysDictTypeServiceImpl.java | 19 +++++++++++++++---- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/controller/SysDictTypeController.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/controller/SysDictTypeController.java index edd9427a..c62ea643 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/controller/SysDictTypeController.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/controller/SysDictTypeController.java @@ -46,17 +46,17 @@ public class SysDictTypeController { } /** - * 新增数据字典类型 + * 新增/编辑数据字典类型 * * @param inputObject * @param outputObject * @throws Exception */ - @ApiOperation(id = "insertDictTypeMation", value = "新增数据字典类型", method = "POST", allUse = "2") + @ApiOperation(id = "writeDictTypeMation", value = "新增/编辑数据字典类型", method = "POST", allUse = "2") @ApiImplicitParams(classBean = SysDictTypeMation.class) - @RequestMapping("/post/SysDictTypeController/insertDictTypeMation") - public void insertDictTypeMation(InputObject inputObject, OutputObject outputObject) { - sysDictTypeService.insertDictTypeMation(inputObject, outputObject); + @RequestMapping("/post/SysDictTypeController/writeDictTypeMation") + public void writeDictTypeMation(InputObject inputObject, OutputObject outputObject) { + sysDictTypeService.writeDictTypeMation(inputObject, outputObject); } } diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/eitity/dict/SysDictTypeMation.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/eitity/dict/SysDictTypeMation.java index 72f696ce..b158daf4 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/eitity/dict/SysDictTypeMation.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/eitity/dict/SysDictTypeMation.java @@ -28,6 +28,7 @@ import java.io.Serializable; public class SysDictTypeMation extends CommonOperatorUserInfo implements Serializable { @TableId("id") + @ApiModelProperty(value = "主键id。为空时新增,不为空时编辑") private String id; @TableField("dict_name") diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/SysDictTypeService.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/SysDictTypeService.java index 11628d19..a2b1f7f1 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/SysDictTypeService.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/SysDictTypeService.java @@ -19,5 +19,5 @@ public interface SysDictTypeService { void queryDictTypeList(InputObject inputObject, OutputObject outputObject); - void insertDictTypeMation(InputObject inputObject, OutputObject outputObject); + void writeDictTypeMation(InputObject inputObject, OutputObject outputObject); } diff --git a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysDictTypeServiceImpl.java b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysDictTypeServiceImpl.java index aa06c8d0..a16ce815 100644 --- a/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysDictTypeServiceImpl.java +++ b/skyeye-promote/skyeye-common/src/main/java/com/skyeye/eve/service/impl/SysDictTypeServiceImpl.java @@ -7,6 +7,7 @@ package com.skyeye.eve.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import com.skyeye.common.constans.CommonConstants; import com.skyeye.common.entity.CommonOperatorUserInfo; import com.skyeye.common.object.InputObject; import com.skyeye.common.object.OutputObject; @@ -16,6 +17,7 @@ import com.skyeye.eve.dao.SysDictTypeDao; import com.skyeye.eve.eitity.dict.SysDictTypeMation; import com.skyeye.eve.eitity.dict.SysDictTypeQueryDO; import com.skyeye.eve.service.SysDictTypeService; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; @@ -54,24 +56,33 @@ public class SysDictTypeServiceImpl implements SysDictTypeService { } /** - * 新增数据字典类型 + * 新增/编辑数据字典类型 * * @param inputObject * @param outputObject * @throws Exception */ @Override - public void insertDictTypeMation(InputObject inputObject, OutputObject outputObject) { + public void writeDictTypeMation(InputObject inputObject, OutputObject outputObject) { SysDictTypeMation sysDictTypeMation = inputObject.getParams(SysDictTypeMation.class); + // 1.根据dictName和dictCode进行校验 QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.and(wrapper -> wrapper.eq(MybatisPlusUtil.getDeclaredFieldsInfo2(SysDictTypeMation.class, "dictName"), sysDictTypeMation.getDictName()) .or().eq(MybatisPlusUtil.getDeclaredFieldsInfo2(SysDictTypeMation.class, "dictCode"), sysDictTypeMation.getDictCode())); + if (StringUtils.isNotEmpty(sysDictTypeMation.getId())) { + queryWrapper.ne(CommonConstants.ID, sysDictTypeMation.getId()); + } SysDictTypeMation checkDictTypeMation = sysDictTypeDao.selectOne(queryWrapper); if (ObjectUtils.isEmpty(checkDictTypeMation)) { String userId = inputObject.getLogParams().get("id").toString(); - DataCommonUtil.setCommonDataByGenericity(sysDictTypeMation, userId); - sysDictTypeDao.insert(sysDictTypeMation); + if (StringUtils.isNotEmpty(sysDictTypeMation.getId())) { + DataCommonUtil.setCommonLastUpdateDataByGenericity(sysDictTypeMation, userId); + sysDictTypeDao.updateById(sysDictTypeMation); + } else { + DataCommonUtil.setCommonDataByGenericity(sysDictTypeMation, userId); + sysDictTypeDao.insert(sysDictTypeMation); + } } else { outputObject.setreturnMessage("this data is non-existent."); }