【7.6.0】【group】更新条件查询的Api

dev-7.6.0-hang
fengshuonan 2023-05-30 17:03:28 +08:00
parent 335d1821e8
commit 76ed9e3b5a
3 changed files with 97 additions and 2 deletions

View File

@ -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.
*
* GunsAPACHE 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>
* baseRequestconditionGroupName
* <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);
}

View File

@ -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 {
/**
*

View File

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