|
|
@ -3,6 +3,7 @@ package awesome.group.game.service.matrix; |
|
|
|
import awesome.group.game.dao.bean.*; |
|
|
|
import awesome.group.game.dao.mapper.*; |
|
|
|
import awesome.group.game.service.bo.*; |
|
|
|
import awesome.group.game.service.bo.citrus.UserBo; |
|
|
|
import awesome.group.game.service.bo.matrix.MatrixAppBo; |
|
|
|
import awesome.group.game.service.common.exception.PaganiException; |
|
|
|
import awesome.group.game.service.common.exception.PaganiExceptionCode; |
|
|
@ -16,6 +17,8 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.google.common.base.Joiner; |
|
|
|
import com.google.common.collect.Lists; |
|
|
|
import com.google.gson.Gson; |
|
|
|
import com.google.gson.reflect.TypeToken; |
|
|
|
import org.apache.commons.lang.RandomStringUtils; |
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -73,8 +76,9 @@ public class AdminService { |
|
|
|
|
|
|
|
public static final int SUPER_ADMIN = 1;//超级管理员
|
|
|
|
public static final int NORMAL_ADMIN = 2;//普通管理员
|
|
|
|
public static final int OTHER = 3;//普通账号
|
|
|
|
public static final int OTHER = 3;//普通账号,游戏主
|
|
|
|
public static final int DEVICE_OWNER = 4; //设备主
|
|
|
|
public static final int PROXY = 5; //代理
|
|
|
|
|
|
|
|
public MatrixAdmin login(String name, String pwd, String channel) { |
|
|
|
MatrixAdmin admin = adminMapper.query(name); |
|
|
@ -119,7 +123,7 @@ public class AdminService { |
|
|
|
if (StringUtils.hasText(param.deviceId)) { |
|
|
|
wrapper.eq("device_id", param.deviceId); |
|
|
|
} |
|
|
|
if(param.userId != null) { |
|
|
|
if (param.userId != null) { |
|
|
|
wrapper.eq("user_id", param.userId); |
|
|
|
} |
|
|
|
if (!CollectionUtils.isEmpty(param.createdAt)) { |
|
|
@ -212,6 +216,41 @@ public class AdminService { |
|
|
|
return data; |
|
|
|
} |
|
|
|
|
|
|
|
public List<UserBo> getGrantUser(Integer adminId) { |
|
|
|
MatrixAdmin admin = adminMapper.selectById(adminId); |
|
|
|
if (!StringUtils.hasText(admin.getUserIds())) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
Gson gson = new Gson(); |
|
|
|
List<Integer> uids = gson.fromJson(admin.getUserIds(), new TypeToken<List<Integer>>() { |
|
|
|
}.getType()); |
|
|
|
if (CollectionUtils.isEmpty(uids)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
List<MatrixUser> list = userMapper.selectBatchIds(uids); |
|
|
|
return list.stream().map(x -> new UserBo(x, true)).toList(); |
|
|
|
} |
|
|
|
|
|
|
|
public void saveGrantUser(Integer adminId, List<Integer> userIds) { |
|
|
|
if (CollectionUtils.isEmpty(userIds)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
List<Integer> appIds = getAdminAppIds(adminId); |
|
|
|
List<MatrixUser> users = userMapper.selectBatchIds(userIds); |
|
|
|
for (MatrixUser u : users) { |
|
|
|
if (!appIds.contains(u.getAppId())) { |
|
|
|
throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "非法请求,有应用未授权"); |
|
|
|
} |
|
|
|
} |
|
|
|
Gson gson = new Gson(); |
|
|
|
adminMapper.updateUids(adminId, gson.toJson(userIds)); |
|
|
|
MatrixUser update = new MatrixUser(); |
|
|
|
update.setAdminId(adminId); |
|
|
|
LambdaQueryWrapper<MatrixUser> query = Wrappers.lambdaQuery(); |
|
|
|
query.in(MatrixUser::getId, userIds); |
|
|
|
userMapper.update(update, query); |
|
|
|
} |
|
|
|
|
|
|
|
public void saveAdmin(int adminId, MatrixAdminBo bo, String channel) { |
|
|
|
MatrixAdmin admin = new MatrixAdmin(); |
|
|
|
BeanUtils.copyProperties(bo, admin); |
|
|
|