mirror of https://gitee.com/stylefeng/roses
【7.6.0】【group】更新条件查询的Api
parent
335d1821e8
commit
76ed9e3b5a
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* Copyright [2020-2030] [https://www.stylefeng.cn]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Guns采用APACHE LICENSE 2.0开源协议,您在使用过程中,需要注意以下几点:
|
||||
*
|
||||
* 1.请不要删除和修改根目录下的LICENSE文件。
|
||||
* 2.请不要删除和修改Guns源码头部的版权声明。
|
||||
* 3.请保留源码和相关描述文件的项目出处,作者声明等。
|
||||
* 4.分发源码时候,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 5.在修改包名,模块名称,项目代码等时,请注明软件出处 https://gitee.com/stylefeng/guns
|
||||
* 6.若您的项目无法满足以上几点,可申请商业授权
|
||||
*/
|
||||
package cn.stylefeng.roses.kernel.group.api;
|
||||
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用在查询条件拼接语句时候的分组Api
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/5/30 16:47
|
||||
*/
|
||||
public interface GroupConditionApi {
|
||||
|
||||
/**
|
||||
* 获取请求是不是请求的未分组
|
||||
* <p>
|
||||
* 判断baseRequest中请求的conditionGroupName参数是否是“未分组”
|
||||
* <p>
|
||||
* 如果是未分组,则查询条件中,应当拼接类似如下语句:
|
||||
* <p>
|
||||
* queryWrapper.nested(ObjectUtil.isNotEmpty(userBizIds), i -> i.notIn(DevopsApp::getAppId, userBizIds));
|
||||
*
|
||||
* @author fengshuonan
|
||||
* @since 2023/5/30 16:49
|
||||
*/
|
||||
Boolean getRequestUnGroupedFlag(BaseRequest baseRequest);
|
||||
|
||||
/**
|
||||
* 获取用户对应的业务分组下的业务id集合
|
||||
*
|
||||
* @param groupBizCode 业务分组编码,应该是个常量,每个分组都应该具有的
|
||||
* @author fengshuonan
|
||||
* @since 2023/5/30 16:49
|
||||
*/
|
||||
List<Long> getUserGroupBizIds(String groupBizCode, BaseRequest baseRequest);
|
||||
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package cn.stylefeng.roses.kernel.group.modular.service;
|
||||
|
||||
import cn.stylefeng.roses.kernel.group.api.GroupApi;
|
||||
import cn.stylefeng.roses.kernel.group.api.GroupConditionApi;
|
||||
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupDTO;
|
||||
import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupRequest;
|
||||
import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup;
|
||||
|
@ -14,7 +15,7 @@ import java.util.List;
|
|||
* @author fengshuonan
|
||||
* @since 2022/05/11 12:54
|
||||
*/
|
||||
public interface SysGroupService extends IService<SysGroup>, GroupApi {
|
||||
public interface SysGroupService extends IService<SysGroup>, GroupApi, GroupConditionApi {
|
||||
|
||||
/**
|
||||
* 添加时候的选择分组列表
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package cn.stylefeng.roses.kernel.group.modular.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.stylefeng.roses.kernel.auth.api.context.LoginContext;
|
||||
import cn.stylefeng.roses.kernel.group.api.constants.GroupConstants;
|
||||
|
@ -8,6 +9,7 @@ import cn.stylefeng.roses.kernel.group.api.pojo.SysGroupRequest;
|
|||
import cn.stylefeng.roses.kernel.group.modular.entity.SysGroup;
|
||||
import cn.stylefeng.roses.kernel.group.modular.mapper.SysGroupMapper;
|
||||
import cn.stylefeng.roses.kernel.group.modular.service.SysGroupService;
|
||||
import cn.stylefeng.roses.kernel.rule.pojo.request.BaseRequest;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
@ -121,6 +123,37 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
|
|||
this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getRequestUnGroupedFlag(BaseRequest baseRequest) {
|
||||
// 获取前端请求的分组名称
|
||||
String conditionGroupName = baseRequest.getConditionGroupName();
|
||||
return GroupConstants.GROUP_DELETE_NAME.equals(conditionGroupName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> getUserGroupBizIds(String groupBizCode, BaseRequest baseRequest) {
|
||||
// 拼接分组相关的查询条件
|
||||
String conditionGroupName = baseRequest.getConditionGroupName();
|
||||
List<Long> userBizIds = new ArrayList<>();
|
||||
|
||||
// 如果查询的是所有分组,就是查询所有的数据,不需要拼接条件
|
||||
if (ObjectUtil.isNotEmpty(conditionGroupName) && !conditionGroupName.equals(GroupConstants.ALL_GROUP_NAME)) {
|
||||
|
||||
SysGroupRequest sysGroupRequest = new SysGroupRequest();
|
||||
sysGroupRequest.setGroupBizCode(groupBizCode);
|
||||
|
||||
// 查詢的不是未分组,则需要拼接一个groupName
|
||||
if (!getRequestUnGroupedFlag(baseRequest)) {
|
||||
sysGroupRequest.setGroupName(conditionGroupName);
|
||||
}
|
||||
|
||||
// 获取到筛选条件的结果
|
||||
userBizIds = this.findUserGroupDataList(sysGroupRequest);
|
||||
}
|
||||
|
||||
return userBizIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回结果增加通用的两个分组名称
|
||||
*
|
||||
|
@ -165,5 +198,4 @@ public class SysGroupServiceImpl extends ServiceImpl<SysGroupMapper, SysGroup> i
|
|||
result.add(0, addGroup);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue