예제 #1
0
  @RequestMapping(value = "/activities", method = RequestMethod.GET)
  @Interceptors({CompanyMemberRequired.class})
  @ResponseBody
  public CompanyActivities showActivities(
      @PathVariable int companyId,
      @RequestParam(value = "until", required = false) @DateTimeFormat(iso = ISO.DATE) Date until,
      @RequestParam(required = false) Integer userId,
      @RequestParam(required = false) Integer projectId,
      @RequestParam(required = false) String type) {
    DateTime dt = until == null ? new DateTime() : new DateTime(until);
    until = dt.withTime(0, 0, 0, 0).plusDays(1).plusMillis(-1).toDate();
    boolean hasNext = false;
    Date nextDay = null;

    List<Activity> activities =
        activityService.getUserVisibleTillDay(companyId, userId, projectId, until, type, LIMIT);

    if (activities.size() > 0) {

      Activity activity = activities.get(activities.size() - 1);
      nextDay = new DateTime(activity.getCreated()).withTime(0, 0, 0, 0).plusMillis(-1).toDate();

      // 如果取到nextDay仍然有数据,则hasNext为true
      List<Activity> nextActivities =
          activityService.getUserVisibleTillDay(companyId, userId, projectId, nextDay, type, LIMIT);

      if (nextActivities.size() > 0) {
        hasNext = true;
      }
    }
    return new CompanyActivities(activities, hasNext, nextDay);
  }
예제 #2
0
 @RequestMapping(value = "/projects/{projectId}/activities", method = RequestMethod.GET)
 @Interceptors({CompanyMemberRequired.class})
 @ResponseBody
 public ResponseEntity<?> getTabView(
     @PathVariable Integer companyId,
     @PathVariable Integer projectId,
     @RequestParam(value = "attachType", required = false) String attachType,
     @RequestParam(value = "attachId", required = false) Integer attachId,
     @RequestParam(required = false, defaultValue = "false") Boolean stat,
     @RequestParam(required = false) Long start,
     @RequestParam(required = false) Long end) {
   if (stat) {
     logger.info("in");
     if (start == 0 || end == 0) {
       return new ResponseEntity<Object>(HttpStatus.BAD_REQUEST);
     } else {
       List<ActivityDTO> activityDTOs =
           getUserActivitiesByProjectAndTimeForStat(companyId, projectId, start, end);
       return new ResponseEntity<List<ActivityDTO>>(activityDTOs, HttpStatus.OK);
     }
   }
   return new ResponseEntity<List<ActivityDTO>>(
       Lists.transform(
           activityService.getByAttachTypeAndId(attachType, attachId),
           ActivityTransForm.ACTIVITY_TO_ACTIVITYDTO_FUNCTION),
       HttpStatus.OK);
 }
예제 #3
0
 private List<ActivityDTO> getUserActivitiesByProjectAndTimeForStat(
     int companyId, int projectId, Long start, Long end) {
   Date since = new Date(start);
   Date until = new Date(end);
   Date limit = new DateTime(until).plusMonths(-6).toDate();
   if (since.after(until) || since.before(limit)) {
     return null;
   }
   List<Activity> activities = activityService.getByProjectBetweenDates(projectId, since, until);
   return Lists.transform(activities, ActivityTransForm.ACTIVITY_TO_ACTIVITYDTO_FUNCTION);
 }