|
@ -18,9 +18,11 @@ |
|
|
package com.epmet.controller; |
|
|
package com.epmet.controller; |
|
|
|
|
|
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
|
|
import com.epmet.constant.CustomerAgencyConstant; |
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
import com.epmet.dto.CustomerAgencyDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.result.AddAgencyResultDTO; |
|
|
import com.epmet.dto.result.AddAgencyResultDTO; |
|
@ -29,6 +31,7 @@ import com.epmet.dto.result.AgencysResultDTO; |
|
|
import com.epmet.dto.result.SubAgencyResultDTO; |
|
|
import com.epmet.dto.result.SubAgencyResultDTO; |
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
import com.epmet.entity.CustomerAgencyEntity; |
|
|
import com.epmet.service.AgencyService; |
|
|
import com.epmet.service.AgencyService; |
|
|
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.web.bind.annotation.*; |
|
|
import org.springframework.web.bind.annotation.*; |
|
@ -57,6 +60,19 @@ public class AgencyController { |
|
|
@PostMapping("addagency") |
|
|
@PostMapping("addagency") |
|
|
public Result<AddAgencyResultDTO> addAgency(@LoginUser TokenDto tokenDTO, @RequestBody AddAgencyFormDTO formDTO) { |
|
|
public Result<AddAgencyResultDTO> addAgency(@LoginUser TokenDto tokenDTO, @RequestBody AddAgencyFormDTO formDTO) { |
|
|
ValidatorUtils.validateEntity(formDTO); |
|
|
ValidatorUtils.validateEntity(formDTO); |
|
|
|
|
|
//机构级别是市级以上则市、区县名称可不传值,是区县级以上则区县名称可不传值
|
|
|
|
|
|
if(!CustomerAgencyConstant.PROVINCE_LEVEL.equals(formDTO.getLevel())&&!CustomerAgencyConstant.CITY_LEVEL.equals(formDTO.getLevel())){ |
|
|
|
|
|
if(StringUtils.isBlank(formDTO.getCity())){ |
|
|
|
|
|
throw new RenException(CustomerAgencyConstant.CITY_EXCEPTION); |
|
|
|
|
|
} |
|
|
|
|
|
if(StringUtils.isBlank(formDTO.getDistrict())){ |
|
|
|
|
|
throw new RenException(CustomerAgencyConstant.DISTRICT_EXCEPTION); |
|
|
|
|
|
} |
|
|
|
|
|
}else if(!CustomerAgencyConstant.PROVINCE_LEVEL.equals(formDTO.getLevel())){ |
|
|
|
|
|
if(StringUtils.isBlank(formDTO.getCity())){ |
|
|
|
|
|
throw new RenException(CustomerAgencyConstant.CITY_EXCEPTION); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return agencyService.addAgency(formDTO); |
|
|
return agencyService.addAgency(formDTO); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|