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 face0257
authored
Jul 21, 2021
by
wangnb
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
账户体系账户类型、角色响应数据转换--think.wang
1 parent
1d17d9c1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
342 additions
and
6 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/response/AccountTypeResponse.java
src/main/java/cn/com/glsx/merchants/response/FunctionRelationResponse.java
src/main/java/cn/com/glsx/merchants/response/ProductRelationResponse.java
src/main/java/cn/com/glsx/merchants/response/RoleAccountTypeResponse.java
src/main/java/cn/com/glsx/merchants/response/RoleResponse.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 @
face025
...
...
@@ -4,6 +4,7 @@ import cn.com.glsx.framework.core.exception.RpcServiceException;
import
cn.com.glsx.framework.rop.response.RopResponse
;
import
cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse
;
import
cn.com.glsx.merchants.request.accounttype.*
;
import
cn.com.glsx.merchants.response.AccountTypeResponse
;
import
cn.com.glsx.merchants.service.MerchantAccountTypeService
;
import
cn.com.glsx.merchants.service.MerchantUserService
;
import
cn.com.glsx.merchants.util.Pagination
;
...
...
@@ -77,7 +78,7 @@ public class MerchantAccountTypeController {
*/
@ServiceMethod
(
method
=
"org.ore.api.accountType.getById"
,
needInSession
=
NeedInSessionType
.
YES
)
@ApiOperation
(
"根据id获取账户类型接口"
)
public
RopResponse
<
Merchant
AccountTypeResponse
>
getById
(
AccountTypeSearchRequest
request
)
{
public
RopResponse
<
AccountTypeResponse
>
getById
(
AccountTypeSearchRequest
request
)
{
try
{
return
RopResponse
.
success
(
accountTypeService
.
getAccountTypeDetail
(
request
.
getId
()));
}
catch
(
RpcServiceException
e
)
{
...
...
src/main/java/cn/com/glsx/merchants/controller/MerchantRoleController.java
View file @
face025
...
...
@@ -8,6 +8,7 @@ import cn.com.glsx.merchants.request.role.RoleDeleteRequest;
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.response.RoleResponse
;
import
cn.com.glsx.merchants.service.MerchantRoleService
;
import
cn.com.glsx.merchants.service.MerchantUserService
;
import
cn.com.glsx.merchants.util.Pagination
;
...
...
@@ -81,7 +82,7 @@ public class MerchantRoleController {
*/
@ServiceMethod
(
method
=
"org.ore.api.role.getById"
,
needInSession
=
NeedInSessionType
.
YES
)
@ApiOperation
(
"根据id获取角色管理接口"
)
public
RopResponse
<
Merchant
RoleResponse
>
getById
(
AccountTypeSearchRequest
request
)
{
public
RopResponse
<
RoleResponse
>
getById
(
AccountTypeSearchRequest
request
)
{
try
{
return
RopResponse
.
success
(
roleService
.
getById
(
request
.
getId
()));
}
catch
(
RpcServiceException
e
)
{
...
...
src/main/java/cn/com/glsx/merchants/response/AccountTypeResponse.java
0 → 100644
View file @
face025
package
cn
.
com
.
glsx
.
merchants
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
@Data
public
class
AccountTypeResponse
implements
Serializable
{
private
Integer
id
;
/**
* 账户类型名称
*/
private
String
accounttypeName
;
/**
* 描述
*/
private
String
accounttypeDetail
;
/**
* 创建人
*/
private
Integer
createdBy
;
/**
* 创建时间
*/
private
Date
createdTime
;
/**
* 更新人
*/
private
Integer
updatedBy
;
/**
* 更新时间
*/
private
Date
updatedTime
;
/**
* 是否删除:0=正常,-1=删除 1.草稿
*/
private
Byte
delFlag
;
/**
* 账户类型编码
*/
private
String
accounttypeCode
;
/**
* 创建账户
*/
private
String
createdAccount
;
/**
* 更新账户
*/
private
String
updatedAccount
;
/**
* 账户类型功能列表
*/
private
List
<
ProductRelationResponse
>
responseList
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
src/main/java/cn/com/glsx/merchants/response/FunctionRelationResponse.java
0 → 100644
View file @
face025
package
cn
.
com
.
glsx
.
merchants
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
/**
* @author zhouhaibao
* @version 1.0
* @description: 功能关系请求
* @date 2021/7/16 16:50
*/
@Data
public
class
FunctionRelationResponse
implements
Serializable
{
/**
* 功能id
*/
private
Integer
id
;
/**
* 父级菜单id
*/
private
Integer
menuId
;
/**
* 选中的功能值
*/
private
String
functionValue
;
}
src/main/java/cn/com/glsx/merchants/response/ProductRelationResponse.java
0 → 100644
View file @
face025
package
cn
.
com
.
glsx
.
merchants
.
response
;
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
ProductRelationResponse
implements
Serializable
{
/**
* 产品id
*/
private
Integer
productId
;
/**
* 菜单id列表
*/
private
List
<
Integer
>
menuIdList
;
/**
* 选中的功能值
*/
private
List
<
FunctionRelationResponse
>
functionIdList
;
}
src/main/java/cn/com/glsx/merchants/response/RoleAccountTypeResponse.java
0 → 100644
View file @
face025
package
cn
.
com
.
glsx
.
merchants
.
response
;
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
RoleAccountTypeResponse
implements
Serializable
{
/**
* 账户类型id
*/
private
Integer
accounttypeId
;
/**
* 产品列表
*/
private
List
<
ProductRelationResponse
>
productList
;
}
src/main/java/cn/com/glsx/merchants/response/RoleResponse.java
0 → 100644
View file @
face025
package
cn
.
com
.
glsx
.
merchants
.
response
;
import
lombok.Data
;
import
java.io.Serializable
;
import
java.util.Date
;
import
java.util.List
;
@Data
public
class
RoleResponse
implements
Serializable
{
private
Integer
id
;
/**
* 角色名称
*/
private
String
roleName
;
/**
* 角色描述
*/
private
String
roleDescription
;
/**
* 所属商户id
*/
private
Integer
merchantId
;
/**
* 创建时间
*/
private
Integer
createdBy
;
/**
* 创建时间
*/
private
Date
createdTime
;
/**
* 更新人
*/
private
Integer
updatedBy
;
/**
* 更新时间
*/
private
Date
updatedTime
;
/**
* 创建账户
*/
private
String
createdAccount
;
/**
* 更新账户
*/
private
String
updatedAccount
;
/**
* 角色关联账户类型列表
*/
private
List
<
RoleAccountTypeResponse
>
responseList
;
private
static
final
long
serialVersionUID
=
1L
;
}
\ No newline at end of file
src/main/java/cn/com/glsx/merchants/service/MerchantAccountTypeService.java
View file @
face025
...
...
@@ -7,6 +7,7 @@ import cn.com.glsx.merchants.convert.ConvertRequest;
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.response.AccountFunctionRelationResponse
;
import
cn.com.glsx.merchants.model.response.MerchantAccountTypeResponse
;
import
cn.com.glsx.merchants.remote.MerchantAccountTypeRemote
;
import
cn.com.glsx.merchants.request.FunctionRequest
;
...
...
@@ -15,6 +16,9 @@ import cn.com.glsx.merchants.request.accounttype.AccountTypeDeleteRequest;
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.response.AccountTypeResponse
;
import
cn.com.glsx.merchants.response.FunctionRelationResponse
;
import
cn.com.glsx.merchants.response.ProductRelationResponse
;
import
cn.com.glsx.merchants.util.Pagination
;
import
com.github.dozermapper.core.Mapper
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -25,6 +29,8 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author zhouhaibao
...
...
@@ -48,10 +54,13 @@ public class MerchantAccountTypeService {
* @param id
* @return
*/
public
Merchant
AccountTypeResponse
getAccountTypeDetail
(
Integer
id
)
{
public
AccountTypeResponse
getAccountTypeDetail
(
Integer
id
)
{
RpcResponse
<
MerchantAccountTypeResponse
>
response
=
accountTypeRemote
.
getByIdRemote
(
id
);
if
(
response
.
isSuccess
()){
return
response
.
getResult
();
AccountTypeResponse
accountTypeResponse
=
new
AccountTypeResponse
();
dozerMapper
.
map
(
response
.
getResult
(),
accountTypeResponse
);
this
.
responseDataTransfer
(
accountTypeResponse
,
response
.
getResult
().
getFunctionList
());
return
accountTypeResponse
;
}
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
}
...
...
@@ -141,6 +150,43 @@ public class MerchantAccountTypeService {
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
}
/**
* 响应返回给前端数据转换
* @param response
* @param functionList
*/
private
void
responseDataTransfer
(
AccountTypeResponse
response
,
List
<
AccountFunctionRelationResponse
>
functionList
){
if
(
CollectionUtils
.
isEmpty
(
functionList
)){
return
;
}
//根据产品id分组
Map
<
Integer
,
List
<
AccountFunctionRelationResponse
>>
map
=
functionList
.
stream
().
collect
(
Collectors
.
groupingBy
(
AccountFunctionRelationResponse:
:
getProductId
));
List
<
ProductRelationResponse
>
responseList
=
new
ArrayList
<>();
for
(
Integer
key
:
map
.
keySet
()){
ProductRelationResponse
relationResponse
=
new
ProductRelationResponse
();
relationResponse
.
setProductId
(
key
);
List
<
AccountFunctionRelationResponse
>
list
=
map
.
get
(
key
);
List
<
Integer
>
menuList
=
new
ArrayList
<>();
List
<
FunctionRelationResponse
>
functionIdList
=
new
ArrayList
<>();
list
.
stream
().
forEach
(
index
->{
if
(
index
.
getFunctionId
()
!=
null
&&
index
.
getFunctionId
()
>
0
){
FunctionRelationResponse
function
=
new
FunctionRelationResponse
();
function
.
setMenuId
(
index
.
getMenuId
());
function
.
setId
(
index
.
getFunctionId
());
function
.
setFunctionValue
(
index
.
getFunctionValue
());
functionIdList
.
add
(
function
);
}
else
{
menuList
.
add
(
index
.
getMenuId
());
}
});
relationResponse
.
setMenuIdList
(
menuList
);
relationResponse
.
setFunctionIdList
(
functionIdList
);
responseList
.
add
(
relationResponse
);
}
response
.
setResponseList
(
responseList
);
}
/**
* 保存数据转换
...
...
src/main/java/cn/com/glsx/merchants/service/MerchantRoleService.java
View file @
face025
...
...
@@ -9,10 +9,16 @@ 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.RoleAccountRelationResponse
;
import
cn.com.glsx.merchants.model.response.RoleFunctionRelationResponse
;
import
cn.com.glsx.merchants.remote.MerchantRoleRemote
;
import
cn.com.glsx.merchants.request.FunctionRequest
;
import
cn.com.glsx.merchants.request.ProductRequest
;
import
cn.com.glsx.merchants.request.role.*
;
import
cn.com.glsx.merchants.response.FunctionRelationResponse
;
import
cn.com.glsx.merchants.response.ProductRelationResponse
;
import
cn.com.glsx.merchants.response.RoleAccountTypeResponse
;
import
cn.com.glsx.merchants.response.RoleResponse
;
import
cn.com.glsx.merchants.util.Pagination
;
import
com.github.dozermapper.core.Mapper
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -23,6 +29,8 @@ import org.springframework.stereotype.Service;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author zhouhaibao
...
...
@@ -46,15 +54,68 @@ public class MerchantRoleService {
* @param id
* @return
*/
public
Merchant
RoleResponse
getById
(
Integer
id
)
{
public
RoleResponse
getById
(
Integer
id
)
{
RpcResponse
<
MerchantRoleResponse
>
response
=
roleRemote
.
getByIdRemote
(
id
);
if
(
response
.
isSuccess
()){
return
response
.
getResult
();
RoleResponse
roleResponse
=
new
RoleResponse
();
dozerMapper
.
map
(
response
.
getResult
(),
roleResponse
);
this
.
responseDataTransfer
(
roleResponse
,
response
.
getResult
().
getAccountList
());
}
throw
new
RpcServiceException
(
response
.
getException
().
getErrId
(),
response
.
getMessage
());
}
/**
* 响应返回给前端数据转换
* @param roleResponse
* @param accountList
*/
private
void
responseDataTransfer
(
RoleResponse
roleResponse
,
List
<
RoleAccountRelationResponse
>
accountList
){
if
(
CollectionUtils
.
isEmpty
(
accountList
)){
return
;
}
List
<
RoleAccountTypeResponse
>
responseList
=
new
ArrayList
<>();
for
(
RoleAccountRelationResponse
accountRelationResponse
:
accountList
)
{
//角色与账户类型关系数据封装
RoleAccountTypeResponse
roleAccountType
=
new
RoleAccountTypeResponse
();
roleAccountType
.
setAccounttypeId
(
accountRelationResponse
.
getAccounttypeId
());
//账户类型id封装
//角色与账户类型子级关系数据封装
List
<
RoleFunctionRelationResponse
>
functionList
=
accountRelationResponse
.
getFunctionList
();
if
(
CollectionUtils
.
isNotEmpty
(
functionList
)){
List
<
ProductRelationResponse
>
productList
=
new
ArrayList
<>();
//子级数据封装对象new
//根据产品id分组
Map
<
Integer
,
List
<
RoleFunctionRelationResponse
>>
functionMap
=
functionList
.
stream
().
collect
(
Collectors
.
groupingBy
(
RoleFunctionRelationResponse:
:
getProductId
));
//分组后遍历封装子级关系数据
for
(
Integer
key
:
functionMap
.
keySet
()){
ProductRelationResponse
relationResponse
=
new
ProductRelationResponse
();
relationResponse
.
setProductId
(
key
);
//产品id
List
<
RoleFunctionRelationResponse
>
list
=
functionMap
.
get
(
key
);
List
<
Integer
>
menuList
=
new
ArrayList
<>();
List
<
FunctionRelationResponse
>
functionIdList
=
new
ArrayList
<>();
list
.
stream
().
forEach
(
index
->{
//功能封装
if
(
index
.
getFuncitonId
()
!=
null
&&
index
.
getFuncitonId
()
>
0
){
FunctionRelationResponse
function
=
new
FunctionRelationResponse
();
function
.
setMenuId
(
index
.
getMenuId
());
function
.
setId
(
index
.
getFuncitonId
());
function
.
setFunctionValue
(
index
.
getFunctionValue
());
functionIdList
.
add
(
function
);
}
else
{
//菜单封装
menuList
.
add
(
index
.
getMenuId
());
}
});
relationResponse
.
setMenuIdList
(
menuList
);
relationResponse
.
setFunctionIdList
(
functionIdList
);
productList
.
add
(
relationResponse
);
//子级菜单数据set
}
roleAccountType
.
setProductList
(
productList
);
//逐级封装返回
}
responseList
.
add
(
roleAccountType
);
}
roleResponse
.
setResponseList
(
responseList
);
}
/**
* 获取角色管理分页数据
*
* @param request
...
...
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