diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java index 5ea3002..b909e2e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/controller/DevInfoController.java @@ -117,8 +117,8 @@ public class DevInfoController extends BaseController { */ // @RequiresPermissions("equip:info:edit") @ApiOperation(value = "修改装备信息") - @PutMapping - public AjaxResult edit(@RequestBody @NotNull @Valid DevInfo devInfo) { + @PostMapping("edit") + public AjaxResult edit(@RequestBody @Valid DevInfo devInfo) { return devInfoService.updateDevInfo(devInfo); } @@ -159,7 +159,7 @@ public class DevInfoController extends BaseController { //@RequiresPermissions("equip:info:add") @ApiOperation(value = "新增装备--含附件上传") @PostMapping - public AjaxResult add(@RequestBody @NotNull @Valid DevInfo devInfo) { + public AjaxResult add(@RequestBody @Valid DevInfo devInfo) { return devInfoService.insertDevInfo(devInfo); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index 83bd228..931e2b8 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -35,7 +35,7 @@ public interface DevInfoMapper { * @param deviceName 物资名称 * @return 条数 */ - Integer getDeviceNameCount(String deviceName); + DevInfo getDeviceNameCount(String deviceName); int insertHotSearch(Long maId); @@ -165,5 +165,7 @@ public interface DevInfoMapper { * @return */ DevInfoVo selectCompanyById(String companyId); + + String getCodeByMaId(Long maId); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index d7438db..a2c5b9f 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -277,8 +277,10 @@ public class DevInfoServiceImpl implements DevInfoService { if (devInfo == null) { return AjaxResult.error("设备信息不能为空"); } + String code = ""; try { if (devInfo.getMaId() != null) { + code = devInfoMapper.getCodeByMaId(devInfo.getMaId()); // 更新设备信息--原本草稿相关内容删除 int deleted = devInfoMapper.deleteDevInfoByMaId(devInfo.getMaId(), MaStatusEnum.UNDER_RENT.getCode()); if (deleted == 0) { @@ -298,8 +300,8 @@ public class DevInfoServiceImpl implements DevInfoService { throw new ServiceException("非法参数异常: " + e.getMessage()); } - Integer deviceNameCount = devInfoMapper.getDeviceNameCount(devInfo.getDeviceName()); - if (deviceNameCount != null && deviceNameCount > 0) { + DevInfo deviceNameCount = devInfoMapper.getDeviceNameCount(devInfo.getDeviceName()); + if (deviceNameCount != null && deviceNameCount.getMaId() > 0) { return AjaxResult.error("设备名称已存在,请修改后重试!"); } @@ -307,7 +309,9 @@ public class DevInfoServiceImpl implements DevInfoService { Long userId = SecurityUtils.getLoginUser().getUserid(); //保存用户信息 devInfo.setCreator(userId).setMaStatus(ON_HIRE.getCode()).setOwnId(userId); - String code = getString(); + if (org.apache.commons.lang3.StringUtils.isBlank(code)){ + code = getString(); + } devInfo.setCode(code); int saveSuccessNum = devInfoMapper.insertDevInfo(devInfo); if (saveSuccessNum == 0) { @@ -424,8 +428,8 @@ public class DevInfoServiceImpl implements DevInfoService { if (devInfo.getMaId() == null) { return AjaxResult.error("设备ID为空,请携带设备信息修改"); } - int deviceId = devInfoMapper.getDeviceNameCount(devInfo.getDeviceName()); - if (deviceId > 0 && deviceId != devInfo.getMaId()) { + DevInfo deviceId = devInfoMapper.getDeviceNameCount(devInfo.getDeviceName()); + if (deviceId != null && !deviceId.getMaId().equals(devInfo.getMaId())) { return AjaxResult.error("设备名称已存在,请修改后重试!"); } return devInfoMapper.updateDevInfo(devInfo) > 0 ? AjaxResult.success("修改成功") : AjaxResult.error("修改失败"); diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index f5ee769..0b7994d 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -406,11 +406,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" where ma_id = #{maId} - - INSERT INTO ma_hot_search (ma_id, search_num, create_time) VALUES (#{maId}, 1, now()) @@ -676,5 +671,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" from bm_company_info where company_id = #{companyId} + +