Commit 6e2d9172 authored by huangcb's avatar huangcb

新增接口:编辑货主帐号信息

parent 27e5c86a
package com.esv.freight.customer.common.component; package com.esv.freight.customer.common.component;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -15,9 +16,13 @@ import org.springframework.stereotype.Component; ...@@ -15,9 +16,13 @@ import org.springframework.stereotype.Component;
*/ */
@Component @Component
@RefreshScope @RefreshScope
@Data
public class ErrorMessageComponent { public class ErrorMessageComponent {
@Value("${error-message.goodsowner.account.add.1001}") @Value("${error-message.goodsowner.account.add.1001}")
public String goodsOwnerAccountAdd1001; private String goodsOwnerAccountAdd1001;
@Value("${error-message.goodsowner.account.edit.1001}")
private String goodsOwnerAccountEdit1001;
} }
...@@ -7,10 +7,12 @@ import com.esv.freight.customer.common.response.EResponse; ...@@ -7,10 +7,12 @@ 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.util.VerifyUtils; import com.esv.freight.customer.common.util.VerifyUtils;
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.goodsowner.GoodsOwnerConstants; import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.form.AccountInfoForm; import com.esv.freight.customer.module.goodsowner.form.AccountInfoForm;
import com.esv.freight.customer.module.goodsowner.service.AccountService; import com.esv.freight.customer.module.goodsowner.service.AccountService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
...@@ -69,4 +71,24 @@ public class GoodsOwnerController { ...@@ -69,4 +71,24 @@ public class GoodsOwnerController {
return EResponse.ok(accountService.createAccountByManager(form)); return EResponse.ok(accountService.createAccountByManager(form));
} }
/**
* description 更新帐号信息
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/18 14:06
**/
@PostMapping("/edit")
public EResponse updateAccountInfo(@RequestBody @Validated(ValidatorUpdate.class) AccountInfoForm form) throws EException {
/****************************** 参数校验 ******************************/
// 校验身份证号码
if (StringUtils.isNotBlank(form.getIdCard()) && !VerifyUtils.isValidIdCard18(form.getIdCard())) {
throw new EException(ECode.PARAM_ERROR.code(), "无效的身份证号码");
}
/****************************** 参数校验 ******************************/
accountService.updateAccountInfo(form);
return EResponse.ok();
}
} }
...@@ -76,12 +76,12 @@ public class AccountEntity implements Serializable { ...@@ -76,12 +76,12 @@ public class AccountEntity implements Serializable {
/** /**
* 修改者 * 修改者
*/ */
@TableField(fill = FieldFill.INSERT) @TableField(fill = FieldFill.INSERT_UPDATE)
private String updateUser; private String updateUser;
/** /**
* 创建时间 * 创建时间
*/ */
@TableField(fill = FieldFill.INSERT_UPDATE) @TableField(fill = FieldFill.INSERT)
private Date createTime; private Date createTime;
/** /**
* 修改时间 * 修改时间
......
package com.esv.freight.customer.module.goodsowner.form; package com.esv.freight.customer.module.goodsowner.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;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
/** /**
...@@ -21,6 +23,9 @@ import javax.validation.constraints.Pattern; ...@@ -21,6 +23,9 @@ import javax.validation.constraints.Pattern;
@Data @Data
public class AccountInfoForm { public class AccountInfoForm {
@NotNull(message = "参数id不能为空", groups = {ValidatorUpdate.class})
private Long id;
/** /**
* (个人或企业联系人手机号)帐号 * (个人或企业联系人手机号)帐号
*/ */
...@@ -30,110 +35,106 @@ public class AccountInfoForm { ...@@ -30,110 +35,106 @@ public class AccountInfoForm {
/** /**
* 帐号密码 * 帐号密码
*/ */
@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;
/** /**
* 货主类型:1-个人、2-企业 * 货主类型:1-个人、2-企业
*/ */
@Pattern(regexp = "[12]", message = "参数ownerType不合法", groups = {ValidatorInsert.class}) @Pattern(regexp = "[12]", message = "参数ownerType不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数ownerType不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数ownerType不能为空", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String ownerType; private String ownerType;
/**
* 客户编码
*/
private String ownerNumber;
/** /**
* 客户名称 * 客户名称
*/ */
@Length(max = 50, message = "参数ownerFullName长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数ownerFullName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String ownerFullName; private String ownerFullName;
/** /**
* 客户简称 * 客户简称
*/ */
@Length(max = 50, message = "参数ownerBriefName长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数ownerBriefName长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String ownerBriefName; private String ownerBriefName;
/** /**
* 统一社会信用代码 * 统一社会信用代码
*/ */
@Length(max = 20, message = "参数uniCreditCode长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数uniCreditCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String uniCreditCode; private String uniCreditCode;
/** /**
* 营业期限 * 营业期限
*/ */
@Length(max = 50, message = "参数creditExpireDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数creditExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String creditExpireDate; private String creditExpireDate;
/** /**
* 营业执照正本ULR * 营业执照正本ULR
*/ */
@Length(max = 200, message = "参数creditOriginalUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数creditOriginalUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String creditOriginalUrl; private String creditOriginalUrl;
/** /**
* 营业执照副本ULR * 营业执照副本ULR
*/ */
@Length(max = 200, message = "参数creditCopyUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数creditCopyUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String creditCopyUrl; private String creditCopyUrl;
/** /**
* 企业法人姓名 * 企业法人姓名
*/ */
@Length(max = 20, message = "参数legalPerson长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数legalPerson长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String legalPerson; private String legalPerson;
/** /**
* 企业法人手机号 * 企业法人手机号
*/ */
@Length(max = 20, message = "参数legalPhone长度不合法", groups = {ValidatorInsert.class}) @Length(max = 20, message = "参数legalPhone长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String legalPhone; private String legalPhone;
/** /**
* 省份代码 * 省份代码
*/ */
@Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class}) @Length(min = 6, max = 6, message = "参数provinceCode长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数provinceCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数provinceCode不能为空", groups = {ValidatorInsert.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})
@NotBlank(message = "参数cityCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数cityCode不能为空", groups = {ValidatorInsert.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})
@NotBlank(message = "参数districtCode不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数districtCode不能为空", groups = {ValidatorInsert.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})
@NotBlank(message = "参数detailAddress不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数detailAddress不能为空", groups = {ValidatorInsert.class})
private String detailAddress; private String detailAddress;
/** /**
* (个人或企业)联系人 * (个人或企业)联系人
*/ */
@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(min = 18, max = 18, message = "参数idCard长度不合法", groups = {ValidatorInsert.class}) @Length(min = 18, max = 18, message = "参数idCard长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCard不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数idCard不能为空", groups = {ValidatorInsert.class})
private String idCard; private String idCard;
/** /**
* (个人或企业)身份证有效期 * (个人或企业)身份证有效期
*/ */
@Length(max = 50, message = "参数idCardExpireDate长度不合法", groups = {ValidatorInsert.class}) @Length(max = 50, message = "参数idCardExpireDate长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
private String idCardExpireDate; private String idCardExpireDate;
/** /**
* 身份证正面图片URL * 身份证正面图片URL
*/ */
@Length(max = 200, message = "参数idCardFrontUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数idCardFrontUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCardFrontUrl不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数idCardFrontUrl不能为空", groups = {ValidatorInsert.class})
private String idCardFrontUrl; private String idCardFrontUrl;
/** /**
* 身份证背面图片URL * 身份证背面图片URL
*/ */
@Length(max = 200, message = "参数idCardBackUrl长度不合法", groups = {ValidatorInsert.class}) @Length(max = 200, message = "参数idCardBackUrl长度不合法", groups = {ValidatorInsert.class, ValidatorUpdate.class})
@NotBlank(message = "参数idCardBackUrl不能为空", groups = {ValidatorInsert.class}) @NotBlank(message = "参数idCardBackUrl不能为空", groups = {ValidatorInsert.class})
private String idCardBackUrl; private String idCardBackUrl;
......
...@@ -24,14 +24,32 @@ public interface AccountService extends IService<AccountEntity> { ...@@ -24,14 +24,32 @@ public interface AccountService extends IService<AccountEntity> {
**/ **/
AccountEntity getAccountRecordByAccount(String account); AccountEntity getAccountRecordByAccount(String account);
/**
* description 通过ID查询帐号记录
* param [id]
* return com.esv.freight.customer.module.goodsowner.entity.AccountEntity
* author Administrator
* createTime 2020/04/17 15:46
**/
AccountEntity getAccountRecordById(Long id);
/** /**
* description 通过管理平台创建帐号 * description 通过管理平台创建帐号
* param [form] * param [form]
* return int * return Long
* author Administrator * author Administrator
* createTime 2020/04/17 16:05 * createTime 2020/04/17 16:05
**/ **/
int createAccountByManager(AccountInfoForm form); Long createAccountByManager(AccountInfoForm form);
/**
* description 更新帐号信息
* param [form]
* return void
* author Administrator
* createTime 2020/04/18 13:46
**/
void updateAccountInfo(AccountInfoForm form);
} }
package com.esv.freight.customer.module.goodsowner.service.impl; package com.esv.freight.customer.module.goodsowner.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.exception.EException; import com.esv.freight.customer.common.exception.EException;
...@@ -19,6 +21,7 @@ import com.esv.freight.customer.module.goodsowner.service.AuditHistoryService; ...@@ -19,6 +21,7 @@ import com.esv.freight.customer.module.goodsowner.service.AuditHistoryService;
import com.esv.freight.customer.module.goodsowner.service.InfoService; import com.esv.freight.customer.module.goodsowner.service.InfoService;
import com.esv.gateway.common.GatewayHeaders; import com.esv.gateway.common.GatewayHeaders;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
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;
...@@ -54,13 +57,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i ...@@ -54,13 +57,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
return this.baseMapper.selectOne(queryWrapper); return this.baseMapper.selectOne(queryWrapper);
} }
@Override
public AccountEntity getAccountRecordById(Long id) {
AccountEntity queryEntity = new AccountEntity();
queryEntity.setId(id);
QueryWrapper<AccountEntity> queryWrapper = new QueryWrapper<>(queryEntity);
return this.baseMapper.selectOne(queryWrapper);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int createAccountByManager(AccountInfoForm form) { public Long createAccountByManager(AccountInfoForm form) {
// 1.判断帐号是否已存在 // 1.判断帐号是否已存在
AccountEntity accountEntity = this.getAccountRecordByAccount(form.getAccount()); AccountEntity accountEntity = this.getAccountRecordByAccount(form.getAccount());
if (null != accountEntity) { if (null != accountEntity) {
throw new EException(1001, errorMessageComponent.goodsOwnerAccountAdd1001); throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountAdd1001());
} else { } else {
accountEntity = new AccountEntity(); accountEntity = new AccountEntity();
} }
...@@ -81,13 +92,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i ...@@ -81,13 +92,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
// 3.新增帐号 // 3.新增帐号
BeanUtils.copyProperties(form, accountEntity); BeanUtils.copyProperties(form, accountEntity);
accountEntity.setId(null);
String salt = UUID.randomUUID().toString().replace("-", ""); String salt = UUID.randomUUID().toString().replace("-", "");
String password = DigestUtils.md5Hex(form.getPassword() + salt); String password = DigestUtils.md5Hex(form.getPassword() + salt);
accountEntity.setSalt(salt); accountEntity.setSalt(salt);
accountEntity.setPassword(password); accountEntity.setPassword(password);
accountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_PLATFORM); accountEntity.setSourceType(GoodsOwnerConstants.OWNER_SOURCE_TYPE_PLATFORM);
accountEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS); accountEntity.setAuditStatus(GoodsOwnerConstants.OWNER_AUDIT_STATUS_SUCCESS);
int accountId = this.baseMapper.insert(accountEntity); this.baseMapper.insert(accountEntity);
Long accountId = accountEntity.getId();
// 4.新增帐号信息 // 4.新增帐号信息
InfoEntity infoEntity = new InfoEntity(); InfoEntity infoEntity = new InfoEntity();
...@@ -104,7 +117,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i ...@@ -104,7 +117,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
infoEntity.setLegalPhone(null); infoEntity.setLegalPhone(null);
} }
infoEntity.setOwnerNumber(ownerNumber); infoEntity.setOwnerNumber(ownerNumber);
infoEntity.setAccountId(Long.parseLong(String.valueOf(accountId))); infoEntity.setAccountId(accountId);
infoService.getBaseMapper().insert(infoEntity); infoService.getBaseMapper().insert(infoEntity);
// 5.新增帐号审核记录 // 5.新增帐号审核记录
...@@ -116,4 +129,43 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i ...@@ -116,4 +129,43 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
return accountId; return accountId;
} }
@Override
public void updateAccountInfo(AccountInfoForm form) {
// 1.判断帐号是否存在
Long accountId = form.getId();
AccountEntity accountEntity = this.getAccountRecordById(accountId);
if (null == accountEntity) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountEdit1001());
}
// 2.更新表:goods_owner_account,更新密码
String password = form.getPassword();
if (StringUtils.isNotBlank(password)) {
AccountEntity accountEntityUpdate = new AccountEntity();
accountEntityUpdate.setId(accountId);
password = DigestUtils.md5Hex(form.getPassword() + accountEntity.getSalt());
accountEntityUpdate.setPassword(password);
this.baseMapper.updateById(accountEntityUpdate);
}
// 3.更新表:goods_owner_info
InfoEntity infoEntity = new InfoEntity();
BeanUtils.copyProperties(form, infoEntity);
// 货主为个人
if (GoodsOwnerConstants.OWNER_TYPE_PERSONAL.equals(form.getOwnerType())) {
infoEntity.setOwnerFullName(null);
infoEntity.setOwnerBriefName(null);
infoEntity.setUniCreditCode(null);
infoEntity.setCreditOriginalUrl(null);
infoEntity.setCreditCopyUrl(null);
infoEntity.setCreditExpireDate(null);
infoEntity.setLegalPerson(null);
infoEntity.setLegalPhone(null);
}
InfoEntity infoEntityWrapper = new InfoEntity();
infoEntityWrapper.setAccountId(accountId);
Wrapper<InfoEntity> InfoUpdateWrapper = new UpdateWrapper<>(infoEntityWrapper);
infoService.getBaseMapper().update(infoEntity, InfoUpdateWrapper);
}
} }
\ No newline at end of file
...@@ -49,4 +49,6 @@ error-message: ...@@ -49,4 +49,6 @@ error-message:
goodsowner: goodsowner:
account: account:
add: add:
1001: 帐号已存在 1001: 帐号已存在
\ No newline at end of file edit:
1001: 无效的帐号ID
\ No newline at end of file
package com.esv.freight.customer.common.component;
import com.esv.freight.customer.BaseTestController;
import lombok.extern.slf4j.Slf4j;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.common.component.ErrorMessageComponentTest
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/18 14:13
* @version:1.0
*/
@RunWith(SpringRunner.class)
@SpringBootTest
@Slf4j
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class ErrorMessageComponentTest extends BaseTestController {
@Autowired
ErrorMessageComponent errorMessageComponent;
@Test
public void test() {
log.info(errorMessageComponent.getGoodsOwnerAccountAdd1001());
}
}
...@@ -22,7 +22,19 @@ public class VerifyUtilsTest { ...@@ -22,7 +22,19 @@ public class VerifyUtilsTest {
String idCard = "360721198712030856"; String idCard = "360721198712030856";
log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard)); log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard));
idCard = "900721198712030856"; idCard = "11010119900307045X";
log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard));
idCard = "110101199003075031";
log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard));
idCard = "110101199003073095";
log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard));
idCard = "110101199003079219";
log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard));
idCard = "110101199003075357";
log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard)); log.info("{}={}", idCard, VerifyUtils.isValidIdCard18(idCard));
idCard = "36072119871203085x"; idCard = "36072119871203085x";
......
...@@ -19,6 +19,8 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; ...@@ -19,6 +19,8 @@ import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers; import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.result.MockMvcResultMatchers; import org.springframework.test.web.servlet.result.MockMvcResultMatchers;
import java.util.UUID;
/** /**
* @description: * @description:
* @project: freight-customer-service * @project: freight-customer-service
...@@ -109,4 +111,85 @@ public class GoodsOwnerControllerTest extends BaseTestController { ...@@ -109,4 +111,85 @@ public class GoodsOwnerControllerTest extends BaseTestController {
JSONObject result = JSONObject.parseObject(responseStr); JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code")); Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
} }
@Test
public void b1_updateAccountInfo_personal_success_test() throws Exception {
String url = "/goodsowner/account/edit";
// 构造数据
JSONObject reqJson = new JSONObject();
AccountInfoForm form = new AccountInfoForm();
form.setId(1L);
form.setPassword(UUID.randomUUID().toString().replaceAll("-", ""));
form.setOwnerType(GoodsOwnerConstants.OWNER_TYPE_PERSONAL);
form.setContactor("黄朝斌01");
form.setIdCard("11010119900307045X");
form.setIdCardExpireDate("2030/12/31");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("双园路");
form.setIdCardFrontUrl("http://127.0.0.1/001.jpg");
form.setIdCardBackUrl("http://127.0.0.1/002.jpg");
form.setOwnerFullName("黄朝斌测试有限公司01");
form.setUniCreditCode("123456789");
form.setCreditCopyUrl("http://127.0.0.1/003.jpg");
form.setLegalPerson("黄卓越");
reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
}
@Test
public void b2_updateAccountInfo_company_success_test() throws Exception {
String url = "/goodsowner/account/edit";
// 构造数据
JSONObject reqJson = new JSONObject();
AccountInfoForm form = new AccountInfoForm();
form.setId(4L);
form.setPassword(UUID.randomUUID().toString().replaceAll("-", ""));
form.setOwnerType(GoodsOwnerConstants.OWNER_TYPE_COMPANY);
form.setContactor("黄朝斌01");
form.setIdCard("110101199003075031");
form.setIdCardExpireDate("2030/12/31");
form.setProvinceCode("210000");
form.setCityCode("210100");
form.setDistrictCode("210102");
form.setDetailAddress("双园路");
form.setIdCardFrontUrl("http://127.0.0.1/001.jpg");
form.setIdCardBackUrl("http://127.0.0.1/002.jpg");
form.setOwnerFullName("黄朝斌测试有限公司01");
form.setOwnerBriefName("黄朝斌测试有限公司01");
form.setUniCreditCode("1234567890");
form.setCreditCopyUrl("http://127.0.0.1/003.jpg");
form.setLegalPerson("黄卓越");
reqJson = JSONObject.parseObject(form.toString());
MvcResult mvcResult = this.getMockMvc().perform(MockMvcRequestBuilders.post(url)
.contentType(MediaType.APPLICATION_JSON_UTF8_VALUE)
.headers(this.getDefaultHttpHeaders())
.content(reqJson.toJSONString()))
.andDo(MockMvcResultHandlers.print())
.andExpect(MockMvcResultMatchers.status().isOk())
.andReturn();
String responseStr = mvcResult.getResponse().getContentAsString();
log.info(responseStr);
JSONObject result = JSONObject.parseObject(responseStr);
Assert.assertEquals(ECode.SUCCESS.code(), result.getIntValue("code"));
}
} }
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