コード例 #1
0
  @RequestMapping(value = "code/code_list", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
  public @ResponseBody List<CmtbCode> codeList() {

    List<CmtbCode> cmtbCodes = cmtbCodeRepository.findAll();

    return cmtbCodes;
  }
コード例 #2
0
  @RequestMapping("code/code_list")
  private String codeList(
      @RequestParam(required = false, defaultValue = "0") Integer page,
      @RequestParam(required = false, defaultValue = "10") Integer size,
      @RequestParam(required = false, defaultValue = "DESC") Direction direction,
      @RequestParam(required = false, defaultValue = "") String searchType,
      @RequestParam(required = false, defaultValue = "") String searchName,
      ModelMap modelMap)
      throws Exception {

    Sort sort =
        new Sort(
            new Order(Direction.DESC, "cmtbCodeId.code"),
            new Order(Direction.DESC, "codeSeq"),
            new org.springframework.data.domain.Sort.Order(Direction.ASC, "codeName"));

    Page<CmtbCode> codePage;
    if (StringUtils.isNotEmpty(searchName)) {
      codePage =
          cmtbCodeRepository.findByCodeNameContaining(
              searchName, new PageRequest(page, size, sort));
    } else {
      codePage = cmtbCodeRepository.findAll(new PageRequest(page, size, sort));
    }

    CmtbCode cccc = cmtbCodeRepository.findByCodeInfo("00001");
    logger.debug("dsdfsdfs = {} ", cccc);
    PageUtils pageUtils = new PageUtils();
    int current = codePage.getNumber() + 1;
    // int begin = Math.max(1, current - 5);
    int begin = pageUtils.pagingBegin(current);
    int end = pageUtils.pagingEnd(codePage.getTotalPages());

    logger.debug("pageInfo = ", codePage);

    modelMap.put("current", current);
    modelMap.put("begin", begin);
    modelMap.put("end", end);
    modelMap.put("searchName", searchName);
    modelMap.put("codePage", codePage);

    return "/code/code_list.tiles";
  }