Pre Merge pull request !554 from AprilWind/dev

This commit is contained in:
AprilWind 2024-06-27 07:31:14 +00:00 committed by Gitee
commit a5912bc31b
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
34 changed files with 77 additions and 123 deletions

View File

@ -1,6 +1,7 @@
package org.dromara.web.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import cn.dev33.satoken.exception.NotLoginException;
import cn.hutool.core.codec.Base64;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
@ -194,8 +195,26 @@ public class AuthController {
*/
@GetMapping("/tenant/list")
public R<LoginTenantVo> tenantList(HttpServletRequest request) throws Exception {
// 返回对象
LoginTenantVo result = new LoginTenantVo();
boolean enable = TenantHelper.isEnable();
result.setTenantEnabled(enable);
// 如果未开启租户这直接返回
if (!enable) {
return R.ok(result);
}
List<SysTenantVo> tenantList = tenantService.queryList(new SysTenantBo());
List<TenantListVo> voList = MapstructUtils.convert(tenantList, TenantListVo.class);
try {
// 如果只超管返回所有租户
if (LoginHelper.isSuperAdmin()) {
result.setVoList(voList);
return R.ok(result);
}
} catch (NotLoginException ignored) {
}
// 获取域名
String host;
String referer = request.getHeader("referer");
@ -208,11 +227,8 @@ public class AuthController {
// 根据域名进行筛选
List<TenantListVo> list = StreamUtils.filter(voList, vo ->
StringUtils.equals(vo.getDomain(), host));
// 返回对象
LoginTenantVo vo = new LoginTenantVo();
vo.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
vo.setTenantEnabled(TenantHelper.isEnable());
return R.ok(vo);
result.setVoList(CollUtil.isNotEmpty(list) ? list : voList);
return R.ok(result);
}
}

View File

@ -24,7 +24,6 @@ import org.dromara.common.redis.utils.RedisUtils;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.common.tenant.helper.TenantHelper;
import org.dromara.common.web.config.properties.CaptchaProperties;
import org.dromara.system.domain.SysClient;
import org.dromara.system.domain.SysUser;
import org.dromara.system.domain.vo.SysClientVo;
import org.dromara.system.domain.vo.SysUserVo;
@ -95,7 +94,7 @@ public class PasswordAuthStrategy implements IAuthStrategy {
* @param uuid 唯一标识
*/
private void validateCaptcha(String tenantId, String username, String code, String uuid) {
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.defaultString(uuid, "");
String verifyKey = GlobalConstants.CAPTCHA_CODE_KEY + StringUtils.blankToDefault(uuid, "");
String captcha = RedisUtils.getCacheObject(verifyKey);
RedisUtils.deleteObject(verifyKey);
if (captcha == null) {

View File

@ -13,7 +13,7 @@ spring.boot.admin.client:
--- # snail-job 配置
snail-job:
enabled: false
enabled: true
# 需要在 SnailJob 后台组管理创建对应名称的组,然后创建任务的时候选择对应的组,才能正确分派任务
group: "ruoyi_group"
# SnailJob 接入验证令牌 详见 script/sql/snail_job.sql `sj_group_config` 表

View File

@ -178,6 +178,7 @@ public class OssClient {
.key(key)
.contentMD5(StringUtils.isNotEmpty(md5Digest) ? md5Digest : null)
.contentType(contentType)
.acl(getAccessPolicy().getObjectCannedACL())
.build())
.addTransferListener(LoggingTransferListener.create())
.source(filePath).build());
@ -223,6 +224,7 @@ public class OssClient {
y -> y.bucket(properties.getBucketName())
.key(key)
.contentType(contentType)
.acl(getAccessPolicy().getObjectCannedACL())
.build())
.build());

View File

@ -1,12 +1,13 @@
package org.dromara.common.redis.utils;
import org.dromara.common.core.utils.SpringUtils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.dromara.common.core.utils.SpringUtils;
import org.redisson.api.*;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* 分布式队列工具
@ -224,7 +225,7 @@ public class QueueUtils {
/**
* 订阅阻塞队列(可订阅所有实现类 例如: 延迟 优先 有界 )
*/
public static <T> void subscribeBlockingQueue(String queueName, Consumer<T> consumer, boolean isDelayed) {
public static <T> void subscribeBlockingQueue(String queueName, Function<T, CompletionStage<Void>> consumer, boolean isDelayed) {
RBlockingQueue<T> queue = CLIENT.getBlockingQueue(queueName);
if (isDelayed) {
// 订阅延迟队列

View File

@ -87,6 +87,13 @@ public class LoginHelper {
return Convert.toLong(getExtra(USER_KEY));
}
/**
* 获取用户账户
*/
public static String getUsername() {
return Convert.toStr(getExtra(USER_NAME_KEY));
}
/**
* 获取租户ID
*/
@ -129,13 +136,6 @@ public class LoginHelper {
}
}
/**
* 获取用户账户
*/
public static String getUsername() {
return getLoginUser().getUsername();
}
/**
* 获取用户类型
*/

View File

@ -1,14 +1,15 @@
package org.dromara.demo.controller.queue;
import cn.dev33.satoken.annotation.SaIgnore;
import org.dromara.common.core.domain.R;
import org.dromara.common.redis.utils.QueueUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.domain.R;
import org.dromara.common.redis.utils.QueueUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;
/**
@ -42,6 +43,10 @@ public class DelayedQueueController {
QueueUtils.subscribeBlockingQueue(queueName, (String orderNum) -> {
// 观察接收时间
log.info("通道: {}, 收到数据: {}", queueName, orderNum);
return CompletableFuture.runAsync(() -> {
// 异步处理数据逻辑 不要在上方处理业务逻辑
log.info("数据处理: {}", orderNum);
});
}, true);
return R.ok("操作成功");
}

View File

@ -55,5 +55,5 @@ public interface TestDemoMapper extends BaseMapperPlus<TestDemo, TestDemoVo> {
@DataColumn(key = "deptName", value = "dept_id"),
@DataColumn(key = "userName", value = "user_id")
})
int deleteBatchIds(@Param(Constants.COLL) Collection<?> idList);
int deleteByIds(@Param(Constants.COLL) Collection<?> idList);
}

View File

@ -101,7 +101,7 @@ public class TestDemoServiceImpl implements ITestDemoService {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
@Override

View File

@ -83,6 +83,6 @@ public class TestTreeServiceImpl implements ITestTreeService {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -165,7 +165,7 @@ public class GenTableServiceImpl implements IGenTableService {
@Override
public void deleteGenTableByIds(Long[] tableIds) {
List<Long> ids = Arrays.asList(tableIds);
baseMapper.deleteBatchIds(ids);
baseMapper.deleteByIds(ids);
genTableColumnMapper.delete(new LambdaQueryWrapper<GenTableColumn>().in(GenTableColumn::getTableId, ids));
}
@ -332,7 +332,7 @@ public class GenTableServiceImpl implements IGenTableService {
if (CollUtil.isNotEmpty(delColumns)) {
List<Long> ids = StreamUtils.toList(delColumns, GenTableColumn::getColumnId);
if (CollUtil.isNotEmpty(ids)) {
genTableColumnMapper.deleteBatchIds(ids);
genTableColumnMapper.deleteByIds(ids);
}
}
}

View File

@ -149,6 +149,6 @@ public class ${ClassName}ServiceImpl implements I${ClassName}Service {
if(isValid){
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -146,6 +146,6 @@ public class SysClientServiceImpl implements ISysClientService {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -178,7 +178,7 @@ public class SysConfigServiceImpl implements ISysConfigService, ConfigService {
}
CacheUtils.evict(CacheNames.SYS_CONFIG, config.getConfigKey());
}
baseMapper.deleteBatchIds(Arrays.asList(configIds));
baseMapper.deleteByIds(Arrays.asList(configIds));
}
/**

View File

@ -141,7 +141,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
}
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
}
baseMapper.deleteBatchIds(Arrays.asList(dictIds));
baseMapper.deleteByIds(Arrays.asList(dictIds));
}
/**

View File

@ -163,7 +163,7 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
*/
@Override
public int deleteLogininforByIds(Long[] infoIds) {
return baseMapper.deleteBatchIds(Arrays.asList(infoIds));
return baseMapper.deleteByIds(Arrays.asList(infoIds));
}
/**

View File

@ -119,6 +119,6 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
*/
@Override
public int deleteNoticeByIds(Long[] noticeIds) {
return baseMapper.deleteBatchIds(Arrays.asList(noticeIds));
return baseMapper.deleteByIds(Arrays.asList(noticeIds));
}
}

View File

@ -122,7 +122,7 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
*/
@Override
public int deleteOperLogByIds(Long[] operIds) {
return baseMapper.deleteBatchIds(Arrays.asList(operIds));
return baseMapper.deleteByIds(Arrays.asList(operIds));
}
/**

View File

@ -135,7 +135,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
SysOssConfig config = baseMapper.selectById(configId);
list.add(config);
}
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
boolean flag = baseMapper.deleteByIds(ids) > 0;
if (flag) {
list.forEach(sysOssConfig ->
CacheUtils.evict(CacheNames.SYS_OSS_CONFIG, sysOssConfig.getConfigKey()));

View File

@ -247,7 +247,7 @@ public class SysOssServiceImpl implements ISysOssService, OssService {
OssClient storage = OssFactory.instance(sysOss.getService());
storage.delete(sysOss.getUrl());
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
/**

View File

@ -202,7 +202,7 @@ public class SysPostServiceImpl implements ISysPostService {
throw new ServiceException(String.format("%1$s已分配不能删除!", post.getPostName()));
}
}
return baseMapper.deleteBatchIds(Arrays.asList(postIds));
return baseMapper.deleteByIds(Arrays.asList(postIds));
}
/**

View File

@ -37,6 +37,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* 角色 业务层处理
@ -104,12 +105,11 @@ public class SysRoleServiceImpl implements ISysRoleService {
public List<SysRoleVo> selectRolesAuthByUserId(Long userId) {
List<SysRoleVo> userRoles = baseMapper.selectRolePermissionByUserId(userId);
List<SysRoleVo> roles = selectRoleAll();
// 使用HashSet提高查找效率
Set<Long> userRoleIds = userRoles.stream().map(SysRoleVo::getRoleId).collect(Collectors.toSet());
for (SysRoleVo role : roles) {
for (SysRoleVo userRole : userRoles) {
if (role.getRoleId().longValue() == userRole.getRoleId().longValue()) {
role.setFlag(true);
break;
}
if (userRoleIds.contains(role.getRoleId())) {
role.setFlag(true);
}
}
return roles;
@ -417,7 +417,7 @@ public class SysRoleServiceImpl implements ISysRoleService {
roleMenuMapper.delete(new LambdaQueryWrapper<SysRoleMenu>().in(SysRoleMenu::getRoleId, ids));
// 删除角色与部门关联
roleDeptMapper.delete(new LambdaQueryWrapper<SysRoleDept>().in(SysRoleDept::getRoleId, ids));
return baseMapper.deleteBatchIds(ids);
return baseMapper.deleteByIds(ids);
}
/**

View File

@ -140,6 +140,6 @@ public class SysTenantPackageServiceImpl implements ISysTenantPackageService {
throw new ServiceException("租户套餐已被使用");
}
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -294,7 +294,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
throw new ServiceException("超管租户不能删除");
}
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
/**

View File

@ -541,7 +541,7 @@ public class SysUserServiceImpl implements ISysUserService, UserService {
// 删除用户与岗位表
userPostMapper.delete(new LambdaQueryWrapper<SysUserPost>().in(SysUserPost::getUserId, ids));
// 防止更新失败导致的数据删除
int flag = baseMapper.deleteBatchIds(ids);
int flag = baseMapper.deleteByIds(ids);
if (flag < 1) {
throw new ServiceException("删除用户失败!");
}

View File

@ -696,7 +696,7 @@ public class ActTaskServiceImpl implements IActTaskService {
if (multiInstance == null && taskList.size() > 1) {
List<Task> tasks = StreamUtils.filter(taskList, e -> !e.getTaskDefinitionKey().equals(task.getTaskDefinitionKey()));
if (CollUtil.isNotEmpty(tasks)) {
actHiTaskinstMapper.deleteBatchIds(StreamUtils.toList(tasks, Task::getId));
actHiTaskinstMapper.deleteByIds(StreamUtils.toList(tasks, Task::getId));
}
}

View File

@ -111,7 +111,7 @@ public class TestLeaveServiceImpl implements ITestLeaveService {
public Boolean deleteWithValidByIds(Collection<Long> ids) {
List<String> idList = StreamUtils.toList(ids, String::valueOf);
workflowService.deleteRunAndHisInstance(idList);
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
/**

View File

@ -114,7 +114,7 @@ public class WfCategoryServiceImpl implements IWfCategoryService {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
/**

View File

@ -107,7 +107,7 @@ public class WfDefinitionConfigServiceImpl implements IWfDefinitionConfigService
*/
@Override
public Boolean deleteByIds(Collection<Long> ids) {
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
@Override

View File

@ -106,6 +106,6 @@ public class WfFormManageServiceImpl implements IWfFormManageService {
*/
@Override
public Boolean deleteByIds(Collection<Long> ids) {
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}
}

View File

@ -50,7 +50,7 @@ public class WfNodeConfigServiceImpl implements IWfNodeConfigService {
*/
@Override
public Boolean deleteByIds(Collection<Long> ids) {
return baseMapper.deleteBatchIds(ids) > 0;
return baseMapper.deleteByIds(ids) > 0;
}

View File

@ -106,7 +106,7 @@ public class WfTaskBackNodeServiceImpl implements IWfTaskBackNodeService {
}
}
if (CollUtil.isNotEmpty(ids)) {
wfTaskBackNodeMapper.deleteBatchIds(ids);
wfTaskBackNodeMapper.deleteByIds(ids);
}
}
return true;

View File

@ -63,7 +63,7 @@ http {
# }
# 限制外网访问内网 actuator 相关路径
location ~ ^(/[^/]*)?/actuator(/.*)?$ {
location ~ ^(/[^/]*)?/actuator.*(/.*)?$ {
return 403;
}

View File

@ -39,29 +39,17 @@ create table test_leave
);
comment on table test_leave is '请假申请表';
comment on column test_leave.id is '主键';
comment on column test_leave.leave_type is '请假类型';
comment on column test_leave.start_date is '开始时间';
comment on column test_leave.end_date is '结束时间';
comment on column test_leave.remark is '请假原因';
comment on column test_leave.status is '状态';
comment on column test_leave.create_dept is '创建部门';
comment on column test_leave.create_by is '创建者';
comment on column test_leave.create_time is '创建时间';
comment on column test_leave.update_by is '更新者';
comment on column test_leave.update_time is '更新时间';
comment on column test_leave.tenant_id is '租户编码';
alter table test_leave
@ -86,27 +74,16 @@ create table wf_category
);
comment on table wf_category is '流程分类';
comment on column wf_category.id is '主键';
comment on column wf_category.category_name is '分类名称';
comment on column wf_category.category_code is '分类编码';
comment on column wf_category.parent_id is '父级id';
comment on column wf_category.sort_num is '排序';
comment on column wf_category.tenant_id is '租户id';
comment on column wf_category.create_dept is '创建部门';
comment on column wf_category.create_by is '创建者';
comment on column wf_category.create_time is '创建时间';
comment on column wf_category.update_by is '修改者';
comment on column wf_category.update_time is '修改时间';
alter table wf_category
@ -137,31 +114,18 @@ create table wf_task_back_node
);
comment on table wf_task_back_node is '节点审批记录';
comment on column wf_task_back_node.id is '主键';
comment on column wf_task_back_node.node_id is '节点id';
comment on column wf_task_back_node.node_name is '节点名称';
comment on column wf_task_back_node.order_no is '排序';
comment on column wf_task_back_node.instance_id is '流程实例id';
comment on column wf_task_back_node.task_type is '节点类型';
comment on column wf_task_back_node.assignee is '审批人';
comment on column wf_task_back_node.tenant_id is '租户id';
comment on column wf_task_back_node.create_dept is '创建部门';
comment on column wf_task_back_node.create_by is '创建者';
comment on column wf_task_back_node.create_time is '创建时间';
comment on column wf_task_back_node.update_by is '修改者';
comment on column wf_task_back_node.update_time is '修改时间';
alter table wf_task_back_node
@ -177,6 +141,7 @@ create table wf_definition_config
process_key varchar(255) not null,
version bigint not null,
tenant_id varchar(20),
remark varchar(500),
create_dept bigint,
create_by bigint,
create_time timestamp,
@ -185,27 +150,17 @@ create table wf_definition_config
);
comment on table wf_definition_config is '流程定义配置';
comment on column wf_definition_config.id is '主键';
comment on column wf_definition_config.table_name is '表名';
comment on column wf_definition_config.definition_id is '流程定义ID';
comment on column wf_definition_config.process_key is '流程KEY';
comment on column wf_definition_config.version is '流程版本';
comment on column wf_definition_config.tenant_id is '租户id';
comment on column wf_definition_config.remark is '备注';
comment on column wf_definition_config.create_dept is '创建部门';
comment on column wf_definition_config.create_by is '创建者';
comment on column wf_definition_config.create_time is '创建时间';
comment on column wf_definition_config.update_by is '修改者';
comment on column wf_definition_config.update_time is '修改时间';
alter table wf_definition_config
@ -231,27 +186,16 @@ create table wf_form_manage
);
comment on table wf_form_manage is '表单管理';
comment on column wf_form_manage.id is '主键';
comment on column wf_form_manage.form_name is '表单名称';
comment on column wf_form_manage.form_type is '表单类型';
comment on column wf_form_manage.router is '路由地址/表单ID';
comment on column wf_form_manage.remark is '备注';
comment on column wf_form_manage.tenant_id is '租户id';
comment on column wf_form_manage.create_dept is '创建部门';
comment on column wf_form_manage.create_by is '创建者';
comment on column wf_form_manage.create_time is '创建时间';
comment on column wf_form_manage.update_by is '修改者';
comment on column wf_form_manage.update_time is '修改时间';
insert into wf_form_manage(id, form_name, form_type, router, remark, tenant_id, create_dept, create_by, create_time, update_by, update_time) VALUES (1, '请假申请', 'static', '/workflow/leaveEdit/index', NULL, '000000', 103, 1, now(), 1, now());
@ -276,31 +220,18 @@ create table wf_node_config
);
comment on table wf_node_config is '节点配置';
comment on column wf_node_config.id is '主键';
comment on column wf_node_config.form_id is '表单id';
comment on column wf_node_config.form_type is '表单类型';
comment on column wf_node_config.node_id is '节点id';
comment on column wf_node_config.node_name is '节点名称';
comment on column wf_node_config.definition_id is '流程定义id';
comment on column wf_node_config.apply_user_task is '是否为申请人节点 0是 1否';
comment on column wf_node_config.tenant_id is '租户id';
comment on column wf_node_config.create_dept is '创建部门';
comment on column wf_node_config.create_by is '创建者';
comment on column wf_node_config.create_time is '创建时间';
comment on column wf_node_config.update_by is '修改者';
comment on column wf_node_config.update_time is '修改时间';
INSERT INTO sys_menu(menu_id, menu_name, parent_id, order_num, path, component, is_frame, is_cache, menu_type, visible, status, perms, icon, create_dept, create_by, create_time, update_by, update_time, remark) VALUES (11638, '请假申请', 5, 1, 'leave', 'workflow/leave/index', 1, 0, 'C', '0', '0', 'workflow:leave:list', '#', 103, 1, now(), NULL, NULL, '请假申请菜单');