Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SuperHive
back-end
customer-service
Commits
6e2d9172
Commit
6e2d9172
authored
Apr 18, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口:编辑货主帐号信息
parent
27e5c86a
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
266 additions
and
35 deletions
+266
-35
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+6
-1
GoodsOwnerController.java
...er/module/goodsowner/controller/GoodsOwnerController.java
+22
-0
AccountEntity.java
...ight/customer/module/goodsowner/entity/AccountEntity.java
+2
-2
AccountInfoForm.java
...ight/customer/module/goodsowner/form/AccountInfoForm.java
+25
-24
AccountService.java
...ht/customer/module/goodsowner/service/AccountService.java
+20
-2
AccountServiceImpl.java
...er/module/goodsowner/service/impl/AccountServiceImpl.java
+56
-4
application-dev.yml
src/main/resources/application-dev.yml
+3
-1
ErrorMessageComponentTest.java
.../customer/common/component/ErrorMessageComponentTest.java
+36
-0
VerifyUtilsTest.java
...com/esv/freight/customer/common/util/VerifyUtilsTest.java
+13
-1
GoodsOwnerControllerTest.java
...odule/goodsowner/controller/GoodsOwnerControllerTest.java
+83
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
6e2d9172
package
com
.
esv
.
freight
.
customer
.
common
.
component
;
import
lombok.Data
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.cloud.context.config.annotation.RefreshScope
;
import
org.springframework.stereotype.Component
;
...
...
@@ -15,9 +16,13 @@ import org.springframework.stereotype.Component;
*/
@Component
@RefreshScope
@Data
public
class
ErrorMessageComponent
{
@Value
(
"${error-message.goodsowner.account.add.1001}"
)
public
String
goodsOwnerAccountAdd1001
;
private
String
goodsOwnerAccountAdd1001
;
@Value
(
"${error-message.goodsowner.account.edit.1001}"
)
private
String
goodsOwnerAccountEdit1001
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/GoodsOwnerController.java
View file @
6e2d9172
...
...
@@ -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.VerifyUtils
;
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.form.AccountInfoForm
;
import
com.esv.freight.customer.module.goodsowner.service.AccountService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.PostMapping
;
...
...
@@ -69,4 +71,24 @@ public class GoodsOwnerController {
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
();
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/entity/AccountEntity.java
View file @
6e2d9172
...
...
@@ -76,12 +76,12 @@ public class AccountEntity implements Serializable {
/**
* 修改者
*/
@TableField
(
fill
=
FieldFill
.
INSERT
)
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
private
String
updateUser
;
/**
* 创建时间
*/
@TableField
(
fill
=
FieldFill
.
INSERT
_UPDATE
)
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
Date
createTime
;
/**
* 修改时间
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/form/AccountInfoForm.java
View file @
6e2d9172
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.ValidatorUpdate
;
import
lombok.Data
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.hibernate.validator.constraints.Length
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
import
javax.validation.constraints.Pattern
;
/**
...
...
@@ -21,6 +23,9 @@ import javax.validation.constraints.Pattern;
@Data
public
class
AccountInfoForm
{
@NotNull
(
message
=
"参数id不能为空"
,
groups
=
{
ValidatorUpdate
.
class
})
private
Long
id
;
/**
* (个人或企业联系人手机号)帐号
*/
...
...
@@ -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
})
private
String
password
;
/**
* 货主类型:1-个人、2-企业
*/
@Pattern
(
regexp
=
"[12]"
,
message
=
"参数ownerType不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@NotBlank
(
message
=
"参数ownerType不能为空"
,
groups
=
{
ValidatorInsert
.
class
})
@Pattern
(
regexp
=
"[12]"
,
message
=
"参数ownerType不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
@NotBlank
(
message
=
"参数ownerType不能为空"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
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
;
/**
* 客户简称
*/
@Length
(
max
=
50
,
message
=
"参数ownerBriefName长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
50
,
message
=
"参数ownerBriefName长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
ownerBriefName
;
/**
* 统一社会信用代码
*/
@Length
(
max
=
20
,
message
=
"参数uniCreditCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
20
,
message
=
"参数uniCreditCode长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
uniCreditCode
;
/**
* 营业期限
*/
@Length
(
max
=
50
,
message
=
"参数creditExpireDate长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
50
,
message
=
"参数creditExpireDate长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
creditExpireDate
;
/**
* 营业执照正本ULR
*/
@Length
(
max
=
200
,
message
=
"参数creditOriginalUrl长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
200
,
message
=
"参数creditOriginalUrl长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
creditOriginalUrl
;
/**
* 营业执照副本ULR
*/
@Length
(
max
=
200
,
message
=
"参数creditCopyUrl长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
200
,
message
=
"参数creditCopyUrl长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
creditCopyUrl
;
/**
* 企业法人姓名
*/
@Length
(
max
=
20
,
message
=
"参数legalPerson长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
20
,
message
=
"参数legalPerson长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
legalPerson
;
/**
* 企业法人手机号
*/
@Length
(
max
=
20
,
message
=
"参数legalPhone长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
20
,
message
=
"参数legalPhone长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
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
})
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
})
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
})
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
})
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
})
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
})
private
String
idCard
;
/**
* (个人或企业)身份证有效期
*/
@Length
(
max
=
50
,
message
=
"参数idCardExpireDate长度不合法"
,
groups
=
{
ValidatorInsert
.
class
})
@Length
(
max
=
50
,
message
=
"参数idCardExpireDate长度不合法"
,
groups
=
{
ValidatorInsert
.
class
,
ValidatorUpdate
.
class
})
private
String
idCardExpireDate
;
/**
* 身份证正面图片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
})
private
String
idCardFrontUrl
;
/**
* 身份证背面图片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
})
private
String
idCardBackUrl
;
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/AccountService.java
View file @
6e2d9172
...
...
@@ -24,14 +24,32 @@ public interface AccountService extends IService<AccountEntity> {
**/
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 通过管理平台创建帐号
* param [form]
* return
int
* return
Long
* author Administrator
* 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
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/AccountServiceImpl.java
View file @
6e2d9172
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
service
.
impl
;
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.update.UpdateWrapper
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.esv.freight.customer.common.component.ErrorMessageComponent
;
import
com.esv.freight.customer.common.exception.EException
;
...
...
@@ -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.gateway.common.GatewayHeaders
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -54,13 +57,21 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
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
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
int
createAccountByManager
(
AccountInfoForm
form
)
{
public
Long
createAccountByManager
(
AccountInfoForm
form
)
{
// 1.判断帐号是否已存在
AccountEntity
accountEntity
=
this
.
getAccountRecordByAccount
(
form
.
getAccount
());
if
(
null
!=
accountEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
g
oodsOwnerAccountAdd1001
);
throw
new
EException
(
1001
,
errorMessageComponent
.
g
etGoodsOwnerAccountAdd1001
()
);
}
else
{
accountEntity
=
new
AccountEntity
();
}
...
...
@@ -81,13 +92,15 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
// 3.新增帐号
BeanUtils
.
copyProperties
(
form
,
accountEntity
);
accountEntity
.
setId
(
null
);
String
salt
=
UUID
.
randomUUID
().
toString
().
replace
(
"-"
,
""
);
String
password
=
DigestUtils
.
md5Hex
(
form
.
getPassword
()
+
salt
);
accountEntity
.
setSalt
(
salt
);
accountEntity
.
setPassword
(
password
);
accountEntity
.
setSourceType
(
GoodsOwnerConstants
.
OWNER_SOURCE_TYPE_PLATFORM
);
accountEntity
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
);
int
accountId
=
this
.
baseMapper
.
insert
(
accountEntity
);
this
.
baseMapper
.
insert
(
accountEntity
);
Long
accountId
=
accountEntity
.
getId
();
// 4.新增帐号信息
InfoEntity
infoEntity
=
new
InfoEntity
();
...
...
@@ -104,7 +117,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
infoEntity
.
setLegalPhone
(
null
);
}
infoEntity
.
setOwnerNumber
(
ownerNumber
);
infoEntity
.
setAccountId
(
Long
.
parseLong
(
String
.
valueOf
(
accountId
))
);
infoEntity
.
setAccountId
(
accountId
);
infoService
.
getBaseMapper
().
insert
(
infoEntity
);
// 5.新增帐号审核记录
...
...
@@ -116,4 +129,43 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
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
src/main/resources/application-dev.yml
View file @
6e2d9172
...
...
@@ -50,3 +50,5 @@ error-message:
account
:
add
:
1001
:
帐号已存在
edit
:
1001
:
无效的帐号ID
\ No newline at end of file
src/test/java/com/esv/freight/customer/common/component/ErrorMessageComponentTest.java
0 → 100644
View file @
6e2d9172
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
());
}
}
src/test/java/com/esv/freight/customer/common/util/VerifyUtilsTest.java
View file @
6e2d9172
...
...
@@ -22,7 +22,19 @@ public class VerifyUtilsTest {
String
idCard
=
"360721198712030856"
;
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
));
idCard
=
"36072119871203085x"
;
...
...
src/test/java/com/esv/freight/customer/module/goodsowner/controller/GoodsOwnerControllerTest.java
View file @
6e2d9172
...
...
@@ -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.MockMvcResultMatchers
;
import
java.util.UUID
;
/**
* @description:
* @project: freight-customer-service
...
...
@@ -109,4 +111,85 @@ public class GoodsOwnerControllerTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
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"
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment