Example #1
0
 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);
     }
   }
 }
Example #2
0
 /*
  * (non-Javadoc)
  *
  * @see q.web.Resource#execute(q.web.ResourceContext)
  */
 @Override
 public void execute(ResourceContext context) throws Exception {
   long peopleId = context.getCookiePeopleId();
   People newpeople = new People();
   newpeople.setId(peopleId);
   newpeople.setYear(Integer.parseInt(context.getString("year")));
   newpeople.setMonth(Integer.parseInt(context.getString("month")));
   newpeople.setDay(Integer.parseInt(context.getString("day")));
   peopleDao.updatePeopleById(newpeople);
   context.redirectServletPath("/people/" + newpeople.getId());
 }