com.jfinal.plugin.activerecord.SqlPara Java Examples

The following examples show how to use com.jfinal.plugin.activerecord.SqlPara. 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: SysUserDao.java    From sdb-mall with 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 #2
Source File: MainController.java    From my_curd with 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 #3
Source File: SysUserDaoTest.java    From sdb-mall with 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 #4
Source File: CartServiceImpl.java    From sdb-mall with 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 #5
Source File: ProductServiceImpl.java    From sdb-mall with 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 #6
Source File: FavoriteGoodsServiceImpl.java    From sdb-mall with 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 #7
Source File: SysConfigServiceImpl.java    From sdb-mall with 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 #8
Source File: SysUserDao.java    From sdb-mall with 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 #9
Source File: ModelExt.java    From jfinal-ext3 with 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 #10
Source File: ResServiceImpl.java    From jboot-admin with 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 #11
Source File: ResServiceImpl.java    From jboot-admin with 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 #12
Source File: ResServiceImpl.java    From jboot-admin with 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 #13
Source File: ResServiceImpl.java    From jboot-admin with 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 #14
Source File: ProductCategoryDao.java    From sdb-mall with 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 #15
Source File: SysMenuDao.java    From sdb-mall with 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 #16
Source File: RoleServiceImpl.java    From jboot-admin with 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 #17
Source File: SysUserDao.java    From sdb-mall with 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 File: OrderMasterServiceImpl.java    From sdb-mall with 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 File: SqlpKit.java    From jfinal-ext3 with 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 #20
Source File: SqlpKit.java    From jfinal-ext3 with 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 #21
Source File: SqlpKit.java    From jfinal-ext3 with 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 #22
Source File: SqlpKit.java    From jfinal-ext3 with 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 #23
Source File: BaseService.java    From sdb-mall with Apache License 2.0 votes vote down vote up
List<M> find(SqlPara sqlPara); 
Example #24
Source File: BaseService.java    From sdb-mall with Apache License 2.0 votes vote down vote up
M findFirst(SqlPara sqlPara);