Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
scrm
/
rop-merchant
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1d17d9c1
authored
Jul 21, 2021
by
wangnb
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
账户体系账户类型、角色保存数据转换--think.wang
1 parent
3f59db3d
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
212 additions
and
21 deletions
src/main/java/cn/com/glsx/merchants/controller/MerchantAccountTypeController.java
src/main/java/cn/com/glsx/merchants/controller/MerchantRoleController.java
src/main/java/cn/com/glsx/merchants/request/FunctionRequest.java
src/main/java/cn/com/glsx/merchants/request/ProductRequest.java
src/main/java/cn/com/glsx/merchants/request/accounttype/AccountTypeInsertRequest.java
src/main/java/cn/com/glsx/merchants/request/accounttype/AccountTypeUpdateRequest.java
src/main/java/cn/com/glsx/merchants/request/role/RoleAccountTypeRequest.java
src/main/java/cn/com/glsx/merchants/request/role/RoleInsertRequest.java
src/main/java/cn/com/glsx/merchants/request/role/RoleUpdateRequest.java
src/main/java/cn/com/glsx/merchants/service/MerchantAccountTypeService.java
src/main/java/cn/com/glsx/merchants/service/MerchantRoleService.java
src/main/java/cn/com/glsx/merchants/controller/MerchantAccountTypeController.java
View file @
1d17d9c
...
@@ -7,6 +7,7 @@ import cn.com.glsx.merchants.request.accounttype.*;
...
@@ -7,6 +7,7 @@ import cn.com.glsx.merchants.request.accounttype.*;
import
cn.com.glsx.merchants.service.MerchantAccountTypeService
;
import
cn.com.glsx.merchants.service.MerchantAccountTypeService
;
import
cn.com.glsx.merchants.service.MerchantUserService
;
import
cn.com.glsx.merchants.service.MerchantUserService
;
import
cn.com.glsx.merchants.util.Pagination
;
import
cn.com.glsx.merchants.util.Pagination
;
import
com.alibaba.fastjson.JSON
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethodBean
;
import
com.rop.annotation.ServiceMethodBean
;
...
@@ -112,6 +113,7 @@ public class MerchantAccountTypeController {
...
@@ -112,6 +113,7 @@ public class MerchantAccountTypeController {
@ServiceMethod
(
method
=
"org.ore.api.accountType.insert"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"org.ore.api.accountType.insert"
,
needInSession
=
NeedInSessionType
.
YES
)
@ApiOperation
(
"账户类型新增接口"
)
@ApiOperation
(
"账户类型新增接口"
)
public
RopResponse
<
Boolean
>
insert
(
AccountTypeInsertRequest
request
)
{
public
RopResponse
<
Boolean
>
insert
(
AccountTypeInsertRequest
request
)
{
log
.
info
(
"账户类型保存数据:{}"
,
JSON
.
toJSONString
(
request
));
merchantUserService
.
setUser
(
request
);
merchantUserService
.
setUser
(
request
);
try
{
try
{
return
RopResponse
.
success
(
accountTypeService
.
insert
(
request
));
return
RopResponse
.
success
(
accountTypeService
.
insert
(
request
));
...
@@ -130,6 +132,7 @@ public class MerchantAccountTypeController {
...
@@ -130,6 +132,7 @@ public class MerchantAccountTypeController {
@ServiceMethod
(
method
=
"org.ore.api.accountType.update"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"org.ore.api.accountType.update"
,
needInSession
=
NeedInSessionType
.
YES
)
@ApiOperation
(
"账户类型更新接口"
)
@ApiOperation
(
"账户类型更新接口"
)
public
RopResponse
<
Boolean
>
update
(
AccountTypeUpdateRequest
request
)
{
public
RopResponse
<
Boolean
>
update
(
AccountTypeUpdateRequest
request
)
{
log
.
info
(
"账户类型更新数据:{}"
,
JSON
.
toJSONString
(
request
));
merchantUserService
.
setUser
(
request
);
merchantUserService
.
setUser
(
request
);
try
{
try
{
return
RopResponse
.
success
(
accountTypeService
.
update
(
request
));
return
RopResponse
.
success
(
accountTypeService
.
update
(
request
));
...
...
src/main/java/cn/com/glsx/merchants/controller/MerchantRoleController.java
View file @
1d17d9c
...
@@ -5,12 +5,13 @@ import cn.com.glsx.framework.rop.response.RopResponse;
...
@@ -5,12 +5,13 @@ import cn.com.glsx.framework.rop.response.RopResponse;
import
cn.com.glsx.merchants.model.response.MerchantRoleResponse
;
import
cn.com.glsx.merchants.model.response.MerchantRoleResponse
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeSearchRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeSearchRequest
;
import
cn.com.glsx.merchants.request.role.RoleDeleteRequest
;
import
cn.com.glsx.merchants.request.role.RoleDeleteRequest
;
import
cn.com.glsx.merchants.request.role.RoleListSearchRequest
;
import
cn.com.glsx.merchants.request.role.RoleInsertRequest
;
import
cn.com.glsx.merchants.request.role.RoleInsertRequest
;
import
cn.com.glsx.merchants.request.role.RoleListSearchRequest
;
import
cn.com.glsx.merchants.request.role.RoleUpdateRequest
;
import
cn.com.glsx.merchants.request.role.RoleUpdateRequest
;
import
cn.com.glsx.merchants.service.MerchantRoleService
;
import
cn.com.glsx.merchants.service.MerchantRoleService
;
import
cn.com.glsx.merchants.service.MerchantUserService
;
import
cn.com.glsx.merchants.service.MerchantUserService
;
import
cn.com.glsx.merchants.util.Pagination
;
import
cn.com.glsx.merchants.util.Pagination
;
import
com.alibaba.fastjson.JSON
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.NeedInSessionType
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethod
;
import
com.rop.annotation.ServiceMethodBean
;
import
com.rop.annotation.ServiceMethodBean
;
...
@@ -116,6 +117,7 @@ public class MerchantRoleController {
...
@@ -116,6 +117,7 @@ public class MerchantRoleController {
@ServiceMethod
(
method
=
"org.ore.api.role.insert"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"org.ore.api.role.insert"
,
needInSession
=
NeedInSessionType
.
YES
)
@ApiOperation
(
"角色管理新增接口"
)
@ApiOperation
(
"角色管理新增接口"
)
public
RopResponse
<
Boolean
>
insert
(
RoleInsertRequest
request
)
{
public
RopResponse
<
Boolean
>
insert
(
RoleInsertRequest
request
)
{
log
.
info
(
"角色管理保存数据:{}"
,
JSON
.
toJSONString
(
request
));
merchantUserService
.
setUser
(
request
);
merchantUserService
.
setUser
(
request
);
try
{
try
{
return
RopResponse
.
success
(
roleService
.
insert
(
request
));
return
RopResponse
.
success
(
roleService
.
insert
(
request
));
...
@@ -134,6 +136,7 @@ public class MerchantRoleController {
...
@@ -134,6 +136,7 @@ public class MerchantRoleController {
@ServiceMethod
(
method
=
"org.ore.api.role.update"
,
needInSession
=
NeedInSessionType
.
YES
)
@ServiceMethod
(
method
=
"org.ore.api.role.update"
,
needInSession
=
NeedInSessionType
.
YES
)
@ApiOperation
(
"角色管理更新接口"
)
@ApiOperation
(
"角色管理更新接口"
)
public
RopResponse
<
Boolean
>
update
(
RoleUpdateRequest
request
)
{
public
RopResponse
<
Boolean
>
update
(
RoleUpdateRequest
request
)
{
log
.
info
(
"角色管理更新数据:{}"
,
JSON
.
toJSONString
(
request
));
merchantUserService
.
setUser
(
request
);
merchantUserService
.
setUser
(
request
);
try
{
try
{
return
RopResponse
.
success
(
roleService
.
update
(
request
));
return
RopResponse
.
success
(
roleService
.
update
(
request
));
...
...
src/main/java/cn/com/glsx/merchants/request/FunctionRequest.java
0 → 100644
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author zhouhaibao
* @version 1.0
* @description: 功能关系请求
* @date 2021/7/16 16:50
*/
@Data
public
class
FunctionRequest
implements
Serializable
{
/**
* 功能id
*/
private
Integer
id
;
/**
* 父级菜单id
*/
private
Integer
menuId
;
/**
* 选中的功能值
*/
private
String
functionValue
;
}
src/main/java/cn/com/glsx/merchants/request/ProductRequest.java
0 → 100644
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @author zhouhaibao
* @version 1.0
* @description: 产品菜单关系请求
* @date 2021/7/16 16:50
*/
@Data
public
class
ProductRequest
implements
Serializable
{
/**
* 产品id
*/
private
Integer
productId
;
/**
* 菜单id列表
*/
private
List
<
Integer
>
menuIdList
;
/**
* 选中的功能值
*/
private
List
<
FunctionRequest
>
functionIdList
;
}
src/main/java/cn/com/glsx/merchants/request/accounttype/AccountTypeInsertRequest.java
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
.
accounttype
;
package
cn
.
com
.
glsx
.
merchants
.
request
.
accounttype
;
import
cn.com.glsx.merchants.
model.request.AccountFunctionRelation
Request
;
import
cn.com.glsx.merchants.
request.Product
Request
;
import
com.rop.AbstractRopRequest
;
import
com.rop.AbstractRopRequest
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -46,6 +46,6 @@ public class AccountTypeInsertRequest extends AbstractRopRequest {
...
@@ -46,6 +46,6 @@ public class AccountTypeInsertRequest extends AbstractRopRequest {
/**
/**
* 功能关系数据
* 功能关系数据
*/
*/
private
List
<
AccountFunctionRelationRequest
>
function
List
;
private
List
<
ProductRequest
>
request
List
;
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/merchants/request/accounttype/AccountTypeUpdateRequest.java
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
.
accounttype
;
package
cn
.
com
.
glsx
.
merchants
.
request
.
accounttype
;
import
cn.com.glsx.merchants.
model.request.AccountFunctionRelation
Request
;
import
cn.com.glsx.merchants.
request.Product
Request
;
import
com.rop.AbstractRopRequest
;
import
com.rop.AbstractRopRequest
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -52,9 +52,9 @@ public class AccountTypeUpdateRequest extends AbstractRopRequest {
...
@@ -52,9 +52,9 @@ public class AccountTypeUpdateRequest extends AbstractRopRequest {
private
String
updatedAccount
;
private
String
updatedAccount
;
/**
/**
* 功能关系数据
*
产品
功能关系数据
*/
*/
private
List
<
AccountFunctionRelationRequest
>
function
List
;
private
List
<
ProductRequest
>
request
List
;
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
...
...
src/main/java/cn/com/glsx/merchants/request/role/RoleAccountTypeRequest.java
0 → 100644
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
.
role
;
import
cn.com.glsx.merchants.request.ProductRequest
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.List
;
/**
* @author zhouhaibao
* @version 1.0
* @description: 角色账户类型关系请求
* @date 2021/7/16 16:50
*/
@Data
public
class
RoleAccountTypeRequest
implements
Serializable
{
/**
* 账户类型id
*/
private
Integer
accounttypeId
;
/**
* 产品列表
*/
private
List
<
ProductRequest
>
productList
;
}
src/main/java/cn/com/glsx/merchants/request/role/RoleInsertRequest.java
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
.
role
;
package
cn
.
com
.
glsx
.
merchants
.
request
.
role
;
import
cn.com.glsx.merchants.model.request.RoleAccountRelationRequest
;
import
com.rop.AbstractRopRequest
;
import
com.rop.AbstractRopRequest
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -41,6 +40,6 @@ public class RoleInsertRequest extends AbstractRopRequest {
...
@@ -41,6 +40,6 @@ public class RoleInsertRequest extends AbstractRopRequest {
/**
/**
* 角色关联账户类型列表
* 角色关联账户类型列表
*/
*/
private
List
<
RoleAccount
RelationRequest
>
accoun
tList
;
private
List
<
RoleAccount
TypeRequest
>
reques
tList
;
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/merchants/request/role/RoleUpdateRequest.java
View file @
1d17d9c
package
cn
.
com
.
glsx
.
merchants
.
request
.
role
;
package
cn
.
com
.
glsx
.
merchants
.
request
.
role
;
import
cn.com.glsx.merchants.model.request.RoleAccountRelationRequest
;
import
com.rop.AbstractRopRequest
;
import
com.rop.AbstractRopRequest
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
lombok.Data
;
...
@@ -55,6 +54,6 @@ public class RoleUpdateRequest extends AbstractRopRequest {
...
@@ -55,6 +54,6 @@ public class RoleUpdateRequest extends AbstractRopRequest {
/**
/**
* 角色关联账户类型列表
* 角色关联账户类型列表
*/
*/
private
List
<
RoleAccount
RelationRequest
>
accoun
tList
;
private
List
<
RoleAccount
TypeRequest
>
reques
tList
;
}
}
\ No newline at end of file
\ No newline at end of file
src/main/java/cn/com/glsx/merchants/service/MerchantAccountTypeService.java
View file @
1d17d9c
...
@@ -5,20 +5,25 @@ import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
...
@@ -5,20 +5,25 @@ import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.framework.core.exception.RpcServiceException
;
import
cn.com.glsx.merchants.convert.ConvertRequest
;
import
cn.com.glsx.merchants.convert.ConvertRequest
;
import
cn.com.glsx.merchants.convert.ConvertResponse
;
import
cn.com.glsx.merchants.convert.ConvertResponse
;
import
cn.com.glsx.merchants.model.request.AccountFunctionRelationRequest
;
import
cn.com.glsx.merchants.model.request.MerchantAccountTypeRequest
;
import
cn.com.glsx.merchants.model.request.MerchantAccountTypeRequest
;
import
cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse
;
import
cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse
;
import
cn.com.glsx.merchants.remote.MerchantAccountTypeRemote
;
import
cn.com.glsx.merchants.remote.MerchantAccountTypeRemote
;
import
cn.com.glsx.merchants.request.FunctionRequest
;
import
cn.com.glsx.merchants.request.ProductRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeDeleteRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeDeleteRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeListSearchRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeInsertRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeInsertRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeListSearchRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeUpdateRequest
;
import
cn.com.glsx.merchants.request.accounttype.AccountTypeUpdateRequest
;
import
cn.com.glsx.merchants.util.Pagination
;
import
cn.com.glsx.merchants.util.Pagination
;
import
com.github.dozermapper.core.Mapper
;
import
com.github.dozermapper.core.Mapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -111,6 +116,7 @@ public class MerchantAccountTypeService {
...
@@ -111,6 +116,7 @@ public class MerchantAccountTypeService {
public
Boolean
insert
(
AccountTypeInsertRequest
request
)
{
public
Boolean
insert
(
AccountTypeInsertRequest
request
)
{
MerchantAccountTypeRequest
typeRequest
=
new
MerchantAccountTypeRequest
();
MerchantAccountTypeRequest
typeRequest
=
new
MerchantAccountTypeRequest
();
dozerMapper
.
map
(
request
,
typeRequest
);
dozerMapper
.
map
(
request
,
typeRequest
);
this
.
dataTransfer
(
typeRequest
,
request
.
getRequestList
());
//数据转换
RpcResponse
<
Boolean
>
response
=
accountTypeRemote
.
insertRemote
(
typeRequest
);
RpcResponse
<
Boolean
>
response
=
accountTypeRemote
.
insertRemote
(
typeRequest
);
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
()){
return
response
.
getResult
();
return
response
.
getResult
();
...
@@ -127,6 +133,7 @@ public class MerchantAccountTypeService {
...
@@ -127,6 +133,7 @@ public class MerchantAccountTypeService {
public
Boolean
update
(
AccountTypeUpdateRequest
request
)
{
public
Boolean
update
(
AccountTypeUpdateRequest
request
)
{
MerchantAccountTypeRequest
typeRequest
=
new
MerchantAccountTypeRequest
();
MerchantAccountTypeRequest
typeRequest
=
new
MerchantAccountTypeRequest
();
dozerMapper
.
map
(
request
,
typeRequest
);
dozerMapper
.
map
(
request
,
typeRequest
);
this
.
dataTransfer
(
typeRequest
,
request
.
getRequestList
());
//数据转换
RpcResponse
<
Boolean
>
response
=
accountTypeRemote
.
updateRemote
(
typeRequest
);
RpcResponse
<
Boolean
>
response
=
accountTypeRemote
.
updateRemote
(
typeRequest
);
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
()){
return
response
.
getResult
();
return
response
.
getResult
();
...
@@ -134,4 +141,40 @@ public class MerchantAccountTypeService {
...
@@ -134,4 +141,40 @@ public class MerchantAccountTypeService {
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
}
}
/**
* 保存数据转换
* @param typeRequest 请求保存的数据
* @param requestList 前端传送产品菜单数据
*/
private
void
dataTransfer
(
MerchantAccountTypeRequest
typeRequest
,
List
<
ProductRequest
>
requestList
){
if
(
CollectionUtils
.
isEmpty
(
requestList
)){
return
;
}
List
<
AccountFunctionRelationRequest
>
functionList
=
new
ArrayList
<>();
requestList
.
stream
().
forEach
(
index
->{
List
<
Integer
>
menuIdList
=
index
.
getMenuIdList
();
List
<
FunctionRequest
>
functionIdList
=
index
.
getFunctionIdList
();
if
(
CollectionUtils
.
isNotEmpty
(
menuIdList
)){
menuIdList
.
stream
().
forEach
(
menuId
->{
AccountFunctionRelationRequest
relation
=
new
AccountFunctionRelationRequest
();
relation
.
setProductId
(
index
.
getProductId
());
relation
.
setMenuId
(
menuId
);
functionList
.
add
(
relation
);
});
}
if
(
CollectionUtils
.
isNotEmpty
(
functionIdList
)){
functionIdList
.
stream
().
forEach
(
function
->{
AccountFunctionRelationRequest
relation
=
new
AccountFunctionRelationRequest
();
relation
.
setProductId
(
index
.
getProductId
());
relation
.
setMenuId
(
function
.
getMenuId
());
relation
.
setFunctionId
(
function
.
getId
());
relation
.
setFunctionValue
(
function
.
getFunctionValue
());
functionList
.
add
(
relation
);
});
}
});
typeRequest
.
setFunctionList
(
functionList
);
}
}
}
src/main/java/cn/com/glsx/merchants/service/MerchantRoleService.java
View file @
1d17d9c
...
@@ -6,19 +6,22 @@ import cn.com.glsx.framework.core.exception.RpcServiceException;
...
@@ -6,19 +6,22 @@ import cn.com.glsx.framework.core.exception.RpcServiceException;
import
cn.com.glsx.merchants.convert.ConvertRequest
;
import
cn.com.glsx.merchants.convert.ConvertRequest
;
import
cn.com.glsx.merchants.convert.ConvertResponse
;
import
cn.com.glsx.merchants.convert.ConvertResponse
;
import
cn.com.glsx.merchants.model.request.MerchantRoleRequest
;
import
cn.com.glsx.merchants.model.request.MerchantRoleRequest
;
import
cn.com.glsx.merchants.model.request.RoleAccountRelationRequest
;
import
cn.com.glsx.merchants.model.request.RoleFunctionRelationRequest
;
import
cn.com.glsx.merchants.model.response.MerchantRoleResponse
;
import
cn.com.glsx.merchants.model.response.MerchantRoleResponse
;
import
cn.com.glsx.merchants.remote.MerchantRoleRemote
;
import
cn.com.glsx.merchants.remote.MerchantRoleRemote
;
import
cn.com.glsx.merchants.request.role.RoleDeleteRequest
;
import
cn.com.glsx.merchants.request.FunctionRequest
;
import
cn.com.glsx.merchants.request.role.RoleListSearchRequest
;
import
cn.com.glsx.merchants.request.ProductRequest
;
import
cn.com.glsx.merchants.request.role.RoleInsertRequest
;
import
cn.com.glsx.merchants.request.role.*
;
import
cn.com.glsx.merchants.request.role.RoleUpdateRequest
;
import
cn.com.glsx.merchants.util.Pagination
;
import
cn.com.glsx.merchants.util.Pagination
;
import
com.github.dozermapper.core.Mapper
;
import
com.github.dozermapper.core.Mapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
/**
/**
...
@@ -109,9 +112,10 @@ public class MerchantRoleService {
...
@@ -109,9 +112,10 @@ public class MerchantRoleService {
* @return
* @return
*/
*/
public
Boolean
insert
(
RoleInsertRequest
request
)
{
public
Boolean
insert
(
RoleInsertRequest
request
)
{
MerchantRoleRequest
typeRequest
=
new
MerchantRoleRequest
();
MerchantRoleRequest
roleRequest
=
new
MerchantRoleRequest
();
dozerMapper
.
map
(
request
,
typeRequest
);
dozerMapper
.
map
(
request
,
roleRequest
);
RpcResponse
<
Boolean
>
response
=
roleRemote
.
insertRemote
(
typeRequest
);
this
.
dataTransfer
(
roleRequest
,
request
.
getRequestList
());
RpcResponse
<
Boolean
>
response
=
roleRemote
.
insertRemote
(
roleRequest
);
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
()){
return
response
.
getResult
();
return
response
.
getResult
();
}
}
...
@@ -125,14 +129,63 @@ public class MerchantRoleService {
...
@@ -125,14 +129,63 @@ public class MerchantRoleService {
* @return
* @return
*/
*/
public
Boolean
update
(
RoleUpdateRequest
request
)
{
public
Boolean
update
(
RoleUpdateRequest
request
)
{
MerchantRoleRequest
typeRequest
=
new
MerchantRoleRequest
();
MerchantRoleRequest
roleRequest
=
new
MerchantRoleRequest
();
dozerMapper
.
map
(
request
,
typeRequest
);
dozerMapper
.
map
(
request
,
roleRequest
);
RpcResponse
<
Boolean
>
response
=
roleRemote
.
updateRemote
(
typeRequest
);
this
.
dataTransfer
(
roleRequest
,
request
.
getRequestList
());
RpcResponse
<
Boolean
>
response
=
roleRemote
.
updateRemote
(
roleRequest
);
if
(
response
.
isSuccess
()){
if
(
response
.
isSuccess
()){
return
response
.
getResult
();
return
response
.
getResult
();
}
}
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
}
}
/**
* 保存数据转换
* @param roleRequest 请求保存的数据
* @param requestList 前端传送产品菜单数据
*/
private
void
dataTransfer
(
MerchantRoleRequest
roleRequest
,
List
<
RoleAccountTypeRequest
>
requestList
){
if
(
CollectionUtils
.
isEmpty
(
requestList
)){
return
;
}
List
<
RoleAccountRelationRequest
>
accountList
=
new
ArrayList
<>();
int
len
=
requestList
.
size
();
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
RoleAccountTypeRequest
roleAccountType
=
requestList
.
get
(
i
);
RoleAccountRelationRequest
relationRequest
=
new
RoleAccountRelationRequest
();
relationRequest
.
setAccounttypeId
(
roleAccountType
.
getAccounttypeId
());
List
<
ProductRequest
>
productList
=
roleAccountType
.
getProductList
();
if
(
CollectionUtils
.
isEmpty
(
productList
)){
accountList
.
add
(
relationRequest
);
continue
;
}
List
<
RoleFunctionRelationRequest
>
functionList
=
new
ArrayList
<>();
productList
.
stream
().
forEach
(
index
->{
List
<
Integer
>
menuIdList
=
index
.
getMenuIdList
();
List
<
FunctionRequest
>
functionIdList
=
index
.
getFunctionIdList
();
if
(
CollectionUtils
.
isNotEmpty
(
menuIdList
)){
menuIdList
.
stream
().
forEach
(
menuId
->{
RoleFunctionRelationRequest
relation
=
new
RoleFunctionRelationRequest
();
relation
.
setProductId
(
index
.
getProductId
());
relation
.
setMenuId
(
menuId
);
functionList
.
add
(
relation
);
});
}
if
(
CollectionUtils
.
isNotEmpty
(
functionIdList
)){
functionIdList
.
stream
().
forEach
(
function
->{
RoleFunctionRelationRequest
relation
=
new
RoleFunctionRelationRequest
();
relation
.
setProductId
(
index
.
getProductId
());
relation
.
setMenuId
(
function
.
getMenuId
());
relation
.
setFuncitonId
(
function
.
getId
());
relation
.
setFunctionValue
(
function
.
getFunctionValue
());
functionList
.
add
(
relation
);
});
}
});
relationRequest
.
setFunctionList
(
functionList
);
accountList
.
add
(
relationRequest
);
}
roleRequest
.
setAccountList
(
accountList
);
//账户角色数据列表set
}
}
}
Write
Preview
Markdown
is supported
Attach a file
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 post a comment