Java Code Examples for com.jfinal.plugin.activerecord.Page#getList()

The following examples show how to use com.jfinal.plugin.activerecord.Page#getList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CartController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 购物车
 */
public void index() {
    Page<UserCart> page = cartService.paginateByUser(1, 20, getLoginedUser().getId());


    if (page != null && page.getList() != null) {
        for (UserCart userCart : page.getList()) {
            userCart.put("optionsMap", ProductManager.me().renderProductOptions(userCart));
        }
    }

    setAttr("page", page);
    setAttr("selectItemCount", cartService.querySelectedCount(getLoginedUser().getId()));

    List<UserCart> selectedUserCarts = cartService.findSelectedListByUserId(getLoginedUser().getId());
    if (selectedUserCarts != null) {
        BigDecimal totalPrice = new BigDecimal(0);
        for (UserCart cart : selectedUserCarts) {
            totalPrice = totalPrice.add(cart.getShouldPayPrice());
        }
        setAttr("selectItemTotalPrice", totalPrice);
    }


    render("cart.html");
}
 
Example 2
Source File: ModelCopier.java    From jboot with Apache License 2.0 5 votes vote down vote up
/**
 * copy model page
 *
 * @param modelPage
 * @param <M>
 * @return
 */
public static <M extends JbootModel> Page<M> copy(Page<M> modelPage) {
    if (modelPage == null) {
        return null;
    }

    List<M> modelList = modelPage.getList();
    if (modelList == null || modelList.isEmpty()) {
        return modelPage;
    }

    modelPage.setList(copy(modelList));
    return modelPage;
}
 
Example 3
Source File: JsonUtils.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * Page<Record>转为Page<Map<String, Object>>,驼峰命名
 *
 * @param records
 * @return
 */
public static Page<Map<String, Object>> recordsToCamelCaseMaps(Page<Record> records) {
    List<Record> recordList = records.getList();
    List<Map<String, Object>> maps = new ArrayList<>();
    for (Record record : recordList) {
        maps.add(recordToCamelCaseMap(record));
    }
    return new Page<>(maps, records.getPageNumber(), records.getPageSize(),
            records.getTotalPage(), records.getTotalRow());
}
 
Example 4
Source File: JsonUtils.java    From my_curd with Apache License 2.0 5 votes vote down vote up
/**
 * Page<Page<? extends Model>转为Page<Map<String, Object>>,驼峰命名
 *
 * @param models
 * @return
 */
public static Page<Map<String, Object>> modelsToCamelCaseMaps(Page<? extends Model> models) {
    List<? extends Model> modelList = models.getList();
    List<Map<String, Object>> maps = new ArrayList<>();
    for (Model model : modelList) {
        maps.add(modelToCamelCaseMap(model));
    }
    return new Page<>(maps, models.getPageNumber(), models.getPageSize(), models.getTotalPage(),
            models.getTotalRow());
}
 
Example 5
Source File: UserOrderServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Page<UserOrder> paginate(int page, int pageSize, String productTitle, String ns) {
    Columns columns = Columns.create().likeAppendPercent("product_title", productTitle).likeAppendPercent("ns", ns);
    Page<UserOrder> userOrderPage = DAO.paginateByColumns(page, pageSize, columns, "id desc");

    for (UserOrder order : userOrderPage.getList()) {
        order.put("items", itemService.findListByOrderId(order.getId()));
    }

    return userOrderPage;
}
 
Example 6
Source File: UserOrderServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Page<UserOrder> paginateByUserId(int page, int pageSize, long userid, String title, String ns) {
    Columns columns = Columns.create("buyer_id", userid).likeAppendPercent("title", title).likeAppendPercent("ns", ns);
    Page<UserOrder> userOrderPage = DAO.paginateByColumns(page, pageSize, columns, "id desc");

    for (UserOrder order : userOrderPage.getList()) {
        order.put("items", itemService.findListByOrderId(order.getId()));
    }

    return userOrderPage;
}
 
Example 7
Source File: SinglePageCommentServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void joinParentUser(Page<SinglePageComment> p) {
    if (p == null || p.getList().isEmpty()) {
        return;
    }

    for (SinglePageComment pageComment : p.getList()) {
        userService.join((SinglePageComment) pageComment.get("parent"), "user_id");
    }
}
 
Example 8
Source File: ArticleCommentServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void joinParentUser(Page<ArticleComment> p) {
    if (p == null || p.getList().isEmpty()) {
        return;
    }

    for (ArticleComment articleComment : p.getList()) {
        userService.join((ArticleComment) articleComment.get("parent"), "user_id");
    }
}
 
Example 9
Source File: ProductCommentServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void joinParentUser(Page<ProductComment> p) {
    if (p == null || p.getList().isEmpty()) {
        return;
    }

    for (ProductComment comment : p.getList()) {
        userService.join((ProductComment) comment.get("parent"), "user_id");
    }
}
 
Example 10
Source File: DataTable.java    From jboot-admin with Apache License 2.0 4 votes vote down vote up
public DataTable(Page<T> page) {
    this.count = page.getTotalRow();
    this.data = page.getList();
}
 
Example 11
Source File: GrouponController.java    From sdb-mall with Apache License 2.0 4 votes vote down vote up
@ResponseBody
@GetMapping("/grouponTop/{goodsId}")
public R grouponTop(@PathVariable String goodsId){
       List<Filter> filterList = new ArrayList<>();
       Filter filter = new Filter();
	filter.setProperty("goods_id");
	filter.setOperator(Filter.Operator.eq);
	filter.setValue(goodsId);
       filterList.add(filter);

       filter = new Filter();
	filter.setProperty("expire_date");
	filter.setOperator(Filter.Operator.gt);
	filter.setValue(new Date());
       filterList.add(filter);

       filter = new Filter();
       filter.setProperty("status");
       filter.setOperator(Filter.Operator.eq);
       filter.setValue(GrouponStatusEnum.PENDING.getCode());
       filterList.add(filter);

	Order order = new Order();
	order.setDirection(Order.Direction.asc);
	order.setProperty("create_date");
	Page<Groupon> page = grouponService.paginate(1, 10, filterList, order);

       List<Groupon> grouponList = page.getList();

       List<GrouponDetailVO> grouponDetailVOList = grouponList.stream().map(item -> {
           GrouponDetailVO grouponDetailVO = new GrouponDetailVO();
           grouponDetailVO.setGrouponId(item.getId());
           grouponDetailVO.setTotalCount(item.getCount());

           List<Filter> gtFilterList = new ArrayList<>();

           Filter gtFilter = new Filter();
           gtFilter.setProperty("groupon_id");
           gtFilter.setOperator(Filter.Operator.eq);
           gtFilter.setValue(item.getId());
           gtFilterList.add(gtFilter);

           List<GrouponTeam> grouponTeamList = grouponTeamService.findByFilters(gtFilterList);
           GrouponTeam captain = new GrouponTeam();
           for (GrouponTeam grouponTeam : grouponTeamList) {
               if (grouponTeam.getCaptain() == GeneralEnum.TRUE.getCode()) {
                   captain = grouponTeam;
                   break;
               }
           }

           User user = userService.findById(captain.getUserId());
           grouponDetailVO.setHeadUrl(user.getAvatar());
           grouponDetailVO.setName(user.getNickname());
           grouponDetailVO.setJoinedCount(grouponTeamList.size());
           return grouponDetailVO;
       }).collect(Collectors.toList());

	return R.ok().put("grouponDetailList", grouponDetailVOList);
}
 
Example 12
Source File: MyCandidateTaskController.java    From my_curd with Apache License 2.0 4 votes vote down vote up
public void query() {
    int pageNumber = getParaToInt("page", 1);
    int pageSize = getParaToInt("rows", 30);

    List<String> roleCodeList = getSessionAttr("roleCodes");
    List<String> roleCodeListNew = new ArrayList<>();
    for (String roleCode : roleCodeList) {
        roleCodeListNew.add("role_" + roleCode);
    }
    String roleCodes = Joiner.on("','").join(roleCodeListNew);
    String username = WebUtils.getSessionUsername(this);
    String sqlSelect = " SELECT DISTINCT RES.* ";
    String sqlExceptSelect = "  FROM " +
            "	ACT_RU_TASK RES " +
            "	INNER JOIN ACT_RU_IDENTITYLINK I ON I.TASK_ID_ = RES.ID_ " +
            "	INNER JOIN ACT_RU_IDENTITYLINK I_OR0 ON I_OR0.TASK_ID_ = RES.ID_  " +
            "WHERE " +
            "	RES.SUSPENSION_STATE_ = 1  " +
            "	AND ( " +
            "		( RES.ASSIGNEE_ IS NULL AND I.TYPE_ = 'candidate' AND ( I.GROUP_ID_ IN ( '" + roleCodes + "' ) ) ) " +
            "	    OR  " +
            "       ( RES.ASSIGNEE_ IS NULL AND I_OR0.TYPE_ = 'candidate' AND ( I_OR0.USER_ID_ = '" + username + "' ) ) " +
            "	) ";

    String instanceId = getPara("extra_instanceId");
    if (StringUtils.notEmpty(instanceId)) {
        sqlExceptSelect += " and RES.PROC_INST_ID_ = '" + instanceId + "' ";
    }
    String taskName = getPara("extra_taskName");
    if (StringUtils.notEmpty(taskName)) {
        sqlExceptSelect += " and RES.NAME_ like '%" + taskName + "%' ";
    }
    sqlExceptSelect += " ORDER BY RES.CREATE_TIME_ desc ";

    Page<Record> page = Db.use(ActivitiConfig.DATASOURCE_NAME).paginate(pageNumber, pageSize, sqlSelect, sqlExceptSelect);

    List<TaskInfo> list = new ArrayList<>();
    ProcessInstance processInstance;
    for (Record record : page.getList()) {
        processInstance = ActivitiKit.getRuntimeProcessInstance(record.getStr("PROC_INST_ID_"), true);
        TaskInfo taskInfo = new TaskInfo()
                .setId(record.getStr("ID_"))
                .setCreateTime(record.getDate("CREATE_TIME_"))
                .setTaskName(record.getStr("NAME_"))
                .setTaskDefinitionKey(record.getStr("TASK_DEF_KEY_"))
                .setProcessInstanceName(processInstance.getName())
                .setProcessInstanceId(record.getStr("PROC_INST_ID_"))
                .setInitiator((String) processInstance.getProcessVariables().get("initiator"));
        list.add(taskInfo);
    }
    renderDatagrid(list, page.getTotalRow());
}
 
Example 13
Source File: MyCompleteTaskController.java    From my_curd with Apache License 2.0 4 votes vote down vote up
public void query() {

        int pageNumber = getParaToInt("page", 1);
        int pageSize = getParaToInt("rows", 30);
        String processName = get("extra_processName");
        String applyUser = get("extra_applyUser");
        String instanceId = getPara("extra_instanceId");

        String username = WebUtils.getSessionUsername(this);
        String sqlSelect = "SELECT " +
                "	c.TEXT_ AS initiator, " +
                "	a.PROC_INST_ID_ AS processInstanceId, " +
                "	b.NAME_ AS name, " +
                "	b.START_TIME_ AS startTime, " +
                "	b.END_TIME_ AS endTime, " +
                "   b.BUSINESS_KEY_ as businessKey  ";
        String sqlExceptSelect = "FROM " +
                "	( SELECT PROC_INST_ID_ FROM act_hi_taskinst WHERE ASSIGNEE_ = '" + username + "' AND END_TIME_ IS NOT NULL GROUP BY PROC_INST_ID_ ) a " +
                "	LEFT JOIN act_hi_procinst b ON a.PROC_INST_ID_ = b.ID_ " +
                "	LEFT JOIN act_hi_varinst c ON a.PROC_INST_ID_ = c.PROC_INST_ID_  AND c.NAME_ = 'initiator'  " +
                "   where b.DELETE_REASON_ is null   and b.START_USER_ID_ != '" + username + "' ";  // 已办任务 不查询自己申请的流程
        // and c.TEXT_ != '"+username+"'  加上此句,已办任务 不查询 自己申请的

        if (StringUtils.notEmpty(processName)) {
            sqlExceptSelect = sqlExceptSelect + " and b.NAME_ like '%" + processName + "%'";
        }
        if (StringUtils.notEmpty(applyUser)) {
            sqlExceptSelect = sqlExceptSelect + " and c.TEXT_ like '%" + applyUser + "%'";
        }
        if (StringUtils.notEmpty(instanceId)) {
            sqlExceptSelect = sqlExceptSelect + " and a.PROC_INST_ID_ =  '" + instanceId + "'";
        }
        sqlExceptSelect = sqlExceptSelect + " order by b.START_TIME_ desc ";

        Page<Record> page = Db.use(ActivitiConfig.DATASOURCE_NAME).paginate(pageNumber, pageSize, sqlSelect, sqlExceptSelect);


        List<ProcessInstanceInfo> retList = new ArrayList<>();
        for (Record record : page.getList()) {
            ProcessInstanceInfo info = new ProcessInstanceInfo();
            info.setProcessInstanceId(record.getStr("processInstanceId"));
            info.setStartTime(record.getDate("startTime"));
            info.setEndTime(record.getDate("endTime"));
            info.setName(record.getStr("name"));
            info.setInitiator(record.getStr("initiator"));
            if (info.getEndTime() == null) {
                info.setActivityName(ActivitiKit.getActivityName(record.getStr("businessKey")));
            }
            retList.add(info);
        }
        renderDatagrid(retList, page.getTotalRow());
    }