mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 09:35:29 +08:00
sso server saas 登录
This commit is contained in:
parent
efc6dc612c
commit
504d80a022
@ -41,10 +41,13 @@ public interface CacheNames {
|
||||
String SYS_CLIENT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_client#30d";
|
||||
|
||||
/**
|
||||
* 客户端
|
||||
* saas客户端
|
||||
*/
|
||||
String SYS_SAAS_CLIENT = GlobalConstants.GLOBAL_REDIS_KEY + "sys_saas_client#30d";
|
||||
|
||||
/**
|
||||
* saas部门
|
||||
*/
|
||||
String SYS_SAAS_DEPT = "sys_saas_dept#30d";
|
||||
/**
|
||||
* 用户账户
|
||||
*/
|
||||
|
||||
@ -165,7 +165,7 @@ public class SsoServerController {
|
||||
}
|
||||
// 已登录情况下,构建 redirectUrl
|
||||
redirect = SaFoxUtil.decoderUrl(redirect);
|
||||
if (SaSsoConsts.MODE_SIMPLE.equals(mode)) {
|
||||
if (SaSsoConsts.MODE_SIMPLE.equals(mode)) {
|
||||
// 模式一
|
||||
SaSsoUtil.checkRedirectUrl(redirect);
|
||||
return SaResult.data(redirect);
|
||||
|
||||
@ -17,13 +17,13 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class UserPasswordProperties {
|
||||
|
||||
/**
|
||||
* 密码最大错误次数
|
||||
* 密码最大错误次数,默认5次
|
||||
*/
|
||||
private Integer maxRetryCount;
|
||||
private Integer maxRetryCount = 5;
|
||||
|
||||
/**
|
||||
* 密码锁定时间(默认10分钟)
|
||||
*/
|
||||
private Integer lockTime;
|
||||
private Integer lockTime = 10;
|
||||
|
||||
}
|
||||
|
||||
@ -31,6 +31,10 @@ spring:
|
||||
|
||||
# Sa-Token配置
|
||||
sa-token:
|
||||
# 允许动态设置 token 有效期
|
||||
dynamic-active-timeout: true
|
||||
# 允许从 请求参数 读取 token
|
||||
is-read-body: true
|
||||
sign:
|
||||
# API 接口签名秘钥 (随便乱摁几个字母即可)
|
||||
secret-key: kQwIOrYbtXmSDkwEiFngrKidMcdrgKor
|
||||
|
||||
@ -1,137 +1,137 @@
|
||||
package org.dromara.system.saas.controller.system;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.saas.domain.bo.SysSaasConfigBo;
|
||||
import org.dromara.system.saas.domain.vo.SysSaasConfigVo;
|
||||
import org.dromara.system.saas.service.ISysSaasConfigService;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 参数配置 信息操作处理
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/saasConfig")
|
||||
public class SysSaasConfigController extends BaseController {
|
||||
|
||||
private final ISysSaasConfigService configService;
|
||||
|
||||
/**
|
||||
* 获取参数配置列表
|
||||
*/
|
||||
@SaCheckPermission("system:config:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<SysSaasConfigVo> list(SysSaasConfigBo config, PageQuery pageQuery) {
|
||||
return configService.selectPageConfigList(config, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出参数配置列表
|
||||
*/
|
||||
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
@SaCheckPermission("system:config:export")
|
||||
@PostMapping("/export")
|
||||
public void export(SysSaasConfigBo config, HttpServletResponse response) {
|
||||
List<SysSaasConfigVo> list = configService.selectConfigList(config);
|
||||
ExcelUtil.exportExcel(list, "参数数据", SysSaasConfigVo.class, response);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数编号获取详细信息
|
||||
*
|
||||
* @param configId 参数ID
|
||||
*/
|
||||
@SaCheckPermission("system:config:query")
|
||||
@GetMapping(value = "/{configId}")
|
||||
public R<SysSaasConfigVo> getInfo(@PathVariable Long configId) {
|
||||
return R.ok(configService.selectConfigById(configId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数键名查询参数值
|
||||
*
|
||||
* @param configKey 参数Key
|
||||
*/
|
||||
@GetMapping(value = "/configKey/{configKey}")
|
||||
public R<String> getConfigKey(@PathVariable String configKey) {
|
||||
return R.ok("操作成功", configService.selectConfigByKey(configKey));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增参数配置
|
||||
*/
|
||||
@SaCheckPermission("system:config:add")
|
||||
@Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Void> add(@Validated @RequestBody SysSaasConfigBo config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
configService.insertConfig(config);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改参数配置
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Void> edit(@Validated @RequestBody SysSaasConfigBo config) {
|
||||
if (!configService.checkConfigKeyUnique(config)) {
|
||||
return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
}
|
||||
configService.updateConfig(config);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据参数键名修改参数配置
|
||||
*/
|
||||
@SaCheckPermission("system:config:edit")
|
||||
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updateByKey")
|
||||
public R<Void> updateByKey(@RequestBody SysSaasConfigBo config) {
|
||||
configService.updateConfig(config);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除参数配置
|
||||
*
|
||||
* @param configIds 参数ID串
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{configIds}")
|
||||
public R<Void> remove(@PathVariable Long[] configIds) {
|
||||
configService.deleteConfigByIds(configIds);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新参数缓存
|
||||
*/
|
||||
@SaCheckPermission("system:config:remove")
|
||||
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
@DeleteMapping("/refreshCache")
|
||||
public R<Void> refreshCache() {
|
||||
configService.resetConfigCache();
|
||||
return R.ok();
|
||||
}
|
||||
}
|
||||
//package org.dromara.system.saas.controller.system;
|
||||
//
|
||||
//import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
//import org.dromara.common.core.domain.R;
|
||||
//import org.dromara.common.excel.utils.ExcelUtil;
|
||||
//import org.dromara.common.log.annotation.Log;
|
||||
//import org.dromara.common.log.enums.BusinessType;
|
||||
//import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
//import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
//import org.dromara.common.web.core.BaseController;
|
||||
//import org.dromara.system.saas.domain.bo.SysSaasConfigBo;
|
||||
//import org.dromara.system.saas.domain.vo.SysSaasConfigVo;
|
||||
//import org.dromara.system.saas.service.ISysSaasConfigService;
|
||||
//import jakarta.servlet.http.HttpServletResponse;
|
||||
//import lombok.RequiredArgsConstructor;
|
||||
//import org.springframework.validation.annotation.Validated;
|
||||
//import org.springframework.web.bind.annotation.*;
|
||||
//
|
||||
//import java.util.List;
|
||||
//
|
||||
///**
|
||||
// * 参数配置 信息操作处理
|
||||
// *
|
||||
// * @author Lion Li
|
||||
// */
|
||||
//@Validated
|
||||
//@RequiredArgsConstructor
|
||||
//@RestController
|
||||
//@RequestMapping("/system/saasConfig")
|
||||
//public class SysSaasConfigController extends BaseController {
|
||||
//
|
||||
// private final ISysSaasConfigService configService;
|
||||
//
|
||||
// /**
|
||||
// * 获取参数配置列表
|
||||
// */
|
||||
// @SaCheckPermission("system:config:list")
|
||||
// @GetMapping("/list")
|
||||
// public TableDataInfo<SysSaasConfigVo> list(SysSaasConfigBo config, PageQuery pageQuery) {
|
||||
// return configService.selectPageConfigList(config, pageQuery);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 导出参数配置列表
|
||||
// */
|
||||
// @Log(title = "参数管理", businessType = BusinessType.EXPORT)
|
||||
// @SaCheckPermission("system:config:export")
|
||||
// @PostMapping("/export")
|
||||
// public void export(SysSaasConfigBo config, HttpServletResponse response) {
|
||||
// List<SysSaasConfigVo> list = configService.selectConfigList(config);
|
||||
// ExcelUtil.exportExcel(list, "参数数据", SysSaasConfigVo.class, response);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据参数编号获取详细信息
|
||||
// *
|
||||
// * @param configId 参数ID
|
||||
// */
|
||||
// @SaCheckPermission("system:config:query")
|
||||
// @GetMapping(value = "/{configId}")
|
||||
// public R<SysSaasConfigVo> getInfo(@PathVariable Long configId) {
|
||||
// return R.ok(configService.selectConfigById(configId));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据参数键名查询参数值
|
||||
// *
|
||||
// * @param configKey 参数Key
|
||||
// */
|
||||
// @GetMapping(value = "/configKey/{configKey}")
|
||||
// public R<String> getConfigKey(@PathVariable String configKey) {
|
||||
// return R.ok("操作成功", configService.selectConfigByKey(configKey));
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 新增参数配置
|
||||
// */
|
||||
// @SaCheckPermission("system:config:add")
|
||||
// @Log(title = "参数管理", businessType = BusinessType.INSERT)
|
||||
// @PostMapping
|
||||
// public R<Void> add(@Validated @RequestBody SysSaasConfigBo config) {
|
||||
// if (!configService.checkConfigKeyUnique(config)) {
|
||||
// return R.fail("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
// }
|
||||
// configService.insertConfig(config);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 修改参数配置
|
||||
// */
|
||||
// @SaCheckPermission("system:config:edit")
|
||||
// @Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping
|
||||
// public R<Void> edit(@Validated @RequestBody SysSaasConfigBo config) {
|
||||
// if (!configService.checkConfigKeyUnique(config)) {
|
||||
// return R.fail("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
|
||||
// }
|
||||
// configService.updateConfig(config);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 根据参数键名修改参数配置
|
||||
// */
|
||||
// @SaCheckPermission("system:config:edit")
|
||||
// @Log(title = "参数管理", businessType = BusinessType.UPDATE)
|
||||
// @PutMapping("/updateByKey")
|
||||
// public R<Void> updateByKey(@RequestBody SysSaasConfigBo config) {
|
||||
// configService.updateConfig(config);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 删除参数配置
|
||||
// *
|
||||
// * @param configIds 参数ID串
|
||||
// */
|
||||
// @SaCheckPermission("system:config:remove")
|
||||
// @Log(title = "参数管理", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{configIds}")
|
||||
// public R<Void> remove(@PathVariable Long[] configIds) {
|
||||
// configService.deleteConfigByIds(configIds);
|
||||
// return R.ok();
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 刷新参数缓存
|
||||
// */
|
||||
// @SaCheckPermission("system:config:remove")
|
||||
// @Log(title = "参数管理", businessType = BusinessType.CLEAN)
|
||||
// @DeleteMapping("/refreshCache")
|
||||
// public R<Void> refreshCache() {
|
||||
// configService.resetConfigCache();
|
||||
// return R.ok();
|
||||
// }
|
||||
//}
|
||||
|
||||
@ -8,14 +8,14 @@ import lombok.EqualsAndHashCode;
|
||||
import java.io.Serial;
|
||||
|
||||
/**
|
||||
* 授权管理对象 sys2_client
|
||||
* 授权管理对象 sys_saas_client
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2023-05-15
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys2_client")
|
||||
@TableName("sys_saas_client")
|
||||
public class SysSaasClient extends BaseEntity {
|
||||
|
||||
@Serial
|
||||
|
||||
@ -12,7 +12,7 @@ import jakarta.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 授权管理业务对象 sys2_client
|
||||
* 授权管理业务对象 sys_saas_client
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2023-05-15
|
||||
|
||||
@ -24,11 +24,6 @@ import org.dromara.system.saas.domain.SysSaasUser;
|
||||
@AutoMapper(target = SysSaasUser.class, reverseConvertGenerate = false)
|
||||
public class SysSaasUserBo extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
@NotBlank(message = "不能为空")
|
||||
private Long applicationId;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
|
||||
@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* 授权管理视图对象 sys2_client
|
||||
* 授权管理视图对象 sys_saas_client
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
* @date 2023-05-15
|
||||
|
||||
@ -127,7 +127,7 @@ public class SysSaasDeptServiceImpl implements ISysSaasDeptService, SaasDeptServ
|
||||
* @param deptId 部门ID
|
||||
* @return 部门信息
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
@Cacheable(cacheNames = CacheNames.SYS_SAAS_DEPT, key = "#deptId")
|
||||
@Override
|
||||
public SysSaasDeptVo selectDeptById(Long deptId) {
|
||||
SysSaasDeptVo dept = baseMapper.selectVoById(deptId);
|
||||
@ -260,7 +260,7 @@ public class SysSaasDeptServiceImpl implements ISysSaasDeptService, SaasDeptServ
|
||||
* @param bo 部门信息
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#bo.deptId")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_SAAS_DEPT, key = "#bo.deptId")
|
||||
@Override
|
||||
public int updateDept(SysSaasDeptBo bo) {
|
||||
SysSaasDept dept = MapstructUtils.convert(bo, SysSaasDept.class);
|
||||
@ -317,7 +317,7 @@ public class SysSaasDeptServiceImpl implements ISysSaasDeptService, SaasDeptServ
|
||||
}
|
||||
if (CollUtil.isNotEmpty(list)) {
|
||||
if (baseMapper.updateBatchById(list)) {
|
||||
list.forEach(dept -> CacheUtils.evict(CacheNames.SYS_DEPT, dept.getDeptId()));
|
||||
list.forEach(dept -> CacheUtils.evict(CacheNames.SYS_SAAS_DEPT, dept.getDeptId()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -328,7 +328,7 @@ public class SysSaasDeptServiceImpl implements ISysSaasDeptService, SaasDeptServ
|
||||
* @param deptId 部门ID
|
||||
* @return 结果
|
||||
*/
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_DEPT, key = "#deptId")
|
||||
@CacheEvict(cacheNames = CacheNames.SYS_SAAS_DEPT, key = "#deptId")
|
||||
@Override
|
||||
public int deleteDeptById(Long deptId) {
|
||||
return baseMapper.deleteById(deptId);
|
||||
|
||||
@ -819,7 +819,7 @@ insert into sys2_oss_config values (5, '000000', 'image', 'ruoyi', '
|
||||
-- ----------------------------
|
||||
-- 系统授权表
|
||||
-- ----------------------------
|
||||
create table sys2_client (
|
||||
create table sys_saas_client (
|
||||
id bigint(20) not null comment 'id',
|
||||
client_id varchar(64) default null comment '客户端id',
|
||||
client_key varchar(32) default null comment '客户端key',
|
||||
@ -837,6 +837,3 @@ create table sys2_client (
|
||||
update_time datetime default null comment '更新时间',
|
||||
primary key (id)
|
||||
) engine=innodb comment='系统授权表';
|
||||
|
||||
insert into sys2_client values (1, 'e5cd7e4891bf95d1d19206ce24a7b32e', 'pc', 'pc123', 'password,social', 'pc', 1800, 604800, 0, 0, 103, 1, sysdate(), 1, sysdate());
|
||||
insert into sys2_client values (2, '428a8310cd442757ae699df5d894f051', 'app', 'app123', 'password,sms,social', 'android', 1800, 604800, 0, 0, 103, 1, sysdate(), 1, sysdate());
|
||||
Loading…
Reference in New Issue
Block a user