Commit 2cf02814 authored by huangcb's avatar huangcb

承运商接口:编辑承运商信息

parent 24f5fc34
...@@ -108,13 +108,21 @@ public class ErrorMessageComponent { ...@@ -108,13 +108,21 @@ public class ErrorMessageComponent {
@Value("${error-message.goodsowner.ext.account-address.1003}") @Value("${error-message.goodsowner.ext.account-address.1003}")
private String goodsOwnerExtAccountAddress1003; private String goodsOwnerExtAccountAddress1003;
@Value("${error-message.carrier.account.add.1011}") @Value("${error-message.carrier.account.add.1001}")
private String carrierAccountAdd1011; private String carrierAccountAdd1001;
@Value("${error-message.carrier.account.add.1012}") @Value("${error-message.carrier.account.add.1002}")
private String carrierAccountAdd1012; private String carrierAccountAdd1002;
@Value("${error-message.carrier.account.add.1013}") @Value("${error-message.carrier.account.add.1003}")
private String carrierAccountAdd1013; private String carrierAccountAdd1003;
@Value("${error-message.carrier.account.add.1014}") @Value("${error-message.carrier.account.add.1004}")
private String carrierAccountAdd1014; private String carrierAccountAdd1004;
@Value("${error-message.carrier.account.edit.1001}")
private String carrierAccountEdit1001;
@Value("${error-message.carrier.account.edit.1002}")
private String carrierAccountEdit1002;
@Value("${error-message.carrier.account.edit.1003}")
private String carrierAccountEdit1003;
@Value("${error-message.carrier.account.edit.1004}")
private String carrierAccountEdit1004;
} }
...@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.exception.EException; ...@@ -5,6 +5,7 @@ import com.esv.freight.customer.common.exception.EException;
import com.esv.freight.customer.common.response.EResponse; import com.esv.freight.customer.common.response.EResponse;
import com.esv.freight.customer.common.util.ReqUtils; import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import com.esv.freight.customer.module.carrier.CarrierConstants; import com.esv.freight.customer.module.carrier.CarrierConstants;
import com.esv.freight.customer.module.carrier.form.CarrierInfoForm; import com.esv.freight.customer.module.carrier.form.CarrierInfoForm;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService; import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
...@@ -36,6 +37,13 @@ public class CarrierAccountController { ...@@ -36,6 +37,13 @@ public class CarrierAccountController {
this.carrierAccountService = carrierAccountService; this.carrierAccountService = carrierAccountService;
} }
/**
* description 新增承运商帐号
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/24 14:49
**/
@PostMapping("/add") @PostMapping("/add")
public EResponse createAccountByManage(@RequestBody @Validated(ValidatorInsert.class) CarrierInfoForm form) throws EException { public EResponse createAccountByManage(@RequestBody @Validated(ValidatorInsert.class) CarrierInfoForm form) throws EException {
/****************************** 参数校验 ******************************/ /****************************** 参数校验 ******************************/
...@@ -52,4 +60,25 @@ public class CarrierAccountController { ...@@ -52,4 +60,25 @@ public class CarrierAccountController {
data.put("id", id); data.put("id", id);
return EResponse.ok(data); return EResponse.ok(data);
} }
/**
* description 编辑承运商信息
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/24 14:50
**/
@PostMapping("/edit")
public EResponse editAccountByManage(@RequestBody @Validated(ValidatorUpdate.class) CarrierInfoForm form) throws EException {
/****************************** 参数校验 ******************************/
// 承运商为企业
if (CarrierConstants.CARRIER_TYPE_COMPANY.equals(form.getCarrierType())) {
String[] notBlankParams = new String[] {"uniCreditCode", "carrierFullName", "provinceCode", "cityCode", "districtCode", "detailAddress"
, "legalPerson", "businessLicenseUrl"};
ReqUtils.checkParamsNotBlank(JSONObject.parseObject(form.toString()), notBlankParams);
}
/****************************** 参数校验 ******************************/
return EResponse.ok(carrierAccountService.updateCarrier(form));
}
} }
package com.esv.freight.customer.module.carrier.form; package com.esv.freight.customer.module.carrier.form;
import com.esv.freight.customer.common.validator.groups.ValidatorInsert; import com.esv.freight.customer.common.validator.groups.ValidatorInsert;
import com.esv.freight.customer.common.validator.groups.ValidatorUpdate;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
...@@ -9,7 +10,6 @@ import org.hibernate.validator.constraints.Range; ...@@ -9,7 +10,6 @@ import org.hibernate.validator.constraints.Range;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
/** /**
* @description: * @description:
...@@ -26,6 +26,7 @@ public class CarrierInfoForm { ...@@ -26,6 +26,7 @@ public class CarrierInfoForm {
/** /**
* *
*/ */
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
private Long id; private Long id;
/** /**
* 登录帐号,承运商联系人电话 * 登录帐号,承运商联系人电话
...@@ -36,108 +37,108 @@ public class CarrierInfoForm { ...@@ -36,108 +37,108 @@ public class CarrierInfoForm {
/** /**
* 帐号密码 * 帐号密码
*/ */
@Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorInsert.class}) @Length(min = 32, max = 32, message = "参数password长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数password不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数password不能为空", groups = {ValidatorInsert.class})
private String password; private String password;
/** /**
* 统一社会信用代码 * 统一社会信用代码
*/ */
@Length(max = 32, message = "参数uniCreditCode长度不合法", groups = {ValidatorInsert.class}) @Length(max = 32, message = "参数uniCreditCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String uniCreditCode; private String uniCreditCode;
/** /**
* 承运商名称 * 承运商名称
*/ */
@Length(max = 50, message = "参数carrierFullName长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数carrierFullName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String carrierFullName; private String carrierFullName;
/** /**
* 承运商简称 * 承运商简称
*/ */
@Length(max = 50, message = "参数carrierBriefName长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数carrierBriefName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String carrierBriefName; private String carrierBriefName;
/** /**
* 承运商类别:1-企业承运人、2-个体承运人 * 承运商类别:1-企业承运人、2-个体承运人
*/ */
@Range(min = 1, max = 2, message = "参数carrierType不合法") @Range(min = 1, max = 2, message = "参数carrierType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数carrierType不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数carrierType不能为空", groups = {ValidatorInsert.class})
private Integer carrierType; private Integer carrierType;
/** /**
* 承运商车辆类型(字典表):1-自营车、2-外协车、3-其他 * 承运商车辆类型(字典表):1-自营车、2-外协车、3-其他
*/ */
@Range(min = 1, max = 3, message = "参数carrierVehicleType不合法") @Range(min = 1, max = 3, message = "参数carrierVehicleType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotNull(message = "参数carrierVehicleType不能为空", groups = {ValidatorInsert.class}) @NotNull(message = "参数carrierVehicleType不能为空", groups = {ValidatorInsert.class})
private Integer carrierVehicleType; private Integer carrierVehicleType;
/** /**
* 企业注册地址-省份代码 * 企业注册地址-省份代码
*/ */
@Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class}) @Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String provinceCode; private String provinceCode;
/** /**
* 企业注册地址-市代码 * 企业注册地址-市代码
*/ */
@Length(min = 6, max = 6, message = "参数cityCode长度不合法", groups = {ValidatorInsert.class}) @Length(min = 6, max = 6, message = "参数cityCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String cityCode; private String cityCode;
/** /**
* 企业注册地址-区县代码 * 企业注册地址-区县代码
*/ */
@Length(min = 6, max = 6, message = "参数districtCode长度不合法", groups = {ValidatorInsert.class}) @Length(min = 6, max = 6, message = "参数districtCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String districtCode; private String districtCode;
/** /**
* 企业注册地址-详细地址 * 企业注册地址-详细地址
*/ */
@Length(max = 100, message = "参数detailAddress长度不合法", groups = {ValidatorInsert.class}) @Length(max = 100, message = "参数detailAddress长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String detailAddress; private String detailAddress;
/** /**
* 企业法人姓名 * 企业法人姓名
*/ */
@Length(max = 20, message = "参数legalPerson长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数legalPerson长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String legalPerson; private String legalPerson;
/** /**
* 营业执照URL * 营业执照URL
*/ */
@Length(max = 200, message = "参数businessLicenseUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数businessLicenseUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String businessLicenseUrl; private String businessLicenseUrl;
/** /**
* 道路运输经营许可证号 * 道路运输经营许可证号
*/ */
@Length(max = 20, message = "参数roadLicenseNumber长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数roadLicenseNumber长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数roadLicenseNumber不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数roadLicenseNumber不能为空", groups = {ValidatorInsert.class})
private String roadLicenseNumber; private String roadLicenseNumber;
/** /**
* 经营范围 * 经营范围
*/ */
@Length(max = 200, message = "参数businessScope长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数businessScope长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String businessScope; private String businessScope;
/** /**
* 道路运输经营许可证有效期 * 道路运输经营许可证有效期
*/ */
@Length(max = 20, message = "参数roadLicenseExpireDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数roadLicenseExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String roadLicenseExpireDate; private String roadLicenseExpireDate;
/** /**
* 道路运输经营许可证URL * 道路运输经营许可证URL
*/ */
@Length(max = 200, message = "参数roadLicenseUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数roadLicenseUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数roadLicenseUrl不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数roadLicenseUrl不能为空", groups = {ValidatorInsert.class})
private String roadLicenseUrl; private String roadLicenseUrl;
/** /**
* 联系人 * 联系人
*/ */
@Length(max = 20, message = "参数contactor长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数contactor长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数contactor不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数contactor不能为空", groups = {ValidatorInsert.class})
private String contactor; private String contactor;
/** /**
* 电子邮件 * 电子邮件
*/ */
@Length(max = 50, message = "参数email长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数email长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String email; private String email;
/** /**
* 信用评分:1-100 * 信用评分:1-100
*/ */
@Range(min = 1, max = 100, message = "参数creditScore不合法") @Range(min = 1, max = 100, message = "参数creditScore不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private Integer creditScore; private Integer creditScore;
/** /**
* 备注 * 备注
*/ */
@Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorInsert.class}) @Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String remark; private String remark;
@Override @Override
......
...@@ -32,5 +32,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> { ...@@ -32,5 +32,14 @@ public interface CarrierAccountService extends IService<CarrierAccountEntity> {
**/ **/
Long insertCarrier(CarrierInfoForm form); Long insertCarrier(CarrierInfoForm form);
/**
* description 编辑承运商信息
* param [form]
* return java.lang.Integer
* author Administrator
* createTime 2020/04/24 14:27
**/
Integer updateCarrier(CarrierInfoForm form);
} }
package com.esv.freight.customer.module.carrier.service.impl; package com.esv.freight.customer.module.carrier.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.esv.freight.customer.common.component.ErrorMessageComponent; import com.esv.freight.customer.common.component.ErrorMessageComponent;
import com.esv.freight.customer.common.component.PasswordComponent; import com.esv.freight.customer.common.component.PasswordComponent;
...@@ -16,6 +17,7 @@ import com.esv.freight.customer.module.carrier.form.CarrierInfoForm; ...@@ -16,6 +17,7 @@ import com.esv.freight.customer.module.carrier.form.CarrierInfoForm;
import com.esv.freight.customer.module.carrier.form.CarrierQueryForm; import com.esv.freight.customer.module.carrier.form.CarrierQueryForm;
import com.esv.freight.customer.module.carrier.service.CarrierAccountService; import com.esv.freight.customer.module.carrier.service.CarrierAccountService;
import com.esv.freight.customer.module.carrier.service.CarrierInfoService; import com.esv.freight.customer.module.carrier.service.CarrierInfoService;
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.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -60,14 +62,14 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca ...@@ -60,14 +62,14 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
CarrierQueryForm carrierQueryForm = new CarrierQueryForm(); CarrierQueryForm carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setAccount(form.getAccount()); carrierQueryForm.setAccount(form.getAccount());
if (this.isAccountExit(carrierQueryForm)) { if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1011, errorMessageComponent.getCarrierAccountAdd1011()); throw new EException(1001, errorMessageComponent.getCarrierAccountAdd1001());
} }
// 1.2:校验道路运输经营许可证号是否已存在 // 1.2:校验道路运输经营许可证号是否已存在
carrierQueryForm = new CarrierQueryForm(); carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setRoadLicenseNumber(form.getRoadLicenseNumber()); carrierQueryForm.setRoadLicenseNumber(form.getRoadLicenseNumber());
if (this.isAccountExit(carrierQueryForm)) { if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1012, errorMessageComponent.getCarrierAccountAdd1012()); throw new EException(1002, errorMessageComponent.getCarrierAccountAdd1002());
} }
// 承运商为企业 // 承运商为企业
...@@ -76,14 +78,14 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca ...@@ -76,14 +78,14 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
carrierQueryForm = new CarrierQueryForm(); carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setUniCreditCode(form.getUniCreditCode()); carrierQueryForm.setUniCreditCode(form.getUniCreditCode());
if (this.isAccountExit(carrierQueryForm)) { if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1013, errorMessageComponent.getCarrierAccountAdd1013()); throw new EException(1003, errorMessageComponent.getCarrierAccountAdd1003());
} }
// 1.4:校验名称是否已存在 // 1.4:校验名称是否已存在
carrierQueryForm = new CarrierQueryForm(); carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setCarrierFullName(form.getCarrierFullName()); carrierQueryForm.setCarrierFullName(form.getCarrierFullName());
if (this.isAccountExit(carrierQueryForm)) { if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1014, errorMessageComponent.getCarrierAccountAdd1014()); throw new EException(1004, errorMessageComponent.getCarrierAccountAdd1004());
} }
} }
...@@ -120,4 +122,58 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca ...@@ -120,4 +122,58 @@ public class CarrierAccountServiceImpl extends ServiceImpl<CarrierAccountDao, Ca
return accountId; return accountId;
} }
@Override
public Integer updateCarrier(CarrierInfoForm form) {
int count = 0;
// 1:校验
// 1.1:校验帐号ID是否有效
CarrierAccountEntity entity = this.baseMapper.selectById(form.getId());
if (null == entity) {
throw new EException(1001, errorMessageComponent.getCarrierAccountEdit1001());
}
// 1.2:校验道路运输经营许可证号是否已存在
CarrierQueryForm carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setId(form.getId());
carrierQueryForm.setRoadLicenseNumber(form.getRoadLicenseNumber());
if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1002, errorMessageComponent.getCarrierAccountEdit1002());
}
// 承运商为企业
if (CarrierConstants.CARRIER_TYPE_COMPANY.equals(form.getCarrierType())) {
// 1.3:校验统一社会信用代码是否已存在
carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setId(form.getId());
carrierQueryForm.setUniCreditCode(form.getUniCreditCode());
if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1003, errorMessageComponent.getCarrierAccountEdit1003());
}
// 1.4:校验名称是否已存在
carrierQueryForm = new CarrierQueryForm();
carrierQueryForm.setId(form.getId());
carrierQueryForm.setCarrierFullName(form.getCarrierFullName());
if (this.isAccountExit(carrierQueryForm)) {
throw new EException(1004, errorMessageComponent.getCarrierAccountEdit1004());
}
}
// 2:更新帐号密码
if (StringUtils.isNotBlank(form.getPassword())) {
CarrierAccountEntity accountEntity = new CarrierAccountEntity();
accountEntity.setId(form.getId());
accountEntity.setPassword(passwordComponent.generatePwd4Salt(form.getPassword(), entity.getSalt()));
count += this.baseMapper.updateById(accountEntity);
}
// 3:更新帐号信息
CarrierInfoEntity carrierInfoEntity = new CarrierInfoEntity();
BeanUtils.copyProperties(form, carrierInfoEntity);
count += this.carrierInfoService.getBaseMapper().update(carrierInfoEntity,
new UpdateWrapper<CarrierInfoEntity>().lambda().
eq(CarrierInfoEntity::getAccountId, form.getId()));
return count;
}
} }
\ No newline at end of file
...@@ -109,7 +109,12 @@ error-message: ...@@ -109,7 +109,12 @@ error-message:
carrier: carrier:
account: account:
add: add:
1011: 帐号已存在 1001: 帐号已存在
1012: 道路运输经营许可证号已存在 1002: 道路运输经营许可证号已存在
1013: 统一社会信用代码已存在 1003: 统一社会信用代码已存在
1014: 承运商名称已存在 1004: 承运商名称已存在
\ No newline at end of file edit:
1001: 无效的帐号ID
1002: 道路运输经营许可证号已存在
1003: 统一社会信用代码已存在
1004: 承运商名称已存在
\ No newline at end of file
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
from carrier_account a, carrier_info b from carrier_account a, carrier_info b
where a.id = b.account_id where a.id = b.account_id
<if test="id != null"> <if test="id != null">
<![CDATA[ a.id <> #{id} ]]> <![CDATA[ and a.id <> #{id} ]]>
</if> </if>
<if test="account != null"> <if test="account != null">
and a.account like CONCAT('%', #{account}, '%') and a.account like CONCAT('%', #{account}, '%')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment