|
|
|
@ -89,39 +89,31 @@ public class BsCompanyController { |
|
|
|
|
try { |
|
|
|
|
BsCompany company = secCompanyModel.getCompany(); |
|
|
|
|
SecUser user = secCompanyModel.getUser(); |
|
|
|
|
if (StringUtils.isBlank(company.getName()) || StringUtils.isBlank(company.getRegionId()) || |
|
|
|
|
StringUtils.isBlank(company.getAddress()) || StringUtils.isBlank(company.getPhone()) || |
|
|
|
|
StringUtils.isBlank(user.getLoginName()) || |
|
|
|
|
StringUtils.isBlank(user.getPassword()) || StringUtils.isBlank(user.getTelephone())) { |
|
|
|
|
if (StringUtils.isBlank(company.getName()) |
|
|
|
|
|| StringUtils.isBlank(company.getRegionId()) |
|
|
|
|
|| StringUtils.isBlank(company.getAddress()) |
|
|
|
|
|| StringUtils.isBlank(company.getPhone()) |
|
|
|
|
|| StringUtils.isBlank(user.getLoginName()) |
|
|
|
|
|| StringUtils.isBlank(user.getPassword()) |
|
|
|
|
) { |
|
|
|
|
log.error("BsCompanyController --> addCompanyAndUser() error!", "参数错误"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
//发布人员
|
|
|
|
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
|
|
|
|
|
|
|
|
|
if(sessionObject == null){ |
|
|
|
|
log.error("SecCompanyController --> updateCompany() error!", ""); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); |
|
|
|
|
} |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
// 校验区域
|
|
|
|
|
if (company.getRegionId().length() >= 4) { |
|
|
|
|
company.setRegionId(company.getRegionId().substring(0,4)); |
|
|
|
|
} else { |
|
|
|
|
log.error("BsCompanyController --> addCompanyAndUser() error!", "单位区域必须选择到市级区域"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_REGION_HAS_IN_CITY_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 校验公司名称
|
|
|
|
|
BsCompany secCompany = bsCompanyService.selectCompanyByName(company.getName()); |
|
|
|
|
if (secCompany != null) { |
|
|
|
|
log.error("BsCompanyController --> addCompanyAndUser() error!", "该单位已经存在"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_NAME_IS_EXIST_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
// // 校验区域下是否存在公司
|
|
|
|
|
// BsCompany companyRegion = bsCompanyService.selectCompanyByRegion(company.getRegionId());
|
|
|
|
|
// if (companyRegion != null) {
|
|
|
|
|
// log.error("BsCompanyController --> addCompanyAndUser() error!", "该区域下已存在单位");
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_REGION_IS_EXIST_ERROR, "");
|
|
|
|
|
// }
|
|
|
|
|
// 校验用户
|
|
|
|
|
SecUser secUser = secUserService.findByLoginName(user.getLoginName()); |
|
|
|
|
if (secUser != null) { |
|
|
|
@ -135,7 +127,6 @@ public class BsCompanyController { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PHONE_HAS_ONE_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//生成公司状态
|
|
|
|
|
company.setStatus(1); |
|
|
|
|
company.setCreateTime(new Date()); |
|
|
|
@ -203,33 +194,18 @@ public class BsCompanyController { |
|
|
|
|
} |
|
|
|
|
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); |
|
|
|
|
|
|
|
|
|
// 校验区域
|
|
|
|
|
if (company.getRegionId().length() >= 4) { |
|
|
|
|
company.setRegionId(company.getRegionId().substring(0,4)); |
|
|
|
|
} else { |
|
|
|
|
log.error("BsCompanyController --> updateCompany() error!", "单位区域必须选择到市级区域"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_REGION_HAS_IN_CITY_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
// 校验公司名称
|
|
|
|
|
BsCompany secCompany = bsCompanyService.selectCompanyByName(company.getName()); |
|
|
|
|
if (secCompany != null && !secCompany.getId().equals(company.getId())) { |
|
|
|
|
log.error("BsCompanyController --> updateCompany() error!", "该单位已经存在"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_NAME_IS_EXIST_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
// // 校验区域下是否存在公司
|
|
|
|
|
// BsCompany companyRegion = bsCompanyService.selectCompanyByRegion(company.getRegionId());
|
|
|
|
|
// if (companyRegion != null && !companyRegion.getId().equals(company.getId())) {
|
|
|
|
|
// log.error("BsCompanyController --> updateCompany() error!", "该区域下已存在单位");
|
|
|
|
|
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_REGION_IS_EXIST_ERROR, "");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
BsOrganization organization = bsOrganizationService.findTopByCompany(company.getId()); |
|
|
|
|
if (organization == null) { |
|
|
|
|
log.error("BsCompanyController --> updateCompany() error!", "未找到该部门信息"); |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_FIND_ORGANIZATION_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 查询用户
|
|
|
|
|
SecUser secUser = secUserService.findById(user.getId()); |
|
|
|
|
if (secUser == null) { |
|
|
|
|