记得上下班打卡 | git大法好,push需谨慎

Commit 66894ef6 authored by Tice's avatar Tice

不允许重复添加

parent e5fe2f52
......@@ -17,7 +17,7 @@ public class MerchantAuthorizationRecordParam implements java.io.Serializable{
@NotBlank
private String performanceId;
@ApiModelProperty(position = 11, required = true, value = "权利人演出角色 checker,目前仅验票员")
@ApiModelProperty(position = 11, required = true, value = "权利人演出角色 CHECKER")
@NotBlank
private String uidRole;
@ApiModelProperty(position = 12, required = true, value = "权利人UID")
......
......@@ -16,7 +16,7 @@ public interface IMerchantFieldsService {
List<MerchantFieldCheckersVo> checkers(String cuid, String fieldId);
void checkerAdd(String cuid, String fieldId, String uid, String mobile, String name);
String checkerAdd(String cuid, String fieldId, String uid, String mobile, String name);
void checkerDel(String cuid, String fieldId, String uid);
}
......@@ -69,9 +69,9 @@ public class MerchantAuthorizationRecordsAdminServiceImpl extends ServiceImpl<Me
List<String> updatedUids3 = this.performanceFielder(performanceId, fieldId);
updatedUids.addAll(updatedUids3);
// 聚合角色及权限 vo
// 聚合角色及权限 vo mongo
for (String uid: updatedUids) {
merchantMongoUtil.syncAndSetAuthorizationPerformanceVo(performanceId, uid);
merchantMongoUtil.getAndSyncAuthorizationPerformanceVo(performanceId, uid);
}
}
......
......@@ -49,7 +49,7 @@ public class MerchantMongoUtil {
return mongoTemplate.findOne(Query.query(Criteria.where("performanceId").is(performanceId).and("uid").is(uid)), MerchantAuthorizationPerformanceVo.class, MerchantAuthorizationPerformanceVo.class.getSimpleName());
}
public void syncAndSetAuthorizationPerformanceVo(String performanceId, String uid) {
public MerchantAuthorizationPerformanceVo getAndSyncAuthorizationPerformanceVo(String performanceId, String uid) {
// 聚合角色及权限
Query recordsQuery = Query.query(Criteria.where("performanceId").is(performanceId).and("uid").is(uid).and("deletedAt").is(null));
List<MerchantAuthorizationRecordsVo> authorizationRecordsVos = mongoTemplate.find(recordsQuery, MerchantAuthorizationRecordsVo.class, MerchantAuthorizationRecordsVo.class.getSimpleName());
......@@ -74,6 +74,7 @@ public class MerchantMongoUtil {
Document document = (Document)mongoConverter.convertToMongoType(vo);
Update update = Update.fromDocument(document);
mongoTemplate.upsert(query, update, MerchantAuthorizationPerformanceVo.class, MerchantAuthorizationPerformanceVo.class.getSimpleName());
return vo;
}
public List<MerchantFieldAppliesVo> getFieldAppliesVosByUid(String uid) {
......
......@@ -61,9 +61,7 @@ public class MerchantAuthorizationsController {
public ResponseDto<Object> recordsCheckerAdd(@Valid @RequestBody MerchantAuthorizationRecordParam parameter) {
String currentUid = CurrentUtil.getCurrentUid();
authorizationRecordsService.performanceRecordCheckerAdd(currentUid, parameter);
return ResponseDto.success();
return ResponseDto.success(authorizationRecordsService.performanceRecordCheckerAdd(currentUid, parameter));
}
@ApiOperationSupport(order = 22)
......
......@@ -122,9 +122,7 @@ public class MerchantFieldsController {
@RequestParam(required = true) String name){
String currentUid = CurrentUtil.getCurrentUid();
merchantFieldsService.checkerAdd(currentUid, fieldId, uid, mobile, name);
return ResponseDto.success();
return ResponseDto.success(merchantFieldsService.checkerAdd(currentUid, fieldId, uid, mobile, name));
}
@ApiOperationSupport(order = 32)
......
......@@ -51,7 +51,7 @@ public class MerchantMongoService {
return mongoTemplate.findOne(Query.query(Criteria.where("performanceId").is(performanceId).and("uid").is(uid)), MerchantAuthorizationPerformanceVo.class, MerchantAuthorizationPerformanceVo.class.getSimpleName());
}
public void syncAndSetAuthorizationPerformanceVo(String performanceId, String uid) {
public MerchantAuthorizationPerformanceVo getAndSyncAuthorizationPerformanceVo(String performanceId, String uid) {
// 聚合角色及权限
Query recordsQuery = Query.query(Criteria.where("performanceId").is(performanceId).and("uid").is(uid).and("deletedAt").is(null));
List<MerchantAuthorizationRecordsVo> authorizationRecordsVos = mongoTemplate.find(recordsQuery, MerchantAuthorizationRecordsVo.class, MerchantAuthorizationRecordsVo.class.getSimpleName());
......@@ -76,6 +76,7 @@ public class MerchantMongoService {
Document document = (Document)mongoConverter.convertToMongoType(vo);
Update update = Update.fromDocument(document);
mongoTemplate.upsert(query, update, MerchantAuthorizationPerformanceVo.class, MerchantAuthorizationPerformanceVo.class.getSimpleName());
return vo;
}
......
......@@ -82,11 +82,21 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
salesPermissionParam = permissionParam;
}
}
// 至少选择一个授权权限
if (null == checkPermissionParam && null == salesPermissionParam) {
// 至少选择一个授权权限
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13305");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
// 不能重复授权
List<MerchantAuthorizationRecordsVo> authorizationRecordsVos = merchantMongoService.getAuthorizationRecordsCheckersVosByCuid(cuid, parameter.getPerformanceId());
if (!CollectionUtil.isEmpty(authorizationRecordsVos)) {
for (MerchantAuthorizationRecordsVo vo : authorizationRecordsVos) {
if (vo.getUid().equals(parameter.getUid())) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13306");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
}
}
}
// 获取最大权限角色
MerchantAuthorizationConst.PerformanceRole maxPerformanceRole = this.getMaxPerformanceRole(cuid, parameter.getPerformanceId());
if (null == maxPerformanceRole || maxPerformanceRole.getLevel() <= MerchantAuthorizationConst.PerformanceRole.CHECKER.getLevel()) {
......@@ -149,8 +159,8 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
mongoTemplate.insert(authorizationRecordsVo, MerchantAuthorizationRecordsVo.class.getSimpleName());
log.debug("#MONGO耗时:{}ms", System.currentTimeMillis() - s);
// 聚合角色及权限 vo
merchantMongoService.syncAndSetAuthorizationPerformanceVo(authorizationRecordsVo.getPerformanceId(), authorizationRecordsVo.getUid());
// 聚合角色及权限 vo mongo
merchantMongoService.getAndSyncAuthorizationPerformanceVo(authorizationRecordsVo.getPerformanceId(), authorizationRecordsVo.getUid());
// sql
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
......@@ -206,8 +216,8 @@ public class MerchantAuthorizationRecordsServiceImpl implements IMerchantAuthori
mongoTemplate.remove(Query.query(Criteria.where("authorizationRecordId").is(authorizationRecordId)), MerchantAuthorizationRecordsVo.class.getSimpleName());
log.debug("#MONGO耗时:{}ms", System.currentTimeMillis() - s);
// 聚合角色及权限 vo
merchantMongoService.syncAndSetAuthorizationPerformanceVo(authorizationRecordsVo.getPerformanceId(), authorizationRecordsVo.getUid());
// 聚合角色及权限 vo mongo
merchantMongoService.getAndSyncAuthorizationPerformanceVo(authorizationRecordsVo.getPerformanceId(), authorizationRecordsVo.getUid());
// sql
LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
......
......@@ -157,11 +157,11 @@ public class MerchantFieldsServiceImpl implements IMerchantFieldsService {
}
@Override
public void checkerAdd(String cuid, String fieldId, String uid, String mobile, String name) {
public String checkerAdd(String cuid, String fieldId, String uid, String mobile, String name) {
// 当前用户是否管理该场地
this.checkFieldAccount(cuid, fieldId);
// 场地默认验票员,是否已经添加
// 场地默认验票员,不能授权自己,不能重复添加
if (cuid.equals(uid)) {
ErrorMapping.ErrorMessage errorMessage = ErrorMapping.get("13105");
throw new LiquidnetServiceException(errorMessage.getCode(), errorMessage.getMessage());
......@@ -207,6 +207,8 @@ public class MerchantFieldsServiceImpl implements IMerchantFieldsService {
SqlMapping.gets(toMqSqls, fieldCheckerInsertObjs)
);
log.debug("#MQ耗时:{}ms", System.currentTimeMillis() - s);
return fieldCheckersVo.getFieldCheckerId();
}
@Override
......
......@@ -32,8 +32,9 @@
13301=无授权权限
13302=无权限授于统计权限
13303=授权时间有误
13304=不能授权自己权限
13304=不能授权自己
13305=至少选择一个授权权限
13306=授权已经已存在
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment