Java Code Examples for org.nutz.lang.Strings#isBlank()

The following examples show how to use org.nutz.lang.Strings#isBlank() . 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: GlobalsSettingProcessor.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@Override
    public void process(ActionContext ac) throws Throwable {

        boolean captcha = Boolean.valueOf(Globals.getConfig("login.captcha"));
        String path = ac.getServletContext().getContextPath();
        String projectName = path.length() > 0 ? path + "/" : "/";
        ac.getRequest().setAttribute("AppBase", projectName);
        ac.getRequest().setAttribute("captchaEnabled", captcha);
        ac.getRequest().setAttribute("pubkey", Globals.getPublicKey());
//      //允许跨越
//        ac.getResponse().addHeader("Access-Control-Allow-Origin", "*");
//        ac.getResponse().addHeader("Access-Control-Allow-Credentials", "true");
//        ac.getResponse().addHeader("Access-Control-Allow-Headers",
//                "Origin, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie");
        // 如果url中有语言属性则设置
        String lang = ac.getRequest().getParameter("lang");
        if (!Strings.isEmpty(lang)) {
            Mvcs.setLocalizationKey(lang);
        } else {
            // Mvcs.getLocalizationKey()  1.r.56 版本是null,所以要做两次判断, 1.r.57已修复为默认值 Nutz:Fix issue 1072
            lang = Strings.isBlank(Mvcs.getLocalizationKey()) ? Mvcs.getDefaultLocalizationKey() : Mvcs.getLocalizationKey();
        }
        ac.getRequest().setAttribute("lang", lang);
        doNext(ac);
    }
 
Example 2
Source File: MasterController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询主人列表
 */
@RequiresPermissions("test:master:list")
@At
@Ok("json")
public Object list(@Param("pageNum")int pageNum,
				   @Param("pageSize")int pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return masterService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 3
Source File: OperLogController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询操作日志记录列表
 */
@RequiresPermissions("monitor:operLog:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("title") String name,
				   @Param("operName") String uid,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		cnd.and("tg", "like", "%" + name +"%");
	}
	if (!Strings.isBlank(uid)){
		cnd.and("u_name", "=", uid);
	}
	return operLogService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc);
}
 
Example 4
Source File: BaseServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
@Override
public QueryResult listPage(int pageNumber, int pageSize, Cnd cnd, String orderByColumn, String isAsc, String linkname){
    Pager pager = this.dao().createPager(pageNumber, pageSize);
    if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
        MappingField field =dao().getEntity(this.getEntityClass()).getField(orderByColumn);
        if(Lang.isNotEmpty(field)){
            cnd.orderBy(field.getColumnName(),isAsc);
        }
    }
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkname)) {
        this.dao().fetchLinks(list, linkname);
    }
    pager.setRecordCount(this.dao().count(getEntityClass(), cnd));
    return new QueryResult(list, pager);
}
 
Example 5
Source File: SiteController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询站点列表
 */
@RequiresPermissions("cms:site:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return siteService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 6
Source File: BaseServiceImpl.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
public TableDataInfo tableListFetchLinks(Integer pageNumber, Integer pageSize,Cnd cnd,String orderByColumn,String isAsc,String linkname){
    Pager pager=null;
    if(Lang.isNotEmpty(pageNumber) && Lang.isNotEmpty(pageSize)){
        pager = this.dao().createPager(pageNumber, pageSize);
    }
    if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) {
        MappingField field =dao().getEntity(this.getEntityClass()).getField(orderByColumn);
        if(Lang.isNotEmpty(field)){
            cnd.orderBy(field.getColumnName(),isAsc);
        }
    }
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkname)) {
        this.dao().fetchLinks(list, linkname);
    }
    return new TableDataInfo(list, this.dao().count(this.getEntityClass(),cnd));
}
 
Example 7
Source File: Globals.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 获取上传文件的根目录
 *
 * @return
 */
public static String getUserfilesBaseDir() {
    String dir = getConfig("userfiles.basedir");
    if (Strings.isBlank(dir)) {
        try {
            dir = Mvcs.getServletContext().getRealPath("/");
        } catch (Exception e) {
            return "";
        }
    }
    if (!dir.endsWith("/")) {
        dir += "/";
    }
    // System.out.println("userfiles.basedir: " + dir);
    return dir;
}
 
Example 8
Source File: UserOnlineController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询在线用户记录列表
 */
@RequiresPermissions("monitor:online:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String ipaddr,
				   @Param("loginName") String loginName,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(ipaddr)){
		cnd.and("ipaddr", "=", ipaddr);
	}
	if (!Strings.isBlank(loginName)){
		cnd.and("login_name", "=", loginName);
	}
	return userOnlineService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 9
Source File: MaterialController.java    From NutzSite with Apache License 2.0 6 votes vote down vote up
/**
 * 查询微信素材列表
 */
@RequiresPermissions("wx:material:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
				   @Param("pageSize")Integer pageSize,
				   @Param("name") String name,
				   @Param("beginTime") Date beginTime,
				   @Param("endTime") Date endTime,
				   @Param("orderByColumn") String orderByColumn,
				   @Param("isAsc") String isAsc,
				   HttpServletRequest req) {
	Cnd cnd = Cnd.NEW();
	if (!Strings.isBlank(name)){
		//cnd.and("name", "like", "%" + name +"%");
	}
	if(Lang.isNotEmpty(beginTime)){
		cnd.and("create_time",">=", beginTime);
	}
	if(Lang.isNotEmpty(endTime)){
		cnd.and("create_time","<=", endTime);
	}
	return materialService.tableList(pageNum,pageSize,cnd,orderByColumn,isAsc,null);
}
 
Example 10
Source File: Wxs.java    From nutzwx with Apache License 2.0 6 votes vote down vote up
/**
 * 根据提交参数,生成签名
 *
 * @param map
 *            要签名的集合
 * @param key
 *            商户秘钥
 * @return 签名
 *
 * @see <a href=
 *      "https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=4_3">
 *      微信商户平台签名算法</a>
 *
 */
public static String genPaySign(Map<String, Object> map, String key, String signType) {
    String[] nms = map.keySet().toArray(new String[map.size()]);
    Arrays.sort(nms);
    StringBuilder sb = new StringBuilder();
    signType = signType == null ? "MD5" : signType.toUpperCase();
    boolean isMD5 = "MD5".equals(signType);
    for (String nm : nms) {
        Object v = map.get(nm);
        if (null == v)
            continue;
        // JSSDK 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。
        // 但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
        if (isMD5 && "timestamp".equals(nm)) {
            nm = "timeStamp";
        }
        String s = v.toString();
        if (Strings.isBlank(s))
            continue;
        sb.append(nm).append('=').append(s).append('&');
    }
    sb.append("key=").append(key);
    return Lang.digest(signType, sb).toUpperCase();
}
 
Example 11
Source File: WxTemplateData.java    From nutzwx with Apache License 2.0 5 votes vote down vote up
public void set(Object value, Object color) {
    this.value = Strings.sBlank(value);
    this.color = Strings.sBlank(color);

    // if (Strings.isBlank(this.value)) {
    // //throw Lang.makeThrow("blank value");
    // }

    if (Strings.isBlank(this.color)) {
        this.color = DFT_COLOR;
    }
}
 
Example 12
Source File: ArticleController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 查询文章列表
 */
@RequiresPermissions("cms:article:list")
@At
@Ok("json")
public Object list(@Param("pageNum")Integer pageNum,
                   @Param("pageSize")Integer pageSize,
                   @Param("name") String name,
                   @Param("categoryId") String categoryId,
                   @Param("beginTime") Date beginTime,
                   @Param("endTime") Date endTime,
                   @Param("orderByColumn") String orderByColumn,
                   @Param("isAsc") String isAsc,
                   HttpServletRequest req) {
    Cnd cnd = Cnd.NEW();
    if (!Strings.isBlank(name)) {
        //cnd.and("name", "like", "%" + name +"%");
    }
    if (!Strings.isBlank(categoryId)){
        //cnd.and("category_id", "=", categoryId);
        cnd.where().andInBySql("category_id","SELECT id FROM cms_category  WHERE FIND_IN_SET ('%s',parent_ids)", categoryId)
                .or("category_id","=", categoryId);
    }
    if (Lang.isNotEmpty(beginTime)) {
        cnd.and("create_time", ">=", beginTime);
    }
    if (Lang.isNotEmpty(endTime)) {
        cnd.and("create_time", "<=", endTime);
    }
    return articleService.tableList(pageNum, pageSize, cnd, orderByColumn, isAsc, "category");
}
 
Example 13
Source File: BaseServiceImpl.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 获取表及关联表全部数据
 *
 * @param cnd      查询条件
 * @param linkName 关联字段,支持正则 ^(a|b)$
 * @return
 */
@Override
public List<T> query(Condition cnd, String linkName) {
    List<T> list = this.dao().query(this.getEntityClass(), cnd);
    if (!Strings.isBlank(linkName)) {
        this.dao().fetchLinks(list, linkName);
    }
    return list;
}
 
Example 14
Source File: MenuController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
/**
 * 选择菜单树
 */
@At("/selectTree/?")
@Ok("th:/sys/menu/tree.html")
public void selectTree(String id, HttpServletRequest req) {
    Menu menu = null;
    if (!Strings.isBlank(id)) {
        menu = menuService.fetch(id);
    }
    if (menu == null) {
        menu = new Menu();
        menu.setId("0");
        menu.setMenuName("主目录");
    }
    req.setAttribute("menu", menu);
}
 
Example 15
Source File: MenuController.java    From NutzSite with Apache License 2.0 5 votes vote down vote up
@At("/add/?")
@Ok("th:/sys/menu/add.html")
public void add(@Param("id") String id, HttpServletRequest req) {
    Menu menu = null;
    if (!Strings.isBlank(id)) {
        menu = menuService.fetch(id);
    }
    if (menu == null) {
        menu = new Menu();
        menu.setId("0");
        menu.setMenuName("主目录");
    }
    req.setAttribute("menu", menu);
}
 
Example 16
Source File: TableDescriptor.java    From flash-waimai with MIT License 5 votes vote down vote up
public List<ColumnDescriptor> getSearchableColumns() {
    List<ColumnDescriptor> result = new ArrayList<ColumnDescriptor>();

    for (ColumnDescriptor column : columns) {
        if (!Strings.isBlank(column.getQueryOperator())) {
            result.add(column);
        }
    }

    return result;
}
 
Example 17
Source File: TableDescriptor.java    From web-flash with MIT License 5 votes vote down vote up
public List<ColumnDescriptor> getSearchableColumns() {
    List<ColumnDescriptor> result = new ArrayList<ColumnDescriptor>();

    for (ColumnDescriptor column : columns) {
        if (!Strings.isBlank(column.getQueryOperator())) {
            result.add(column);
        }
    }

    return result;
}
 
Example 18
Source File: Wxs.java    From nutzwx with Apache License 2.0 4 votes vote down vote up
public static String cdata(String str) {
    if (Strings.isBlank(str))
        return "";
    return "<![CDATA[" + str.replaceAll("]]", "__") + "]]>";
}
 
Example 19
Source File: RedisAccessTokenStore.java    From nutzwx with Apache License 2.0 4 votes vote down vote up
public RedisAccessTokenStore(String tokenKey, JedisPool jedisPool) {
    if (!Strings.isBlank(tokenKey))
        this.tokenKey = tokenKey;
    this.jedisPool = jedisPool;
}
 
Example 20
Source File: BaseServiceImpl.java    From NutzSite with Apache License 2.0 3 votes vote down vote up
/**
 * 分页关联字段查询(支持关联条件)
 *
 * @param cnd      查询条件
 * @param linkName 关联字段,支持正则 ^(a|b)$
 * @param linkCnd  关联条件
 * @param pager    分页对象
 * @return
 */
@Override
public List<T> query(Condition cnd, String linkName, Condition linkCnd, Pager pager) {
    List<T> list = this.dao().query(this.getEntityClass(), cnd, pager);
    if (!Strings.isBlank(linkName)) {
        this.dao().fetchLinks(list, linkName, linkCnd);
    }
    return list;
}