Java Code Examples for com.baomidou.mybatisplus.core.toolkit.StringUtils#isNotEmpty()

The following examples show how to use com.baomidou.mybatisplus.core.toolkit.StringUtils#isNotEmpty() . 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: RoleServiceImpl.java    From admin-plus with Apache License 2.0 6 votes vote down vote up
@Override
public Result edit(Role role)  throws  Exception{
    System.out.println("======role="+role);
    String idstr = role.getIds();
    if(StringUtils.isNotEmpty(idstr)){
        String[] ids = idstr.split(",");
        BigInteger newRights = RightsHelper.sumRights(ids);
        String qx = role.getQx();
        if("rights".equalsIgnoreCase(qx)){
            role.setRights(newRights);
        }else if("add_qx".equalsIgnoreCase(qx)){
            role.setAddQx(newRights);
        }else if("del_qx".equalsIgnoreCase(qx)){
            role.setDelQx(newRights);
        }else if("edit_qx".equalsIgnoreCase(qx)){
            role.setEditQx(newRights);
        }else if("query_qx".equalsIgnoreCase(qx)){
            role.setQueryQx(newRights);
        }
    }
    this.updateById(role);
    return Result.ok();
}
 
Example 2
Source File: RegisterCenterServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<RegisterCenterModel> findPageByParam(RegisterCenterPageRequest model) {
    PageResult<RegisterCenterModel> pageResult= new PageResult<RegisterCenterModel>();
    Page pageRequest = new Page(model.getPageNo(),model.getPageSize());
    QueryWrapper<RegisterCenter> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(model.getCode())){
        queryWrapper.like("code",model.getCode());
    }
    queryWrapper.eq("is_deleted",Constants.IS_DELETE_FALSE);
    IPage<RegisterCenter> page=registerCenterMapper.selectPage(pageRequest, queryWrapper);
    List<RegisterCenterModel> list= BeanMapper.mapList(page.getRecords(),RegisterCenter.class,RegisterCenterModel.class);
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 3
Source File: UserServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<UserVO> findPageByParam(UserPageListRequest userPageListRequest) {
    Page pageRequest = new Page(userPageListRequest.getPageNo(),userPageListRequest.getPageSize());
    QueryWrapper<User> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(userPageListRequest.getName())){
        queryWrapper.like("name",userPageListRequest.getName());
    }
    if(StringUtils.isNotEmpty(userPageListRequest.getUsername())){
        queryWrapper.like("username",userPageListRequest.getUsername());
    }
    queryWrapper.eq("is_deleted",Constants.IS_DELETE_FALSE);
    IPage<User> page=userMapper.selectPage(pageRequest, queryWrapper);
    List<UserVO> list= BeanMapper.mapList(page.getRecords(),User.class,UserVO.class);
    PageResult<UserVO> pageResult=new PageResult<UserVO>();
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 4
Source File: UserServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
@Transactional
public void update(UserModel model) {
    User entity=userMapper.selectById(model.getId());
    if(null==entity){
        throw new ApplicationException("您更新的用户不存在") ;
    }
    if(StringUtils.isNotEmpty(model.getPassword())){
        entity.setPassword(MD5.md5(entity.getPassword()));
    }
    if(StringUtils.isNotEmpty(model.getEmail())){
        entity.setEmail(model.getEmail());
    }
    if(StringUtils.isNotEmpty(model.getName())){
        entity.setName(model.getName());
    }
    entity.setStatus(model.getStatus());
    entity.setGmtModified(new Timestamp(System.currentTimeMillis()));
    userMapper.updateById(entity);
}
 
Example 5
Source File: ProjectServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<ProjectModel> findPageByParam(ProjectByPageRequest model) {
    Page pageRequest = new Page(model.getPageNo(),model.getPageSize());
    QueryWrapper<Project> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(model.getName())){
        queryWrapper.like("name",model.getName());
    }
    queryWrapper.eq("is_deleted",Constants.IS_DELETE_FALSE);
    IPage<Project> page=projectMapper.selectPage(pageRequest, queryWrapper);
    List<ProjectModel> list= BeanMapper.mapList(page.getRecords(),Project.class,ProjectModel.class);
    PageResult<ProjectModel> pageResult=new PageResult<ProjectModel>();
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 6
Source File: DictServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Override
public PageResult<DictTypeListVO> findByPageVague(DictTypeListRequest dictTypeListRequest) {
    Page pageRequest = new Page(dictTypeListRequest.getPageNo(),dictTypeListRequest.getPageSize());
    QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(dictTypeListRequest.getDictCode())){
        queryWrapper.like("dict_code",dictTypeListRequest.getDictCode());
    }
    if(StringUtils.isNotEmpty(dictTypeListRequest.getDictName())){
        queryWrapper.like("dict_name",dictTypeListRequest.getDictName());
    }
    queryWrapper.eq("is_deleted",Constants.IS_DELETE_FALSE);
    IPage<DictType> page=dictTypeMapper.selectPage(pageRequest, queryWrapper);
    List<DictTypeListVO> list= BeanMapper.mapList(page.getRecords(),DictType.class,DictTypeListVO.class);
    for (DictTypeListVO dictTypeListVO:list) {
        List<DictData> dictDataList= dictDataMapper.findDictDataByDictCode(dictTypeListVO.getDictCode());
        dictTypeListVO.setDictDataModelList(BeanMapper.mapList(dictDataList,DictData.class,DictDataModel.class));
    }
    PageResult<DictTypeListVO> pageResult=new PageResult<DictTypeListVO>();
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 7
Source File: AppServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
/**
 * 查询所有的App
 * @param appId
 * @return
 */
@Override
public List<AppModel> findAllByParamter(String appId,String ownerName,String ownerId) {
    Map<String, Object> param = new HashMap<>();
    if(StringUtils.isNotEmpty(appId)){
        param.put("spring_application_name", appId);
    }
    if(StringUtils.isNotEmpty(ownerName)){
        param.put("owner_name", ownerName);
    }
    if(StringUtils.isNotEmpty(ownerId)){
        param.put("owner_id", ownerId);
    }
    List<App> apps = appMapper.selectByMap(param);
    return BeanMapper.mapList(apps,App.class,AppModel.class);
}
 
Example 8
Source File: AppServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
/**
 * 根据查询条件查询App并分页
 * @param appPageRequest
 * @return
 */
@Override
public PageResult<AppModel> findByPageVague(AppPageRequest appPageRequest) {
    Page pageRequest = new Page(appPageRequest.getPageNo(), appPageRequest.getPageSize());
    QueryWrapper<App> queryWrapper = new QueryWrapper<>();
    if(StringUtils.isNotEmpty(appPageRequest.getProjectName())){
        queryWrapper.like("project_name", appPageRequest.getProjectName());
    }
    if(StringUtils.isNotEmpty(appPageRequest.getStatus())){
        queryWrapper.eq("status",Integer.valueOf(appPageRequest.getStatus()).intValue());
    }
    if(StringUtils.isNotEmpty(appPageRequest.getName())){
        queryWrapper.like("app_id", appPageRequest.getName().toLowerCase());
    }
    if(StringUtils.isNotEmpty(appPageRequest.getTakeOver())){
        queryWrapper.eq("take_over",Long.valueOf(appPageRequest.getTakeOver()).intValue());
    }
    IPage<App> page=appMapper.selectPage(pageRequest, queryWrapper);
    List<AppModel> list= BeanMapper.mapList(page.getRecords(),App.class,AppModel.class);
    PageResult<AppModel> pageResult=new PageResult<AppModel>();
    pageResult.setCurrentPage(page.getCurrent());
    pageResult.setTotalCount(page.getTotal());
    pageResult.setList(list);
    pageResult.setTotalPage(page.getSize());
    return pageResult;
}
 
Example 9
Source File: AppServiceImpl.java    From Moss with Apache License 2.0 6 votes vote down vote up
@Transactional
@Override
public boolean checkAppAndMappingName(String appName) {
    Map<String, Object> param = new HashMap<>();
    if(StringUtils.isNotEmpty(appName)){
        param.put("app_id", appName.toLowerCase());
    }
    List<App> apps = appMapper.selectByMap(param);
    if(null==apps||apps.size()==0){
        return false;
    }
    App app=apps.get(0);
    app.setSpringApplicationName(appName.toLowerCase());
    appMapper.updateById(app);
    return true;

}
 
Example 10
Source File: GatewayRouteController.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 添加路由
 *
 * @param path        路径表达式
 * @param routeName   描述
 * @param serviceId   服务名方转发
 * @param url         地址转发
 * @param stripPrefix 忽略前缀
 * @param retryable   支持重试
 * @param status      是否启用
 * @return
 */
@ApiOperation(value = "添加路由", notes = "添加路由")
@ApiImplicitParams({
        @ApiImplicitParam(name = "path", required = true, value = "路径表达式", paramType = "form"),
        @ApiImplicitParam(name = "routeName", required = true, value = "路由标识", paramType = "form"),
        @ApiImplicitParam(name = "routeDesc", required = true, value = "路由名称", paramType = "form"),
        @ApiImplicitParam(name = "serviceId", required = false, value = "服务名方转发", paramType = "form"),
        @ApiImplicitParam(name = "url", required = false, value = "地址转发", paramType = "form"),
        @ApiImplicitParam(name = "stripPrefix", required = false, allowableValues = "0,1", defaultValue = "1", value = "忽略前缀", paramType = "form"),
        @ApiImplicitParam(name = "retryable", required = false, allowableValues = "0,1", defaultValue = "0", value = "支持重试", paramType = "form"),
        @ApiImplicitParam(name = "status", required = false, allowableValues = "0,1", defaultValue = "1", value = "是否启用", paramType = "form")
})
@PostMapping("/gateway/route/add")
public ResultBody<Long> addRoute(
        @RequestParam(value = "routeName", required = true, defaultValue = "") String routeName,
        @RequestParam(value = "routeDesc", required = true, defaultValue = "") String routeDesc,
        @RequestParam(value = "path") String path,
        @RequestParam(value = "serviceId", required = false) String serviceId,
        @RequestParam(value = "url", required = false) String url,
        @RequestParam(value = "stripPrefix", required = false, defaultValue = "1") Integer stripPrefix,
        @RequestParam(value = "retryable", required = false, defaultValue = "0") Integer retryable,
        @RequestParam(value = "status", defaultValue = "1") Integer status
) {
    GatewayRoute route = new GatewayRoute();
    route.setPath(path);
    route.setServiceId(serviceId);
    route.setUrl(url);
    route.setRetryable(retryable);
    route.setStripPrefix(stripPrefix);
    route.setStatus(status);
    route.setRouteName(routeName);
    route.setRouteDesc(routeDesc);
    if(route.getUrl()!=null && StringUtils.isNotEmpty(route.getUrl())){
        route.setServiceId(null);
    }
    gatewayRouteService.addRoute(route);
    // 刷新网关
    openRestTemplate.refreshGateway();
    return ResultBody.ok();
}
 
Example 11
Source File: GatewayRouteController.java    From open-cloud with MIT License 4 votes vote down vote up
/**
 * 编辑路由
 *
 * @param routeId     路由ID
 * @param path        路径表达式
 * @param serviceId   服务名方转发
 * @param url         地址转发
 * @param stripPrefix 忽略前缀
 * @param retryable   支持重试
 * @param status      是否启用
 * @param routeName   描述
 * @return
 */
@ApiOperation(value = "编辑路由", notes = "编辑路由")
@ApiImplicitParams({
        @ApiImplicitParam(name = "routeId", required = true, value = "路由Id", paramType = "form"),
        @ApiImplicitParam(name = "routeName", required = true, value = "路由标识", paramType = "form"),
        @ApiImplicitParam(name = "routeDesc", required = true, value = "路由名称", paramType = "form"),
        @ApiImplicitParam(name = "path", required = true, value = "路径表达式", paramType = "form"),
        @ApiImplicitParam(name = "serviceId", required = false, value = "服务名方转发", paramType = "form"),
        @ApiImplicitParam(name = "url", required = false, value = "地址转发", paramType = "form"),
        @ApiImplicitParam(name = "stripPrefix", required = false, allowableValues = "0,1", defaultValue = "1", value = "忽略前缀", paramType = "form"),
        @ApiImplicitParam(name = "retryable", required = false, allowableValues = "0,1", defaultValue = "0", value = "支持重试", paramType = "form"),
        @ApiImplicitParam(name = "status", required = false, allowableValues = "0,1", defaultValue = "1", value = "是否启用", paramType = "form")
})
@PostMapping("/gateway/route/update")
public ResultBody updateRoute(
        @RequestParam("routeId") Long routeId,
        @RequestParam(value = "routeName", defaultValue = "") String routeName,
        @RequestParam(value = "routeDesc", defaultValue = "") String routeDesc,
        @RequestParam(value = "path") String path,
        @RequestParam(value = "serviceId", required = false) String serviceId,
        @RequestParam(value = "url", required = false) String url,
        @RequestParam(value = "stripPrefix", required = false, defaultValue = "1") Integer stripPrefix,
        @RequestParam(value = "retryable", required = false, defaultValue = "0") Integer retryable,
        @RequestParam(value = "status", defaultValue = "1") Integer status
) {
    GatewayRoute route = new GatewayRoute();
    route.setRouteId(routeId);
    route.setPath(path);
    route.setServiceId(serviceId);
    route.setUrl(url);
    route.setRetryable(retryable);
    route.setStripPrefix(stripPrefix);
    route.setStatus(status);
    route.setRouteName(routeName);
    route.setRouteDesc(routeDesc);
    if(route.getUrl()!=null  && StringUtils.isNotEmpty(route.getUrl())){
        route.setServiceId(null);
    }
    gatewayRouteService.updateRoute(route);
    // 刷新网关
    openRestTemplate.refreshGateway();
    return ResultBody.ok();
}
 
Example 12
Source File: SqlInjectorUtil.java    From albedo with GNU Lesser General Public License v3.0 4 votes vote down vote up
public static String sqlSelectColumns(TableInfo table, boolean entityWrapper, String columnPrefix, String selectProfix) {
	StringBuilder columns = new StringBuilder();
	if (null != table.getResultMap()) {
		if (entityWrapper) {
			columns.append("<choose><when test=\"ew != null and ew.sqlSelect != null\">${ew.sqlSelect}</when><otherwise>");
		}

		columns.append("*");
		if (entityWrapper) {
			columns.append("</otherwise></choose>");
		}
	} else {
		if (entityWrapper) {
			columns.append("<choose><when test=\"ew != null and ew.sqlSelect != null\">${ew.sqlSelect}</when><otherwise>");
		}

		List<TableFieldInfo> fieldList = table.getFieldList();
		int size = 0;
		if (null != fieldList) {
			size = fieldList.size();
		}

		if (StringUtils.isNotEmpty(table.getKeyProperty())) {
			if (StringUtil.isNotEmpty(columnPrefix)) {
				columns.append('`').append(columnPrefix).append("`.");
			}
			String keyProperty = table.getKeyProperty();
			if (StringUtil.isNotEmpty(selectProfix)) {
				keyProperty = selectProfix + StringUtil.DOT + keyProperty;
			}
			columns.append(table.getKeyColumn()).append(" AS ").append(sqlWordConvert(keyProperty));

			if (size >= 1) {
				columns.append(",");
			}
		}

		if (size >= 1) {
			int i = 0;

			for (Iterator iterator = fieldList.iterator(); iterator.hasNext(); ++i) {
				TableFieldInfo fieldInfo = (TableFieldInfo) iterator.next();
				String property = fieldInfo.getProperty();
				if (StringUtil.isNotEmpty(selectProfix)) {
					property = selectProfix + StringUtil.DOT + property;
				}
				String wordConvert = sqlWordConvert(property);
				if (StringUtil.isNotEmpty(columnPrefix)) {
					columns.append('`').append(columnPrefix).append("`.");
				}
				columns.append(fieldInfo.getColumn());
				columns.append(" AS ").append(wordConvert);

				if (i + 1 < size) {
					columns.append(",");
				}
			}
		}

		if (entityWrapper) {
			columns.append("</otherwise></choose>");
		}
	}

	return columns.toString();
}