房间管理员数量限制
room
This commit is contained in:
@@ -913,6 +913,7 @@ public enum BusiStatus {
|
|||||||
INVITE_NOT_REWARD(20504, "暂无可领取奖励。"),
|
INVITE_NOT_REWARD(20504, "暂无可领取奖励。"),
|
||||||
|
|
||||||
ROOM_LEVEL_NOT_ENOUGH(20504, "房间等级不够,不能使用该皮肤。"),
|
ROOM_LEVEL_NOT_ENOUGH(20504, "房间等级不够,不能使用该皮肤。"),
|
||||||
|
ROOM_LEVEL_NOT_MANAGER(20504, "管理员数量已达上限"),
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@@ -10,10 +10,12 @@ import com.accompany.common.utils.BlankUtil;
|
|||||||
import com.accompany.common.utils.GsonUtil;
|
import com.accompany.common.utils.GsonUtil;
|
||||||
import com.accompany.common.utils.StringUtils;
|
import com.accompany.common.utils.StringUtils;
|
||||||
import com.accompany.core.service.base.BaseService;
|
import com.accompany.core.service.base.BaseService;
|
||||||
|
import com.accompany.core.util.BeanUtils;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -798,4 +800,42 @@ public class ErBanNetEaseService extends BaseService {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {"creator": true,"manager": true,"blacklist": false,"mute": false}
|
||||||
|
* @param roomId
|
||||||
|
* @param roles
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public List<RoomMemberRet> queryMembersByRole(Long roomId, String roles) {
|
||||||
|
List<RoomMemberRet> resultList = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
String url = NetEaseConstant.basicUrl + NetEaseConstant.RoomUrl.queryMembersByRole;
|
||||||
|
NetEaseBaseClient netEaseBaseClient = new NetEaseBaseClient(NetEaseConfig.neteaseAppKey, NetEaseConfig.neteaseAppSecret, url);
|
||||||
|
Map<String, Object> param = Maps.newHashMap();
|
||||||
|
param.put("roomid", roomId);
|
||||||
|
param.put("roles", roles);
|
||||||
|
String result = netEaseBaseClient.buildHttpPostParam(param).executePost();
|
||||||
|
logger.info("getRoomOnlineUids result:{}", result);
|
||||||
|
RubbishRet rubbishRet = GsonUtil.getDefGson().fromJson(result, RubbishRet.class);
|
||||||
|
if (rubbishRet.getCode() != 200) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
RoomUserListRet roomUserListRet = gsonDefine.fromJson(result, RoomUserListRet.class);
|
||||||
|
List<Map<String, Object>> list = roomUserListRet.getDesc().get("data");
|
||||||
|
if (CollectionUtils.isEmpty(list)) {
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
for (Map<String, Object> item : list) {
|
||||||
|
RoomMemberRet membersByPage = new RoomMemberRet();
|
||||||
|
membersByPage.setAccid(Long.valueOf(item.get("accid").toString()));
|
||||||
|
membersByPage.setRoomid(Long.valueOf(item.get("roomid").toString()));
|
||||||
|
membersByPage.setOnlineStat(Boolean.valueOf(item.get("onlineStat").toString()));
|
||||||
|
resultList.add(membersByPage);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
return resultList;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -77,6 +77,7 @@ public class NetEaseConstant {
|
|||||||
* 房间踢人
|
* 房间踢人
|
||||||
*/
|
*/
|
||||||
public static String kickMember = "/chatroom/kickMember.action";
|
public static String kickMember = "/chatroom/kickMember.action";
|
||||||
|
public static String queryMembersByRole = "/chatroom/queryMembersByRole.action";//根据角色获取
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,4 +212,10 @@ public class NetEaseConstant {
|
|||||||
String ANONYMOUS = "ANONYMOUS"; // 匿名用户
|
String ANONYMOUS = "ANONYMOUS"; // 匿名用户
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class ChatMemberRole {
|
||||||
|
public static final Byte CHAT_ROLE_MASTER = 1; // 群主
|
||||||
|
public static final Byte CHAT_ROLE_MANAGER = 2; // 管理员
|
||||||
|
public static final Byte CHAT_ROLE_NORMAL = 3; // 普通成员
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,7 @@ import java.util.List;
|
|||||||
public class RoomLevelVo {
|
public class RoomLevelVo {
|
||||||
private BigDecimal roomVal;
|
private BigDecimal roomVal;
|
||||||
private String currentLevelIcon;
|
private String currentLevelIcon;
|
||||||
private Integer currnetLevel;
|
private Integer currentLevel;
|
||||||
private BigDecimal currentLevelExp;
|
private BigDecimal currentLevelExp;
|
||||||
private Integer nextLevel = 0;
|
private Integer nextLevel = 0;
|
||||||
private BigDecimal nextLevelExp = BigDecimal.ZERO;
|
private BigDecimal nextLevelExp = BigDecimal.ZERO;
|
||||||
|
@@ -5,6 +5,8 @@ import com.accompany.business.model.room.RoomLevelInfo;
|
|||||||
import com.accompany.business.model.room.RoomMicDress;
|
import com.accompany.business.model.room.RoomMicDress;
|
||||||
import com.accompany.business.service.user.UsersService;
|
import com.accompany.business.service.user.UsersService;
|
||||||
import com.accompany.business.vo.room.RoomLevelVo;
|
import com.accompany.business.vo.room.RoomLevelVo;
|
||||||
|
import com.accompany.common.netease.ErBanNetEaseService;
|
||||||
|
import com.accompany.common.netease.neteaseacc.result.RoomMemberRet;
|
||||||
import com.accompany.common.result.BusiResult;
|
import com.accompany.common.result.BusiResult;
|
||||||
import com.accompany.common.status.BusiStatus;
|
import com.accompany.common.status.BusiStatus;
|
||||||
import com.accompany.core.exception.ServiceException;
|
import com.accompany.core.exception.ServiceException;
|
||||||
@@ -41,6 +43,9 @@ public class RoomLevelService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RoomMicDressService roomMicDressService;
|
private RoomMicDressService roomMicDressService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ErBanNetEaseService erBanNetEaseService;
|
||||||
|
|
||||||
public RScoredSortedSet<Long> roomExpCache(Integer partitionId) {
|
public RScoredSortedSet<Long> roomExpCache(Integer partitionId) {
|
||||||
return redissonClient.getScoredSortedSet(RoomConstant.RedisKey.room_val.getKey(partitionId), LongCodec.INSTANCE);
|
return redissonClient.getScoredSortedSet(RoomConstant.RedisKey.room_val.getKey(partitionId), LongCodec.INSTANCE);
|
||||||
}
|
}
|
||||||
@@ -67,7 +72,7 @@ public class RoomLevelService {
|
|||||||
TreeMap<BigDecimal, RoomLevelInfo> levelInfoTreeMap = roomLevelInfoService.getLevelInfoTreeMap();
|
TreeMap<BigDecimal, RoomLevelInfo> levelInfoTreeMap = roomLevelInfoService.getLevelInfoTreeMap();
|
||||||
Map.Entry<BigDecimal, RoomLevelInfo> currentLevelInfo = levelInfoTreeMap.headMap(roomVal, true).lastEntry();
|
Map.Entry<BigDecimal, RoomLevelInfo> currentLevelInfo = levelInfoTreeMap.headMap(roomVal, true).lastEntry();
|
||||||
Map.Entry<BigDecimal, RoomLevelInfo> nextleveInfo = levelInfoTreeMap.tailMap(roomVal, false).firstEntry();
|
Map.Entry<BigDecimal, RoomLevelInfo> nextleveInfo = levelInfoTreeMap.tailMap(roomVal, false).firstEntry();
|
||||||
roomLevelVo.setCurrnetLevel(currentLevelInfo.getValue().getLevelSeq());
|
roomLevelVo.setCurrentLevel(currentLevelInfo.getValue().getLevelSeq());
|
||||||
roomLevelVo.setCurrentLevelExp(currentLevelInfo.getValue().getLevelExp());
|
roomLevelVo.setCurrentLevelExp(currentLevelInfo.getValue().getLevelExp());
|
||||||
roomLevelVo.setCurrentLevelIcon(currentLevelInfo.getValue().getLevelIcon());
|
roomLevelVo.setCurrentLevelIcon(currentLevelInfo.getValue().getLevelIcon());
|
||||||
if (nextleveInfo != null) {
|
if (nextleveInfo != null) {
|
||||||
@@ -75,12 +80,12 @@ public class RoomLevelService {
|
|||||||
roomLevelVo.setNextLevelExp(nextleveInfo.getValue().getLevelExp());
|
roomLevelVo.setNextLevelExp(nextleveInfo.getValue().getLevelExp());
|
||||||
}
|
}
|
||||||
roomLevelVo.setMicEffects(roomMicDressService.getRoomMicDressCacheOrDbList(RoomConstant.MicDressType.EFFECT));
|
roomLevelVo.setMicEffects(roomMicDressService.getRoomMicDressCacheOrDbList(RoomConstant.MicDressType.EFFECT));
|
||||||
RoomMicDress roomMicDress = roomMicDressService.roomMicDressUsed(RoomConstant.MicDressType.EFFECT, roomUid, roomLevelVo.getCurrnetLevel());
|
RoomMicDress roomMicDress = roomMicDressService.roomMicDressUsed(RoomConstant.MicDressType.EFFECT, roomUid, roomLevelVo.getCurrentLevel());
|
||||||
if (roomMicDress != null) {
|
if (roomMicDress != null) {
|
||||||
roomLevelVo.setUsedMicEffectId(roomMicDress.getId());
|
roomLevelVo.setUsedMicEffectId(roomMicDress.getId());
|
||||||
}
|
}
|
||||||
roomLevelVo.setMicSkins(roomMicDressService.getRoomMicDressCacheOrDbList(RoomConstant.MicDressType.SKIN));
|
roomLevelVo.setMicSkins(roomMicDressService.getRoomMicDressCacheOrDbList(RoomConstant.MicDressType.SKIN));
|
||||||
RoomMicDress roomMicSkin = roomMicDressService.roomMicDressUsed(RoomConstant.MicDressType.SKIN, roomUid, roomLevelVo.getCurrnetLevel());
|
RoomMicDress roomMicSkin = roomMicDressService.roomMicDressUsed(RoomConstant.MicDressType.SKIN, roomUid, roomLevelVo.getCurrentLevel());
|
||||||
if (roomMicSkin != null) {
|
if (roomMicSkin != null) {
|
||||||
roomLevelVo.setUsedMicSkinId(roomMicSkin.getId());
|
roomLevelVo.setUsedMicSkinId(roomMicSkin.getId());
|
||||||
}
|
}
|
||||||
@@ -138,4 +143,16 @@ public class RoomLevelService {
|
|||||||
return resultMap;
|
return resultMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public BusiResult<Void> checkManageNum(Long roomUid) {
|
||||||
|
Map<String, Object> roles = new HashMap<>();
|
||||||
|
roles.put("manager", true);
|
||||||
|
List<RoomMemberRet> managers = erBanNetEaseService.queryMembersByRole(roomUid, JSONObject.toJSONString(roles));
|
||||||
|
Users usersByUid = usersService.getUsersByUid(roomUid);
|
||||||
|
RoomLevelInfo roomLevelInfo = getRoomLevelByRoomUid(usersByUid.getPartitionId(), roomUid);
|
||||||
|
if (managers.size() >= roomLevelInfo.getManageNum()) {
|
||||||
|
throw new ServiceException(BusiStatus.ROOM_LEVEL_NOT_MANAGER);
|
||||||
|
}
|
||||||
|
return BusiResult.success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ package com.accompany.business.controller.room;
|
|||||||
import com.accompany.business.service.room.RoomLevelService;
|
import com.accompany.business.service.room.RoomLevelService;
|
||||||
import com.accompany.business.vo.room.RoomLevelVo;
|
import com.accompany.business.vo.room.RoomLevelVo;
|
||||||
import com.accompany.common.annotation.Authorization;
|
import com.accompany.common.annotation.Authorization;
|
||||||
|
import com.accompany.common.netease.ErBanNetEaseService;
|
||||||
import com.accompany.common.result.BusiResult;
|
import com.accompany.common.result.BusiResult;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
@@ -20,6 +21,8 @@ public class RoomLevelController {
|
|||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RoomLevelService roomLevelService;
|
private RoomLevelService roomLevelService;
|
||||||
|
@Autowired
|
||||||
|
private ErBanNetEaseService erBanNetEaseService;
|
||||||
|
|
||||||
|
|
||||||
@ApiImplicitParams({
|
@ApiImplicitParams({
|
||||||
@@ -44,4 +47,13 @@ public class RoomLevelController {
|
|||||||
Integer micDressType, Integer micDressId) {
|
Integer micDressType, Integer micDressId) {
|
||||||
return roomLevelService.useMicSkinEffect(uid, roomUid, micDressType, micDressId);
|
return roomLevelService.useMicSkinEffect(uid, roomUid, micDressType, micDressId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = "roomUid", value = "房间UID", dataType = "Long", required = true),
|
||||||
|
})
|
||||||
|
@ApiOperation(value = "校验是否可以继续设置管理员数量", httpMethod = "POST")
|
||||||
|
@PostMapping("/checkManageNum")
|
||||||
|
public BusiResult<Void> checkManageNum(@RequestParam Long roomUid) {
|
||||||
|
return roomLevelService.checkManageNum(roomUid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user