Search in sources :

Example 6 with ClubMember

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;
}
Also used : UserBean(com.code.server.constant.game.UserBean) HashMap(java.util.HashMap) Club(com.code.server.db.model.Club) ClubMember(com.code.server.constant.club.ClubMember) ResponseVo(com.code.server.constant.response.ResponseVo)

Example 7 with ClubMember

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;
}
Also used : Club(com.code.server.db.model.Club) ClubMember(com.code.server.constant.club.ClubMember) ResponseVo(com.code.server.constant.response.ResponseVo)

Aggregations

ClubMember (com.code.server.constant.club.ClubMember)7 ResponseVo (com.code.server.constant.response.ResponseVo)5 Club (com.code.server.db.model.Club)5 UserBean (com.code.server.constant.game.UserBean)2 ClubVo (com.code.server.constant.response.ClubVo)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1