Java Code Examples for io.jboot.db.model.Columns#create()

The following examples show how to use io.jboot.db.model.Columns#create() . 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: _FinanceController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@AdminMenu(text = "支付记录", groupId = JPressConsts.SYSTEM_MENU_ORDER, order = 3)
public void paylist() {
    Columns columns = Columns.create();
    columns.likeAppendPercent("trx_no", getPara("ns"));
    columns.likeAppendPercent("product_title", getPara("pt"));
    columns.eq("status", getPara("status"));

    Page<PaymentRecord> page = paymentService.paginate(getPagePara(), 20, columns);
    setAttr("page", page);

    long successCount = paymentService.findCountByColumns(Columns.create("status", PaymentRecord.STATUS_PAY_SUCCESS));
    long prepayCount = paymentService.findCountByColumns(Columns.create("status", PaymentRecord.STATUS_PAY_PRE));
    long failCount = paymentService.findCountByColumns(Columns.create("status", PaymentRecord.STATUS_PAY_FAILURE));

    setAttr("successCount", successCount);
    setAttr("prepayCount", prepayCount);
    setAttr("failCount", failCount);
    setAttr("totalCount", successCount + prepayCount + failCount);

    render("finance/paylist.html");
}
 
Example 2
Source File: SinglePageCommentServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Page<SinglePageComment> paginateByPageIdInNormal(int page, int pagesize, long pageId) {
    Columns columns = Columns.create("page_id", pageId);
    columns.add("status", SinglePageComment.STATUS_NORMAL);


    Page<SinglePageComment> p = DAO.paginateByColumns(
            page,
            pagesize,
            columns,
            "id desc");

    join(p, "pid", "parent");
    joinParentUser(p);
    userService.join(p, "user_id");

    return p;
}
 
Example 3
Source File: ProductCommentServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Page<ProductComment> paginateByProductIdInNormal(int page, int pagesize, long productId) {
    Columns columns = Columns.create("product_id", productId);
    columns.add("status", ProductComment.STATUS_NORMAL);


    Page<ProductComment> p = DAO.paginateByColumns(
            page,
            pagesize,
            columns,
            "id desc");

    join(p, "pid", "parent");
    joinParentUser(p);
    userService.join(p, "user_id");

    return p;
}
 
Example 4
Source File: PermissionServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public int sync(List<Permission> permissions) {

    if (permissions == null || permissions.isEmpty()) {
        return 0;
    }

    int syncCounter = 0;
    for (Permission permission : permissions) {

        Columns columns = Columns.create("node", permission.getNode());
        columns.eq("action_key", permission.getActionKey());

        Permission dbPermission = DAO.findFirstByColumns(columns);

        if (dbPermission == null) {
            permission.save();
            syncCounter++;
        }
    }
    return syncCounter;
}
 
Example 5
Source File: ProductApiController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 获取产品列表
 */
public void list(){
    String flag = getPara("flag");
    Boolean hasThumbnail = getParaToBoolean("hasThumbnail");
    String orderBy = getPara("orderBy", "id desc");
    int count = getParaToInt("count", 10);


    Columns columns = Columns.create("flag", flag);
    if (hasThumbnail != null) {
        if (hasThumbnail) {
            columns.isNotNull("thumbnail");
        } else {
            columns.isNull("thumbnail");
        }
    }

    List<Product> products = productService.findListByColumns(columns, orderBy, count);
    renderOkJson("products", products);
}
 
Example 6
Source File: ArticleApiController.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * 通过 文章属性 获得文章列表
 */
public void list() {
    String flag = getPara("flag");
    Boolean hasThumbnail = getParaToBoolean("hasThumbnail");
    String orderBy = getPara("orderBy", "id desc");
    int count = getParaToInt("count", 10);


    Columns columns = Columns.create("flag", flag);
    if (hasThumbnail != null) {
        if (hasThumbnail) {
            columns.isNotNull("thumbnail");
        } else {
            columns.isNull("thumbnail");
        }
    }

    List<Article> articles = articleService.findListByColumns(columns, orderBy, count);
    renderJson(Ret.ok("articles", articles));
}
 
Example 7
Source File: ArticleServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
@Cacheable(name = "articles")
public List<Article> findRelevantListByArticleId(long articleId, String status, Integer count) {

    List<ArticleCategory> tags = categoryService.findListByArticleId(articleId, ArticleCategory.TYPE_TAG);
    if (tags == null || tags.isEmpty()) {
        return null;
    }

    List<Long> tagIds = tags.stream().map(category -> category.getId()).collect(Collectors.toList());

    Columns columns = Columns.create();
    columns.in("m.category_id", tagIds.toArray());
    columns.ne("article.id", articleId);
    columns.eq("article.status", status);

    List<Article> articles = DAO.leftJoin("article_category_mapping").as("m")
            .on("article.id = m.`article_id`")
            .findListByColumns(columns, count);

    return joinUserInfo(articles);
}
 
Example 8
Source File: RoleServiceImpl.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
@Override
public Page<Role> findPage(Role sysRole, int pageNumber, int pageSize) {
    Columns columns = Columns.create();

    if (StrKit.notBlank(sysRole.getName())) {
        columns.like("name", "%"+sysRole.getName()+"%");
    }

    return DAO.paginateByColumns(pageNumber, pageSize, columns.getList(), "seq asc");
}
 
Example 9
Source File: ArticlesDirective.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void onRender(Env env, Scope scope, Writer writer) {

    String flag = getPara("flag", scope);
    String style = getPara("style", scope);
    Boolean hasThumbnail = getParaToBool("hasThumbnail", scope);
    String orderBy = getPara("orderBy", scope, "id desc");
    int count = getParaToInt("count", scope, 10);


    Columns columns = Columns.create();

    columns.add("flag", flag);
    columns.add("style", style);
    columns.add("status", Article.STATUS_NORMAL);

    if (hasThumbnail != null) {
        if (hasThumbnail) {
            columns.isNotNull("thumbnail");
        } else {
            columns.isNull("thumbnail");
        }
    }

    List<Article> articles = service.findListByColumns(columns, orderBy, count);

    if (articles == null || articles.isEmpty()) {
        return;
    }

    scope.setLocal("articles", articles);
    renderBody(env, scope, writer);
}
 
Example 10
Source File: ArticleServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Article findNextById(long id) {
    Columns columns = Columns.create();
    columns.add(Column.create("id", id, Column.LOGIC_GT));
    columns.add(Column.create("status", Article.STATUS_NORMAL));
    return joinUserInfo(DAO.findFirstByColumns(columns));
}
 
Example 11
Source File: SinglePageServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Page<SinglePage> _paginateWithoutTrash(int page, int pagesize, String title) {

    Columns columns = Columns.create(Column.create("status", SinglePage.STATUS_TRASH, Column.LOGIC_NOT_EQUALS));
    if (StrUtil.isNotBlank(title)) {
        columns.like("title", "%" + title + "%");
    }

    return DAO.paginateByColumns(page,
            pagesize,
            columns,
            "id desc");
}
 
Example 12
Source File: DataServiceImpl.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
@Cacheable(name = CacheKey.CACHE_KEYVALUE)
@Override
public List<Data> getListByTypeOnUse(String type) {
    Columns columns = Columns.create();
    columns.eq("type", type).eq("status", DataStatus.USED);
    return DAO.findListByColumns(columns);
}
 
Example 13
Source File: DataServiceImpl.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
@Cacheable(name = CacheKey.CACHE_KEYVALUE)
@Override
public Map<String, String> getMapByType(String type) {
    Columns columns = Columns.create();
    columns.eq("type", type);
    List<Data> dataList = DAO.findListByColumns(columns);

    Map<String, String> map = new LinkedHashMap<String, String>();
    for (Data data : dataList) {
        map.put(data.getCodeDesc(), data.getCode());
    }
    return map;
}
 
Example 14
Source File: DataServiceImpl.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
@Cacheable(name = CacheKey.CACHE_KEYVALUE)
@Override
public Map<String, String> getMapByTypeOnUse(String type) {
    Columns columns = Columns.create();
    columns.eq("type", type).eq("status", DataStatus.USED);
    List<Data> dataList = DAO.findListByColumns(columns);

    Map<String, String> map = new LinkedHashMap<String, String>();
    for (Data data : dataList) {
        map.put(data.getCodeDesc(), data.getCode());
    }
    return map;
}
 
Example 15
Source File: _UserController.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@AdminMenu(text = "用户管理", groupId = JPressConsts.SYSTEM_MENU_USER, order = 0)
    public void index() {

        Columns columns = Columns.create("status", getPara("status"));
        columns.likeAppendPercent("username", getTrimPara("username"));
//        columns.likeAppendPercent("nickname", getPara("username"));
        columns.likeAppendPercent("email", getTrimPara("email"));
        columns.likeAppendPercent("mobile", getTrimPara("mobile"));
        columns.eq("create_source", getPara("create_source"));


        List<MemberGroup> memberGroups = memberGroupService.findAll();
        setAttr("memberGroups", memberGroups);

        Page<User> page = userService._paginate(getPagePara(), 10, columns, getParaToLong("group_id"), getPara("tag"));

        int lockedCount = userService.findCountByStatus(User.STATUS_LOCK);
        int regCount = userService.findCountByStatus(User.STATUS_REG);
        int okCount = userService.findCountByStatus(User.STATUS_OK);

        setAttr("lockedCount", lockedCount);
        setAttr("regCount", regCount);
        setAttr("okCount", okCount);
        setAttr("totalCount", lockedCount + regCount + okCount);

        setAttr("page", page);

        List<Role> roles = roleService.findAll();
        setAttr("roles", roles);

        render("user/list.html");
    }
 
Example 16
Source File: DataServiceImpl.java    From jboot-admin with Apache License 2.0 5 votes vote down vote up
@Override
public Page<Data> findPage(Data data, int pageNumber, int pageSize) {
    Columns columns = Columns.create();

    if (StrKit.notBlank(data.getType())) {
        columns.like("type", "%"+data.getType()+"%");
    }
    if (StrKit.notBlank(data.getTypeDesc())) {
        columns.like("typeDesc", "%"+data.getTypeDesc()+"%");
    }
    return DAO.paginateByColumns(pageNumber, pageSize, columns.getList(), "type asc ,orderNo asc");
}
 
Example 17
Source File: ProductServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public Product findNextById(long id) {
    Columns columns = Columns.create();
    columns.add(Column.create("id", id, Column.LOGIC_GT));
    columns.add(Column.create("status", Product.STATUS_NORMAL));
    return joinUserInfo(DAO.findFirstByColumns(columns));
}
 
Example 18
Source File: ProductCategoryServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<ProductCategory> findOrCreateByTagString(String[] tags) {
    if (tags == null || tags.length == 0) {
        return null;
    }

    List<ProductCategory> productCategories = new ArrayList<>();

    boolean needClearCache = false;

    for (String tag : tags) {

        if (StrUtil.isBlank(tag)) {
            continue;
        }

        //slug不能包含字符串点 " . ",否则url不能被访问
        String slug = tag.contains(".")
                ? tag.replace(".", "_")
                : tag;

        Columns columns = Columns.create("type", ProductCategory.TYPE_TAG);
        columns.add(Column.create("slug", slug));

        ProductCategory productCategory = DAO.findFirstByColumns(columns);

        if (productCategory == null) {
            productCategory = new ProductCategory();
            productCategory.setTitle(tag);
            productCategory.setSlug(slug);
            productCategory.setType(ProductCategory.TYPE_TAG);
            productCategory.save();
            needClearCache = true;
        }

        productCategories.add(productCategory);
    }

    if (needClearCache) {
        AopCache.removeAll("productCategory");
    }

    return productCategories;
}
 
Example 19
Source File: PermissionServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public List<Permission> findListByNode(String node) {
    Columns columns = Columns.create();
    columns.likeAppendPercent("node", node);
    return DAO.findListByColumns(columns);
}
 
Example 20
Source File: UserTagServiceProvider.java    From jpress with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
    public List<UserTag> findOrCreateByTagString(String[] tags) {
        if (tags == null || tags.length == 0) {
            return null;
        }

        boolean needClearCache = false;
        List<UserTag> userTags = new ArrayList<>();
        for (String tag : tags) {

            if (StrUtil.isBlank(tag)) {
                continue;
            }

            //slug不能包含字符串点 " . ",否则url不能被访问
            String slug = tag.contains(".")
                    ? tag.replace(".", "_")
                    : tag;

            Columns columns = Columns.create(Column.create("slug", slug));
            UserTag userTag = findFirstByColumns(columns);

            if (userTag == null) {
                userTag = new UserTag();
                userTag.setTitle(tag);
                userTag.setSlug(slug);
                userTag.setType("tag");
                userTag.save();

                needClearCache = true;
            }

            userTags.add(userTag);
        }

        if (needClearCache){
//            AopCache.removeAll("articleCategory");
        }

        return userTags;
    }