'提交代码'

dev-discount
hurui 4 years ago
parent 5620edca7d
commit b4ef815606
  1. 41
      hai-bweb/src/main/java/com/bweb/controller/BsCompanyController.java
  2. 2
      hai-service/src/main/java/com/hai/service/impl/BsCompanyServiceImpl.java

@ -89,10 +89,13 @@ public class BsCompanyController {
try { try {
BsCompany company = secCompanyModel.getCompany(); BsCompany company = secCompanyModel.getCompany();
SecUser user = secCompanyModel.getUser(); SecUser user = secCompanyModel.getUser();
if (StringUtils.isBlank(company.getName()) || StringUtils.isBlank(company.getRegionId()) || if (StringUtils.isBlank(company.getName())
StringUtils.isBlank(company.getAddress()) || StringUtils.isBlank(company.getPhone()) || || StringUtils.isBlank(company.getRegionId())
StringUtils.isBlank(user.getLoginName()) || || StringUtils.isBlank(company.getAddress())
StringUtils.isBlank(user.getPassword()) || StringUtils.isBlank(user.getTelephone())) { || StringUtils.isBlank(company.getPhone())
|| StringUtils.isBlank(user.getLoginName())
|| StringUtils.isBlank(user.getPassword())
|| StringUtils.isBlank(user.getTelephone())) {
log.error("BsCompanyController --> addCompanyAndUser() error!", "参数错误"); log.error("BsCompanyController --> addCompanyAndUser() error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
@ -103,25 +106,13 @@ public class BsCompanyController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");
} }
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); 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()); BsCompany secCompany = bsCompanyService.selectCompanyByName(company.getName());
if (secCompany != null) { if (secCompany != null) {
log.error("BsCompanyController --> addCompanyAndUser() error!", "该单位已经存在"); log.error("BsCompanyController --> addCompanyAndUser() error!", "该单位已经存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_NAME_IS_EXIST_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()); SecUser secUser = secUserService.findByLoginName(user.getLoginName());
if (secUser != null) { if (secUser != null) {
@ -135,7 +126,6 @@ public class BsCompanyController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PHONE_HAS_ONE_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PHONE_HAS_ONE_ERROR, "");
} }
//生成公司状态 //生成公司状态
company.setStatus(1); company.setStatus(1);
company.setCreateTime(new Date()); company.setCreateTime(new Date());
@ -203,33 +193,18 @@ public class BsCompanyController {
} }
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); 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()); BsCompany secCompany = bsCompanyService.selectCompanyByName(company.getName());
if (secCompany != null && !secCompany.getId().equals(company.getId())) { if (secCompany != null && !secCompany.getId().equals(company.getId())) {
log.error("BsCompanyController --> updateCompany() error!", "该单位已经存在"); log.error("BsCompanyController --> updateCompany() error!", "该单位已经存在");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPANY_NAME_IS_EXIST_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()); BsOrganization organization = bsOrganizationService.findTopByCompany(company.getId());
if (organization == null) { if (organization == null) {
log.error("BsCompanyController --> updateCompany() error!", "未找到该部门信息"); log.error("BsCompanyController --> updateCompany() error!", "未找到该部门信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_FIND_ORGANIZATION_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_FIND_ORGANIZATION_ERROR, "");
} }
// 查询用户 // 查询用户
SecUser secUser = secUserService.findById(user.getId()); SecUser secUser = secUserService.findById(user.getId());
if (secUser == null) { if (secUser == null) {

@ -71,7 +71,7 @@ public class BsCompanyServiceImpl implements BsCompanyService {
secOrganization.setManagerName(secUser.getUserName()); secOrganization.setManagerName(secUser.getUserName());
secOrganization.setManagerPhone(secUser.getTelephone()); secOrganization.setManagerPhone(secUser.getTelephone());
bsOrganizationMapper.updateByPrimaryKey(secOrganization); bsOrganizationMapper.updateByPrimaryKey(secOrganization);
// 保存用户角色[就业局主角色] // 保存用户角色
SecUserRoleRel userRole = new SecUserRoleRel(); SecUserRoleRel userRole = new SecUserRoleRel();
userRole.setUserId(secUser.getId()); userRole.setUserId(secUser.getId());
userRole.setRoleId(2L); userRole.setRoleId(2L);

Loading…
Cancel
Save