com.baomidou.mybatisplus.core.toolkit.StringUtils Java Examples

The following examples show how to use com.baomidou.mybatisplus.core.toolkit.StringUtils. 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: 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 #2
Source File: AbstractLogicCustomMethod.java    From albedo with GNU Lesser General Public License v3.0 6 votes vote down vote up
public String getAllSqlWhere(TableInfo table, boolean ignoreLogicDelFiled, boolean withId, String prefix, String columnPrefix) {
	String newPrefix = prefix == null ? "" : prefix;
	String filedSqlScript = table.getFieldList().stream().filter((i) -> {
		if (!ignoreLogicDelFiled) {
			return true;
		} else {
			return !table.isLogicDelete() || !i.isLogicDelete();
		}
	}).map((i) -> i.getSqlWhere(newPrefix)).collect(Collectors.joining("\n"));
	if (withId && !StringUtils.isEmpty(table.getKeyProperty())) {
		String newKeyProperty = newPrefix + table.getKeyProperty();
		String keySqlScript = columnPrefix + table.getKeyColumn() + "=" + SqlScriptUtils.safeParam(newKeyProperty);
		return SqlScriptUtils.convertIf(keySqlScript, String.format("%s != null", newKeyProperty), false) + "\n" + filedSqlScript;
	} else {
		return filedSqlScript;
	}
}
 
Example #3
Source File: MyBatisUtil.java    From summerframework with Apache License 2.0 6 votes vote down vote up
public static <T> String getFieldName(EntityGetterMethod<T, Object> expression) {
    if (expression == null)
        throw new IllegalArgumentException("Expression should not be null");
    try {
        Method method = expression.getClass().getDeclaredMethod("writeReplace");
        method.setAccessible(Boolean.TRUE);
        SerializedLambda serializedLambda = (SerializedLambda)method.invoke(expression);
        String fieldName = StringUtils.resolveFieldName(serializedLambda.getImplMethodName());
        String className = serializedLambda.getImplClass().replace("/", ".");
        Field field = ReflectionUtils.findField(Class.forName(className), fieldName);
        String columnName = field.getName();
        TableField[] tableField = field.getAnnotationsByType(TableField.class);
        if (null != tableField && tableField.length == 1) {
            if (!StringUtils.isEmpty(tableField[0].value())) {
                columnName = tableField[0].value();
            }
        }
        String ret = StringUtils.camelToUnderline(columnName);
        return ret;
    } catch (ReflectiveOperationException e) {
        throw new RuntimeException("This will never happen!", e);
    }
}
 
Example #4
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 #5
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 #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: 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 #8
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 #9
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 #10
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 #11
Source File: SuperServiceImpl.java    From microservices-platform with Apache License 2.0 6 votes vote down vote up
@Override
public boolean saveOrUpdateIdempotency(T entity, DistributedLock lock, String lockKey, Wrapper<T> countWrapper, String msg) throws Exception {
    if (null != entity) {
        Class<?> cls = entity.getClass();
        TableInfo tableInfo = TableInfoHelper.getTableInfo(cls);
        if (null != tableInfo && StrUtil.isNotEmpty(tableInfo.getKeyProperty())) {
            Object idVal = ReflectionKit.getMethodValue(cls, entity, tableInfo.getKeyProperty());
            if (StringUtils.checkValNull(idVal) || Objects.isNull(getById((Serializable) idVal))) {
                if (StrUtil.isEmpty(msg)) {
                    msg = "已存在";
                }
                return this.saveIdempotency(entity, lock, lockKey, countWrapper, msg);
            } else {
                return updateById(entity);
            }
        } else {
            throw ExceptionUtils.mpe("Error:  Can not execute. Could not find @TableId.");
        }
    }
    return false;
}
 
Example #12
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 #13
Source File: CustomMybatisPlusParameterHandler.java    From sqlhelper with GNU Lesser General Public License v3.0 5 votes vote down vote up
public static Object populateKeys(MetaObjectHandler metaObjectHandler, TableInfo tableInfo, MappedStatement ms, Object parameterObject, boolean isInsert) {
    if (null == tableInfo) {
        return parameterObject;
    } else {
        MetaObject metaObject = ms.getConfiguration().newMetaObject(parameterObject);
        if (isInsert && !StringUtils.isEmpty(tableInfo.getKeyProperty()) && null != tableInfo.getIdType() && tableInfo.getIdType().getKey() >= 3) {
            Object idValue = metaObject.getValue(tableInfo.getKeyProperty());
            if (StringUtils.checkValNull(idValue)) {
                if (tableInfo.getIdType() == IdType.ID_WORKER) {
                    metaObject.setValue(tableInfo.getKeyProperty(), IdWorker.getId());
                } else if (tableInfo.getIdType() == IdType.ID_WORKER_STR) {
                    metaObject.setValue(tableInfo.getKeyProperty(), IdWorker.getIdStr());
                } else if (tableInfo.getIdType() == IdType.UUID) {
                    metaObject.setValue(tableInfo.getKeyProperty(), IdWorker.get32UUID());
                }
            }
        }

        if (metaObjectHandler != null) {
            if (isInsert && metaObjectHandler.openInsertFill()) {
                metaObjectHandler.insertFill(metaObject);
            } else if (!isInsert) {
                metaObjectHandler.updateFill(metaObject);
            }
        }

        return metaObject.getOriginalObject();
    }
}
 
Example #14
Source File: DepotService.java    From jshERP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create by: qiankunpingtai
 * website:https://qiankunpingtai.cn
 * description:
 *  正常删除,要考虑数据完整性,进行完整性校验
 * create time: 2019/4/10 16:52
 * @Param: ids
 * @return int
 */
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteDepotByIdsNormal(String ids) throws Exception {
    /**
     * 校验
     * 1、单据主表	jsh_depothead
     * 2、单据子表	jsh_depotitem
     * 是否有相关数据
     * */
    int deleteTotal=0;
    if(StringUtils.isEmpty(ids)){
        return deleteTotal;
    }
    String [] idArray=ids.split(",");

    /**
     * 校验单据子表	jsh_depotitem
     * */
    List<DepotItem> depotItemList=null;
    try{
        depotItemList=  depotItemMapperEx.getDepotItemListListByDepotIds(idArray);
    }catch(Exception e){
        JshException.readFail(logger, e);
    }
    if(depotItemList!=null&&depotItemList.size()>0){
        logger.error("异常码[{}],异常提示[{}],参数,DepotIds[{}]",
                ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
        throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
                ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
    }
    /**
     * 校验通过执行删除操作
     * */
    deleteTotal= batchDeleteDepotByIds(ids);
    return deleteTotal;

}
 
Example #15
Source File: MaterialService.java    From jshERP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create by: qiankunpingtai
 * website:https://qiankunpingtai.cn
 * description:
 *  正常删除,要考虑数据完整性,进行完整性校验
 * create time: 2019/4/10 18:00
 * @Param: ids
 * @return int
 */
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteMaterialByIdsNormal(String ids) throws Exception{
    /**
     * 校验
     * 1、单据子表	jsh_depotitem
     * 是否有相关数据
     * */
    int deleteTotal=0;
    if(StringUtils.isEmpty(ids)){
        return deleteTotal;
    }
    String [] idArray=ids.split(",");

    /**
     * 校验单据子表	jsh_depotitem
     * */
    List<DepotItem> depotItemList =null;
    try{
        depotItemList=  depotItemMapperEx.getDepotItemListListByMaterialIds(idArray);
    }catch(Exception e){
        JshException.readFail(logger, e);
    }
    if(depotItemList!=null&&depotItemList.size()>0){
        logger.error("异常码[{}],异常提示[{}],参数,MaterialIds[{}]",
                ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
        throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
                ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
    }
    /**
     * 校验通过执行删除操作
     * */
    deleteTotal= batchDeleteMaterialByIds(ids);
    return deleteTotal;

}
 
Example #16
Source File: InOutItemService.java    From jshERP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create by: qiankunpingtai
 * website:https://qiankunpingtai.cn
 * description:
 *  正常删除,要考虑数据完整性,进行完整性校验
 * create time: 2019/4/10 16:23
 * @Param: ids
 * @return int
 */
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteInOutItemByIdsNormal(String ids) throws Exception {
    /**
     * 校验
     * 1、财务子表	jsh_accountitem
     * 是否有相关数据
     * */
    int deleteTotal=0;
    if(StringUtils.isEmpty(ids)){
        return deleteTotal;
    }
    String [] idArray=ids.split(",");
    /**
     * 校验财务子表	jsh_accountitem
     * */
    List<AccountItem> accountItemList=null;
    try{
        accountItemList=accountItemMapperEx.getAccountItemListByInOutItemIds(idArray);
    }catch(Exception e){
        JshException.readFail(logger, e);
    }
    if(accountItemList!=null&&accountItemList.size()>0){
        logger.error("异常码[{}],异常提示[{}],参数,InOutItemIds[{}]",
                ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
        throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
                ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
    }
    /**
     * 校验通过执行删除操作
     * */
    deleteTotal= batchDeleteInOutItemByIds(ids);
    return deleteTotal;

}
 
Example #17
Source File: UnitService.java    From jshERP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create by: qiankunpingtai
 * website:https://qiankunpingtai.cn
 * description:
 *  正常删除,要考虑数据完整性,进行完整性校验
 * create time: 2019/4/11 10:20
 * @Param: ids
 * @return int
 */
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteUnitByIdsNormal(String ids) throws Exception {
    /**
     * 校验
     * 1、产品表	jsh_material
     * 是否有相关数据
     * */
    int deleteTotal=0;
    if(StringUtils.isEmpty(ids)){
        return deleteTotal;
    }
    String [] idArray=ids.split(",");
    /**
     * 校验产品表	jsh_material
     * */
    List<Material> materialList=null;
    try{
        materialList=materialMapperEx.getMaterialListByUnitIds(idArray);
    }catch(Exception e){
        JshException.readFail(logger, e);
    }
    if(materialList!=null&&materialList.size()>0){
        logger.error("异常码[{}],异常提示[{}],参数,UnitIds[{}]",
                ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
        throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
                ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
    }
    /**
     * 校验通过执行删除操作
     * */
    deleteTotal= batchDeleteUnitByIds(ids);
    return deleteTotal;
}
 
Example #18
Source File: AccountHeadService.java    From jshERP with GNU General Public License v3.0 5 votes vote down vote up
/**
 * create by: qiankunpingtai
 * website:https://qiankunpingtai.cn
 * description:
 *  正常删除,要考虑数据完整性,进行完整性校验
 * create time: 2019/4/10 15:49
 * @Param: ids
 * @return int
 */
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
public int batchDeleteAccountHeadByIdsNormal(String ids) throws Exception {
    /**
     * 校验
     * 1、财务子表	jsh_accountitem
     * 是否有相关数据
     * */
    int deleteTotal=0;
    if(StringUtils.isEmpty(ids)){
        return deleteTotal;
    }
    String [] idArray=ids.split(",");
    /**
     * 校验财务子表	jsh_accountitem
     * */
    List<AccountItem> accountItemList = null;
    try{
        accountItemList = accountItemMapperEx.getAccountItemListByHeaderIds(idArray);
    }catch(Exception e){
        JshException.readFail(logger, e);
    }
    if(accountItemList!=null&&accountItemList.size()>0){
        logger.error("异常码[{}],异常提示[{}],参数,HeaderIds[{}]",
                ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,ExceptionConstants.DELETE_FORCE_CONFIRM_MSG,ids);
        throw new BusinessRunTimeException(ExceptionConstants.DELETE_FORCE_CONFIRM_CODE,
                ExceptionConstants.DELETE_FORCE_CONFIRM_MSG);
    }
    /**
     * 校验通过执行删除操作
     * */
    deleteTotal= batchDeleteAccountHeadByIds(ids);
    return deleteTotal;
}
 
Example #19
Source File: BladeCodeGenerator.java    From blade-tool with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 页面生成的文件名
 */
private String getGeneratorViewPath(String viewOutputDir, TableInfo tableInfo, String suffixPath) {
	String name = StringUtils.firstToLowerCase(tableInfo.getEntityName());
	String path = viewOutputDir + "/" + name + "/" + name + suffixPath;
	File viewDir = new File(path).getParentFile();
	if (!viewDir.exists()) {
		viewDir.mkdirs();
	}
	return path;
}
 
Example #20
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 #21
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();
}
 
Example #22
Source File: MyExceptionUtil.java    From ywh-frame with GNU General Public License v3.0 4 votes vote down vote up
public static MyException mxe(String msg, Object... params){
    return new MyException(StringUtils.format(msg, params));
}
 
Example #23
Source File: MyExceptionUtil.java    From ywh-frame with GNU General Public License v3.0 4 votes vote down vote up
public static MyException mxe(String msg, Throwable t, Object... params){
    return new MyException(StringUtils.format(msg, params),t);
}
 
Example #24
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();
}