Java Code Examples for com.jfinal.plugin.activerecord.SqlPara

The following examples show how to use com.jfinal.plugin.activerecord.SqlPara. These examples are extracted from open source projects. 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 Project: jboot-admin   Source File: ResServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Res> findByRoleIdAndStatusUsed(Long id) {
    SqlPara sp = Db.getSqlPara("system-res.findByRoleIdAndStatusUsed");
    sp.addPara(ResStatus.USED);
    sp.addPara(RoleStatus.USED);
    sp.addPara(id);
    return DAO.find(sp);
}
 
Example 2
Source Project: jboot-admin   Source File: ResServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Res> findByUserNameAndStatusUsed(String name) {
    SqlPara sp = Db.getSqlPara("system-res.findByUserNameAndStatusUsed");
    sp.addPara(ResStatus.USED);
    sp.addPara(RoleStatus.USED);
    sp.addPara(name);
    return DAO.find(sp);
}
 
Example 3
Source Project: jboot-admin   Source File: ResServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Res> findTopMenuByUserName(String name) {
    SqlPara sp = Db.getSqlPara("system-res.findTopMenuByUserName");
    sp.addPara(ResStatus.USED);
    sp.addPara(RoleStatus.USED);
    sp.addPara(0L);
    sp.addPara(name);
    return DAO.find(sp);
}
 
Example 4
Source Project: jboot-admin   Source File: ResServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<Res> findLeftMenuByUserNameAndPid(String name, Long pid) {
    SqlPara sp = Db.getSqlPara("system-res.findLeftMenuByUserNameAndPid");
    sp.addPara(ResStatus.USED);
    sp.addPara(RoleStatus.USED);
    sp.addPara(pid);
    sp.addPara(name);
    return DAO.find(sp);
}
 
Example 5
Source Project: jfinal-ext3   Source File: ModelExt.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Data Count
 */
public Long dataCount() {
	SqlPara sql = SqlpKit.select(this, "count(*) AS cnt");
	Record record = Db.findFirst(sql);
	if (null != record) {
		return record.get("cnt");
	}
	return 0L;
}
 
Example 6
Source Project: sdb-mall   Source File: SysUserDao.java    License: Apache License 2.0 5 votes vote down vote up
public List<String> queryAllPerms(Long userId) {
    SqlPara sqlPara = Db.getSqlPara("sysUser.queryAllPerms", Kv.by("userId", userId));
    List<Record> sysUserList = Db.find(sqlPara);
    List<String> perms = new ArrayList<>();
    for (Record r:sysUserList
         ) {
        if(r == null || r.get("perms") == null) {
            continue;
        }
        perms.add(r.get("perms"));
    }

    return perms;
}
 
Example 7
Source Project: sdb-mall   Source File: SysUserDao.java    License: Apache License 2.0 5 votes vote down vote up
public List<Long> queryAllMenuId(Long userId) {
    SqlPara sqlPara = Db.getSqlPara("sysUser.queryAllMenuId", Kv.by("userId", userId));
    List<Record> sysMenuList = Db.find(sqlPara);
    List<Long> menuIds = new ArrayList<>();
    for (Record r:sysMenuList
         ) {
        if(r == null || r.get("menu_id") == null) {
            continue;
        }
        menuIds.add(r.get("menu_id"));
    }

    return menuIds;
}
 
Example 8
Source Project: sdb-mall   Source File: SysConfigServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
@JFinalTx
public void updateValueByKey(String key, String value) {
	SqlPara sqlPara = Db.getSqlPara("sysConfig.updateValueByKey", Kv.by("paramValue", value).set("paramKey", key));
	Db.update(sqlPara);
	sysConfigRedis.delete(key);
}
 
Example 9
Source Project: sdb-mall   Source File: FavoriteGoodsServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<FavoriteGoodsDTO> list(String userId) {
    SqlPara sqlPara =  Db.getSqlPara("favoriteGoods.list", Kv.by("userId", userId));
    List<Record> recordList = Db.find(sqlPara);
    List<FavoriteGoodsDTO> favoriteGoodsDTOList = RecordUtils.converModel(recordList, FavoriteGoodsDTO.class);
    return favoriteGoodsDTOList;
}
 
Example 10
Source Project: sdb-mall   Source File: ProductServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<ProductDTO> listDetailByProductIds(String productIds) {
    String[] productIdArr = productIds.split(",");
    SqlPara sqlPara = Db.getSqlPara("product.listDetailByProductIds", Kv.by("productIds", productIdArr));
    List<Record> recordList = Db.find(sqlPara);
    List<ProductDTO> productDTOList = RecordUtils.converModel(recordList, ProductDTO.class);

    return productDTOList;
}
 
Example 11
Source Project: sdb-mall   Source File: CartServiceImpl.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public List<CartDTO> listDetail(String userId) {
    SqlPara sqlPara =  Db.getSqlPara("cart.listDetail", Kv.by("userId", userId));
    List<Record> recordList = Db.find(sqlPara);
    List<CartDTO> cartDTOList = RecordUtils.converModel(recordList, CartDTO.class);
    return cartDTOList;
}
 
Example 12
Source Project: sdb-mall   Source File: SysUserDaoTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    List<Filter> filterList = new ArrayList<>();
    Filter filter = new Filter();
    filter.setProperty("aaa");
    filter.setOperator(Filter.Operator.eq);
    filter.setValue("123");
    filterList.add(filter);

    filter = new Filter();
    filter.setProperty(null);
    filter.setOperator(Filter.Operator.eq);
    filter.setValue("111");
    filterList.add(filter);

    filter = new Filter();
    filter.setProperty("bbb");
    filter.setOperator(Filter.Operator.eq);
    filter.setValue("321");
    filterList.add(filter);

    filter = new Filter();
    filter.setProperty("intest");
    filter.setOperator(Filter.Operator.in);
    filter.setValue(new ArrayList<String>() {
        {add("aaa");add("bbb");}
    });
    filterList.add(filter);
    SqlPara sqlPara = Db.getSqlPara("common.findList", Kv.by("tableName", "aaa").set("filters", filterList));
    List<Record> record = Db.find(sqlPara);
    log.info("{}", record);
}
 
Example 13
Source Project: my_curd   Source File: MainController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 当前用户通知全部设置为已读
 */
public void noticeSetAllRead() {
    SysUser sysUser = WebUtils.getSysUser(this);
    SqlPara sqlPara = new SqlPara();
    String sql = "update sys_notice_detail set hasRead = 'Y' , readTime = ? where receiver = ? and hasRead = 'N' ";
    sqlPara.setSql(sql).addPara(new Date()).addPara(sysUser.getId());
    Db.update(sqlPara);
    renderSuccess("设置 全部已读 操作成功");
}
 
Example 14
Source Project: jboot-admin   Source File: RoleServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public List<Role> findByUserName(String name) {
    SqlPara sp = Db.getSqlPara("system-role.findByUserName");
    sp.addPara(name);
    return DAO.find(sp);
}
 
Example 15
Source Project: sdb-mall   Source File: ProductCategoryDao.java    License: Apache License 2.0 4 votes vote down vote up
public List<ProductCategory> queryListOrder(){
    SqlPara sqlPara = Db.getSqlPara("productCategory.queryListOrder");
    return this.find(sqlPara);
}
 
Example 16
Source Project: sdb-mall   Source File: SysMenuDao.java    License: Apache License 2.0 4 votes vote down vote up
public List<SysMenu> queryNotButtonList() {
    SqlPara sqlPara = Db.getSqlPara("sysMenu.queryNotButtonList");
    return this.find(sqlPara);
}
 
Example 17
Source Project: sdb-mall   Source File: SysUserDao.java    License: Apache License 2.0 4 votes vote down vote up
public SysUser queryByUserName(String name) {
    SqlPara sqlPara = Db.getSqlPara("sysUser.queryByUserName", Kv.by("username", name));
    SysUser sysUserList = this.findFirst(sqlPara);
    return sysUserList;
}
 
Example 18
Source Project: sdb-mall   Source File: OrderMasterServiceImpl.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Boolean updateByGrouponId(String grouponId,Integer status) {
    SqlPara sqlPara = Db.getSqlPara("order.updateByGrouponId", Kv.by("orderStatus", status).set("grouponId", grouponId));
    return Db.update(sqlPara) > 0;
}
 
Example 19
Source Project: jfinal-ext3   Source File: SqlpKit.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * make SqlPara use the model with attr datas.
 * @param model
 */
public static SqlPara select(ModelExt<?> model) {
	return SqlpKit.select(model, FLAG.ALL, "*");
}
 
Example 20
Source Project: jfinal-ext3   Source File: SqlpKit.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * make SqlPara use the model with attr datas.
 * @param model
 * @columns fetch columns 
 */
public static SqlPara select(ModelExt<?> model, String... columns) {
	return SqlpKit.select(model, FLAG.ALL, columns);
}
 
Example 21
Source Project: jfinal-ext3   Source File: SqlpKit.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * make SqlPara use the model with attr datas.
 * @param model
 */
public static SqlPara selectOne(ModelExt<?> model) {
	return SqlpKit.select(model, FLAG.ONE, "*");
}
 
Example 22
Source Project: jfinal-ext3   Source File: SqlpKit.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * make SqlPara use the model with attr datas.
 * @param model
 * @columns fetch columns 
 */
public static SqlPara selectOne(ModelExt<?> model, String... columns) {
	return SqlpKit.select(model, FLAG.ONE, columns);
}
 
Example 23
Source Project: sdb-mall   Source File: BaseService.java    License: Apache License 2.0 votes vote down vote up
List<M> find(SqlPara sqlPara); 
Example 24
Source Project: sdb-mall   Source File: BaseService.java    License: Apache License 2.0 votes vote down vote up
M findFirst(SqlPara sqlPara);