Browse Source

政府端-组织添加-Bug修改

dev_shibei_match
sunyuchao 5 years ago
parent
commit
38dee30efa
  1. 10
      epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java
  2. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java
  3. 16
      epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

10
epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/AddAgencyFormDTO.java

@ -69,22 +69,20 @@ public class AddAgencyFormDTO implements Serializable {
/** /**
* 省份 * 省份
*/ */
@NotBlank(message = "省级名称不能为空") @NotBlank(message = "省级机关名称不能为空")
@Length(max=30,message = "省名称不能超过30个字") @Length(max=30,message = "省级机关名称不能超过30个字")
private String province; private String province;
/** /**
* 城市 * 城市
*/ */
@NotBlank(message = "市级名称不能为空") @Length(max=30,message = "市级机关名称不能超过30个字")
@Length(max=30,message = "市级名称不能超过30个字")
private String city; private String city;
/** /**
* 区县 * 区县
*/ */
@NotBlank(message = "区县名称不能为空") @Length(max=30,message = "区县级机关名称不能超过30个字")
@Length(max=30,message = "区县名称不能超过30个字")
private String district; private String district;
} }

16
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/CustomerAgencyConstant.java

@ -18,4 +18,20 @@ public interface CustomerAgencyConstant {
* 组织删除失败 * 组织删除失败
*/ */
String DEL_EXCEPTION = "组织删除失败"; String DEL_EXCEPTION = "组织删除失败";
/**
* 机关级别-省级
*/
String PROVINCE_LEVEL = "province";
/**
* 机关级别-市级
*/
String CITY_LEVEL = "city";
/**
* 市级名称不能为空
*/
String CITY_EXCEPTION = "市级机关名称不能为空";
/**
* 区县名称不能为空
*/
String DISTRICT_EXCEPTION = "区县级机关名称不能为空";
} }

16
epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/AgencyController.java

@ -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);
} }

Loading…
Cancel
Save