public void addPeopleJoinGroup(long peopleId, long groupId) throws SQLException { PeopleJoinGroup oldRelation = groupDao.getJoinPeopleByGroupIdPeopleId(peopleId, groupId); if (oldRelation == null) { groupDao.addPeopleJoinGroup(peopleId, groupId); groupDao.incrGroupJoinNumByGroupId(groupId); peopleDao.incrPeopleGroupNumberByPeopleId(peopleId); } else if (oldRelation.getStatus() == Status.DELETE.getValue()) { int rowEffected = groupDao.updatePeopleJoinGroupStatusByIdAndOldStatus( oldRelation.getId(), Status.COMMON, Status.DELETE); if (rowEffected > 0) { groupDao.incrGroupJoinNumByGroupId(groupId); peopleDao.incrPeopleGroupNumberByPeopleId(peopleId); } } }
/* * (non-Javadoc) * * @see q.web.Resource#validate(q.web.ResourceContext) */ @Override public void validate(ResourceContext context) throws Exception { long loginPeopleId = context.getCookiePeopleId(); if (IdCreator.isNotValidId(loginPeopleId)) { throw new PeopleNotLoginException(); } long groupId = context.getResourceIdLong(); if (IdCreator.isNotValidId(groupId)) { throw new RequestParameterInvalidException("group:invalid"); } Group group = groupDao.getGroupById(groupId); if (null == group) { throw new RequestParameterInvalidException("group:invalid"); } if (loginPeopleId == group.getCreatorId()) { throw new RequestParameterInvalidException("join:不需要加入您自己创建的圈子"); } }