io.jboot.db.model.Columns Java Examples
The following examples show how to use
io.jboot.db.model.Columns.
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: SinglePageCommentServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@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 #2
Source File: _FinanceController.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@AdminMenu(text = "提现管理", groupId = JPressConsts.SYSTEM_MENU_ORDER, order = 4) public void payout() { Page<UserAmountPayout> page = payoutService.paginateByColumns(getPagePara(), 10, Columns.create("status", getPara("status")), "id desc"); userService.join(page, "user_id"); setAttr("page", page); long totalCount = payoutService.findCountByColumns(Columns.EMPTY); long payingCount = payoutService.findCountByColumns(Columns.create("status", UserAmountPayout.STATUS_APPLYING)); long refuseCount = payoutService.findCountByColumns(Columns.create("status", UserAmountPayout.STATUS_REFUSE)); long successCount = payoutService.findCountByColumns(Columns.create("status", UserAmountPayout.STATUS_SUCCESS)); setAttr("totalCount", totalCount); setAttr("payingCount", payingCount); setAttr("refuseCount", refuseCount); setAttr("successCount", successCount); render("finance/payout.html"); }
Example #3
Source File: DbController.java From jboot with Apache License 2.0 | 6 votes |
public static void main(String[] args) { //设置 数据源 的相关信息 JbootApplication.setBootArg("jboot.datasource.type", "mysql"); JbootApplication.setBootArg("jboot.datasource.url", "jdbc:mysql://127.0.0.1:3306/jbootdemo"); JbootApplication.setBootArg("jboot.datasource.user", "root"); JbootApplication.setBootArg("jboot.datasource.password", "123456"); JbootApplication.setBootArg("jboot.model.unscanPackage", "*"); JbootApplication.setBootArg("jboot.model.scanPackage", "io.jboot.test.db.model"); JbootApplication.setBootArg("undertow.devMode", "false"); //启动应用程序 JbootApplication.run(args); Columns columns = Columns.create(); columns.between("id",1,5); List<User> users = new User().findListByColumns(columns); System.out.println(Arrays.toString(users.toArray())); }
Example #4
Source File: _FinanceController.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@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 #5
Source File: ProductCommentServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
@Override public Page<ProductComment> _paginateByStatus(int page, int pagesize, Long productId, String keyword, int status) { Columns columns = Columns.create("product_id", productId) .add("status", status) .likeAppendPercent("content", keyword); Page<ProductComment> p = DAO.paginateByColumns(page, pagesize, columns, "id desc"); userService.join(p, "user_id"); productService.join(p, "product_id"); return p; }
Example #6
Source File: ArticleApiController.java From jpress with GNU Lesser General Public License v3.0 | 6 votes |
/** * 通过 文章属性 获得文章列表 */ 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: UserOrderServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@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 #8
Source File: ArticleServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Page<Article> _paginateByStatus(int page, int pagesize, String title, Long categoryId, String status) { return _paginateByBaseColumns(page , pagesize , title , categoryId , Columns.create("article.status", status)); }
Example #9
Source File: ProductServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override @Cacheable(name = "products") public Page<Product> paginateInNormal(int page, int pagesize, String orderBy) { orderBy = StrUtil.obtainDefaultIfBlank(orderBy, DEFAULT_ORDER_BY); Columns columns = new Columns(); columns.add("status", Product.STATUS_NORMAL); Page<Product> dataPage = DAO.paginateByColumns(page, pagesize, columns, orderBy); return joinUserInfo(dataPage); }
Example #10
Source File: ProductServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override @Cacheable(name = "products") public Page<Product> paginateByCategoryIdInNormal(int page, int pagesize, long categoryId, String orderBy) { Columns columns = new Columns(); columns.add("m.category_id", categoryId); columns.add("product.status", Product.STATUS_NORMAL); return _paginateByBaseColumns(page, pagesize, columns, categoryId, orderBy); }
Example #11
Source File: SinglePageServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Page<SinglePage> _paginateByStatus(int page, int pagesize, String title, String status) { Columns columns = Columns.create("status", status); if (StrUtil.isNotBlank(title)) { columns.like("title", "%" + title + "%"); } return DAO.paginateByColumns(page, pagesize, columns, "id desc"); }
Example #12
Source File: ResServiceImpl.java From jboot-admin with Apache License 2.0 | 5 votes |
@Override public Page<Res> findPage(Res sysRes, int pageNumber, int pageSize) { Columns columns = Columns.create(); columns.eq("pid", sysRes.getPid() == null ? 0L : sysRes.getPid()); if (StrKit.notBlank(sysRes.getName())) { columns.like("name", "%"+sysRes.getName()+"%"); } if (StrKit.notBlank(sysRes.getUrl())) { columns.like("url", "%"+sysRes.getUrl()+"%"); } return DAO.paginateByColumns(pageNumber, pageSize, columns.getList(), "seq asc"); }
Example #13
Source File: DataServiceImpl.java From jboot-admin with Apache License 2.0 | 5 votes |
@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: RoleServiceImpl.java From jboot-admin with Apache License 2.0 | 5 votes |
@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 #15
Source File: ArticleServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
public Page<Article> _paginateByBaseColumns(int page, int pagesize, String title, Long categoryId, Columns baseColumns) { Columns columns = baseColumns; columns.add("m.category_id", categoryId); columns.likeAppendPercent("article.title", title); Page<Article> dataPage = DAO.leftJoinIf("article_category_mapping", categoryId != null) .as("m") .on("article.id = m.article_id") .paginateByColumns(page, pagesize, columns, "id desc"); return joinUserInfo(dataPage); }
Example #16
Source File: ArticleServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@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 #17
Source File: ArticleServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Article findPreviousById(long id) { Columns columns = Columns.create(); columns.add(Column.create("id", id, Column.LOGIC_LT)); columns.add(Column.create("status", Article.STATUS_NORMAL)); return joinUserInfo(DAO.findFirstByColumns(columns, "id desc")); }
Example #18
Source File: ArticleServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Page<Article> _paginateWithoutTrash(int page, int pagesize, String title, Long categoryId) { return _paginateByBaseColumns(page , pagesize , title , categoryId , Columns.create().ne("article.status", Article.STATUS_TRASH)); }
Example #19
Source File: DbController.java From jboot with Apache License 2.0 | 5 votes |
public void find7(){ User dao = new User(); Columns columns = Columns.create(); columns.in("user.`id`",1,2,3,4); columns.likeAppendPercent("login_name","c"); // List<User> users = dao.leftJoin("article","a","user.id=a.user_id").findListByColumns(columns); List<User> users = dao.leftJoin("article").as("a").on("user.id=a.user_id").findListByColumns(columns); renderJson(users); }
Example #20
Source File: DbController.java From jboot with Apache License 2.0 | 5 votes |
public void safeMode(){ User dao = new User(); Columns columns = Columns.safeMode(); columns.in("user.`id`",1,2,3,4); columns.likeAppendPercent("login_name",null); List<User> users = dao.leftJoin("article").as("a").on("user.id=a.user_id").findListByColumns(columns); renderJson(users); }
Example #21
Source File: _CouponController.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
public void useds() { Columns columns = Columns.create(); columns.add("code_id", getPara("codeid")); columns.add("code_user_id", getPara("cuid")); columns.add("coupon_id", getPara("coid")); Page<CouponUsedRecord> page = couponUsedRecordService.paginate(getPagePara(), 10, columns); setAttr("page", page); render("finance/coupon_useds.html"); }
Example #22
Source File: ProductServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Page<Product> _paginateWithoutTrash(int page, int pagesize, String title, Long categoryId) { return _paginateByBaseColumns(page , pagesize , Columns.create().ne("product.status", Product.STATUS_TRASH).likeAppendPercent("product.title", title) , categoryId , null); }
Example #23
Source File: JbootDbPro.java From jboot with Apache License 2.0 | 4 votes |
public List<Record> find(String tableName, Columns columns, Object limit) { return find(tableName, columns, null, limit); }
Example #24
Source File: CouponUsedRecordServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override public Page<CouponUsedRecord> paginate(int page, int pageSize, Columns columns) { return doJoin(paginateByColumns(page, pageSize, columns, "id desc")); }
Example #25
Source File: ArticleServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override @Cacheable(name = "articles", key = "#(columns.cacheKey)-#(orderBy)-#(count)", liveSeconds = 60 * 60) public List<Article> findListByColumns(Columns columns, String orderBy, Integer count) { return joinUserInfo(DAO.findListByColumns(columns, orderBy, count)); }
Example #26
Source File: CouponUsedRecordServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override public long queryCountByCouponId(long couponId) { return findCountByColumns(Columns.create("coupon_id", couponId)); }
Example #27
Source File: UserTagServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override public UserTag findFirstByTag(String tag) { return findFirstByColumns(Columns.create("slug",tag)); }
Example #28
Source File: ArticleCategoryServiceProvider.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@Override public List<ArticleCategory> doNewOrFindByTagString(String[] tags) { if (tags == null || tags.length == 0) { return null; } boolean needClearCache = false; List<ArticleCategory> articleCategories = new ArrayList<>(); for (String tag : tags) { if (StrUtil.isBlank(tag)) { continue; } //slug不能包含字符串点 " . ",否则url不能被访问 String slug = tag.contains(".") ? tag.replace(".", "_") : tag; Columns columns = Columns.create("type", ArticleCategory.TYPE_TAG); columns.add(Column.create("slug", slug)); ArticleCategory articleCategory = DAO.findFirstByColumns(columns); if (articleCategory == null) { articleCategory = new ArticleCategory(); articleCategory.setTitle(tag); articleCategory.setSlug(slug); articleCategory.setType(ArticleCategory.TYPE_TAG); articleCategory.save(); needClearCache = true; } articleCategories.add(articleCategory); } if (needClearCache) { AopCache.removeAll("articleCategory"); } return articleCategories; }
Example #29
Source File: JbootDbPro.java From jboot with Apache License 2.0 | 4 votes |
public List<Record> find(String tableName, Columns columns, String orderBy, Object limit) { JbootDialect dialect = (JbootDialect) getConfig().getDialect(); String sql = dialect.forFindByColumns(null, tableName, "*", columns.getList(), orderBy, limit); return columns.isEmpty() ? find(sql) : find(sql, columns.getValueArray()); }
Example #30
Source File: _CouponController.java From jpress with GNU Lesser General Public License v3.0 | 4 votes |
@AdminMenu(text = "优惠券", groupId = JPressConsts.SYSTEM_MENU_ORDER, order = 8) public void index() { Page<Coupon> page = couponService.paginateByColumns(getPagePara(), 10,Columns.create(),"id desc"); setAttr("page", page); render("finance/coupon.html"); }