|
@@ -14,9 +14,11 @@ import com.zanxiang.game.module.manage.pojo.params.GameAuthAddParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.GameAuthListParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.params.GameAuthUpdateParam;
|
|
|
import com.zanxiang.game.module.manage.pojo.vo.GameAuthVO;
|
|
|
+import com.zanxiang.game.module.manage.service.IGameAuthRoleService;
|
|
|
import com.zanxiang.game.module.manage.service.IGameAuthService;
|
|
|
import com.zanxiang.game.module.manage.service.IGameService;
|
|
|
import com.zanxiang.game.module.mybatis.entity.GameAuth;
|
|
|
+import com.zanxiang.game.module.mybatis.entity.GameAuthRole;
|
|
|
import com.zanxiang.game.module.mybatis.mapper.GameAuthMapper;
|
|
|
import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
import com.zanxiang.module.util.exception.BaseException;
|
|
@@ -41,26 +43,37 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
@Autowired
|
|
|
private IGameService gameService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IGameAuthRoleService gameAuthRoleService;
|
|
|
+
|
|
|
@DubboReference(providedBy = ErpServer.SERVER_DUBBO_NAME)
|
|
|
private ISysUserRpc sysUserRpc;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public boolean gameAuthAdd(GameAuthAddParam param) {
|
|
|
- //游戏id
|
|
|
- Long gameId = param.getGameId();
|
|
|
- List<GameAuthAddParam.GameAuthUserBean> userAuthList = param.getUserAuthList();
|
|
|
+ List<Long> userIdList = param.getUserIdList();
|
|
|
+ List<Long> gameIdList = param.getGameIdList();
|
|
|
List<GameAuth> addList = new ArrayList<>();
|
|
|
- userAuthList.forEach(userAuth -> {
|
|
|
- //判断提交的参数数据是否已经存在
|
|
|
- if (super.count(new LambdaQueryWrapper<GameAuth>()
|
|
|
- .eq(GameAuth::getGameId, gameId)
|
|
|
- .eq(GameAuth::getUserId, userAuth.getUserId())
|
|
|
- .eq(GameAuth::getType, userAuth.getType())
|
|
|
- ) > 0) {
|
|
|
- return;
|
|
|
+ userIdList.forEach(userId -> {
|
|
|
+ //判断角色是否正确
|
|
|
+ if (gameAuthRoleService.count(new LambdaQueryWrapper<GameAuthRole>()
|
|
|
+ .eq(GameAuthRole::getUserId, userId)
|
|
|
+ .eq(GameAuthRole::getAuthType, param.getGameAuthEnum().getValue())
|
|
|
+ ) <= 0) {
|
|
|
+ throw new BaseException("参数错误, 提交得用户存在权限不匹配");
|
|
|
}
|
|
|
- addList.add(this.transform(gameId, userAuth));
|
|
|
+ //循环添加
|
|
|
+ gameIdList.forEach(gameId -> {
|
|
|
+ //判断提交的参数数据是否已经存在
|
|
|
+ if (super.count(new LambdaQueryWrapper<GameAuth>()
|
|
|
+ .eq(GameAuth::getGameId, gameId)
|
|
|
+ .eq(GameAuth::getUserId, userId)
|
|
|
+ ) <= 0) {
|
|
|
+ throw new BaseException("参数错误, 提交的用户存在重复权限");
|
|
|
+ }
|
|
|
+ addList.add(this.transform(gameId, userId));
|
|
|
+ });
|
|
|
});
|
|
|
if (addList.isEmpty()) {
|
|
|
return Boolean.FALSE;
|
|
@@ -68,11 +81,10 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
return super.saveBatch(addList);
|
|
|
}
|
|
|
|
|
|
- private GameAuth transform(Long gameId, GameAuthAddParam.GameAuthUserBean gameAuthUserBean) {
|
|
|
+ private GameAuth transform(Long gameId, Long userId) {
|
|
|
return GameAuth.builder()
|
|
|
.gameId(gameId)
|
|
|
- .userId(gameAuthUserBean.getUserId())
|
|
|
- .type(gameAuthUserBean.getType())
|
|
|
+ .userId(userId)
|
|
|
.isDelete(DeleteEnum.NO.getCode())
|
|
|
.createBy(SecurityUtil.getUserId())
|
|
|
.createTime(LocalDateTime.now())
|
|
@@ -88,7 +100,6 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
if (super.count(new LambdaQueryWrapper<GameAuth>()
|
|
|
.eq(GameAuth::getGameId, param.getGameId())
|
|
|
.eq(GameAuth::getUserId, param.getUserId())
|
|
|
- .eq(GameAuth::getType, param.getType())
|
|
|
) > 0) {
|
|
|
throw new BaseException("参数错误, 要修改的数据已经存在相同数据");
|
|
|
}
|
|
@@ -96,7 +107,6 @@ public class GameAuthServiceImpl extends ServiceImpl<GameAuthMapper, GameAuth> i
|
|
|
return super.update(new LambdaUpdateWrapper<GameAuth>()
|
|
|
.set(GameAuth::getGameId, param.getGameId())
|
|
|
.set(GameAuth::getUserId, param.getUserId())
|
|
|
- .set(GameAuth::getType, param.getType())
|
|
|
.set(GameAuth::getUpdateBy, SecurityUtil.getUserId())
|
|
|
.set(GameAuth::getUpdateTime, LocalDateTime.now())
|
|
|
.eq(GameAuth::getId, param.getId()));
|