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
23eee501
Commit
23eee501
authored
Apr 18, 2020
by
huangcb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增接口:货主帐号审核
parent
cee6bbc3
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
216 additions
and
4 deletions
+216
-4
ErrorMessageComponent.java
...ight/customer/common/component/ErrorMessageComponent.java
+5
-0
GoodsOwnerController.java
...er/module/goodsowner/controller/GoodsOwnerController.java
+25
-2
AccountForm.java
.../freight/customer/module/goodsowner/form/AccountForm.java
+13
-1
AccountService.java
...ht/customer/module/goodsowner/service/AccountService.java
+10
-0
AccountServiceImpl.java
...er/module/goodsowner/service/impl/AccountServiceImpl.java
+28
-0
ValidatorAudit.java
...er/module/goodsowner/validator/groups/ValidatorAudit.java
+15
-0
ValidatorBlock.java
...er/module/goodsowner/validator/groups/ValidatorBlock.java
+15
-0
ValidatorUnblock.java
.../module/goodsowner/validator/groups/ValidatorUnblock.java
+15
-0
application-dev.yml
src/main/resources/application-dev.yml
+4
-1
GoodsOwnerControllerTest.java
...odule/goodsowner/controller/GoodsOwnerControllerTest.java
+86
-0
No files found.
src/main/java/com/esv/freight/customer/common/component/ErrorMessageComponent.java
View file @
23eee501
...
...
@@ -35,4 +35,9 @@ public class ErrorMessageComponent {
@Value
(
"${error-message.goodsowner.account.unblock.1002}"
)
private
String
goodsOwnerAccountUnblock1002
;
@Value
(
"${error-message.goodsowner.account.audit.1001}"
)
private
String
goodsOwnerAccountAudit1001
;
@Value
(
"${error-message.goodsowner.account.audit.1002}"
)
private
String
goodsOwnerAccountAudit1002
;
}
src/main/java/com/esv/freight/customer/module/goodsowner/controller/GoodsOwnerController.java
View file @
23eee501
...
...
@@ -12,6 +12,9 @@ import com.esv.freight.customer.module.goodsowner.GoodsOwnerConstants;
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.service.AccountService
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -101,7 +104,7 @@ public class GoodsOwnerController {
* createTime 2020/04/18 15:11
**/
@PostMapping
(
"/block"
)
public
EResponse
blockAccount
(
@RequestBody
@Validated
AccountForm
form
)
throws
EException
{
public
EResponse
blockAccount
(
@RequestBody
@Validated
(
ValidatorBlock
.
class
)
AccountForm
form
)
throws
EException
{
accountService
.
blockAccount
(
form
.
getId
());
return
EResponse
.
ok
();
}
...
...
@@ -114,8 +117,28 @@ public class GoodsOwnerController {
* createTime 2020/04/18 15:11
**/
@PostMapping
(
"/unblock"
)
public
EResponse
unblockAccount
(
@RequestBody
@Validated
AccountForm
form
)
throws
EException
{
public
EResponse
unblockAccount
(
@RequestBody
@Validated
(
ValidatorUnblock
.
class
)
AccountForm
form
)
throws
EException
{
accountService
.
unblockAccount
(
form
.
getId
());
return
EResponse
.
ok
();
}
/**
* description 审核帐号
* param [form]
* return com.esv.freight.customer.common.response.EResponse
* author Administrator
* createTime 2020/04/18 16:08
**/
@PostMapping
(
"/audit"
)
public
EResponse
auditAccount
(
@RequestBody
@Validated
(
ValidatorAudit
.
class
)
AccountForm
form
)
throws
EException
{
/****************************** 参数校验 ******************************/
// 校验备注
if
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_FAILURE
.
equals
(
form
.
getAuditStatus
())
&&
StringUtils
.
isBlank
(
form
.
getRemark
()))
{
throw
new
EException
(
ECode
.
PARAM_ERROR
.
code
(),
"参数remark不能为空"
);
}
/****************************** 参数校验 ******************************/
accountService
.
auditAccount
(
form
);
return
EResponse
.
ok
();
}
}
src/main/java/com/esv/freight/customer/module/goodsowner/form/AccountForm.java
View file @
23eee501
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
com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock
;
import
com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock
;
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.NotNull
;
...
...
@@ -18,9 +24,15 @@ import javax.validation.constraints.NotNull;
@Data
public
class
AccountForm
{
@NotNull
(
message
=
"参数id不能为空"
)
@NotNull
(
message
=
"参数id不能为空"
,
groups
=
{
ValidatorBlock
.
class
,
ValidatorUnblock
.
class
,
ValidatorAudit
.
class
}
)
private
Long
id
;
@NotNull
(
message
=
"参数auditStatus不能为空"
,
groups
=
{
ValidatorAudit
.
class
})
private
Integer
auditStatus
;
@Length
(
max
=
100
,
message
=
"参数remark长度不合法"
,
groups
=
{
ValidatorAudit
.
class
})
private
String
remark
;
@Override
public
String
toString
()
{
return
ToStringBuilder
.
reflectionToString
(
this
,
ToStringStyle
.
JSON_STYLE
);
...
...
src/main/java/com/esv/freight/customer/module/goodsowner/service/AccountService.java
View file @
23eee501
...
...
@@ -2,6 +2,7 @@ package com.esv.freight.customer.module.goodsowner.service;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.esv.freight.customer.module.goodsowner.entity.AccountEntity
;
import
com.esv.freight.customer.module.goodsowner.form.AccountForm
;
import
com.esv.freight.customer.module.goodsowner.form.AccountInfoForm
;
import
java.util.List
;
...
...
@@ -69,5 +70,14 @@ public interface AccountService extends IService<AccountEntity> {
**/
void
unblockAccount
(
Long
id
);
/**
* description 审核帐号
* param [form]
* return void
* author Administrator
* createTime 2020/04/18 15:41
**/
void
auditAccount
(
AccountForm
form
);
}
src/main/java/com/esv/freight/customer/module/goodsowner/service/impl/AccountServiceImpl.java
View file @
23eee501
...
...
@@ -15,6 +15,7 @@ import com.esv.freight.customer.module.goodsowner.dao.AccountDao;
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.InfoEntity
;
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.service.AccountService
;
import
com.esv.freight.customer.module.goodsowner.service.AuditHistoryService
;
...
...
@@ -206,4 +207,31 @@ public class AccountServiceImpl extends ServiceImpl<AccountDao, AccountEntity> i
accountEntityUpdate
.
setAccountStatus
(
GoodsOwnerConstants
.
OWNER_ACCOUNT_STATUS_UNBLOCK
);
this
.
baseMapper
.
updateById
(
accountEntityUpdate
);
}
@Override
public
void
auditAccount
(
AccountForm
form
)
{
// 1.判断帐号是否存在
Long
accountId
=
form
.
getId
();
AccountEntity
accountEntity
=
this
.
getAccountRecordById
(
accountId
);
if
(
null
==
accountEntity
)
{
throw
new
EException
(
1001
,
errorMessageComponent
.
getGoodsOwnerAccountAudit1001
());
}
else
{
if
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
.
equals
(
accountEntity
.
getAuditStatus
()))
{
throw
new
EException
(
1002
,
errorMessageComponent
.
getGoodsOwnerAccountAudit1002
());
}
}
// 2.更新帐号审核状态
AccountEntity
accountEntityUpdate
=
new
AccountEntity
();
accountEntityUpdate
.
setId
(
accountId
);
accountEntityUpdate
.
setAuditStatus
(
form
.
getAuditStatus
());
this
.
baseMapper
.
updateById
(
accountEntityUpdate
);
// 3.更新帐号审核历史
AuditHistoryEntity
auditHistoryEntity
=
new
AuditHistoryEntity
();
auditHistoryEntity
.
setAccountId
(
accountId
);
auditHistoryEntity
.
setAuditStatus
(
form
.
getAuditStatus
());
auditHistoryEntity
.
setOperateUser
(
ReqUtils
.
getRequestHeader
(
GatewayHeaders
.
USER_ACCOUNT
));
auditHistoryService
.
getBaseMapper
().
insert
(
auditHistoryEntity
);
}
}
\ No newline at end of file
src/main/java/com/esv/freight/customer/module/goodsowner/validator/groups/ValidatorAudit.java
0 → 100644
View file @
23eee501
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
validator
.
groups
;
import
javax.validation.groups.Default
;
/**
* @description: 参数校验分组:审核
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorAudit
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public
interface
ValidatorAudit
extends
Default
{
}
src/main/java/com/esv/freight/customer/module/goodsowner/validator/groups/ValidatorBlock.java
0 → 100644
View file @
23eee501
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
validator
.
groups
;
import
javax.validation.groups.Default
;
/**
* @description: 参数校验分组:停用
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorBlock
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public
interface
ValidatorBlock
extends
Default
{
}
src/main/java/com/esv/freight/customer/module/goodsowner/validator/groups/ValidatorUnblock.java
0 → 100644
View file @
23eee501
package
com
.
esv
.
freight
.
customer
.
module
.
goodsowner
.
validator
.
groups
;
import
javax.validation.groups.Default
;
/**
* @description: 参数校验分组:启用
* @project: SpringCloudTemplate
* @name: com.esv.freight.customer.module.goodsowner.validator.groups.ValidatorUnblock
* @author: 黄朝斌
* @email: huangchaobin@esvtek.com
* @createTime: 2020/03/12 17:58
* @version:1.0
*/
public
interface
ValidatorUnblock
extends
Default
{
}
src/main/resources/application-dev.yml
View file @
23eee501
...
...
@@ -58,3 +58,6 @@ error-message:
unblock
:
1001
:
无效的帐号ID
1002
:
帐号已启用
audit
:
1001
:
无效的帐号ID
1002
:
帐号已审核通过
\ No newline at end of file
src/test/java/com/esv/freight/customer/module/goodsowner/controller/GoodsOwnerControllerTest.java
View file @
23eee501
...
...
@@ -285,4 +285,90 @@ public class GoodsOwnerControllerTest extends BaseTestController {
JSONObject
result
=
JSONObject
.
parseObject
(
responseStr
);
Assert
.
assertEquals
(
1002
,
result
.
getIntValue
(
"code"
));
}
/**
* 审核不通过,备注为空
**/
@Test
public
void
e1_auditAccount_failure_test
()
throws
Exception
{
String
url
=
"/goodsowner/account/audit"
;
// 构造数据
AccountForm
form
=
new
AccountForm
();
form
.
setId
(
1L
);
form
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_FAILURE
);
form
.
setRemark
(
null
);
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"
));
}
/**
* 审核不通过
**/
@Test
public
void
e2_auditAccount_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/account/audit"
;
// 构造数据
AccountForm
form
=
new
AccountForm
();
form
.
setId
(
1L
);
form
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_FAILURE
);
form
.
setRemark
(
"测试"
);
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
e3_auditAccount_success_test
()
throws
Exception
{
String
url
=
"/goodsowner/account/audit"
;
// 构造数据
AccountForm
form
=
new
AccountForm
();
form
.
setId
(
1L
);
form
.
setAuditStatus
(
GoodsOwnerConstants
.
OWNER_AUDIT_STATUS_SUCCESS
);
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"
));
}
}
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