Esempio n. 1
0
  /**
   * 完成线上任务
   *
   * @param onTaskId 线上任务ID
   * @param request
   * @param response POST不要使用@PathVariable
   * @return
   */
  @RequestMapping(value = "onlinecomplete")
  public String onlineComplete(
      String onTaskId, HttpServletRequest request, HttpServletResponse response) {
    PgOnlineTask onlineTask = pgOnlineTaskService.get(onTaskId); // 线上任务

    String onlineCheck = request.getParameter("answerChk"); // 用户选择的答案(ID)
    PgAnswer answer = pgAnswerService.get(onlineCheck); // 答案对象
    if (answer != null && answer.getRightOrNot().equals("1")) {
      onlineTask.setRightOrNot("1"); // 答案是否正确(1:正确;0:错误)
      // 答题正确给予积分奖励
      PgTaskList taskList = pgTaskListService.get(onlineTask.getTaskId());
      PgOnlineQuestion onlineQuestion = pgOnlineQuestionService.get(taskList.getQuestionId());
      Integer integral = onlineQuestion.getBaseIntegral();
      // 构造方法PgIntegral(String integralDate,String integralType,Integer integral,User user)
      // 积分类型(integralType):0线上任务/1线下任务/2签到/3日记
      PgIntegral pi = new PgIntegral(DateUtils.getDateTime(), "0", integral, UserUtils.getUser());
      pi.setRemarks(onlineQuestion.getQuestion());
      pgIntegralService.save(pi);

    } else {
      onlineTask.setRightOrNot("0"); // 答案是否正确(1:正确;0:错误)
    }
    onlineTask.setOnlineTaskStatus("1"); // 状态:1 表示已完成
    onlineTask.setAnswerId(onlineCheck); // 用户选择的答案(ID)
    String answerType =
        ""; // 答题方式
            // 未完成***********************************-------------------------------------------

    // 更新"是否正确"
    pgOnlineTaskService.save(onlineTask); // 更新会员在线任务
    return "redirect:" + Global.getFrontPath() + "/task";
  }
Esempio n. 2
0
  public Page<Log> find(Page<Log> page, Map<String, Object> paramMap) {
    DetachedCriteria dc = logDao.createDetachedCriteria();

    Long createById = StringUtils.toLong(paramMap.get("createById"));
    if (createById > 0) {
      dc.add(Restrictions.eq("createBy.id", createById));
    }

    String requestUri = ObjectUtils.toString(paramMap.get("requestUri"));
    if (StringUtils.isNotBlank(requestUri)) {
      dc.add(Restrictions.like("requestUri", "%" + requestUri + "%"));
    }

    String exception = ObjectUtils.toString(paramMap.get("exception"));
    if (StringUtils.isNotBlank(exception)) {
      dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION));
    }

    Date beginDate = DateUtils.parseDate(paramMap.get("beginDate"));
    if (beginDate == null) {
      beginDate = DateUtils.setDays(new Date(), 1);
      paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
    }
    Date endDate = DateUtils.parseDate(paramMap.get("endDate"));
    if (endDate == null) {
      endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1);
      paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd"));
    }
    dc.add(Restrictions.between("createDate", beginDate, endDate));

    dc.addOrder(Order.desc("id"));
    return logDao.find(page, dc);
  }
Esempio n. 3
0
  /**
   * 完成线下任务
   *
   * @param offTaskId
   * @param request
   * @param response
   * @param model
   * @return
   */
  @RequestMapping(value = "offlinecomplete")
  public String offlinecomplete(
      String offTaskId, HttpServletRequest request, HttpServletResponse response, Model model) {
    model.addAttribute("site", site);
    String feel = request.getParameter("feel");
    PgOfflineTask offlineTask = pgOfflineTaskService.get(offTaskId);
    offlineTask.setOfflineFeel(feel);
    offlineTask.setOfflineStatus("1"); // 状态:1 表示已完成
    // 保存线下任务
    pgOfflineTaskService.save(offlineTask);

    // 完成线下任务给予积分奖励
    PgTaskList taskList = pgTaskListService.get(offlineTask.getTaskId());
    PgOfflineQuestion offlineQuestion = pgOfflineQuestionService.get(taskList.getQuestionId());
    Integer integral = offlineQuestion.getBaseIntegral();
    // 构造方法PgIntegral(String integralDate,String integralType,Integer integral,User user)
    // 积分类型(integralType):0线上任务/1线下任务/2签到/3日记
    PgIntegral pi = new PgIntegral(DateUtils.getDateTime(), "1", integral, UserUtils.getUser());
    pi.setRemarks(offlineQuestion.getOfflineTask());
    // 累计线下任务积分
    pgIntegralService.save(pi);

    return "redirect:" + Global.getFrontPath() + "/task";
  }
Esempio n. 4
0
  /**
   * 我接受的任务列表
   *
   * @param taskType
   * @param request
   * @param response
   * @param model
   * @return
   */
  @RequestMapping(value = "list-{taskType}${urlSuffix}")
  public String taskList(
      @PathVariable String taskType,
      PgOnlineTask pgOnlineTask,
      PgOfflineTask pgOfflineTask,
      HttpServletRequest request,
      HttpServletResponse response,
      Model model) {
    model.addAttribute("site", site);
    // 0:线上任务,1:线下任务
    Page p = null;
    Task task = null;
    List<Task> taskList = new ArrayList<Task>();

    // 0:线上任务
    if (taskType.equals("0") || taskType.equals("all")) {
      pgOnlineTask.setUser(UserUtils.getUser());
      p = pgOnlineTaskService.findPage(new Page<PgOnlineTask>(request, response), pgOnlineTask);
      List<PgOnlineTask> list = p.getList();
      if (null != list && list.size() > 0) {
        for (PgOnlineTask on : list) {
          PgOnlineQuestion onlineQuestion =
              pgOnlineQuestionService.get(pgTaskListService.get(on.getTaskId()).getQuestionId());
          String id = on.getTaskId(); // 任务ID
          String questionId = onlineQuestion.getId();
          String name = onlineQuestion.getQuestion();
          String type = "0";
          String status = on.getOnlineTaskStatus();
          String time = DateUtils.formatDateTime(on.getCreateDate());
          String userName = UserUtils.getUser().getName();
          task = new Task(id, questionId, name, type, status, time, userName);
          taskList.add(task);
        }
      }
    }
    // 1:线下任务
    if (taskType.equals("1") || taskType.equals("all")) {
      pgOfflineTask.setUser(UserUtils.getUser());
      p = pgOfflineTaskService.findPage(new Page<PgOfflineTask>(request, response), pgOfflineTask);
      List<PgOfflineTask> list = p.getList();
      if (null != list && list.size() > 0) {
        for (PgOfflineTask off : list) {
          PgOfflineQuestion offlineQuestion =
              pgOfflineQuestionService.get(pgTaskListService.get(off.getTaskId()).getQuestionId());
          // public Task(String questionId,String name,String type,String time)
          String id = off.getTaskId();
          String questionId = offlineQuestion.getId();
          String name = offlineQuestion.getOfflineTask();
          String type = "1";
          String status = off.getOfflineStatus();
          String time = DateUtils.formatDateTime(off.getCreateDate());
          String userName = UserUtils.getUser().getName();
          task = new Task(id, questionId, name, type, status, time, userName);
          taskList.add(task);
        }
      }
    }
    if (taskList.size() != 0) {
      Page<Task> page =
          pgTaskListService.findPage(new Page<Task>(request, response), task, taskList);
      model.addAttribute("page", page);
    }
    return "modules/cms/front/themes/" + site.getTheme() + "/myTaskList";
  }