添加分组树搜索条件

pull/22/head
rays 2021-06-18 18:36:59 +08:00
parent c0eceb4690
commit a07ae49b63
6 changed files with 59 additions and 6 deletions

View File

@ -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);
}

View File

@ -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>

View File

@ -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);
}

View File

@ -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;

View File

@ -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);

View File

@ -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);