| | |
| | | import com.vincent.rsf.server.common.domain.KeyValVo; |
| | | import com.vincent.rsf.server.common.domain.PageParam; |
| | | import com.vincent.rsf.server.manager.entity.Companys; |
| | | import com.vincent.rsf.server.manager.entity.Warehouse; |
| | | import com.vincent.rsf.server.manager.service.CompanysService; |
| | | import com.vincent.rsf.server.system.controller.BaseController; |
| | | import io.swagger.annotations.Api; |
| | |
| | | if (Objects.isNull(companys.getType())) { |
| | | throw new CoolException("企业类型不能为空!!"); |
| | | } |
| | | |
| | | List<Companys> warehouses = companysService.list(new LambdaQueryWrapper<Companys>().eq(Companys::getName, companys.getName())); |
| | | if (!warehouses.isEmpty()) { |
| | | throw new CoolException("企业名称已存在!!"); |
| | | } |
| | | if (!companysService.list(new LambdaQueryWrapper<Companys>().eq(Companys::getCode, companys.getBreifCode())).isEmpty()) { |
| | | throw new CoolException("编码已存在!!"); |
| | | } |
| | | |
| | | companys.setCreateBy(getLoginUserId()); |
| | | companys.setUpdateBy(getLoginUserId()); |
| | | if (!companysService.save(companys)) { |
| | |
| | | @PostMapping("/companys/update") |
| | | public R update(@RequestBody Companys companys) { |
| | | companys.setUpdateBy(getLoginUserId()); |
| | | companys.setUpdateTime(new Date()); |
| | | if (Objects.isNull(companys.getName())) { |
| | | throw new CoolException("名称不能为空!!"); |
| | | } |
| | | if (Objects.isNull(companys.getBreifCode())) { |
| | | throw new CoolException("助记码不能为空!!"); |
| | | } |
| | | if (Objects.isNull(companys.getType())) { |
| | | throw new CoolException("类型不能为空!!"); |
| | | } |
| | | Companys companys1 = companysService.getById(companys.getId()); |
| | | if (!companys.getName().equals(companys1.getName())) { |
| | | List<Companys> areasList = companysService.list(new LambdaQueryWrapper<Companys>().eq(Companys::getName, companys.getName())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("企业名已存在!!"); |
| | | } |
| | | } |
| | | if (!companys.getBreifCode().equals(companys1.getBreifCode())) { |
| | | List<Companys> areasList = companysService.list(new LambdaQueryWrapper<Companys>().eq(Companys::getBreifCode, companys.getBreifCode())); |
| | | if (!areasList.isEmpty()) { |
| | | throw new CoolException("编码已存在!!"); |
| | | } |
| | | } |
| | | |
| | | if (!companysService.updateById(companys)) { |
| | | return R.error("Update Fail"); |
| | | } |