Exemplo n.º 1
0
  @Override
  public UpdateUserPwdResponse execute(UpdateUserPwdRequest request, ExecutionContext response)
      throws DispatchException {

    String message =
        userService.updateUserPwd(
            request.getStaffId(), request.getPwd(), request.getSession().getToken());
    return new UpdateUserPwdResponse(message);
  }
  @Override
  public SearchDictionaryListResponse execute(
      SearchDictionaryListRequest action, ExecutionContext context) throws DispatchException {
    SearchDictionaryListResponse rep = new SearchDictionaryListResponse();
    UserContext u = new UserContext();
    if (action.getSession() != null) {
      u.setCorporationId(action.getSession().getCorporationId());
      u.setUserId(action.getSession().getToken());
      u.setDeptId(action.getSession().getDepartmentId());
    }

    DictionarySearchCriteria criteria = new DictionarySearchCriteria();
    if (action.getCriteria().getPagination() != null) {
      PaginationDetail detail = new PaginationDetail();
      detail.setLimit(action.getCriteria().getPagination().getLimit());
      detail.setStart(action.getCriteria().getPagination().getStart());

      criteria.setPaginationDetail(detail);
    }
    if (action.getCriteria().getSorting() != null) {
      SortingDetail sortingDetail = new SortingDetail();
      sortingDetail.setSort(action.getCriteria().getSorting().getSort());
      sortingDetail.setDirection(action.getCriteria().getSorting().getDirection());
      criteria.setSortingDetail(sortingDetail);
    }
    criteria.setDictionaryType(action.getCriteria().getDictionaryType());
    if (!StringUtil.isEmpty(action.getCriteria().getDeptId()))
      criteria.setDeptId(action.getCriteria().getDeptId());

    if (!StringUtil.isEmpty(action.getCriteria().getCorpId()))
      criteria.setCorpId(action.getCriteria().getCorpId());

    PageStore<Dictionary> userpage = userService.getDictionaryListList(u, criteria);
    rep.setTotal(userpage.getResultCount());

    List<DictionaryListClient> result = new ArrayList<DictionaryListClient>();
    if (userpage.getResultList() != null && userpage.getResultList().size() >= 0) {
      int indexNo = 1;
      if (action.getCriteria() != null
          && action.getCriteria().getPagination() != null
          && action.getCriteria().getPagination().getStart() != 0)
        indexNo = action.getCriteria().getPagination().getStart() + 1;
      for (Dictionary d : userpage.getResultList()) {
        DictionaryListClient r = new DictionaryListClient();
        r.setId(d.getId());
        r.setName(d.getName());
        r.setDictionaryType(d.getDictionaryType());
        r.setIndexNo(indexNo + "");
        result.add(r);
        indexNo++;
      }
    }
    rep.setResult(result);
    return rep;
  }
Exemplo n.º 3
0
 @Override
 public TokenValidResponse execute(TokenValidRequest action, ExecutionContext context)
     throws DispatchException {
   TokenValidResponse tokenRep = new TokenValidResponse();
   UserSessionVo userSessionVo = userService.tokenVaild(action.getToken());
   if (userSessionVo != null) {
     tokenRep.setCorporationId(userSessionVo.getCorporationId());
     tokenRep.setLoginName(userSessionVo.getUsername());
     tokenRep.setToken(userSessionVo.getId());
     tokenRep.setUserRoles(UserRoleTool.adaptToRoleVo(userSessionVo.getUserRoles()));
     tokenRep.setDepartmentId(userSessionVo.getDepartmentId());
     tokenRep.setStaffId(userSessionVo.getStaffId());
     tokenRep.setCorporationName(userSessionVo.getCorporationName());
     tokenRep.setPhoto(userSessionVo.getPhoto());
     tokenRep.setCid(userSessionVo.getCid());
     tokenRep.setDepartmentName(userSessionVo.getDepartmentName());
     if (userSessionVo.getLastLoginRole() != null) {
       tokenRep.setLastLoginRole(UserRoleVo.valueOf(userSessionVo.getLastLoginRole().toString()));
     }
   }
   return tokenRep;
 }