コード例 #1
0
  // @RequiresPermissions("sys:user:edit")
  @RequestMapping(value = "begin-{taskId}${urlSuffix}")
  public void beginTask(
      @PathVariable String taskId,
      HttpServletRequest request,
      HttpServletResponse response,
      Model model)
      throws IOException {
    // 需要判断该任务是不是已经接受过了
    PgOfflineTask off = new PgOfflineTask(UserUtils.getUser(), taskId, null);
    List<PgOfflineTask> list = pgOfflineTaskService.findList(off);
    if (null != list && list.size() > 0) { // 任务已经领取
      // 如果已经接受任务,判断任务是否完成
      off = list.get(0);
      if (off.getOfflineStatus().equals("0")) {
        // status =0 表示任务未完成
        response.getWriter().print(off.getId()); // 返回线下任务的ID
      } else {
        response.getWriter().print("exist"); // 返回线下任务的ID
      }

    } else {
      // 点击"接受任务"/"开始任务"时,将任务信息和用户信息关联,并计算开始结束时间,最后返回线下任务的ID
      String status = "0"; // 未完成
      User user = UserUtils.getUser();
      PgOfflineTask offlineTask = new PgOfflineTask(user, taskId, status);
      pgOfflineTaskService.save(offlineTask);
      response.getWriter().print(offlineTask.getId()); // 返回线下任务的ID
    }
  }
コード例 #2
0
 public List<Office> findList(Boolean isAll) {
   if (isAll != null && isAll) {
     return UserUtils.getOfficeAllList();
   } else {
     return UserUtils.getOfficeList();
   }
 }
コード例 #3
0
 /** 授权查询回调函数, 进行鉴权但缓存中无用户的授权信息时调用 */
 @Override
 protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) {
   Principal principal = (Principal) getAvailablePrincipal(principals);
   // 获取当前已登录的用户
   if (!Global.TRUE.equals(Global.getConfig("user.multiAccountLogin"))) {
     Collection<Session> sessions =
         getSystemService()
             .getSessionDao()
             .getActiveSessions(true, principal, UserUtils.getSession());
     if (sessions.size() > 0) {
       // 如果是登录进来的,则踢出已在线用户
       if (UserUtils.getSubject().isAuthenticated()) {
         for (Session session : sessions) {
           getSystemService().getSessionDao().delete(session);
         }
       }
       // 记住我进来的,并且当前用户已登录,则退出当前用户提示信息。
       else {
         UserUtils.getSubject().logout();
         throw new AuthenticationException("msg:账号已在其它地方登录,请重新登录。");
       }
     }
   }
   User user = getSystemService().getUserByLoginName(principal.getLoginName());
   if (user != null) {
     SimpleAuthorizationInfo info = new SimpleAuthorizationInfo();
     List<Menu> list = UserUtils.getMenuList();
     for (Menu menu : list) {
       if (StringUtils.isNotBlank(menu.getPermission())) {
         // 添加基于Permission的权限信息
         for (String permission : StringUtils.split(menu.getPermission(), ",")) {
           info.addStringPermission(permission);
         }
       }
     }
     // 添加用户权限
     info.addStringPermission("user");
     // 添加用户角色信息
     for (Role role : user.getRoleList()) {
       info.addRole(role.getEnname());
     }
     // 更新登录IP和时间
     getSystemService().updateUserLoginInfo(user);
     // 记录登录日志
     LogUtils.saveLog(Servlets.getRequest(), "系统登录");
     return info;
   } else {
     return null;
   }
 }
コード例 #4
0
 /** 获取SESSIONID */
 public String getSessionid() {
   try {
     return (String) UserUtils.getSession().getId();
   } catch (Exception e) {
     return "";
   }
 }
コード例 #5
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";
  }
コード例 #6
0
ファイル: SystemService.java プロジェクト: hqm1988/jeesite
 @Transactional(readOnly = false)
 public void saveRole(Role role) {
   if (role.getId() == null) {
     role.setUser(UserUtils.getUser());
   }
   roleDao.save(role);
   systemRealm.clearAllCachedAuthorizationInfo();
 }
コード例 #7
0
ファイル: SystemService.java プロジェクト: hqm1988/jeesite
 public List<Role> findAllRole() {
   User currentUser = UserUtils.getUser();
   if (!currentUser.isAdmin()) {
     return roleDao.findByUserId(currentUser.getId());
   } else {
     return roleDao.findAllList();
   }
 }
コード例 #8
0
ファイル: OfficeType.java プロジェクト: newdon/jeesite
 /** 获取对象值(导入) */
 public static Object getValue(String val) {
   for (Office e : UserUtils.getOfficeList()) {
     if (StringUtils.trimToEmpty(val).equals(e.getName())) {
       return e;
     }
   }
   return null;
 }
コード例 #9
0
ファイル: ActTaskController.java プロジェクト: Craaie/jeesite
 /**
  * 签收任务
  *
  * @param taskId 任务ID
  */
 @RequestMapping(value = "claim")
 @ResponseBody
 public String claim(Act act) {
   String userId =
       UserUtils.getUser().getLoginName(); // ObjectUtils.toString(UserUtils.getUser().getId());
   actTaskService.claim(act.getTaskId(), userId);
   return "true"; // adminPath + "/act/task";
 }
コード例 #10
0
ファイル: ActTaskController.java プロジェクト: Craaie/jeesite
 /**
  * 获取待办列表
  *
  * @param procDefKey 流程定义标识
  * @return
  */
 @RequestMapping(value = {"todo", ""})
 public String todoList(Act act, HttpServletResponse response, Model model) throws Exception {
   List<Act> list = actTaskService.todoList(act);
   model.addAttribute("list", list);
   if (UserUtils.getPrincipal().isMobileLogin()) {
     return renderString(response, list);
   }
   return "modules/act/actTaskTodoList";
 }
コード例 #11
0
ファイル: ActTaskController.java プロジェクト: Craaie/jeesite
 /**
  * 获取已办任务
  *
  * @param page
  * @param procDefKey 流程定义标识
  * @return
  */
 @RequestMapping(value = "historic")
 public String historicList(
     Act act, HttpServletRequest request, HttpServletResponse response, Model model)
     throws Exception {
   Page<Act> page = new Page<Act>(request, response);
   page = actTaskService.historicList(page, act);
   model.addAttribute("page", page);
   if (UserUtils.getPrincipal().isMobileLogin()) {
     return renderString(response, page);
   }
   return "modules/act/actTaskHistoricList";
 }
コード例 #12
0
  /**
   * 开始(接受)线上任务
   *
   * @param taskId
   * @param request
   * @param response
   * @param model
   * @return
   */
  @RequestMapping(value = "onlineBegin-{taskId}${urlSuffix}")
  public void onlineBegin(
      @PathVariable String taskId,
      HttpServletRequest request,
      HttpServletResponse response,
      Model model)
      throws IOException {
    // 点击"接受任务"/"开始任务"时,将任务信息和用户信息关联,并计算开始结束时间,最后返回线下任务的ID
    // 需要判断该任务是不是已经接受过了
    PgOnlineTask pot = new PgOnlineTask(taskId, UserUtils.getUser());
    List<PgOnlineTask> list = pgOnlineTaskService.findList(pot);
    if (null != list && list.size() > 0) { // 任务已经领取
      // 如果已经接受任务,判断任务是否完成
      pot = list.get(0);
      if (pot.getOnlineTaskStatus().equals("0")) {
        // status =0 表示任务未完成
        response.getWriter().print(pot.getId()); // 返回线上任务的ID
      } else {
        response.getWriter().print("exist"); // 返回线上任务的ID
      }
    } else {
      PgTaskList taskList = pgTaskListService.get(taskId);
      PgOnlineQuestion onlineQuestion = pgOnlineQuestionService.get(taskList.getQuestionId());
      Integer timeLength = onlineQuestion.getTimeLength();

      String status = "0"; // 未完成
      User user = UserUtils.getUser();
      // user:用户,taskId:任务ID,status:任务状态 answerBeginDate:任务开始时间,
      // answerEndDate:任务结束时间,answerId:答案ID,answerType:答题方式,rightOrNot:是否正确

      Date answerBeginDate = new Date();
      Date answerEndDate = new Date(answerBeginDate.getTime() + timeLength * 60 * 1000); // 任务结束时间
      PgOnlineTask onlineTask =
          new PgOnlineTask(user, taskId, status, answerBeginDate, answerEndDate, null, null, null);
      pgOnlineTaskService.save(onlineTask);
      response.getWriter().print(onlineTask.getId()); // 返回线上任务的ID
    }
  }
コード例 #13
0
ファイル: AreaService.java プロジェクト: java10000/jeesite
 @Transactional(readOnly = false)
 public void save(Area area) {
   area.setParent(this.get(area.getParent().getId()));
   String oldParentIds = area.getParentIds(); // 获取修改前的parentIds,用于更新子节点的parentIds
   area.setParentIds(area.getParent().getParentIds() + area.getParent().getId() + ",");
   areaDao.clear();
   areaDao.save(area);
   // 更新子节点 parentIds
   List<Area> list = areaDao.findByParentIdsLike("%," + area.getId() + ",%");
   for (Area e : list) {
     e.setParentIds(e.getParentIds().replace(oldParentIds, area.getParentIds()));
   }
   areaDao.save(list);
   UserUtils.removeCache("areaList");
 }
コード例 #14
0
ファイル: LinkService.java プロジェクト: jacking124/jeesite
 @Transactional(readOnly = false)
 public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) {
   // 更新过期的权重,间隔为“6”个小时
   Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink");
   if (updateExpiredWeightDate == null
       || (updateExpiredWeightDate != null
           && updateExpiredWeightDate.getTime() < new Date().getTime())) {
     linkDao.updateExpiredWeight();
     CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6));
   }
   DetachedCriteria dc = linkDao.createDetachedCriteria();
   dc.createAlias("category", "category");
   dc.createAlias("category.site", "category.site");
   if (link.getCategory() != null
       && StringUtils.isNotBlank(link.getCategory().getId())
       && !Category.isRoot(link.getCategory().getId())) {
     Category category = categoryDao.get(link.getCategory().getId());
     if (category != null) {
       dc.add(
           Restrictions.or(
               Restrictions.eq("category.id", category.getId()),
               Restrictions.like("category.parentIds", "%," + category.getId() + ",%")));
       dc.add(Restrictions.eq("category.site.id", category.getSite().getId()));
       link.setCategory(category);
     } else {
       dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
     }
   } else {
     dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
   }
   if (StringUtils.isNotEmpty(link.getTitle())) {
     dc.add(Restrictions.like("title", "%" + link.getTitle() + "%"));
   }
   if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) {
     dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId()));
   }
   if (isDataScopeFilter) {
     dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy");
     dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy"));
   }
   dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag()));
   dc.addOrder(Order.desc("weight"));
   dc.addOrder(Order.desc("updateDate"));
   return linkDao.find(page, dc);
 }
コード例 #15
0
ファイル: ArticleController.java プロジェクト: newdon/jeesite
 @RequiresPermissions("cms:article:edit")
 @RequestMapping(value = "delete")
 public String delete(
     Article article,
     String categoryId,
     @RequestParam(required = false) Boolean isRe,
     RedirectAttributes redirectAttributes) {
   // 如果没有审核权限,则不允许删除或发布。
   if (!UserUtils.getSubject().isPermitted("cms:article:audit")) {
     addMessage(redirectAttributes, "你没有删除或发布权限");
   }
   articleService.delete(article, isRe);
   addMessage(redirectAttributes, (isRe != null && isRe ? "发布" : "删除") + "文章成功");
   return "redirect:"
       + adminPath
       + "/cms/article/?repage&category.id="
       + (categoryId != null ? categoryId : "");
 }
コード例 #16
0
ファイル: SystemService.java プロジェクト: hqm1988/jeesite
 @Transactional(readOnly = false)
 public void saveMenu(Menu menu) {
   menu.setParent(this.getMenu(menu.getParent().getId()));
   String oldParentIds = menu.getParentIds(); // 获取修改前的parentIds,用于更新子节点的parentIds
   menu.setParentIds(menu.getParent().getParentIds() + menu.getParent().getId() + ",");
   if (menu.getId() == null) {
     menu.setUser(UserUtils.getUser());
   }
   menuDao.clear();
   menuDao.save(menu);
   // 更新子节点 parentIds
   List<Menu> list = menuDao.findByParentIdsLike("%," + menu.getId() + ",%");
   for (Menu e : list) {
     e.setParentIds(e.getParentIds().replace(oldParentIds, menu.getParentIds()));
   }
   menuDao.save(list);
   systemRealm.clearAllCachedAuthorizationInfo();
 }
コード例 #17
0
ファイル: SystemService.java プロジェクト: hqm1988/jeesite
 public Page<User> findUser(Page<User> page, User user) {
   DetachedCriteria dc = userDao.createDetachedCriteria();
   User currentUser = UserUtils.getUser();
   if (!currentUser.isAdmin()) {
     if (user.getArea() == null || user.getArea().getId() == null) {
       user.setArea(currentUser.getArea());
     }
     if (user.getOffice() == null || user.getOffice().getId() == null) {
       user.setOffice(currentUser.getOffice());
     }
   }
   dc.createAlias("area", "area");
   if (user.getArea() != null && user.getArea().getId() != null) {
     dc.add(
         Restrictions.or(
             Restrictions.eq("area.id", user.getArea().getId()),
             Restrictions.eq("area.parent.id", user.getArea().getId()),
             Restrictions.like("area.parentIds", "%," + user.getArea().getId() + ",%")));
   }
   dc.createAlias("office", "office");
   if (user.getOffice() != null && user.getOffice().getId() != null) {
     dc.add(
         Restrictions.or(
             Restrictions.eq("office.id", user.getOffice().getId()),
             Restrictions.eq("office.parent.id", user.getOffice().getId()),
             Restrictions.like("office.parentIds", "%," + user.getOffice().getId() + ",%")));
   }
   if (StringUtils.isNotEmpty(user.getLoginName())) {
     dc.add(Restrictions.like("loginName", "%" + user.getLoginName() + "%"));
   }
   if (StringUtils.isNotEmpty(user.getName())) {
     dc.add(Restrictions.like("name", "%" + user.getName() + "%"));
   }
   dc.add(Restrictions.eq("delFlag", User.DEL_FLAG_NORMAL));
   if (!StringUtils.isNotEmpty(page.getOrderBy())) {
     dc.addOrder(Order.asc("area.code")).addOrder(Order.asc("office.code"));
   }
   return userDao.find(page, dc);
 }
コード例 #18
0
  /** 认证回调函数, 登录时调用 */
  @Override
  protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) {
    UsernamePasswordToken token = (UsernamePasswordToken) authcToken;

    int activeSessionSize = getSystemService().getSessionDao().getActiveSessions(false).size();
    if (logger.isDebugEnabled()) {
      logger.debug(
          "login submit, active session size: {}, username: {}",
          activeSessionSize,
          token.getUsername());
    }

    // 校验登录验证码
    if (LoginController.isValidateCodeLogin(token.getUsername(), false, false)) {
      Session session = UserUtils.getSession();
      String code = (String) session.getAttribute(ValidateCodeServlet.VALIDATE_CODE);
      if (token.getCaptcha() == null || !token.getCaptcha().toUpperCase().equals(code)) {
        throw new AuthenticationException("msg:验证码错误, 请重试.");
      }
    }

    // 校验用户名密码
    User user = getSystemService().getUserByLoginName(token.getUsername());
    if (user != null) {
      if (Global.NO.equals(user.getLoginFlag())) {
        throw new AuthenticationException("msg:该帐号已禁止登录.");
      }
      byte[] salt = Encodes.decodeHex(user.getPassword().substring(0, 16));
      return new SimpleAuthenticationInfo(
          new Principal(user, token.isMobileLogin()),
          user.getPassword().substring(16),
          ByteSource.Util.bytes(salt),
          getName());
    } else {
      return null;
    }
  }
コード例 #19
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";
  }
コード例 #20
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";
  }
コード例 #21
0
ファイル: AreaService.java プロジェクト: newdon/jeesite
 @Transactional(readOnly = false)
 public void delete(Area area) {
   super.delete(area);
   UserUtils.removeCache(UserUtils.CACHE_AREA_LIST);
 }
コード例 #22
0
ファイル: AreaService.java プロジェクト: newdon/jeesite
 public List<Area> findAll() {
   return UserUtils.getAreaList();
 }
コード例 #23
0
 @Transactional(readOnly = false)
 public void delete(Office office) {
   super.delete(office);
   UserUtils.removeCache(UserUtils.CACHE_OFFICE_LIST);
 }
コード例 #24
0
ファイル: SystemService.java プロジェクト: hqm1988/jeesite
 public List<Menu> findAllMenu() {
   return UserUtils.getMenuList();
 }
コード例 #25
0
 public List<Office> findAll() {
   return UserUtils.getOfficeList();
 }
コード例 #26
0
ファイル: AreaService.java プロジェクト: java10000/jeesite
 @Transactional(readOnly = false)
 public void delete(Long id) {
   areaDao.deleteById(id, "%," + id + ",%");
   UserUtils.removeCache("areaList");
 }