记得上下班打卡 | git大法好,push需谨慎
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liquidnet-bus-v1
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董敬伟
liquidnet-bus-v1
Commits
92823cd2
Commit
92823cd2
authored
Nov 18, 2021
by
Tice
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
5b731dcf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
271 additions
and
125 deletions
+271
-125
MerchantAuthorizationPerformanceVo.java
...e/merchant/dto/vo/MerchantAuthorizationPerformanceVo.java
+36
-0
MerchantAuthorizationRecordsAdminServiceImpl.java
...ce/impl/MerchantAuthorizationRecordsAdminServiceImpl.java
+175
-119
MerchantAuthorizationRecordsServiceImpl.java
...service/impl/MerchantAuthorizationRecordsServiceImpl.java
+56
-6
MerchantFieldsServiceImpl.java
...vice/merchant/service/impl/MerchantFieldsServiceImpl.java
+4
-0
No files found.
liquidnet-bus-api/liquidnet-service-merchant-api/src/main/java/com/liquidnet/service/merchant/dto/vo/MerchantAuthorizationPerformanceVo.java
0 → 100644
View file @
92823cd2
package
com
.
liquidnet
.
service
.
merchant
.
dto
.
vo
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
java.util.List
;
@ApiModel
(
value
=
"MerchantAuthorizationPerformanceVo"
,
description
=
"演出纬度权限聚合"
)
@Data
public
class
MerchantAuthorizationPerformanceVo
implements
java
.
io
.
Serializable
,
Cloneable
{
private
static
final
long
serialVersionUID
=
-
225012446820470899L
;
@ApiModelProperty
(
value
=
"演出ID"
)
private
String
performanceId
;
@ApiModelProperty
(
value
=
"权利人"
)
private
String
uid
;
@ApiModelProperty
(
value
=
"权利人演出所有角色"
)
private
List
<
String
>
uidRoles
;
@ApiModelProperty
(
value
=
"权利人演出所有权限"
)
private
List
<
String
>
permissionIds
;
private
static
final
MerchantAuthorizationPerformanceVo
obj
=
new
MerchantAuthorizationPerformanceVo
();
public
static
MerchantAuthorizationPerformanceVo
getNew
()
{
try
{
return
(
MerchantAuthorizationPerformanceVo
)
obj
.
clone
();
}
catch
(
CloneNotSupportedException
e
)
{
e
.
printStackTrace
();
}
return
new
MerchantAuthorizationPerformanceVo
();
}
}
liquidnet-bus-client/liquidnet-client-admin/liquidnet-client-admin-zhengzai/src/main/java/com/liquidnet/client/admin/zhengzai/merchant/service/impl/MerchantAuthorizationRecordsAdminServiceImpl.java
View file @
92823cd2
...
@@ -15,10 +15,13 @@ import com.liquidnet.service.merchant.dto.vo.*;
...
@@ -15,10 +15,13 @@ import com.liquidnet.service.merchant.dto.vo.*;
import
com.liquidnet.service.merchant.entity.*
;
import
com.liquidnet.service.merchant.entity.*
;
import
com.liquidnet.service.merchant.mapper.MerchantAuthorizationRecordsMapper
;
import
com.liquidnet.service.merchant.mapper.MerchantAuthorizationRecordsMapper
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.convert.MongoConverter
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -39,6 +42,9 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -39,6 +42,9 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
@Autowired
@Autowired
MongoTemplate
mongoTemplate
;
MongoTemplate
mongoTemplate
;
@Autowired
MongoConverter
mongoConverter
;
@Autowired
@Autowired
IMerchantFieldsAdminService
fieldsAdminService
;
IMerchantFieldsAdminService
fieldsAdminService
;
...
@@ -57,11 +63,11 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -57,11 +63,11 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
// 创建者
// 创建者
this
.
performanceCreator
(
performanceId
,
cuid
);
this
.
performanceCreator
(
performanceId
,
cuid
);
// 场地方
this
.
performanceFielder
(
performanceId
,
fieldId
);
// 主办方
// 主办方
this
.
performanceSponsor
(
performanceId
,
sponsorId
);
this
.
performanceSponsor
(
performanceId
,
sponsorId
);
// 场地方
this
.
performanceFielder
(
performanceId
,
fieldId
);
}
}
// 创建者
// 创建者
...
@@ -92,7 +98,7 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -92,7 +98,7 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
ArrayList
<
MerchantAuthorizationRecords
>
authorizationRecordsArrayList
=
new
ArrayList
<>();
ArrayList
<
MerchantAuthorizationRecords
>
authorizationRecordsArrayList
=
new
ArrayList
<>();
ArrayList
<
MerchantAuthorizationPermissions
>
authorizationPermissionsArrayList
=
new
ArrayList
<>();
ArrayList
<
MerchantAuthorizationPermissions
>
authorizationPermissionsArrayList
=
new
ArrayList
<>();
// 授权记录
// 授权记录
entity
// todo 用户信息
// todo 用户信息
MerchantAuthorizationRecords
creatorAuthorizationRecords
=
new
MerchantAuthorizationRecords
();
MerchantAuthorizationRecords
creatorAuthorizationRecords
=
new
MerchantAuthorizationRecords
();
creatorAuthorizationRecords
.
setAuthorizationRecordId
(
IDGenerator
.
nextSnowId
());
creatorAuthorizationRecords
.
setAuthorizationRecordId
(
IDGenerator
.
nextSnowId
());
...
@@ -106,7 +112,7 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -106,7 +112,7 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
creatorAuthorizationRecords
.
setCreatedAt
(
now
);
creatorAuthorizationRecords
.
setCreatedAt
(
now
);
authorizationRecordsArrayList
.
add
(
creatorAuthorizationRecords
);
authorizationRecordsArrayList
.
add
(
creatorAuthorizationRecords
);
// 授权权限
// 授权权限
entity vo
ArrayList
<
MerchantAuthorizationPermissionsVo
>
creatorAuthorizationPermissionsVos
=
new
ArrayList
<>();
ArrayList
<
MerchantAuthorizationPermissionsVo
>
creatorAuthorizationPermissionsVos
=
new
ArrayList
<>();
String
[]
fielderPermissionIds
=
{
String
[]
fielderPermissionIds
=
{
MerchantAuthorizationConst
.
PerformancePermission
.
READ
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
READ
.
getId
(),
...
@@ -132,6 +138,11 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -132,6 +138,11 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
creatorAuthorizationPermissionsVos
.
add
(
authorizationPermissionsVo
);
creatorAuthorizationPermissionsVos
.
add
(
authorizationPermissionsVo
);
}
}
// 授权记录 vo
MerchantAuthorizationRecordsVo
authorizationRecordsVo
=
MerchantAuthorizationRecordsVo
.
getNew
();
authorizationRecordsVo
.
copy
(
creatorAuthorizationRecords
);
authorizationRecordsVo
.
setPermissionsVos
(
creatorAuthorizationPermissionsVos
);
// mysql
// mysql
boolean
success
=
saveBatch
(
authorizationRecordsArrayList
);
boolean
success
=
saveBatch
(
authorizationRecordsArrayList
);
if
(!
success
)
{
if
(!
success
)
{
...
@@ -145,11 +156,137 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -145,11 +156,137 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
}
}
// mongo
// mongo
MerchantAuthorizationRecordsVo
authorizationRecordsVo
=
MerchantAuthorizationRecordsVo
.
getNew
();
authorizationRecordsVo
.
copy
(
creatorAuthorizationRecords
);
authorizationRecordsVo
.
setPermissionsVos
(
creatorAuthorizationPermissionsVos
);
mongoTemplate
.
insert
(
authorizationRecordsVo
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
mongoTemplate
.
insert
(
authorizationRecordsVo
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
performanceId
,
authorizationRecordsVo
.
getUid
());
return
true
;
}
// 授权主办方
private
boolean
performanceSponsor
(
String
performanceId
,
String
sponsorId
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
// 查询已有权限
LambdaQueryWrapper
<
MerchantAuthorizationRecords
>
authorizationRecordsLambdaQueryWrapper
=
Wrappers
.
lambdaQuery
(
MerchantAuthorizationRecords
.
class
);
authorizationRecordsLambdaQueryWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getPerformanceId
,
performanceId
);
authorizationRecordsLambdaQueryWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getUidRole
,
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
());
authorizationRecordsLambdaQueryWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getDeletedAt
,
null
);
MerchantAuthorizationRecords
authorizationRecords
=
getOne
(
authorizationRecordsLambdaQueryWrapper
);
// 查询主办方
LambdaQueryWrapper
<
MerchantSponsors
>
sponsorsLambdaQueryWrapper
=
Wrappers
.
lambdaQuery
(
MerchantSponsors
.
class
);
sponsorsLambdaQueryWrapper
.
eq
(
MerchantSponsors:
:
getSponsorId
,
sponsorId
);
MerchantSponsors
sponsors
=
sponsorsAdminService
.
getOne
(
sponsorsLambdaQueryWrapper
);
// 是否已存在权限
if
(
null
!=
authorizationRecords
)
{
if
(
null
!=
sponsors
&&
authorizationRecords
.
getUid
().
equals
(
sponsors
.
getUid
()))
{
// 前后 主办方一致 不处理
return
true
;
}
// 前后 主办方不一致 删除旧权限 及 我的授权
authorizationRecords
.
setUpdatedAt
(
now
);
authorizationRecords
.
setDeletedAt
(
now
);
// 删除旧权限 mysql
LambdaUpdateWrapper
<
MerchantAuthorizationRecords
>
authorizationRecordsLambdaUpdateWrapper
=
Wrappers
.
lambdaUpdate
(
MerchantAuthorizationRecords
.
class
);
authorizationRecordsLambdaUpdateWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getPerformanceId
,
performanceId
)
.
eq
(
MerchantAuthorizationRecords:
:
getDeletedAt
,
null
);
authorizationRecordsLambdaUpdateWrapper
.
and
(
wrapper
->
wrapper
.
eq
(
MerchantAuthorizationRecords:
:
getAuthorizationRecordId
,
authorizationRecords
.
getAuthorizationRecordId
())
.
or
(
wrapper1
->
wrapper1
.
eq
(
MerchantAuthorizationRecords:
:
getCuid
,
authorizationRecords
.
getUid
())
.
eq
(
MerchantAuthorizationRecords:
:
getCuidRole
,
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
()))
);
authorizationRecordsLambdaUpdateWrapper
.
set
(
MerchantAuthorizationRecords:
:
getUpdatedAt
,
authorizationRecords
.
getUpdatedAt
());
authorizationRecordsLambdaUpdateWrapper
.
set
(
MerchantAuthorizationRecords:
:
getDeletedAt
,
authorizationRecords
.
getDeletedAt
());
boolean
success
=
update
(
authorizationRecordsLambdaUpdateWrapper
);
if
(!
success
)
{
// todo error
throw
new
LiquidnetServiceException
();
}
// 删除旧权限 mongo
Criteria
criteria
=
Criteria
.
where
(
"performanceId"
).
is
(
performanceId
).
and
(
"deletedAt"
).
is
(
null
);
criteria
.
orOperator
(
Criteria
.
where
(
"authorizationRecordId"
).
is
(
authorizationRecords
.
getAuthorizationRecordId
()),
Criteria
.
where
(
"cuid"
).
is
(
authorizationRecords
.
getUid
()).
and
(
"cuidRole"
).
is
(
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
())
);
Query
query
=
Query
.
query
(
criteria
);
mongoTemplate
.
remove
(
query
,
MerchantAuthorizationRecordsVo
.
class
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
performanceId
,
authorizationRecords
.
getUid
());
}
// 是否添加权限
if
(
null
!=
sponsors
&&
!
sponsors
.
getUid
().
isEmpty
())
{
ArrayList
<
MerchantAuthorizationRecords
>
authorizationRecordsArrayList
=
new
ArrayList
<>();
ArrayList
<
MerchantAuthorizationPermissions
>
authorizationPermissionsArrayList
=
new
ArrayList
<>();
// 授权记录 entity
// todo 用户信息
MerchantAuthorizationRecords
sponsorAuthorizationRecords
=
new
MerchantAuthorizationRecords
();
sponsorAuthorizationRecords
.
setAuthorizationRecordId
(
IDGenerator
.
nextSnowId
());
sponsorAuthorizationRecords
.
setPerformanceId
(
performanceId
);
sponsorAuthorizationRecords
.
setUidRole
(
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
());
sponsorAuthorizationRecords
.
setUid
(
sponsors
.
getUid
());
sponsorAuthorizationRecords
.
setMobile
(
""
);
sponsorAuthorizationRecords
.
setName
(
""
);
sponsorAuthorizationRecords
.
setCuid
(
""
);
sponsorAuthorizationRecords
.
setCuidRole
(
""
);
sponsorAuthorizationRecords
.
setCreatedAt
(
now
);
authorizationRecordsArrayList
.
add
(
sponsorAuthorizationRecords
);
// 授权权限 entity vo
ArrayList
<
MerchantAuthorizationPermissionsVo
>
sponsorAuthorizationPermissionsVos
=
new
ArrayList
<>();
String
[]
fielderPermissionIds
=
{
MerchantAuthorizationConst
.
PerformancePermission
.
READ
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
CHECK
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
SALES
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
ACCREDIT
.
getId
()
};
for
(
String
permissionId
:
fielderPermissionIds
)
{
MerchantAuthorizationPermissions
sponsorAuthorizationPermissions
=
new
MerchantAuthorizationPermissions
();
sponsorAuthorizationPermissions
.
setAuthorizationPermissionId
(
IDGenerator
.
nextSnowId
());
sponsorAuthorizationPermissions
.
setAuthorizationRecordId
(
sponsorAuthorizationRecords
.
getAuthorizationRecordId
());
sponsorAuthorizationPermissions
.
setPermissionId
(
permissionId
);
sponsorAuthorizationPermissions
.
setStartTime
(
now
);
sponsorAuthorizationPermissions
.
setEndTime
(
now
.
plusYears
(
10
));
sponsorAuthorizationPermissions
.
setCreatedAt
(
now
);
authorizationPermissionsArrayList
.
add
(
sponsorAuthorizationPermissions
);
MerchantAuthorizationPermissionsVo
sponsorAuthorizationPermissionsVo
=
MerchantAuthorizationPermissionsVo
.
getNew
();
sponsorAuthorizationPermissionsVo
.
copy
(
sponsorAuthorizationPermissions
);
sponsorAuthorizationPermissionsVos
.
add
(
sponsorAuthorizationPermissionsVo
);
}
// 授权记录 vo
MerchantAuthorizationRecordsVo
sponsorAuthorizationRecordsVo
=
MerchantAuthorizationRecordsVo
.
getNew
();
sponsorAuthorizationRecordsVo
.
copy
(
sponsorAuthorizationRecords
);
sponsorAuthorizationRecordsVo
.
setPermissionsVos
(
sponsorAuthorizationPermissionsVos
);
// mysql
boolean
success
=
saveBatch
(
authorizationRecordsArrayList
);
if
(!
success
)
{
// todo error
throw
new
LiquidnetServiceException
();
}
success
=
authorizationPermissionsAdminService
.
saveBatch
(
authorizationPermissionsArrayList
);
if
(!
success
)
{
// todo error
throw
new
LiquidnetServiceException
();
}
// mongo
mongoTemplate
.
insert
(
sponsorAuthorizationRecordsVo
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
performanceId
,
sponsorAuthorizationRecordsVo
.
getUid
());
}
return
true
;
return
true
;
}
}
...
@@ -207,6 +344,9 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -207,6 +344,9 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
);
);
Query
query
=
Query
.
query
(
criteria
);
Query
query
=
Query
.
query
(
criteria
);
mongoTemplate
.
remove
(
query
,
MerchantAuthorizationRecordsVo
.
class
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
mongoTemplate
.
remove
(
query
,
MerchantAuthorizationRecordsVo
.
class
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
performanceId
,
authorizationRecords
.
getUid
());
}
}
// 是否添加权限
// 是否添加权限
...
@@ -319,128 +459,44 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
...
@@ -319,128 +459,44 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
// mongo
// mongo
mongoTemplate
.
insert
(
authorizationRecordsVoArrayList
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
mongoTemplate
.
insert
(
authorizationRecordsVoArrayList
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
for
(
MerchantAuthorizationRecordsVo
authorizationRecordsVo
:
authorizationRecordsVoArrayList
)
{
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
performanceId
,
authorizationRecordsVo
.
getUid
());
}
}
}
return
true
;
return
true
;
}
}
// 授权主办方
private
boolean
performanceSponsor
(
String
performanceId
,
String
sponsorId
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
// 查询已有权限
LambdaQueryWrapper
<
MerchantAuthorizationRecords
>
authorizationRecordsLambdaQueryWrapper
=
Wrappers
.
lambdaQuery
(
MerchantAuthorizationRecords
.
class
);
authorizationRecordsLambdaQueryWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getPerformanceId
,
performanceId
);
authorizationRecordsLambdaQueryWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getUidRole
,
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
());
authorizationRecordsLambdaQueryWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getDeletedAt
,
null
);
MerchantAuthorizationRecords
authorizationRecords
=
getOne
(
authorizationRecordsLambdaQueryWrapper
);
// 查询主办方
LambdaQueryWrapper
<
MerchantSponsors
>
sponsorsLambdaQueryWrapper
=
Wrappers
.
lambdaQuery
(
MerchantSponsors
.
class
);
sponsorsLambdaQueryWrapper
.
eq
(
MerchantSponsors:
:
getSponsorId
,
sponsorId
);
MerchantSponsors
sponsors
=
sponsorsAdminService
.
getOne
(
sponsorsLambdaQueryWrapper
);
// 是否已存在权限
if
(
null
!=
authorizationRecords
)
{
if
(
null
!=
sponsors
&&
authorizationRecords
.
getUid
().
equals
(
sponsors
.
getUid
()))
{
// 前后 主办方一致 不处理
return
true
;
}
// 前后 主办方不一致 删除旧权限 及 我的授权
authorizationRecords
.
setUpdatedAt
(
now
);
authorizationRecords
.
setDeletedAt
(
now
);
// 删除旧权限 mysql
LambdaUpdateWrapper
<
MerchantAuthorizationRecords
>
authorizationRecordsLambdaUpdateWrapper
=
Wrappers
.
lambdaUpdate
(
MerchantAuthorizationRecords
.
class
);
authorizationRecordsLambdaUpdateWrapper
.
eq
(
MerchantAuthorizationRecords:
:
getPerformanceId
,
performanceId
)
.
eq
(
MerchantAuthorizationRecords:
:
getDeletedAt
,
null
);
authorizationRecordsLambdaUpdateWrapper
.
and
(
wrapper
->
wrapper
.
eq
(
MerchantAuthorizationRecords:
:
getAuthorizationRecordId
,
authorizationRecords
.
getAuthorizationRecordId
())
.
or
(
wrapper1
->
wrapper1
.
eq
(
MerchantAuthorizationRecords:
:
getCuid
,
authorizationRecords
.
getUid
())
.
eq
(
MerchantAuthorizationRecords:
:
getCuidRole
,
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
()))
);
authorizationRecordsLambdaUpdateWrapper
.
set
(
MerchantAuthorizationRecords:
:
getUpdatedAt
,
authorizationRecords
.
getUpdatedAt
());
authorizationRecordsLambdaUpdateWrapper
.
set
(
MerchantAuthorizationRecords:
:
getDeletedAt
,
authorizationRecords
.
getDeletedAt
());
boolean
success
=
update
(
authorizationRecordsLambdaUpdateWrapper
);
if
(!
success
)
{
// todo error
throw
new
LiquidnetServiceException
();
}
// 删除旧权限 mongo
Criteria
criteria
=
Criteria
.
where
(
"performanceId"
).
is
(
performanceId
).
and
(
"deletedAt"
).
is
(
null
);
criteria
.
orOperator
(
Criteria
.
where
(
"authorizationRecordId"
).
is
(
authorizationRecords
.
getAuthorizationRecordId
()),
Criteria
.
where
(
"cuid"
).
is
(
authorizationRecords
.
getUid
()).
and
(
"cuidRole"
).
is
(
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
())
);
Query
query
=
Query
.
query
(
criteria
);
mongoTemplate
.
remove
(
query
,
MerchantAuthorizationRecordsVo
.
class
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
}
// 是否添加权限
if
(
null
!=
sponsors
&&
!
sponsors
.
getUid
().
isEmpty
())
{
ArrayList
<
MerchantAuthorizationRecords
>
authorizationRecordsArrayList
=
new
ArrayList
<>();
ArrayList
<
MerchantAuthorizationPermissions
>
authorizationPermissionsArrayList
=
new
ArrayList
<>();
// 授权记录 entity
private
void
syncAuthorizationPerformanceVo
(
String
performanceId
,
String
uid
)
{
// todo 用户信息
List
<
MerchantAuthorizationRecordsVo
>
authorizationRecordsVos
=
mongoTemplate
.
find
(
Query
.
query
(
Criteria
.
where
(
"performanceId"
).
is
(
performanceId
).
and
(
"uid"
).
is
(
uid
).
and
(
"deletedAt"
).
is
(
null
)),
MerchantAuthorizationRecordsVo
.
class
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
MerchantAuthorizationRecords
sponsorAuthorizationRecords
=
new
MerchantAuthorizationRecords
();
sponsorAuthorizationRecords
.
setAuthorizationRecordId
(
IDGenerator
.
nextSnowId
());
sponsorAuthorizationRecords
.
setPerformanceId
(
performanceId
);
sponsorAuthorizationRecords
.
setUidRole
(
MerchantAuthorizationConst
.
PerformanceRole
.
SPONSOR
.
getRole
());
sponsorAuthorizationRecords
.
setUid
(
sponsors
.
getUid
());
sponsorAuthorizationRecords
.
setMobile
(
""
);
sponsorAuthorizationRecords
.
setName
(
""
);
sponsorAuthorizationRecords
.
setCuid
(
""
);
sponsorAuthorizationRecords
.
setCuidRole
(
""
);
sponsorAuthorizationRecords
.
setCreatedAt
(
now
);
authorizationRecordsArrayList
.
add
(
sponsorAuthorizationRecords
);
// 授权权限 entity vo
ArrayList
<
MerchantAuthorizationPermissionsVo
>
sponsorAuthorizationPermissionsVos
=
new
ArrayList
<>();
String
[]
fielderPermissionIds
=
{
MerchantAuthorizationConst
.
PerformancePermission
.
READ
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
CHECK
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
SALES
.
getId
(),
MerchantAuthorizationConst
.
PerformancePermission
.
ACCREDIT
.
getId
()
};
for
(
String
permissionId
:
fielderPermissionIds
)
{
MerchantAuthorizationPermissions
sponsorAuthorizationPermissions
=
new
MerchantAuthorizationPermissions
();
sponsorAuthorizationPermissions
.
setAuthorizationPermissionId
(
IDGenerator
.
nextSnowId
());
sponsorAuthorizationPermissions
.
setAuthorizationRecordId
(
sponsorAuthorizationRecords
.
getAuthorizationRecordId
());
sponsorAuthorizationPermissions
.
setPermissionId
(
permissionId
);
sponsorAuthorizationPermissions
.
setStartTime
(
now
);
sponsorAuthorizationPermissions
.
setEndTime
(
now
.
plusYears
(
10
));
sponsorAuthorizationPermissions
.
setCreatedAt
(
now
);
authorizationPermissionsArrayList
.
add
(
sponsorAuthorizationPermissions
);
MerchantAuthorizationPermissionsVo
sponsorAuthorizationPermissionsVo
=
MerchantAuthorizationPermissionsVo
.
getNew
();
List
<
String
>
uidRoles
=
new
ArrayList
<>();
sponsorAuthorizationPermissionsVo
.
copy
(
sponsorAuthorizationPermissions
);
List
<
String
>
permissionIds
=
new
ArrayList
<>();
sponsorAuthorizationPermissionsVos
.
add
(
sponsorAuthorizationPermissionsVo
);
}
// 授权记录 vo
MerchantAuthorizationRecordsVo
sponsorAuthorizationRecordsVo
=
MerchantAuthorizationRecordsVo
.
getNew
();
sponsorAuthorizationRecordsVo
.
copy
(
sponsorAuthorizationRecords
);
sponsorAuthorizationRecordsVo
.
setPermissionsVos
(
sponsorAuthorizationPermissionsVos
);
// mysql
for
(
MerchantAuthorizationRecordsVo
authorizationRecordsVo:
authorizationRecordsVos
)
{
boolean
success
=
saveBatch
(
authorizationRecordsArrayList
);
if
(!
uidRoles
.
contains
(
authorizationRecordsVo
.
getUidRole
()))
{
if
(!
success
)
{
uidRoles
.
add
(
authorizationRecordsVo
.
getUidRole
());
// todo error
throw
new
LiquidnetServiceException
();
}
}
success
=
authorizationPermissionsAdminService
.
saveBatch
(
authorizationPermissionsArrayList
);
for
(
MerchantAuthorizationPermissionsVo
authorizationPermissionsVo:
authorizationRecordsVo
.
getPermissionsVos
())
{
if
(!
success
)
{
if
(!
permissionIds
.
contains
(
authorizationPermissionsVo
.
getPermissionId
())
)
{
// todo error
permissionIds
.
add
(
authorizationPermissionsVo
.
getPermissionId
());
throw
new
LiquidnetServiceException
();
}
}
}
// mongo
mongoTemplate
.
insert
(
sponsorAuthorizationRecordsVo
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
}
}
return
true
;
// 聚合角色及权限
MerchantAuthorizationPerformanceVo
vo
=
MerchantAuthorizationPerformanceVo
.
getNew
();
vo
.
setUid
(
uid
);
vo
.
setPerformanceId
(
performanceId
);
vo
.
setUidRoles
(
uidRoles
);
vo
.
setPermissionIds
(
permissionIds
);
Query
query
=
Query
.
query
(
Criteria
.
where
(
"performanceId"
).
is
(
performanceId
).
and
(
"uid"
).
is
(
uid
));
Document
document
=
(
Document
)
mongoConverter
.
convertToMongoType
(
vo
);
Update
update
=
Update
.
fromDocument
(
document
);
mongoTemplate
.
upsert
(
query
,
update
,
MerchantAuthorizationPerformanceVo
.
class
,
MerchantAuthorizationPerformanceVo
.
class
.
getSimpleName
());
}
}
}
}
liquidnet-bus-service/liquidnet-service-merchant/liquidnet-service-merchant-impl/src/main/java/com/liquidnet/service/merchant/service/impl/MerchantAuthorizationRecordsServiceImpl.java
View file @
92823cd2
...
@@ -10,16 +10,20 @@ import com.liquidnet.service.base.constant.MQConst;
...
@@ -10,16 +10,20 @@ import com.liquidnet.service.base.constant.MQConst;
import
com.liquidnet.service.merchant.constant.MerchantAuthorizationConst
;
import
com.liquidnet.service.merchant.constant.MerchantAuthorizationConst
;
import
com.liquidnet.service.merchant.dto.param.MerchantAuthorizationPermissionParam
;
import
com.liquidnet.service.merchant.dto.param.MerchantAuthorizationPermissionParam
;
import
com.liquidnet.service.merchant.dto.param.MerchantAuthorizationRecordParam
;
import
com.liquidnet.service.merchant.dto.param.MerchantAuthorizationRecordParam
;
import
com.liquidnet.service.merchant.dto.vo.MerchantAuthorizationPerformanceVo
;
import
com.liquidnet.service.merchant.dto.vo.MerchantAuthorizationPermissionsVo
;
import
com.liquidnet.service.merchant.dto.vo.MerchantAuthorizationPermissionsVo
;
import
com.liquidnet.service.merchant.dto.vo.MerchantAuthorizationRecordsVo
;
import
com.liquidnet.service.merchant.dto.vo.MerchantAuthorizationRecordsVo
;
import
com.liquidnet.service.merchant.service.IMerchantAuthorizationRecordsService
;
import
com.liquidnet.service.merchant.service.IMerchantAuthorizationRecordsService
;
import
com.liquidnet.service.merchant.service.MerchantMongoService
;
import
com.liquidnet.service.merchant.service.MerchantMongoService
;
import
com.liquidnet.service.merchant.util.QueueUtil
;
import
com.liquidnet.service.merchant.util.QueueUtil
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.bson.Document
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.convert.MongoConverter
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.data.mongodb.core.query.Update
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.time.LocalDateTime
;
import
java.time.LocalDateTime
;
...
@@ -38,6 +42,9 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
...
@@ -38,6 +42,9 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
@Autowired
@Autowired
MongoTemplate
mongoTemplate
;
MongoTemplate
mongoTemplate
;
@Autowired
MongoConverter
mongoConverter
;
@Autowired
@Autowired
QueueUtil
queueUtils
;
QueueUtil
queueUtils
;
...
@@ -46,6 +53,11 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
...
@@ -46,6 +53,11 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
LocalDateTime
now
=
LocalDateTime
.
now
();
LocalDateTime
now
=
LocalDateTime
.
now
();
// 目前仅授权 验票 统计
// 目前仅授权 验票 统计
if
(
cuid
.
equals
(
parameter
.
getUid
()))
{
// 无授权权限
ErrorMapping
.
ErrorMessage
errorMessage
=
ErrorMapping
.
get
(
"13301"
);
throw
new
LiquidnetServiceException
(
errorMessage
.
getCode
(),
errorMessage
.
getMessage
());
}
MerchantAuthorizationPermissionParam
checkPermissionParam
=
null
;
MerchantAuthorizationPermissionParam
checkPermissionParam
=
null
;
MerchantAuthorizationPermissionParam
salesPermissionParam
=
null
;
MerchantAuthorizationPermissionParam
salesPermissionParam
=
null
;
for
(
MerchantAuthorizationPermissionParam
permissionParam:
parameter
.
getPermissions
())
{
for
(
MerchantAuthorizationPermissionParam
permissionParam:
parameter
.
getPermissions
())
{
...
@@ -121,6 +133,9 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
...
@@ -121,6 +133,9 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
mongoTemplate
.
insert
(
checkerAuthorizationRecordsVo
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
mongoTemplate
.
insert
(
checkerAuthorizationRecordsVo
,
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
log
.
debug
(
"#MONGO耗时:{}ms"
,
System
.
currentTimeMillis
()
-
s
);
log
.
debug
(
"#MONGO耗时:{}ms"
,
System
.
currentTimeMillis
()
-
s
);
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
parameter
.
getPerformanceId
(),
checkerAuthorizationRecordsVo
.
getUid
());
// sql
// sql
LinkedList
<
String
>
toMqSqls
=
CollectionUtil
.
linkedListString
();
LinkedList
<
String
>
toMqSqls
=
CollectionUtil
.
linkedListString
();
LinkedList
<
Object
[]>
authorizationRecordsInsertObjs
=
CollectionUtil
.
linkedListObjectArr
();
LinkedList
<
Object
[]>
authorizationRecordsInsertObjs
=
CollectionUtil
.
linkedListObjectArr
();
...
@@ -175,6 +190,9 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
...
@@ -175,6 +190,9 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
mongoTemplate
.
remove
(
Query
.
query
(
Criteria
.
where
(
"authorizationRecordId"
).
is
(
authorizationRecordId
)),
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
mongoTemplate
.
remove
(
Query
.
query
(
Criteria
.
where
(
"authorizationRecordId"
).
is
(
authorizationRecordId
)),
MerchantAuthorizationRecordsVo
.
class
.
getSimpleName
());
log
.
debug
(
"#MONGO耗时:{}ms"
,
System
.
currentTimeMillis
()
-
s
);
log
.
debug
(
"#MONGO耗时:{}ms"
,
System
.
currentTimeMillis
()
-
s
);
// 聚合角色及权限
this
.
syncAuthorizationPerformanceVo
(
authorizationRecordsVo
.
getPerformanceId
(),
authorizationRecordsVo
.
getUid
());
// sql
// sql
LinkedList
<
String
>
toMqSqls
=
CollectionUtil
.
linkedListString
();
LinkedList
<
String
>
toMqSqls
=
CollectionUtil
.
linkedListString
();
LinkedList
<
Object
[]>
authorizationRecordsUpdateObjs
=
CollectionUtil
.
linkedListObjectArr
();
LinkedList
<
Object
[]>
authorizationRecordsUpdateObjs
=
CollectionUtil
.
linkedListObjectArr
();
...
@@ -200,15 +218,17 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
...
@@ -200,15 +218,17 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
private
MerchantAuthorizationConst
.
PerformanceRole
getMaxPerformanceRole
(
String
uid
,
String
performanceId
)
{
private
MerchantAuthorizationConst
.
PerformanceRole
getMaxPerformanceRole
(
String
uid
,
String
performanceId
)
{
List
<
MerchantAuthorizationRecordsVo
>
authorizationRecordsVos
=
merchantMongoService
.
getAuthorizationRecordsVosByUid
(
uid
,
performanceId
);
MerchantAuthorizationPerformanceVo
authorizationPerformanceVo
=
mongoTemplate
.
findOne
(
Query
.
query
(
Criteria
.
where
(
"performanceId"
).
is
(
performanceId
).
and
(
"uid"
).
is
(
uid
)),
MerchantAuthorizationPerformanceVo
.
class
,
MerchantAuthorizationPerformanceVo
.
class
.
getSimpleName
());
if
(
null
==
authorizationPerformanceVo
)
{
if
(!
CollectionUtil
.
isEmpty
(
authorizationRecordsVos
))
{
return
null
;
}
if
(!
CollectionUtil
.
isEmpty
(
authorizationPerformanceVo
.
getUidRoles
()))
{
return
null
;
return
null
;
}
}
MerchantAuthorizationConst
.
PerformanceRole
maxRole
=
MerchantAuthorizationConst
.
PerformanceRole
.
valueOf
(
authorization
RecordsVos
.
get
(
0
).
getUidRole
(
));
MerchantAuthorizationConst
.
PerformanceRole
maxRole
=
MerchantAuthorizationConst
.
PerformanceRole
.
valueOf
(
authorization
PerformanceVo
.
getUidRoles
().
get
(
0
));
for
(
MerchantAuthorizationRecordsVo
authorizationRecordsVo
:
authorizationRecordsVos
)
{
for
(
String
uidRole
:
authorizationPerformanceVo
.
getUidRoles
()
)
{
MerchantAuthorizationConst
.
PerformanceRole
role
=
MerchantAuthorizationConst
.
PerformanceRole
.
valueOf
(
authorizationRecordsVo
.
getUidRole
()
);
MerchantAuthorizationConst
.
PerformanceRole
role
=
MerchantAuthorizationConst
.
PerformanceRole
.
valueOf
(
uidRole
);
if
(
role
.
getLevel
()
>
maxRole
.
getLevel
())
{
if
(
role
.
getLevel
()
>
maxRole
.
getLevel
())
{
maxRole
=
role
;
maxRole
=
role
;
}
}
...
@@ -216,4 +236,34 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
...
@@ -216,4 +236,34 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
return
maxRole
;
return
maxRole
;
}
}
private
void
syncAuthorizationPerformanceVo
(
String
performanceId
,
String
uid
)
{
List
<
MerchantAuthorizationRecordsVo
>
authorizationRecordsVos
=
merchantMongoService
.
getAuthorizationRecordsVosByUid
(
uid
,
performanceId
);
List
<
String
>
uidRoles
=
new
ArrayList
<>();
List
<
String
>
permissionIds
=
new
ArrayList
<>();
for
(
MerchantAuthorizationRecordsVo
authorizationRecordsVo:
authorizationRecordsVos
)
{
if
(!
uidRoles
.
contains
(
authorizationRecordsVo
.
getUidRole
()))
{
uidRoles
.
add
(
authorizationRecordsVo
.
getUidRole
());
}
for
(
MerchantAuthorizationPermissionsVo
authorizationPermissionsVo:
authorizationRecordsVo
.
getPermissionsVos
())
{
if
(!
permissionIds
.
contains
(
authorizationPermissionsVo
.
getPermissionId
()))
{
permissionIds
.
add
(
authorizationPermissionsVo
.
getPermissionId
());
}
}
}
// 聚合角色及权限
MerchantAuthorizationPerformanceVo
vo
=
MerchantAuthorizationPerformanceVo
.
getNew
();
vo
.
setUid
(
uid
);
vo
.
setPerformanceId
(
performanceId
);
vo
.
setUidRoles
(
uidRoles
);
vo
.
setPermissionIds
(
permissionIds
);
Query
query
=
Query
.
query
(
Criteria
.
where
(
"performanceId"
).
is
(
performanceId
).
and
(
"uid"
).
is
(
uid
));
Document
document
=
(
Document
)
mongoConverter
.
convertToMongoType
(
vo
);
Update
update
=
Update
.
fromDocument
(
document
);
mongoTemplate
.
upsert
(
query
,
update
,
MerchantAuthorizationPerformanceVo
.
class
,
MerchantAuthorizationPerformanceVo
.
class
.
getSimpleName
());
}
}
}
liquidnet-bus-service/liquidnet-service-merchant/liquidnet-service-merchant-impl/src/main/java/com/liquidnet/service/merchant/service/impl/MerchantFieldsServiceImpl.java
View file @
92823cd2
...
@@ -136,6 +136,10 @@ public class MerchantFieldsServiceImpl implements IMerchantFieldsService {
...
@@ -136,6 +136,10 @@ public class MerchantFieldsServiceImpl implements IMerchantFieldsService {
this
.
checkFieldAccount
(
cuid
,
fieldId
);
this
.
checkFieldAccount
(
cuid
,
fieldId
);
// 场地默认验票员,是否已经添加
// 场地默认验票员,是否已经添加
if
(
cuid
.
equals
(
uid
))
{
ErrorMapping
.
ErrorMessage
errorMessage
=
ErrorMapping
.
get
(
"13103"
);
throw
new
LiquidnetServiceException
(
errorMessage
.
getCode
(),
errorMessage
.
getMessage
());
}
List
<
MerchantFieldCheckersVo
>
fieldCheckersVos
=
merchantRdmService
.
getFieldCheckersVosByFieldId
(
fieldId
);
List
<
MerchantFieldCheckersVo
>
fieldCheckersVos
=
merchantRdmService
.
getFieldCheckersVosByFieldId
(
fieldId
);
if
(!
CollectionUtils
.
isEmpty
(
fieldCheckersVos
))
{
if
(!
CollectionUtils
.
isEmpty
(
fieldCheckersVos
))
{
for
(
MerchantFieldCheckersVo
vo
:
fieldCheckersVos
)
{
for
(
MerchantFieldCheckersVo
vo
:
fieldCheckersVos
)
{
...
...
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