コード例 #1
0
  /**
   * 模糊查询评价基础
   *
   * @param request 模糊查询评价基础请求
   * @param passport 用户护照
   * @return 模糊查询评价基础应答
   */
  @Override
  @Transactional(readOnly = true)
  public EvaluateSearchResponse search(EvaluateSearchRequest request, Passport passport) {
    EvaluateSearchResponse response = new EvaluateSearchResponse();
    List<Evaluate> modelList = new ArrayList<>();
    Long count = evaluateMapper.searchCount(request, passport);

    if (count > 0) {
      // 处理分页参数
      if (request.getPageSize() > 0) {
        // 如果输入的页码大于实际的分页数,将页码设置为最后一页的页码
        int lastPageNumber = (int) ((count - 1) / request.getPageSize() + 1);
        if (request.getPageNumber() > lastPageNumber) {
          request.setPageNumber(lastPageNumber);
        }
      }

      // 通过关键字查询出用户集合
      List<EvaluatePO> entityList = evaluateMapper.search(request, passport);

      for (EvaluatePO entity : entityList) {
        Evaluate evaluate = this.getMapper().map(entity, Evaluate.class);
        modelList.add(evaluate);
      }
    }

    response.setTotalCount(count);
    response.setResult(modelList);
    return response;
  }
コード例 #2
0
 /**
  * 删除评价基础
  *
  * @param request 删除评价基础请求
  * @param passport 用户护照
  * @return 删除评价基础应答
  */
 @Override
 public EvaluateDeleteResponse delete(EvaluateDeleteRequest request, Passport passport) {
   EvaluateDeleteResponse response = new EvaluateDeleteResponse();
   Long result = evaluateMapper.delete(request.getId(), passport);
   response.setResult(result);
   return response;
 }
コード例 #3
0
 /**
  * 根据Id获取评价基础
  *
  * @param request 获取评价基础请求
  * @param passport 用户护照
  * @return 获取评价基础应答
  */
 @Override
 @Transactional(readOnly = true)
 public EvaluateGetResponse get(EvaluateGetRequest request, Passport passport) {
   EvaluatePO entity = evaluateMapper.getById(request.getId(), passport);
   EvaluateGetResponse response = new EvaluateGetResponse();
   if (entity != null) {
     Evaluate evaluate = this.getMapper().map(entity, Evaluate.class);
     response.setEvaluate(evaluate);
   } else {
     response.addError(ErrorType.EXPECTATION_NULL, Message.COMMON_GET_FAILURE);
   }
   return response;
 }
コード例 #4
0
  /**
   * 更新评价基础
   *
   * @param request 更新评价基础请求
   * @param passport 用户护照
   * @return 更新评价基础应答
   */
  @Override
  public EvaluateUpdateResponse update(EvaluateUpdateRequest request, Passport passport) {
    EvaluatePO entity = this.getMapper().map(request, EvaluatePO.class);

    EvaluateUpdateResponse response = new EvaluateUpdateResponse();
    Long result = evaluateMapper.update(entity, passport);
    if (result != 1) {
      response.addError(ErrorType.BUSINESS_ERROR, Message.COMMON_UPDATE_FAILURE);
      return response;
    }
    response.setResult(result);
    return response;
  }
コード例 #5
0
  /**
   * 创建评价基础
   *
   * @param request 创建评价基础请求
   * @param passport 用户护照
   * @return 创建评价基础应答
   */
  @Override
  public EvaluateCreateResponse create(EvaluateCreateRequest request, Passport passport) {
    EvaluatePO entity = this.getMapper().map(request, EvaluatePO.class);
    long id = foundationService.getNewId();
    entity.setId(id);

    EvaluateCreateResponse response = new EvaluateCreateResponse();

    /* 先检查关键数据是否有重复,在检查通过后才能做插入操作 */
    checkValidate(entity, passport, response);

    if (1 == evaluateMapper.insert(entity, passport)) {
      response.setId(id);
    } else {
      response.addError(ErrorType.EXPECTATION_NULL, Message.COMMON_CREATE_FAILURE);
    }
    return response;
  }
コード例 #6
0
  /**
   * 获取所有评价基础列表
   *
   * @param request 获取所有评价基础列表请求
   * @param passport 用户护照
   * @return 获取所有评价基础列表应答
   */
  @Override
  @Transactional(readOnly = true)
  public EvaluateGetAllListResponse getAllList(
      EvaluateGetAllListRequest request, Passport passport) {
    EvaluateGetAllListResponse response = new EvaluateGetAllListResponse();

    List<EvaluatePO> entityList = evaluateMapper.getAllList(request, passport);

    List<Evaluate> modelList = new ArrayList<>();
    for (EvaluatePO entity : entityList) {
      Evaluate evaluate = this.getMapper().map(entity, Evaluate.class);
      modelList.add(evaluate);
    }

    response.setResult(modelList);

    response.setTotalCount(modelList.size());
    return response;
  }
コード例 #7
0
  /**
   * 导入评价基础
   *
   * @param request 导入评价基础请求
   * @param passport 用户护照
   * @return 导入评价基础应答
   */
  @Override
  public EvaluateListImportResponse importList(
      EvaluateListImportRequest request, Passport passport) {
    DataTable<EvaluateImport> dataTable = request.getDataTable();

    List<EvaluatePO> importList = new ArrayList<>(); // 需要创建的对象的集合

    List<Long> result = new LinkedList<>(); // 存储ID的集合
    List<EvaluateImport> beanList = request.getList(); // 取出导入对象的集合
    EvaluateListImportResponse response = new EvaluateListImportResponse(); // 最终的返回结果

    /* 批量获取ID */
    IdsGetRequest idsGetRequest = new IdsGetRequest();
    idsGetRequest.setCount(beanList.size());
    List<Long> ids = foundationService.getNewIds(idsGetRequest).getIds();

    int index = 0;
    for (EvaluateImport importBean : beanList) {
      // 设置
      EvaluatePO entity = this.getMapper().map(importBean, EvaluatePO.class);

      importList.add(entity);
      result.add(ids.get(index)); // 将取到的ID放入返回结果中
      entity.setId(ids.get(index)); // 设置ID

      index++;
    }

    if (!dataTable.hasError()) {
      if (importList.size() > 0) {
        evaluateMapper.insertBatch(importList, passport);
      }
    } else {
      //  response.setDataTable(dataTable);
      response.addErrors(dataTable.getErrorList());
    }

    response.setList(result);
    return response;
  }