| | |
| | | if(!checkNameUnique(company)){ |
| | | throw new ApiException("公司名称已存在"); |
| | | } |
| | | if(!checkCodeUnique(company)){ |
| | | throw new ApiException("公司编码已存在"); |
| | | } |
| | | company.setCode(company.getCode().toUpperCase()); |
| | | company.setCreateBy(SecurityUtils.getUsername()); |
| | | int row= baseMapper.insert(company); |
| | | if(row<1){ |
| | | throw new ApiException("新增公司失败"); |
| | | } |
| | | |
| | | return row; |
| | | } |
| | | |
| | |
| | | if(!checkNameUnique(company)){ |
| | | throw new ApiException("公司名称已存在"); |
| | | } |
| | | if(!checkCodeUnique(company)){ |
| | | throw new ApiException("公司编码已存在"); |
| | | } |
| | | company.setCode(company.getCode().toUpperCase()); |
| | | company.setUpdateBy(SecurityUtils.getUsername()); |
| | | return baseMapper.updateById(company); |
| | | } |
| | |
| | | } |
| | | return UserConstant.UNIQUE; |
| | | } |
| | | |
| | | |
| | | public boolean checkCodeUnique(SysCompany company){ |
| | | Long companyId=company.getId()==null?-1L:company.getId(); |
| | | SysCompany com= baseMapper.checkCodeUnique(company.getCode()); |
| | | if(com!=null&&com.getId().longValue()!=companyId.longValue()){ |
| | | return UserConstant.NOT_UNIQUE; |
| | | } |
| | | return UserConstant.UNIQUE; |
| | | } |
| | | } |