Commit e33d13e9 authored by huangcb's avatar huangcb

新增接口:获取帐号详情

parent d7e1df8b
...@@ -43,4 +43,9 @@ public class ErrorMessageComponent { ...@@ -43,4 +43,9 @@ public class ErrorMessageComponent {
@Value("${error-message.goodsowner.account.audit-history.1001}") @Value("${error-message.goodsowner.account.audit-history.1001}")
private String goodsOwnerAccountAuditHistory1001; private String goodsOwnerAccountAuditHistory1001;
@Value("${error-message.goodsowner.account.detail.1001}")
private String goodsOwnerAccountDetail1001;
@Value("${error-message.goodsowner.account.detail.1002}")
private String goodsOwnerAccountDetail1002;
} }
...@@ -6,9 +6,11 @@ import com.esv.freight.customer.common.response.ECode; ...@@ -6,9 +6,11 @@ import com.esv.freight.customer.common.response.ECode;
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.util.VerifyUtils; import com.esv.freight.customer.common.util.VerifyUtils;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
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.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.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity; import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.form.AccountForm; import com.esv.freight.customer.module.goodsowner.form.AccountForm;
import com.esv.freight.customer.module.goodsowner.form.AccountInfoForm; import com.esv.freight.customer.module.goodsowner.form.AccountInfoForm;
...@@ -17,6 +19,7 @@ import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudi ...@@ -17,6 +19,7 @@ import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudi
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAuditHistory; import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAuditHistory;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock; import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock; import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock;
import com.esv.freight.customer.module.goodsowner.vo.AccountInfoVO;
import com.esv.freight.customer.module.goodsowner.vo.AuditHistoryVO; import com.esv.freight.customer.module.goodsowner.vo.AuditHistoryVO;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
...@@ -172,4 +175,25 @@ public class GoodsOwnerController { ...@@ -172,4 +175,25 @@ public class GoodsOwnerController {
return EResponse.ok(auditHistoryVOList); return EResponse.ok(auditHistoryVOList);
} }
/**
* description 获取帐号详细信息
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/20 10:12
**/
@PostMapping("/detail")
public EResponse getAccountDetail(@RequestBody @Validated(ValidatorDetail.class) AccountForm form) throws EException {
/****************************** 参数校验 ******************************/
if (null == form.getId() && null == form.getAccount()) {
throw new EException(ECode.PARAM_ERROR.code(), "参数id、account不能同时为空");
}
/****************************** 参数校验 ******************************/
AccountInfoDto accountInfoDto = accountService.getAccountInfo(form);
AccountInfoVO accountInfoVO = new AccountInfoVO();
BeanUtils.copyProperties(accountInfoDto, accountInfoVO);
return EResponse.ok(accountInfoVO);
}
} }
package com.esv.freight.customer.module.goodsowner.dao; package com.esv.freight.customer.module.goodsowner.dao;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
/** /**
...@@ -14,4 +15,22 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -14,4 +15,22 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
public interface AccountDao extends BaseMapper<AccountEntity> { public interface AccountDao extends BaseMapper<AccountEntity> {
/**
* description 通过帐号id获取帐号信息
* param [id]
* return com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
* author Administrator
* createTime 2020/04/20 9:41
**/
AccountInfoDto getAccountInfoById(Long id);
/**
* description 通过帐号获取帐号信息
* param [account]
* return com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
* author Administrator
* createTime 2020/04/20 9:41
**/
AccountInfoDto getAccountInfoByAccount(String account);
} }
package com.esv.freight.customer.module.goodsowner.dto;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
/**
* @description:
* @project: freight-customer-service
* @name: com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/04/20 9:24
* @version:1.0
*/
@Data
public class AccountInfoDto {
/**
*
*/
@TableId
private Long id;
/**
* 租户ID
*/
private Long tenantId;
/**
* 部门ID
*/
private Long departmentId;
/**
* 登录帐号,货主手机号
*/
private String account;
/**
* 帐号密码
*/
private String password;
/**
* 密码加盐
*/
private String salt;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private String sourceType;
/**
* 帐号状态:1-正常、2-停用
*/
private String accountStatus;
/**
* 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败,APP自行注册需要平台审核
*/
private Integer auditStatus;
/**
* 上报状态:字典表
*/
private Integer uploadStatus;
/**
* 上报时间
*/
private Date uploadTime;
/**
* 创建者
*/
private String createUser;
/**
* 修改者
*/
private String updateUser;
/**
* 创建时间
*/
private Date createTime;
/**
* 修改时间
*/
private Date updateTime;
/**
* 货主类型:1-个人、2-企业
*/
private String ownerType;
/**
* 客户编码
*/
private String ownerNumber;
/**
* 客户名称
*/
private String ownerFullName;
/**
* 客户简称
*/
private String ownerBriefName;
/**
* 统一社会信用代码
*/
private String uniCreditCode;
/**
* 营业期限
*/
private String creditExpireDate;
/**
* 营业执照正本ULR
*/
private String creditOriginalUrl;
/**
* 营业执照副本ULR
*/
private String creditCopyUrl;
/**
* 企业法人姓名
*/
private String legalPerson;
/**
* 企业法人手机号
*/
private String legalPhone;
/**
* 省份代码
*/
private String provinceCode;
/**
* 市代码
*/
private String cityCode;
/**
* 区县代码
*/
private String districtCode;
/**
* 详细地址
*/
private String detailAddress;
/**
* (个人或企业)联系人
*/
private String contactor;
/**
* (个人或企业)身份证号码
*/
private String idCard;
/**
* (个人或企业)身份证有效期
*/
private String idCardExpireDate;
/**
* 身份证正面图片URL
*/
private String idCardFrontUrl;
/**
* 身份证背面图片URL
*/
private String idCardBackUrl;
}
package com.esv.freight.customer.module.goodsowner.form; package com.esv.freight.customer.module.goodsowner.form;
import com.esv.freight.customer.common.validator.groups.ValidatorDetail;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit; import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAuditHistory; import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAuditHistory;
import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock; import com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock;
...@@ -32,6 +33,9 @@ public class AccountForm { ...@@ -32,6 +33,9 @@ public class AccountForm {
@Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorAudit.class}) @Length(max = 100, message = "参数remark长度不合法", groups = {ValidatorAudit.class})
private String remark; private String remark;
@Length(max = 11, message = "参数account长度不合法", groups = {ValidatorDetail.class})
private String account;
@Override @Override
public String toString() { public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE); return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
......
package com.esv.freight.customer.module.goodsowner.service; package com.esv.freight.customer.module.goodsowner.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity; import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity; import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.form.AccountForm; import com.esv.freight.customer.module.goodsowner.form.AccountForm;
...@@ -89,5 +90,14 @@ public interface AccountService extends IService<AccountEntity> { ...@@ -89,5 +90,14 @@ public interface AccountService extends IService<AccountEntity> {
**/ **/
List<AuditHistoryEntity> getAuditHistory(Long id); List<AuditHistoryEntity> getAuditHistory(Long id);
/**
* description 获取帐号详细信息
* param [form]
* return com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto
* author Administrator
* createTime 2020/04/20 9:47
**/
AccountInfoDto getAccountInfo(AccountForm form);
} }
...@@ -12,6 +12,7 @@ import com.esv.freight.customer.common.util.ReqUtils; ...@@ -12,6 +12,7 @@ import com.esv.freight.customer.common.util.ReqUtils;
import com.esv.freight.customer.feign.FeignBaseService; import com.esv.freight.customer.feign.FeignBaseService;
import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants; import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
import com.esv.freight.customer.module.goodsowner.dao.AccountDao; import com.esv.freight.customer.module.goodsowner.dao.AccountDao;
import com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto;
import com.esv.freight.customer.module.goodsowner.entity.AccountEntity; import com.esv.freight.customer.module.goodsowner.entity.AccountEntity;
import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity; import com.esv.freight.customer.module.goodsowner.entity.AuditHistoryEntity;
import com.esv.freight.customer.module.goodsowner.entity.InfoEntity; import com.esv.freight.customer.module.goodsowner.entity.InfoEntity;
...@@ -251,4 +252,24 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i ...@@ -251,4 +252,24 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
queryWrapper.orderByAsc("operate_time"); queryWrapper.orderByAsc("operate_time");
return this.auditHistoryService.getBaseMapper().selectList(queryWrapper); return this.auditHistoryService.getBaseMapper().selectList(queryWrapper);
} }
@Override
public AccountInfoDto getAccountInfo(AccountForm form) {
AccountInfoDto dto = null;
if (null != form.getId()) {
dto = this.baseMapper.getAccountInfoById(form.getId());
if (null == dto) {
throw new EException(1001, errorMessageComponent.getGoodsOwnerAccountDetail1001());
}
} else if (null != form.getAccount()) {
dto = this.baseMapper.getAccountInfoByAccount(form.getAccount());
if (null == dto) {
throw new EException(1002, errorMessageComponent.getGoodsOwnerAccountDetail1002());
}
} else {
}
return dto;
}
} }
\ No newline at end of file
package com.esv.freight.customer.module.goodsowner.vo;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serializable;
/**
* 货主信息表
*
* @author 黄朝斌
* @email huangchaobin@esvtek.com
* @date 2020-04-17 13:54:57
*/
@Data
public class AccountInfoVO implements Serializable {
private static final long serialVersionUID = 6178403738228133215L;
/**
*
*/
private Long id;
/**
* 登录帐号,货主手机号
*/
private String account;
/**
* 创建来源:1-平台创建、2-自行注册
*/
private String sourceType;
/**
* 帐号状态:1-正常、2-停用
*/
private String accountStatus;
/**
* 货主帐号审核状态:0-待审核、1-审核成功,2-审核失败,APP自行注册需要平台审核
*/
private Integer auditStatus;
/**
* 货主类型:1-个人、2-企业
*/
private String ownerType;
/**
* 客户编码
*/
private String ownerNumber;
/**
* 客户名称
*/
private String ownerFullName;
/**
* 客户简称
*/
private String ownerBriefName;
/**
* 统一社会信用代码
*/
private String uniCreditCode;
/**
* 营业期限
*/
private String creditExpireDate;
/**
* 营业执照正本ULR
*/
private String creditOriginalUrl;
/**
* 营业执照副本ULR
*/
private String creditCopyUrl;
/**
* 企业法人姓名
*/
private String legalPerson;
/**
* 企业法人手机号
*/
private String legalPhone;
/**
* 省份代码
*/
private String provinceCode;
/**
* 市代码
*/
private String cityCode;
/**
* 区县代码
*/
private String districtCode;
/**
* 详细地址
*/
private String detailAddress;
/**
* (个人或企业)联系人
*/
private String contactor;
/**
* (个人或企业)身份证号码
*/
private String idCard;
/**
* (个人或企业)身份证有效期
*/
private String idCardExpireDate;
/**
* 身份证正面图片URL
*/
private String idCardFrontUrl;
/**
* 身份证背面图片URL
*/
private String idCardBackUrl;
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.JSON_STYLE);
}
}
...@@ -63,3 +63,6 @@ error-message: ...@@ -63,3 +63,6 @@ error-message:
1002: 帐号已审核通过 1002: 帐号已审核通过
audit-history: audit-history:
1001: 无效的帐号ID 1001: 无效的帐号ID
detail:
1001: 无效的帐号ID
1002: 无效的手机号
\ No newline at end of file
...@@ -22,5 +22,26 @@ ...@@ -22,5 +22,26 @@
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<select id="getAccountInfoById" parameterType="java.lang.Long" resultType="com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto">
select a.*,
b.owner_type, b.owner_number, b.owner_full_name, b.owner_brief_name, b.uni_credit_code, b.credit_expire_date, b.credit_original_url,
b.credit_copy_url, b.legal_person, b.legal_phone, b.province_code, b.city_code, b.district_code, b.detail_address, b.contactor,
b.id_card, b.id_card_expire_date, b.id_card_front_url, b.id_card_back_url
from goods_owner_account a
left join goods_owner_info b
on a.id = b.account_id
where a.id = #{id}
</select>
<select id="getAccountInfoByAccount" parameterType="java.lang.String" resultType="com.esv.freight.customer.module.goodsowner.dto.AccountInfoDto">
select a.*,
b.owner_type, b.owner_number, b.owner_full_name, b.owner_brief_name, b.uni_credit_code, b.credit_expire_date, b.credit_original_url,
b.credit_copy_url, b.legal_person, b.legal_phone, b.province_code, b.city_code, b.district_code, b.detail_address, b.contactor,
b.id_card, b.id_card_expire_date, b.id_card_front_url, b.id_card_back_url
from goods_owner_account a
left join goods_owner_info b
on a.id = b.account_id
where a.account = #{account}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -398,4 +398,138 @@ public class GoodsOwnerControllerTest extends BaseTestController { ...@@ -398,4 +398,138 @@ 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"));
} }
/**
* 获取帐号详细信息:通过帐号id
**/
@Test
public void g1_getAccountDetail_by_id_success_test() throws Exception {
String url = "/goodsowner/account/detail";
// 构造数据
AccountForm form = new AccountForm();
form.setId(1L);
JSONObject 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 g2_getAccountDetail_by_account_success_test() throws Exception {
String url = "/goodsowner/account/detail";
// 构造数据
AccountForm form = new AccountForm();
form.setAccount("18524431581");
JSONObject 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 g3_getAccountDetail_no_param_failure_test() throws Exception {
String url = "/goodsowner/account/detail";
// 构造数据
AccountForm form = new AccountForm();
JSONObject 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.PARAM_ERROR.code(), result.getIntValue("code"));
}
/**
* 获取帐号详细信息:无效的帐号ID
**/
@Test
public void g4_getAccountDetail_wrong_id_failure_test() throws Exception {
String url = "/goodsowner/account/detail";
// 构造数据
AccountForm form = new AccountForm();
form.setId(99999L);
JSONObject 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(1001, result.getIntValue("code"));
}
/**
* 获取帐号详细信息:无效的帐号
**/
@Test
public void g5_getAccountDetail_wrong_account_failure_test() throws Exception {
String url = "/goodsowner/account/detail";
// 构造数据
AccountForm form = new AccountForm();
form.setAccount("12012345678");
JSONObject 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(1002, 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