use of com.code.server.constant.club.ClubMember in project summer by foxsugar.
the class GameClubService method joinClub.
/**
* 加入俱乐部
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int joinClub(KafkaMsgKey msgKey, long userId, String clubId, String mark) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
// 自己加入了几个俱乐部
List<String> joinList = ClubManager.getInstance().getUserClubs(userId);
if (joinList.size() >= JOIN_LIMIT) {
return ErrorCode.CLUB_CANNOT_NUM;
}
if (joinList.contains(clubId)) {
return ErrorCode.CLUB_CANNOT_JOIN;
}
// 加入申请列表
if (isInApplyList(club, userId)) {
return ErrorCode.CLUB_CANNOT_JOIN;
}
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
String name = userBean.getUsername();
String image = userBean.getImage();
ClubMember apply = new ClubMember().setTime(System.currentTimeMillis()).setUserId(userId).setMark(mark).setName(name).setImage(image);
club.getClubInfo().getApplyList().add(apply);
Map<String, Object> result = new HashMap<>();
sendMsg(msgKey, new ResponseVo("clubService", "joinClub", result));
return 0;
}
use of com.code.server.constant.club.ClubMember in project summer by foxsugar.
the class GameClubService method agree.
/**
* 同意加入俱乐部
*
* @param msgKey
* @param userId
* @param clubId
* @param agreeId
* @param isAgree
* @return
*/
public int agree(KafkaMsgKey msgKey, long userId, String clubId, long agreeId, boolean isAgree) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
if (ClubManager.getInstance().getUserClubNum(agreeId) >= JOIN_LIMIT) {
return ErrorCode.CLUB_CANNOT_JOIN;
}
// 加入俱乐部
ClubMember apply = getApply(club, agreeId);
if (isAgree) {
if (apply != null) {
clubAddMember(club, apply);
}
String name = apply == null ? "" : apply.getName();
}
// 删除申请列表
// removeUserFromApplyList(club, agreeId);
club.getClubInfo().getApplyList().remove(apply);
sendMsg(msgKey, new ResponseVo("clubService", "agree", "ok"));
return 0;
}
Aggregations