Java Code Examples for jodd.util.StringUtil#isNotBlank()

The following examples show how to use jodd.util.StringUtil#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: MenuController.java    From DAFramework with MIT License 6 votes vote down vote up
@RequestMapping(value = "/allMenu", method = RequestMethod.POST)
public ActionResultObj findAllmenu(@RequestBody SearchQueryJS queryJs) {
	ActionResultObj result = new ActionResultObj();
	try {
		WMap query = queryJs.getQuery();
		//处理查询条件
		Criteria cnd = Cnd.cri();
		cnd.where().andEquals("del_flag", Constans.POS_NEG.NEG);
		if (query.get("extId") != null && StringUtil.isNotBlank(query.get("extId").toString())) {
			cnd.where().andNotIn("id", query.get("extId").toString());
			cnd.where().andNotLike("parent_ids", "%," + query.get("extId").toString() + ",%");
		}
		cnd.getOrderBy().asc("sort");
		List<EMenu> allMenus = menuDao.query(cnd);
		EMenu menu = menuDao.buildMenuTree(allMenus);
		WMap map = new WMap();
		map.put("data", menu.getItems());
		result.setData(map);
		result.okMsg("查询成功!");
	} catch (Exception e) {
		e.printStackTrace();
		LOG.error("查询失败,原因:" + e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 2
Source File: DictController.java    From DAFramework with MIT License 6 votes vote down vote up
@RequestMapping(value="type/{type}")
public ActionResultObj findByType(@PathVariable String type){
	ActionResultObj result = new ActionResultObj();
	try{
		if(StringUtil.isNotBlank(type)){
				List<EDict> dictList = dictDao.query(Cnd.where("type", "=", type).and("del_flag", "=", Constans.POS_NEG.NEG).orderBy("sort", "asc"));
				//处理返回值
				WMap map = new WMap();
				map.put("type", type);
				map.put("data", dictList);
				result.ok(map);
				result.okMsg("查询成功!");
		}else{
			result.errorMsg("查询失败,字典类型不存在!");
		}
	}catch(Exception e){
		e.printStackTrace();
		LOG.error("查询失败,原因:"+e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 3
Source File: AreaDao.java    From DAFramework with MIT License 6 votes vote down vote up
public EArea allArea(WMap query) {
	//处理查询条件
	Criteria cnd = Cnd.cri();
	cnd.where().andEquals("del_flag", Constans.POS_NEG.NEG);
	if (query.get("extId") != null && StringUtil.isNotBlank(query.get("extId").toString())) {
		cnd.where().andNotIn("id", query.get("extId").toString());
		cnd.where().andNotLike("parent_ids", "%," + query.get("extId").toString() + ",%");
	}
	cnd.getOrderBy().asc("sort");
	List<EArea> allAreas = query(cnd);
	List<ITreeNode<EArea>> allNodes = new ArrayList<>();
	EArea root = new EArea();
	root.setId(0L);
	allNodes.add(root);
	if (allAreas != null && !allAreas.isEmpty()) {
		allNodes.addAll(allAreas);
	}
	return (EArea) root.buildTree(allNodes);
}
 
Example 4
Source File: UserController.java    From DAFramework with MIT License 6 votes vote down vote up
/**
 * 新增一个用户,同时增加account和user
 *
 * @param account
 * @return
 */
@RequestMapping(value = "/save")
public ActionResultObj save(@RequestBody EAccount account) {
	ActionResultObj result = new ActionResultObj();
	try {
		account = userDetailsService.saveUser(account);
		if (account.getId() != null && account.getId() != 0) {
			result.okMsg("保存成功!");
		} else {
			result.errorMsg("保存失败!");
		}
	} catch (Exception e) {
		LOG.error("保存失败,原因:" + e.getMessage());
		result.error(e);
		EUser user = account.getUser();
		if (user.getUsername() != null && StringUtil.isNotBlank(user.getUsername())) {
			if (userDetailsService.isUserExisted(user.getUsername())) {
				result.errorMsg("用户  " + user.getUsername() + " 已存在!");
			}
		}
	}
	return result;
}
 
Example 5
Source File: UserController.java    From DAFramework with MIT License 6 votes vote down vote up
@RequestMapping(value = "/currInfo", method = RequestMethod.GET)
public ActionResultObj getUser() {
	ActionResultObj result = new ActionResultObj();
	// 获取当前用户
	UserDetails userDetails = (UserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	if (StringUtil.isNotBlank(userDetails.getUsername())) {
		EUser currentUser = userDao.fetchByName(userDetails.getUsername());
		EAccount account = accountDao.fetch(currentUser);
		EOrg org = orgDao.fetch(currentUser.getOrgId());
		WMap map = new WMap();
		map.put("userName", account != null ? account.getFullName() : currentUser.getUsername());
		map.put("accountId", account != null ? account.getId() : "");
		map.put("orgName", org.getName());
		result.ok(map);
	} else {
		result.errorMsg("获取失败");
	}
	return result;
}
 
Example 6
Source File: MoneyUtil.java    From DAFramework with MIT License 5 votes vote down vote up
public static Double parseDouble(Object number) {
	if (number != null && number instanceof Number) {
		return ((Number) number).doubleValue();
	} else if (number != null && number instanceof BigDecimal) {
		return ((Number) number).doubleValue();
	} else if (number != null && StringUtil.isNotBlank(number.toString())) {
		return Double.parseDouble(number.toString().trim());
	}
	return null;
}
 
Example 7
Source File: AreaController.java    From DAFramework with MIT License 5 votes vote down vote up
@RequestMapping(value = "/list")
public ActionResultObj list(@RequestBody SearchQueryJS queryJs) {
	ActionResultObj result = new ActionResultObj();
	try {
		Pager pager = queryJs.toPager();
		WMap query = queryJs.getQuery();

		//处理查询条件
		Criteria cnd = Cnd.cri();
		cnd.where().andEquals("del_flag", Constans.POS_NEG.NEG);
		if (query.get("name") != null && StringUtil.isNotBlank(query.get("name").toString())) {
			cnd.where().andLike("name", query.get("name").toString()).orLike("full_name", query.get("name").toString());
		}
		cnd.getOrderBy().asc("sort");

		//分页查询
		List<EArea> areaList = areaDao.query(cnd, pager);
		pager.setRecordCount(areaDao.count(cnd));

		//处理返回值
		WMap map = new WMap();
		if (queryJs.getQuery() != null) {
			map.putAll(queryJs.getQuery());
		}
		map.put("data", areaList);
		map.put("page", queryJs.toWPage(pager));
		result.ok(map);
		result.okMsg("查询成功!");
	} catch (Exception e) {
		e.printStackTrace();
		LOG.error("查询失败,原因:" + e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 8
Source File: DictController.java    From DAFramework with MIT License 5 votes vote down vote up
@RequestMapping(value="list")
public ActionResultObj list(@RequestBody SearchQueryJS queryJs){
	ActionResultObj result = new ActionResultObj();
	try{
		Pager pager = queryJs.toPager();
		WMap query = queryJs.getQuery();
		
		//处理查询条件
		Criteria cnd = Cnd.cri();
		if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){
			cnd.where().andEquals("type", query.get("type").toString());
		}
		cnd.getGroupBy().groupBy("type");
		cnd.getOrderBy().desc("sort");
		//分页查询
		List<EDict> projectList = dictDao.query(cnd, pager);
		
		//处理返回值
		WMap map = new WMap();
		if(queryJs.getQuery() != null){
			map.putAll(queryJs.getQuery());
		}
		map.put("data", projectList);
		map.put("page", queryJs.toWPage(pager));
		result.ok(map);
		result.okMsg("查询成功!");
	}catch(Exception e){
		e.printStackTrace();
		LOG.error("查询失败,原因:"+e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 9
Source File: OrgController.java    From DAFramework with MIT License 5 votes vote down vote up
@RequestMapping(value = "/getOrgs/{type}")
public ActionResultObj getOrgsByListByType(@PathVariable String type) {
	ActionResultObj result = new ActionResultObj();
	try {
		if (StringUtil.isNotBlank(type)) {
			// 处理查询条件
			Criteria cnd = Cnd.cri();
			if(!type.equals("all")){
				cnd.where().andEquals("type", type);
			}
			cnd.getOrderBy().desc("id");

			// 分页查询
			List<EOrg> orgList = orgDao.query(cnd);

			// 处理返回值
			WMap map = new WMap();
			map.put("data", orgList);
			result.ok(map);
			result.okMsg("查询成功!");
		} else {
			result.errorMsg("删除失败,链接不存在!");
		}
	} catch (Exception e) {
		e.printStackTrace();
		LOG.error("查询失败,原因:" + e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 10
Source File: XSSUtil.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 校验 是否是非法XSS攻击字符
 *
 * @param value 需要校验的字符串
 * @return 校验后的字符串
 */
public static String checkXssStr(String value) {
    if (StringUtil.isNotBlank(value) && sqlInject(value)) {
        logger.error("提交参数存在非法字符!,value:{}", value);
        throw new RuntimeException("提交参数存在非法字符!value:" + value);
    }
    value = scriptingFilter(value);
    return value;
}
 
Example 11
Source File: MoneyUtil.java    From DAFramework with MIT License 5 votes vote down vote up
public static Long parseLong(Object number) {
	if (number != null && number instanceof Number) {
		return ((Number) number).longValue();
	} else if (number != null && number instanceof BigDecimal) {
		return ((Number) number).longValue();
	} else if (number != null && StringUtil.isNotBlank(number.toString())) {
		return Long.parseLong(number.toString().trim());
	}
	return null;
}
 
Example 12
Source File: EMenu.java    From DAFramework with MIT License 5 votes vote down vote up
public List<Long> getPids() {
	if (!StringUtil.equals(parentIds, ",0,")) {
		pids = new ArrayList<>();
		parentIds = StringUtil.replace(parentIds, ",0,", "");
		String[] pidsStr = StringUtil.split(parentIds, ",");
		for (String pidStr : pidsStr) {
			if (StringUtil.isNotBlank(pidStr) && !StringUtil.equals(pidStr, "0")) {
				pids.add(Long.parseLong(pidStr));
			}
		}
		return pids;
	}
	return new ArrayList<>();
}
 
Example 13
Source File: EArea.java    From DAFramework with MIT License 5 votes vote down vote up
public List<Long> getPids() {
	if (!StringUtil.equals(parentIds, ",0,")) {
		pids = new ArrayList<>();
		parentIds = StringUtil.replace(parentIds, ",0,", "");
		String[] pidsStr = StringUtil.split(parentIds, ",");
		for (String pidStr : pidsStr) {
			if (StringUtil.isNotBlank(pidStr) && !StringUtil.equals(pidStr, "0")) {
				pids.add(Long.parseLong(pidStr));
			}
		}
		return pids;
	}
	return new ArrayList<>();
}
 
Example 14
Source File: UserController.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequiresPermissions("ueboot:user:save")
@PostMapping(value = "/save")
public Response<Void> save(@RequestBody UserReq req) {
    User entity = null;
    if (req.getId() == null) {
        entity = new User();
        User user = this.userService.findByUserName(req.getUserName());
        if (user != null) {
            throw new BusinessException("当前用户名已经存在,不能重复添加!");
        }
    } else {
        entity = userService.findById(req.getId());
    }

    BeanUtils.copyProperties(req, entity, "password");
    if (StringUtil.isNotBlank(req.getPassword())) {
        entity.setPassword(PasswordUtil.sha512(entity.getUserName(), req.getPassword()));
        if (req.getCredentialExpiredDate() == null) {
            JDateTime dateTime = new JDateTime();
            //默认密码过期日期为x个月,x个月后要求更换密码
            Date expiredDate = dateTime.addMonth(this.shiroService.getPasswordExpiredMonth()).convertToDate();
            entity.setCredentialExpiredDate(expiredDate);
        }
    }
    //解锁
    if(!req.isLocked()){
        String key = MessageFormat.format(RetryLimitHashedCredentialsMatcher .PASSWORD_RETRY_CACHE,req.getUserName());
        redisTemplate.delete(key);
    }
    userService.save(entity);

    // 保存用户日志记录
    String optUserName = (String) SecurityUtils.getSubject().getPrincipal();
    this.shiroEventListener.saveUserEvent(optUserName, req.getUserName());
    return new Response<>();
}
 
Example 15
Source File: ResourcesController.java    From ueboot with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequiresPermissions("ueboot:resources:save")
@PostMapping(value = "/save")
public Response<Void> save(@RequestBody ResourcesReq req) {
    Resources entity = null;
    if (req.getId() == null) {
        entity = new Resources();
    } else {
        entity = resourcesService.get(req.getId());
    }
    BeanUtils.copyProperties(req, entity);
    //菜单样式配置
    Map<String, String> theme = new HashMap<>();
    if (StringUtil.isNotBlank(req.getIconName())) {
        theme.put("iconName", req.getIconName());
    }
    if (StringUtil.isNotBlank(req.getFontColor())) {
        theme.put("fontColor", req.getFontColor());
    }
    if (theme.size() > 0) {
        entity.setThemeJson(JSON.toJSONString(theme));
    } else {
        entity.setThemeJson(null);
    }
    if (req.getParentId() != 0L) {
        Resources parent = resourcesService.findById(req.getParentId());
        Assert.notNull(parent, "父节点不存在");
        entity.setParent(parent);
        entity.setParentName(parent.getName());
    } else {
        entity.setParent(null);
        entity.setParentName(null);
    }

    resourcesService.save(entity);

    // 保存/修改资源日志记录
    String optUserName = (String) SecurityUtils.getSubject().getPrincipal();
    this.shiroEventListener.saveResourceEvent(optUserName, req.getName());
    return new Response<>();
}
 
Example 16
Source File: FileController.java    From DAFramework with MIT License 5 votes vote down vote up
@RequestMapping(value="/list")
public ActionResultObj list(@RequestBody SearchQueryJS queryJs){
	ActionResultObj result = new ActionResultObj();
	try{
		Pager pager = queryJs.toPager();
		WMap query = queryJs.getQuery();
		
		//处理查询条件
		Criteria cnd = Cnd.cri();
		if(query.get("type") != null && StringUtil.isNotBlank(query.get("type").toString())){
			cnd.where().andEquals("type", query.get("type").toString());
		}
		cnd.getGroupBy().groupBy("type");
		cnd.getOrderBy().desc("sort");
		//分页查询
		List<EFile> projectList = fileDao.query(cnd, pager);
		
		//处理返回值
		WMap map = new WMap();
		if(queryJs.getQuery() != null){
			map.putAll(queryJs.getQuery());
		}
		map.put("data", projectList);
		map.put("page", queryJs.toWPage(pager));
		result.ok(map);
		result.okMsg("查询成功!");
	}catch(Exception e){
		e.printStackTrace();
		LOG.error("查询失败,原因:"+e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 17
Source File: OrgController.java    From DAFramework with MIT License 4 votes vote down vote up
@RequestMapping(value = "/list")
public ActionResultObj list(@RequestBody SearchQueryJS queryJs) {
	ActionResultObj result = new ActionResultObj();
	try {
		Pager pager = queryJs.toPager();
		WMap query = queryJs.getQuery();

		// 处理查询条件
		Criteria cnd = Cnd.cri();
		cnd.where().andEquals("del_flag", Constans.POS_NEG.NEG);
		if (query.get("queryArea") != null && StringUtil.isNotBlank(query.get("queryArea").toString())) {
			cnd.where().andEquals("area_id", query.get("queryArea").toString());
		}
		if (query.get("queryType") != null && StringUtil.isNotBlank(query.get("queryType").toString())) {
			cnd.where().andEquals("type", query.get("queryType").toString());
		}
		if (query.get("queryName") != null && StringUtil.isNotBlank(query.get("queryName").toString())) {
			cnd.where().andLike("name", "%" + query.get("queryName").toString() + "%");
		}
		cnd.getOrderBy().asc("id");

		// 分页查询
		List<EOrg> orgList = orgDao.query(cnd, pager);
		pager.setRecordCount(orgDao.count(cnd));
		for (EOrg eOrg : orgList) {
			EArea area = areaDao.fetch(eOrg.getAreaId());
			if (area != null) {
				eOrg.setArea(area);
			}
		}

		// 处理返回值
		WMap map = new WMap();
		if (queryJs.getQuery() != null) {
			map.putAll(queryJs.getQuery());
		}
		map.put("data", orgList);
		map.put("page", queryJs.toWPage(pager));
		result.ok(map);
		result.okMsg("查询成功!");
	} catch (Exception e) {
		e.printStackTrace();
		LOG.error("查询失败,原因:" + e.getMessage());
		result.error(e);
	}
	return result;
}
 
Example 18
Source File: GeneratorDialog.java    From ueboot with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private void readDefaultSetting() {
    String userHome = System.getProperty("user.home");
    String path = userHome + separator + "ueboot.properties";
    File file = new File(path);
    if (file.exists()) {
        Properties pro = new Properties();
        try {
            FileInputStream in = new FileInputStream(path);
            pro.load(in);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }

        String entityModuleNameValue = (String) pro.get("entityModuleName");
        String repositoryModuleNameValue = (String) pro.get("repositoryModuleName");
        String controllerModuleNameValue = (String) pro.get("controllerModuleName");
        String vuePageModuleNameValue = (String) pro.get("vuePageModuleName");
        String serviceModuleNameValue = (String) pro.get("serviceModuleName");

        String entityPackageNameValue = (String) pro.get("entityPackageName");
        String repositoryPackageNameValue = (String) pro.get("repositoryPackageName");
        String servicePackageNameValue = (String) pro.get("servicePackageName");
        String controllerPackageNameValue = (String) pro.get("controllerPackageName");
        String vueFilePathValue = (String) pro.get("vueFilePathName");
        String requestPathValue = (String) pro.get("requestPath");

        if (StringUtil.isNotBlank(entityModuleNameValue)) {
            entityModuleName.setText(entityModuleNameValue);
        }
        if (StringUtil.isNotBlank(repositoryModuleNameValue)) {
            repositoryModuleName.setText(repositoryModuleNameValue);
        }
        if (StringUtil.isNotBlank(controllerModuleNameValue)) {
            controllerModuleName.setText(controllerModuleNameValue);
        }
        if (StringUtil.isNotBlank(vuePageModuleNameValue)) {
            vuePageModuleName.setText(vuePageModuleNameValue);
        }
        if (StringUtil.isNotBlank(serviceModuleNameValue)) {
            serviceModuleName.setText(serviceModuleNameValue);
        }

        if (StringUtil.isNotBlank(entityPackageNameValue)) {
            entityPackageName.setText(entityPackageNameValue);
        }
        if (StringUtil.isNotBlank(repositoryPackageNameValue)) {
            repositoryPackageName.setText(repositoryPackageNameValue);
        }
        if (StringUtil.isNotBlank(servicePackageNameValue)) {
            servicePackageName.setText(servicePackageNameValue);
        }
        if (StringUtil.isNotBlank(controllerPackageNameValue)) {
            controllerPackageName.setText(controllerPackageNameValue);
        }
        if (StringUtil.isNotBlank(vueFilePathValue)) {
            vueFilePath.setText(vueFilePathValue);
        }
        if (StringUtil.isNotBlank(requestPathValue)) {
            requestPath.setText(requestPathValue);
        }
    }
}