Java Code Examples for org.nutz.lang.Strings#isNotBlank()
The following examples show how to use
org.nutz.lang.Strings#isNotBlank() .
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: CategoryController.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 选择菜单树 */ @At("/selectTree/?") @Ok("th:/cms/category/tree.html") public void selectTree(String id, HttpServletRequest req) { Category category = null; if(Strings.isNotBlank(id)) { category = categoryService.fetch(id); } if (category ==null) { category=new Category(); category.setId(""); category.setParentId("0"); category.setName("无"); } req.setAttribute("category",category); }
Example 2
Source File: CategoryController.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 新增栏目 */ @At({"/add/?","/add"}) @Ok("th:/cms/category/add.html") public void add(@Param("id") String id, HttpServletRequest req) { Category category = null; if(Strings.isNotBlank(id)) { category = categoryService.fetch(id); } if(Lang.isNotEmpty(category)) { category.setParentName(category.getName()); }else{ category=new Category(); category.setParentId("0"); category.setName("无"); } req.setAttribute("category",category); }
Example 3
Source File: WxMenuController.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 选择菜单树 */ @At("/selectTree/?") @Ok("th:/wx/menu/tree.html") public void selectTree(String id, HttpServletRequest req) { WxMenu wxMenu = null; if(Strings.isNotBlank(id)) { wxMenu = wxMenuService.fetch(id); } if (wxMenu ==null) { wxMenu =new WxMenu(); wxMenu.setId(""); wxMenu.setParentId("0"); wxMenu.setName("无"); } req.setAttribute("menu", wxMenu); }
Example 4
Source File: ProfileController.java From NutzSite with Apache License 2.0 | 6 votes |
@At @POST @Ok("json") @Slog(tag="个人信息", after="重置密码") public Result resetPwdDo(@Param("oldPassword") String oldPassword, @Param("newPassword") String newPassword) { User user = ShiroUtils.getSysUser(); String old = new Sha256Hash(oldPassword, user.getSalt(), 1024).toBase64(); if (Strings.isNotBlank(newPassword) && old.equals(user.getPassword())) { user.setPassword(newPassword); if (userService.resetUserPwd(user) > 0) { ShiroUtils.setSysUser(userService.fetch(user.getId())); return Result.success("system.success"); } return Result.error("system.error"); } else { return Result.error("profile.resetpwd"); } }
Example 5
Source File: AreaServiceImpl.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 查询数据树 * @param parentId * @param name * @return */ @Override public List<Map<String, Object>> selectTree(String parentId, String name) { Cnd cnd = Cnd.NEW(); if (Strings.isNotBlank(name)) { //cnd.and("name", "like", "%" + name + "%"); } if (Strings.isNotBlank(parentId)) { cnd.and("parent_id", "=", parentId); } // cnd.and("status", "=", false).and("del_flag", "=", false); List<Area> list = this.query(cnd); List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); trees = getTrees(list); return trees; }
Example 6
Source File: RoleServiceImpl.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 校验角色名称是否唯一 * @param roleName * @return */ @Override public boolean checkRoleNameUnique(String id, String roleName, String roleKey) { Cnd cnd =Cnd.NEW(); if(Strings.isNotBlank(id)){ cnd.and("id","!=",id); } if(Strings.isNotBlank(roleName)){ cnd.and("role_name", "=", roleName); } if(Strings.isNotBlank(roleKey)){ cnd.and("role_key", "=", roleKey); } List<Role> roleList = this.query(cnd); if (Lang.isEmpty(roleList)) { return true; } return false; }
Example 7
Source File: RoleServiceImpl.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 更新角色 * * @param data * @return */ @Override public int update(Role data) { List<String> ids = new ArrayList<>(); if (data != null && data.getMenuIds() != null) { if (Strings.isNotBlank(data.getMenuIds())) { ids = Arrays.asList(data.getMenuIds().split(",")); } //清除已有关系 Role tmpData = this.fetch(data.getId()); this.fetchLinks(tmpData, "menus"); dao().clearLinks(tmpData, "menus"); } if (ids != null && ids.size() > 0) { Criteria cri = Cnd.cri(); cri.where().andInStrList("id", ids); List<Menu> menuList = menuService.query(cri); data.setMenus(menuList); } int count = dao().update(data); dao().insertRelation(data, "menus"); return count; }
Example 8
Source File: BaseServiceImpl.java From NutzSite with Apache License 2.0 | 6 votes |
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 9
Source File: UserServiceImpl.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 更新角色 * * @param data */ @Override public void updataRelation(User data) { List<String> ids = new ArrayList<>(); if (data != null && Strings.isNotBlank(data.getRoleIds())) { if (Strings.isNotBlank(data.getRoleIds())) { ids = Arrays.asList(data.getRoleIds().split(",")); } //清除已有关系 User tmpData = this.fetch(data.getId()); this.fetchLinks(tmpData, "roles"); dao().clearLinks(tmpData, "roles"); } if (ids != null && ids.size() > 0) { Criteria cri = Cnd.cri(); cri.where().andInStrList("id", ids); List<Role> roleList = roleService.query(cri); data.setRoles(roleList); } //更新关系 dao().insertRelation(data, "roles"); }
Example 10
Source File: MenuServiceImpl.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 根据角色ID查询菜单 * * @param roleId 角色对象 * @return 菜单列表 */ @Override public List<Map<String, Object>> roleMenuTreeData(String roleId) { List<Map<String, Object>> trees = new ArrayList<Map<String, Object>>(); List<String> roleMenuList = new ArrayList<>(); if(Strings.isNotBlank(roleId)){ Role role = roleService.fetch(roleId); role = roleService.fetchLinks(role, "menus"); if (role.getMenus() != null && role.getMenus().size() > 0) { role.getMenus().forEach(menu -> { roleMenuList.add(menu.getId() + menu.getPerms()); }); } } List<Menu> menuList = this.query(Cnd.NEW().orderBy("order_num","asc")); if (Strings.isNotBlank(roleId)) { trees = getTrees(menuList, true, roleMenuList, true); } else { trees = getTrees(menuList, false, null, true); } return trees; }
Example 11
Source File: XssHttpServletRequestWrapper.java From NutzSite with Apache License 2.0 | 6 votes |
/** * 覆盖getParameter方法,将参数名和参数值都做xss过滤。<br/> * 如果需要获得原始的值,则通过super.getParameterValues(name)来获取<br/> * getParameterNames,getParameterValues和getParameterMap也可能需要覆盖 */ @Override public String getParameter(String name) { if(("content".equals(name) || name.endsWith("WithHtml")) && !isIncludeRichText){ return super.getParameter(name); } name = JsoupUtil.clean(name); String value = super.getParameter(name); if (Strings.isNotBlank(value)) { // HTML transformation characters value = JsoupUtil.clean(value); // SQL injection characters value = StringEscapeUtils.escapeSql(value); } return value; }
Example 12
Source File: MaterialServiceImpl.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 获取素材 * @param token * @param type * @param count * @return */ private static List<Material> getWxMaterial(String token,String type,long count){ //计算页数 double temp = Math.ceil(count / (double)20); int offset = (int) temp; List<Material> materialList =new ArrayList<>(); for(int i=0; i <= offset; i++){ String param = JSON.toJSONString(new MaterialParam(type,i,20)); System.out.println(param); String res = HttpUtils.sendPostJson(material_url + token, param); System.out.println(res); if(Strings.isNotBlank(res) && !res.contains("errcode")){ MaterialData materialData = JSON.parseObject(res, MaterialData.class); if(Lang.isNotEmpty(materialData) && materialData.item.size()>0){ materialData.item.forEach(material->{ Material m =new Material(); m.setType(type); m.setMediaId(material.media_id); m.setUpdateTime(material.update_time); if("news".equals(type)){ m.setContent(material.content); }else { m.setName(material.name); m.setUrl(material.url); } materialList.add(m); }); } } } return materialList; }
Example 13
Source File: ImageServiceImpl.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 图片存储共用类 * @param tempFile * @param type * @param userId * @return */ @Override public String save(TempFile tempFile, ImageType type , String userId, String id){ if(Strings.isNotBlank(id)){ this.delete(id); } Image image =new Image(); String url; switch (type){ case Base64: url =UpLoadUtil.upLoadFileBase64(tempFile); image.setPhotoType(Base64.getType()); image .setBase64(url); break; case Qiniu: url =UpLoadUtil.upLoadFile(tempFile); image.setPhotoType(Qiniu.getType()); image .setUrl(url); break; default: url =UpLoadUtil.upLoadFileSysConfigPath(tempFile,userId); image.setPhotoType(Local.getType()); image .setLocalPath(url); break; } image = this.insert(image); return image.getId(); }
Example 14
Source File: CategoryServiceImpl.java From NutzSite with Apache License 2.0 | 5 votes |
@Override public int update(Category category) { if(Lang.isNotEmpty(category) && Strings.isNotBlank(category.getParentId())){ Category parent = this.fetch(category.getParentId()); if(Lang.isNotEmpty(parent)){ category.setParentIds(parent.getParentIds() + "," + category.getParentId()); } } return super.update(category); }
Example 15
Source File: OpenWeixinController.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 查询微信openID * @param code * @return */ @At @Ok("json:full") public Object getOpenId(@Param("code") String code) { if (Strings.isNotBlank(code)) { String openId = HttpUtils.sendGet(MpConfig.api_url, "appid=" + MpConfig.appID + "&secret=" + MpConfig.appSecret + "&js_code=" + code + "&grant_type=authorization_code"); Map maps = (Map) JSON.parse(openId); return Result.success("请求成功", maps.get("openid")); } return Result.error("参数错误"); }
Example 16
Source File: AreaController.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 新增区域 */ @At({"/add","/add/*"}) @Ok("th:/sys/area/add.html") public void add(@Param("id") String id, HttpServletRequest req) { Area area = null; if (Strings.isNotBlank(id)) { area = areaService.fetch(id); } if (area ==null) { area =new Area(); area.setParentId("0"); area.setName("无"); } req.setAttribute("area", area); }
Example 17
Source File: AreaController.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 选择菜单树 */ @At("/selectTree/?") @Ok("th:/sys/area/tree.html") public void selectTree(String id, HttpServletRequest req) { Area area = null; if (Strings.isNotBlank(id)) { area = areaService.fetch(id); } if (area ==null) { area =new Area(); area.setParentId("0"); area.setName("无"); } req.setAttribute("area", area); }
Example 18
Source File: DeptController.java From NutzSite with Apache License 2.0 | 5 votes |
@At @Ok("json") public Object list(@Param("deptName") String deptName, HttpServletRequest req) { Cnd cnd = Cnd.NEW(); if (Strings.isNotBlank(deptName)) { cnd.and("dept_name", "like", "%" + deptName + "%"); } cnd.and("del_flag", "=", false); return deptService.query(cnd); }
Example 19
Source File: DeptController.java From NutzSite with Apache License 2.0 | 5 votes |
@At("/add/?") @Ok("th:/sys/dept/add.html") public void add(@Param("id") String id, HttpServletRequest req) { Dept data = null; if (Strings.isNotBlank(id)) { data = deptService.fetch(id); } if (data == null) { data = new Dept(); data.setId("0"); data.setDeptName("无"); } req.setAttribute("dept", data); }
Example 20
Source File: GenServiceImpl.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 查询数据库表信息 * * @param tableName * @param tableComment * @param pageNumber * @param pageSize * @return */ @Override public TableDataInfo selectTableList(String tableName, String tableComment, int pageNumber, int pageSize, String orderByColumn, String isAsc) { String sqlstr = "select table_name, table_comment, create_time, update_time from information_schema.tables " + "where table_comment <> '' and table_schema = (select database()) "; if (Strings.isNotBlank(tableName)) { sqlstr += "and table_name like @tableName"; } if (Strings.isNotBlank(tableComment)) { sqlstr += "and table_comment like @tableComment"; } if (Strings.isNotBlank(orderByColumn) && Strings.isNotBlank(isAsc)) { MappingField field =dao.getEntity(TableInfo.class).getField(orderByColumn); if(Lang.isNotEmpty(field)){ sqlstr += " order by " + field.getColumnName() + " " + isAsc; } } Sql sql = Sqls.create(sqlstr); sql.params().set("tableName", "%" + tableName + "%"); sql.params().set("tableComment", "%" + tableComment + "%"); sql.setCallback(Sqls.callback.entities()); Entity<TableInfo> entity = dao.getEntity(TableInfo.class); Pager pager = dao.createPager(pageNumber, pageSize); //记录数需手动设置 pager.setRecordCount((int) Daos.queryCount(dao, sql)); sql.setPager(pager); sql.setEntity(entity).setCondition(Cnd.wrap(sqlstr)); dao.execute(sql); // return sql.getList(TableInfo.class); return new TableDataInfo(sql.getList(TableInfo.class), pager.getRecordCount()); }