mirror of https://gitee.com/stylefeng/roses
添加分组树搜索条件
parent
c0eceb4690
commit
a07ae49b63
|
@ -1,7 +1,11 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.resource.mapper;
|
||||
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ApiGroupRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiResource;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 接口信息 Mapper 接口
|
||||
|
@ -11,4 +15,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||
*/
|
||||
public interface ApiResourceMapper extends BaseMapper<ApiResource> {
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*
|
||||
* @param apiGroupRequest 分组请求数据
|
||||
* @return {@link java.util.List<cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiResource>}
|
||||
* @author majianguo
|
||||
* @date 2021/6/18 下午6:30
|
||||
**/
|
||||
List<ApiResource> dataList(@Param("paramCondition") ApiGroupRequest apiGroupRequest);
|
||||
}
|
|
@ -2,4 +2,28 @@
|
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.stylefeng.roses.kernel.system.modular.resource.mapper.ApiResourceMapper">
|
||||
|
||||
<select id="dataList" resultType="cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiResource">
|
||||
SELECT
|
||||
ar.api_resource_id,
|
||||
ar.group_id,
|
||||
ar.request_method,
|
||||
ar.api_alias,
|
||||
ar.resource_code,
|
||||
ar.last_request_header,
|
||||
ar.last_request_content,
|
||||
ar.last_response_content,
|
||||
ar.resource_sort,
|
||||
ar.create_time,
|
||||
ar.create_user,
|
||||
ar.update_time,
|
||||
ar.update_user
|
||||
FROM
|
||||
api_resource ar
|
||||
LEFT JOIN sys_resource sr ON ar.resource_code = sr.resource_code
|
||||
WHERE 1=1
|
||||
<if test="paramCondition.groupName != null and paramCondition.groupName != ''">
|
||||
AND sr.resource_name LIKE CONCAT('%', #{paramCondition.groupName}, '%')
|
||||
OR sr.url LIKE CONCAT('%', #{paramCondition.groupName}, '%')
|
||||
</if>
|
||||
</select>
|
||||
</mapper>
|
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.system.modular.resource.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.db.api.pojo.page.PageResult;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ApiGroupRequest;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ApiResourceRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiResource;
|
||||
import cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiResourceField;
|
||||
|
@ -95,4 +96,14 @@ public interface ApiResourceService extends IService<ApiResource> {
|
|||
* @date 2021/5/27 下午3:34
|
||||
**/
|
||||
ApiResource reset(ApiResourceRequest apiResourceRequest);
|
||||
|
||||
/**
|
||||
* 数据列表
|
||||
*
|
||||
* @param apiGroupRequest 分组请求数据
|
||||
* @return {@link java.util.List<cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiResource>}
|
||||
* @author majianguo
|
||||
* @date 2021/6/18 下午6:28
|
||||
**/
|
||||
List<ApiResource> dataList(ApiGroupRequest apiGroupRequest);
|
||||
}
|
|
@ -176,6 +176,7 @@ public class ApiGroupServiceImpl extends ServiceImpl<ApiGroupMapper, ApiGroup> i
|
|||
Map<String, SysResource> stringSysResourceMap = new HashMap<>();
|
||||
LambdaQueryWrapper<SysResource> sysResourceLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
sysResourceLambdaQueryWrapper.eq(SysResource::getViewFlag, YesOrNotEnum.N.getCode());
|
||||
|
||||
List<SysResource> sysResources = this.sysResourceService.list(sysResourceLambdaQueryWrapper);
|
||||
for (SysResource sysResource : sysResources) {
|
||||
stringSysResourceMap.put(sysResource.getResourceCode(), sysResource);
|
||||
|
@ -204,8 +205,8 @@ public class ApiGroupServiceImpl extends ServiceImpl<ApiGroupMapper, ApiGroup> i
|
|||
}
|
||||
}
|
||||
|
||||
// 查询所有资源
|
||||
List<ApiResource> apiResourceList = this.apiResourceService.list();
|
||||
// 查询资源
|
||||
List<ApiResource> apiResourceList = this.apiResourceService.dataList(apiGroupRequest);
|
||||
if (ObjectUtil.isNotEmpty(apiResourceList)) {
|
||||
for (ApiResource apiResource : apiResourceList) {
|
||||
ApiGroupTreeWrapper item = new ApiGroupTreeWrapper();
|
||||
|
@ -219,8 +220,8 @@ public class ApiGroupServiceImpl extends ServiceImpl<ApiGroupMapper, ApiGroup> i
|
|||
SysResource sysResource = stringSysResourceMap.get(apiResource.getResourceCode());
|
||||
if (ObjectUtil.isNotEmpty(sysResource)) {
|
||||
item.setUrl(sysResource.getUrl());
|
||||
allApiGroupTreeWrapperList.add(item);
|
||||
}
|
||||
allApiGroupTreeWrapperList.add(item);
|
||||
}
|
||||
}
|
||||
return allApiGroupTreeWrapperList;
|
||||
|
|
|
@ -13,6 +13,7 @@ import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.FieldMetadata;
|
|||
import cn.stylefeng.roses.kernel.scanner.api.pojo.resource.ResourceDefinition;
|
||||
import cn.stylefeng.roses.kernel.system.api.exception.SystemModularException;
|
||||
import cn.stylefeng.roses.kernel.system.api.exception.enums.resource.ApiResourceExceptionEnum;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ApiGroupRequest;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ApiResourceFieldRequest;
|
||||
import cn.stylefeng.roses.kernel.system.api.pojo.resource.ApiResourceRequest;
|
||||
import cn.stylefeng.roses.kernel.system.modular.resource.entity.ApiGroup;
|
||||
|
@ -318,7 +319,6 @@ public class ApiResourceServiceImpl extends ServiceImpl<ApiResourceMapper, ApiRe
|
|||
// 删除原有的
|
||||
this.del(apiResourceRequest);
|
||||
|
||||
|
||||
// 新增一个新的
|
||||
apiResourceRequest.setResourceSort(oldApiResource.getResourceSort());
|
||||
this.add(apiResourceRequest);
|
||||
|
@ -327,6 +327,11 @@ public class ApiResourceServiceImpl extends ServiceImpl<ApiResourceMapper, ApiRe
|
|||
return this.getById(apiResourceRequest.getApiResourceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiResource> dataList(ApiGroupRequest apiGroupRequest) {
|
||||
return this.baseMapper.dataList(apiGroupRequest);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ApiResource> findList(ApiResourceRequest apiResourceRequest) {
|
||||
LambdaQueryWrapper<ApiResource> wrapper = this.createWrapper(apiResourceRequest);
|
||||
|
|
|
@ -205,8 +205,7 @@ public class SysResourceServiceImpl extends ServiceImpl<SysResourceMapper, SysRe
|
|||
|
||||
// 查询条件
|
||||
if (ObjectUtil.isNotEmpty(resourceRequest.getResourceName())) {
|
||||
sysResourceLambdaQueryWrapper.like(SysResource::getUrl, resourceRequest.getUrl());
|
||||
sysResourceLambdaQueryWrapper.like(SysResource::getResourceName, resourceRequest.getResourceName());
|
||||
sysResourceLambdaQueryWrapper.like(SysResource::getUrl, resourceRequest.getUrl()).or().like(SysResource::getResourceName, resourceRequest.getResourceName());
|
||||
}
|
||||
|
||||
List<SysResource> allResource = this.list(sysResourceLambdaQueryWrapper);
|
||||
|
|
Loading…
Reference in New Issue