mirror of
https://gitee.com/dromara/RuoYi-Cloud-Plus.git
synced 2025-09-03 11:05:58 +00:00
@@ -9,11 +9,17 @@ public interface RemoteDataScopeService {
|
||||
|
||||
/**
|
||||
* 获取角色自定义权限语句
|
||||
*
|
||||
* @param roleId 角色ID
|
||||
* @return 返回角色的自定义权限语句,如果没有找到则返回 null
|
||||
*/
|
||||
String getRoleCustom(Long roleId);
|
||||
|
||||
/**
|
||||
* 获取部门和下级权限语句
|
||||
*
|
||||
* @param deptId 部门ID
|
||||
* @return 返回部门及其下级的权限语句,如果没有找到则返回 null
|
||||
*/
|
||||
String getDeptAndChild(Long deptId);
|
||||
|
||||
|
@@ -18,4 +18,5 @@ public interface RemoteDictService {
|
||||
* @return 字典数据集合信息
|
||||
*/
|
||||
List<RemoteDictDataVo> selectDictDataByType(String dictType);
|
||||
|
||||
}
|
||||
|
@@ -23,4 +23,5 @@ public interface RemoteLogService {
|
||||
* @param sysLogininfor 访问实体
|
||||
*/
|
||||
void saveLogininfor(RemoteLogininforBo sysLogininfor);
|
||||
|
||||
}
|
||||
|
@@ -13,22 +13,32 @@ import java.util.List;
|
||||
public interface RemoteSocialService {
|
||||
|
||||
/**
|
||||
* 根据 authId 查询用户信息
|
||||
* 根据 authId 查询用户授权信息
|
||||
*
|
||||
* @param authId 认证id
|
||||
* @return 授权信息
|
||||
*/
|
||||
List<RemoteSocialVo> selectByAuthId(String authId);
|
||||
|
||||
/**
|
||||
* 保存社会化关系
|
||||
*
|
||||
* @param bo 社会化关系业务对象
|
||||
*/
|
||||
void insertByBo(RemoteSocialBo bo);
|
||||
|
||||
/**
|
||||
* 更新社会化关系
|
||||
*
|
||||
* @param bo 社会化关系业务对象
|
||||
*/
|
||||
void updateByBo(RemoteSocialBo bo);
|
||||
|
||||
/**
|
||||
* 删除社会化关系
|
||||
*
|
||||
* @param socialId 社会化关系ID
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean deleteWithValidById(Long socialId);
|
||||
|
||||
|
@@ -6,6 +6,8 @@ import org.dromara.system.api.domain.vo.RemoteTenantVo;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 租户服务
|
||||
*
|
||||
* @author zhujie
|
||||
*/
|
||||
public interface RemoteTenantService {
|
||||
|
@@ -81,6 +81,22 @@ public interface RemoteUserService {
|
||||
*/
|
||||
String selectNicknameById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户手机号
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户手机号
|
||||
*/
|
||||
String selectPhonenumberById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户邮箱
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户邮箱
|
||||
*/
|
||||
String selectEmailById(Long userId);
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
*
|
||||
|
@@ -11,7 +11,6 @@ import java.io.Serializable;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class SysUserOnline implements Serializable {
|
||||
|
@@ -14,7 +14,6 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class RemoteLogininforBo implements Serializable {
|
||||
|
@@ -14,7 +14,6 @@ import java.util.Map;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class RemoteOperLogBo implements Serializable {
|
||||
|
@@ -19,7 +19,6 @@ import java.util.Date;
|
||||
*
|
||||
* @author Michelle.Chung
|
||||
*/
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class RemoteUserBo implements Serializable {
|
||||
|
@@ -67,5 +67,4 @@ public class RemoteClientVo implements Serializable {
|
||||
*/
|
||||
private String status;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -64,6 +64,7 @@ public class CaptchaController {
|
||||
AbstractCaptcha captcha = SpringUtils.getBean(captchaProperties.getCategory().getClazz());
|
||||
captcha.setGenerator(codeGenerator);
|
||||
captcha.createCode();
|
||||
// 如果是数学验证码,使用SpEL表达式处理验证码结果
|
||||
String code = captcha.getCode();
|
||||
if (isMath) {
|
||||
ExpressionParser parser = new SpelExpressionParser();
|
||||
|
@@ -10,10 +10,19 @@ import lombok.Data;
|
||||
@Data
|
||||
public class TenantListVo {
|
||||
|
||||
/**
|
||||
* 租户编号
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 企业名称
|
||||
*/
|
||||
private String companyName;
|
||||
|
||||
/**
|
||||
* 域名
|
||||
*/
|
||||
private String domain;
|
||||
|
||||
}
|
||||
|
@@ -11,7 +11,6 @@ import org.dromara.common.core.domain.model.LoginBody;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class EmailLoginBody extends LoginBody {
|
||||
|
@@ -31,6 +31,9 @@ public class RegisterBody extends LoginBody {
|
||||
@Length(min = PASSWORD_MIN_LENGTH, max = PASSWORD_MAX_LENGTH, message = "{user.password.length.valid}")
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 用户类型
|
||||
*/
|
||||
private String userType;
|
||||
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ import org.dromara.common.core.domain.model.LoginBody;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SmsLoginBody extends LoginBody {
|
||||
|
@@ -10,7 +10,6 @@ import org.dromara.common.core.domain.model.LoginBody;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SocialLoginBody extends LoginBody {
|
||||
|
@@ -10,7 +10,6 @@ import org.dromara.common.core.domain.model.LoginBody;
|
||||
*
|
||||
* @author Lion Li
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class XcxLoginBody extends LoginBody {
|
||||
|
@@ -17,6 +17,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
@RefreshScope
|
||||
@ConfigurationProperties(prefix = "security.captcha")
|
||||
public class CaptchaProperties {
|
||||
|
||||
/**
|
||||
* 验证码类型
|
||||
*/
|
||||
|
@@ -16,6 +16,11 @@ public interface IAuthStrategy {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param body 登录对象
|
||||
* @param client 授权管理视图对象
|
||||
* @param grantType 授权类型
|
||||
* @return 登录验证信息
|
||||
*/
|
||||
static LoginVo login(String body, RemoteClientVo client, String grantType) {
|
||||
// 授权类型和客户端id
|
||||
@@ -29,6 +34,10 @@ public interface IAuthStrategy {
|
||||
|
||||
/**
|
||||
* 登录
|
||||
*
|
||||
* @param body 登录对象
|
||||
* @param client 授权管理视图对象
|
||||
* @return 登录验证信息
|
||||
*/
|
||||
LoginVo login(String body, RemoteClientVo client);
|
||||
|
||||
|
@@ -45,6 +45,9 @@ public class LogEventListener {
|
||||
remoteLogService.saveLog(sysOperLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存系统访问记录
|
||||
*/
|
||||
@Async
|
||||
@EventListener
|
||||
public void saveLogininfor(LogininforEvent logininforEvent) {
|
||||
@@ -52,10 +55,10 @@ public class LogEventListener {
|
||||
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
||||
final String ip = ServletUtils.getClientIP(request);
|
||||
// 客户端信息
|
||||
String clientid = request.getHeader(LoginHelper.CLIENT_KEY);
|
||||
String clientId = request.getHeader(LoginHelper.CLIENT_KEY);
|
||||
RemoteClientVo clientVo = null;
|
||||
if (StringUtils.isNotBlank(clientid)) {
|
||||
clientVo = remoteClientService.queryByClientId(clientid);
|
||||
if (StringUtils.isNotBlank(clientId)) {
|
||||
clientVo = remoteClientService.queryByClientId(clientId);
|
||||
}
|
||||
|
||||
String address = AddressUtils.getRealAddressByIP(ip);
|
||||
|
@@ -101,6 +101,12 @@ public class LoginHelper {
|
||||
return Convert.toLong(getExtra(DEPT_KEY));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前 Token 的扩展信息
|
||||
*
|
||||
* @param key 键值
|
||||
* @return 对应的扩展数据
|
||||
*/
|
||||
private static Object getExtra(String key) {
|
||||
try {
|
||||
return StpUtil.getExtra(key);
|
||||
@@ -135,12 +141,17 @@ public class LoginHelper {
|
||||
return UserConstants.SUPER_ADMIN_ID.equals(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为超级管理员
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isSuperAdmin() {
|
||||
return isSuperAdmin(getUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为超级管理员
|
||||
* 是否为租户管理员
|
||||
*
|
||||
* @param rolePermission 角色权限标识组
|
||||
* @return 结果
|
||||
@@ -149,10 +160,20 @@ public class LoginHelper {
|
||||
return rolePermission.contains(TenantConstants.TENANT_ADMIN_ROLE_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为租户管理员
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isTenantAdmin() {
|
||||
return Convert.toBool(isTenantAdmin(getLoginUser().getRolePermission()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查当前用户是否已登录
|
||||
*
|
||||
* @return 结果
|
||||
*/
|
||||
public static boolean isLogin() {
|
||||
return getLoginUser() != null;
|
||||
}
|
||||
|
@@ -21,6 +21,7 @@ import java.util.List;
|
||||
@RefreshScope
|
||||
@ConfigurationProperties(prefix = "security.ignore")
|
||||
public class IgnoreWhiteProperties {
|
||||
|
||||
/**
|
||||
* 放行白名单配置,网关不校验此处的白名单
|
||||
*/
|
||||
|
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
@RefreshScope
|
||||
@ConfigurationProperties(prefix = "security.xss")
|
||||
public class XssProperties {
|
||||
|
||||
/**
|
||||
* Xss开关
|
||||
*/
|
||||
|
@@ -26,14 +26,38 @@ public class GlobalCorsFilter implements WebFilter, Ordered {
|
||||
* 这里为支持的请求头,如果有自定义的header字段请自己添加
|
||||
*/
|
||||
private static final String ALLOWED_HEADERS = "X-Requested-With, Content-Language, Content-Type, Authorization, clientid, credential, X-XSRF-TOKEN, isToken, token, Admin-Token, App-Token";
|
||||
|
||||
/**
|
||||
* 允许的请求方法
|
||||
*/
|
||||
private static final String ALLOWED_METHODS = "GET,POST,PUT,DELETE,OPTIONS,HEAD";
|
||||
|
||||
/**
|
||||
* 允许的请求来源,使用 * 表示允许任何来源
|
||||
*/
|
||||
private static final String ALLOWED_ORIGIN = "*";
|
||||
|
||||
/**
|
||||
* 允许前端访问的响应头,使用 * 表示允许任何响应头
|
||||
*/
|
||||
private static final String ALLOWED_EXPOSE = "*";
|
||||
|
||||
/**
|
||||
* 预检请求的缓存时间,单位为秒(此处设置为 5 小时)
|
||||
*/
|
||||
private static final String MAX_AGE = "18000L";
|
||||
|
||||
/**
|
||||
* 实现跨域配置的 Web 过滤器
|
||||
*
|
||||
* @param exchange ServerWebExchange 对象,表示一次 Web 交换
|
||||
* @param chain WebFilterChain 对象,表示一组 Web 过滤器链
|
||||
* @return Mono<Void> 表示异步的过滤器链处理结果
|
||||
*/
|
||||
@Override
|
||||
public Mono<Void> filter(ServerWebExchange exchange, WebFilterChain chain) {
|
||||
ServerHttpRequest request = exchange.getRequest();
|
||||
// 判断请求是否为跨域请求
|
||||
if (CorsUtils.isCorsRequest(request)) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
HttpHeaders headers = response.getHeaders();
|
||||
@@ -43,6 +67,7 @@ public class GlobalCorsFilter implements WebFilter, Ordered {
|
||||
headers.add("Access-Control-Expose-Headers", ALLOWED_EXPOSE);
|
||||
headers.add("Access-Control-Max-Age", MAX_AGE);
|
||||
headers.add("Access-Control-Allow-Credentials", "true");
|
||||
// 处理预检请求的 OPTIONS 方法,直接返回成功状态码
|
||||
if (request.getMethod() == HttpMethod.OPTIONS) {
|
||||
response.setStatusCode(HttpStatus.OK);
|
||||
return Mono.empty();
|
||||
|
@@ -87,4 +87,5 @@ public class SysOssConfig extends BaseEntity {
|
||||
* 桶权限类型(0private 1public 2custom)
|
||||
*/
|
||||
private String accessPolicy;
|
||||
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ import jakarta.validation.constraints.Size;
|
||||
* @author 孤舟烟雨
|
||||
* @date 2021-08-13
|
||||
*/
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@AutoMapper(target = SysOssConfig.class, reverseConvertGenerate = false)
|
||||
@@ -107,5 +106,4 @@ public class SysOssConfigBo extends BaseEntity {
|
||||
@NotBlank(message = "桶权限类型不能为空", groups = {AddGroup.class, EditGroup.class})
|
||||
private String accessPolicy;
|
||||
|
||||
|
||||
}
|
||||
|
@@ -10,4 +10,5 @@ import org.dromara.resource.domain.vo.SysOssVo;
|
||||
* @author Lion Li
|
||||
*/
|
||||
public interface SysOssMapper extends BaseMapperPlus<SysOss, SysOssVo> {
|
||||
|
||||
}
|
||||
|
@@ -37,7 +37,7 @@ public interface ISysOssConfigService {
|
||||
* 根据新增业务对象插入对象存储配置
|
||||
*
|
||||
* @param bo 对象存储配置新增业务对象
|
||||
* @return
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean insertByBo(SysOssConfigBo bo);
|
||||
|
||||
@@ -45,7 +45,7 @@ public interface ISysOssConfigService {
|
||||
* 根据编辑业务对象修改对象存储配置
|
||||
*
|
||||
* @param bo 对象存储配置编辑业务对象
|
||||
* @return
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean updateByBo(SysOssConfigBo bo);
|
||||
|
||||
@@ -54,7 +54,7 @@ public interface ISysOssConfigService {
|
||||
*
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
|
||||
|
@@ -1,13 +1,12 @@
|
||||
package org.dromara.resource.service;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.resource.domain.bo.SysOssBo;
|
||||
import org.dromara.resource.domain.vo.SysOssVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
@@ -20,21 +19,77 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysOssService {
|
||||
|
||||
/**
|
||||
* 查询OSS对象存储列表
|
||||
*
|
||||
* @param sysOss OSS对象存储分页查询对象
|
||||
* @param pageQuery 分页查询实体类
|
||||
* @return 结果
|
||||
*/
|
||||
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 根据一组 ossIds 获取对应的 SysOssVo 列表
|
||||
*
|
||||
* @param ossIds 一组文件在数据库中的唯一标识集合
|
||||
* @return 包含 SysOssVo 对象的列表
|
||||
*/
|
||||
List<SysOssVo> listByIds(Collection<Long> ossIds);
|
||||
|
||||
/**
|
||||
* 根据一组 ossIds 获取对应文件的 URL 列表
|
||||
*
|
||||
* @param ossIds 以逗号分隔的 ossId 字符串
|
||||
* @return 以逗号分隔的文件 URL 字符串
|
||||
*/
|
||||
String selectUrlByIds(String ossIds);
|
||||
|
||||
/**
|
||||
* 根据 ossId 从缓存或数据库中获取 SysOssVo 对象
|
||||
*
|
||||
* @param ossId 文件在数据库中的唯一标识
|
||||
* @return SysOssVo 对象,包含文件信息
|
||||
*/
|
||||
SysOssVo getById(Long ossId);
|
||||
|
||||
/**
|
||||
* 上传 MultipartFile 到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
* @param file 要上传的 MultipartFile 对象
|
||||
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||
*/
|
||||
SysOssVo upload(MultipartFile file);
|
||||
|
||||
/**
|
||||
* 上传文件到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
* @param file 要上传的文件对象
|
||||
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||
*/
|
||||
SysOssVo upload(File file);
|
||||
|
||||
/**
|
||||
* 新增OSS对象存储
|
||||
*
|
||||
* @param bo SysOssBo 对象,包含待插入的数据
|
||||
* @return 插入操作是否成功的布尔值
|
||||
*/
|
||||
Boolean insertByBo(SysOssBo bo);
|
||||
|
||||
/**
|
||||
* 文件下载方法,支持一次性下载完整文件
|
||||
*
|
||||
* @param ossId OSS对象ID
|
||||
* @param response HttpServletResponse对象,用于设置响应头和向客户端发送文件内容
|
||||
*/
|
||||
void download(Long ossId, HttpServletResponse response) throws IOException;
|
||||
|
||||
/**
|
||||
* 删除OSS对象存储
|
||||
*
|
||||
* @param ids OSS对象ID串
|
||||
* @param isValid 判断是否需要校验
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
|
@@ -51,6 +51,13 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
|
||||
private final SysOssMapper baseMapper;
|
||||
|
||||
/**
|
||||
* 查询OSS对象存储列表
|
||||
*
|
||||
* @param bo OSS对象存储分页查询对象
|
||||
* @param pageQuery 分页查询实体类
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
|
||||
@@ -60,6 +67,12 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一组 ossIds 获取对应的 SysOssVo 列表
|
||||
*
|
||||
* @param ossIds 一组文件在数据库中的唯一标识集合
|
||||
* @return 包含 SysOssVo 对象的列表
|
||||
*/
|
||||
@Override
|
||||
public List<SysOssVo> listByIds(Collection<Long> ossIds) {
|
||||
List<SysOssVo> list = new ArrayList<>();
|
||||
@@ -71,11 +84,18 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
} catch (Exception ignored) {
|
||||
// 如果oss异常无法连接则将数据直接返回
|
||||
list.add(vo);
|
||||
} }
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据一组 ossIds 获取对应文件的 URL 列表
|
||||
*
|
||||
* @param ossIds 以逗号分隔的 ossId 字符串
|
||||
* @return 以逗号分隔的文件 URL 字符串
|
||||
*/
|
||||
@Override
|
||||
public String selectUrlByIds(String ossIds) {
|
||||
List<String> list = new ArrayList<>();
|
||||
@@ -108,12 +128,24 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
return lqw;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据 ossId 从缓存或数据库中获取 SysOssVo 对象
|
||||
*
|
||||
* @param ossId 文件在数据库中的唯一标识
|
||||
* @return SysOssVo 对象,包含文件信息
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
|
||||
@Override
|
||||
public SysOssVo getById(Long ossId) {
|
||||
return baseMapper.selectVoById(ossId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件下载方法,支持一次性下载完整文件
|
||||
*
|
||||
* @param ossId OSS对象ID
|
||||
* @param response HttpServletResponse对象,用于设置响应头和向客户端发送文件内容
|
||||
*/
|
||||
@Override
|
||||
public void download(Long ossId, HttpServletResponse response) throws IOException {
|
||||
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
|
||||
@@ -123,7 +155,7 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
|
||||
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
|
||||
OssClient storage = OssFactory.instance(sysOss.getService());
|
||||
try(InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
|
||||
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
|
||||
int available = inputStream.available();
|
||||
IoUtil.copy(inputStream, response.getOutputStream(), available);
|
||||
response.setContentLength(available);
|
||||
@@ -132,6 +164,13 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传 MultipartFile 到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
* @param file 要上传的 MultipartFile 对象
|
||||
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||
* @throws ServiceException 如果上传过程中发生异常,则抛出 ServiceException 异常
|
||||
*/
|
||||
@Override
|
||||
public SysOssVo upload(MultipartFile file) {
|
||||
String originalfileName = file.getOriginalFilename();
|
||||
@@ -147,6 +186,12 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到对象存储服务,并保存文件信息到数据库
|
||||
*
|
||||
* @param file 要上传的文件对象
|
||||
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||
*/
|
||||
@Override
|
||||
public SysOssVo upload(File file) {
|
||||
String originalfileName = file.getName();
|
||||
@@ -169,6 +214,12 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
return this.matchingUrl(sysOssVo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增OSS对象存储
|
||||
*
|
||||
* @param bo SysOssBo 对象,包含待插入的数据
|
||||
* @return 插入操作是否成功的布尔值
|
||||
*/
|
||||
@Override
|
||||
public Boolean insertByBo(SysOssBo bo) {
|
||||
SysOss oss = BeanUtil.toBean(bo, SysOss.class);
|
||||
@@ -179,6 +230,13 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
return flag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除OSS对象存储
|
||||
*
|
||||
* @param ids OSS对象ID串
|
||||
* @param isValid 判断是否需要校验
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if (isValid) {
|
||||
@@ -193,7 +251,7 @@ public class SysOssServiceImpl implements ISysOssService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配Url
|
||||
* 桶类型为 private 的URL 修改为临时URL时长为120s
|
||||
*
|
||||
* @param oss OSS对象
|
||||
* @return oss 匹配Url的OSS对象
|
||||
|
@@ -148,16 +148,50 @@ public class RemoteUserServiceImpl implements RemoteUserService {
|
||||
return userService.registerUser(sysUserBo, remoteUserBo.getTenantId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户账户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户账户
|
||||
*/
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
return userService.selectUserNameById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户昵称
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户昵称
|
||||
*/
|
||||
@Override
|
||||
public String selectNicknameById(Long userId) {
|
||||
return userService.selectNicknameById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户手机号
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户手机号
|
||||
*/
|
||||
@Override
|
||||
public String selectPhonenumberById(Long userId) {
|
||||
return userService.selectPhonenumberById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户邮箱
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户邮箱
|
||||
*/
|
||||
@Override
|
||||
public String selectEmailById(Long userId) {
|
||||
return userService.selectEmailById(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建登录用户
|
||||
*/
|
||||
|
@@ -219,11 +219,27 @@ public interface ISysUserService {
|
||||
*/
|
||||
String selectNicknameById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户手机号
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户手机号
|
||||
*/
|
||||
String selectPhonenumberById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户邮箱
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户邮箱
|
||||
*/
|
||||
String selectEmailById(Long userId);
|
||||
|
||||
/**
|
||||
* 通过部门id查询当前部门所有用户
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
* @param deptId 部门id
|
||||
* @return 结果
|
||||
*/
|
||||
List<SysUserVo> selectUserListByDept(Long deptId);
|
||||
|
||||
|
@@ -94,7 +94,7 @@ public class SysClientServiceImpl implements ISysClientService {
|
||||
SysClient add = MapstructUtils.convert(bo, SysClient.class);
|
||||
validEntityBeforeSave(add);
|
||||
add.setGrantType(String.join(",", bo.getGrantTypeList()));
|
||||
// 生成clientid
|
||||
// 生成clientId
|
||||
String clientKey = bo.getClientKey();
|
||||
String clientSecret = bo.getClientSecret();
|
||||
add.setClientId(SecureUtil.md5(clientKey + clientSecret));
|
||||
|
@@ -523,8 +523,8 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
/**
|
||||
* 通过部门id查询当前部门所有用户
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
* @param deptId 部门ID
|
||||
* @return 用户信息集合信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUserVo> selectUserListByDept(Long deptId) {
|
||||
@@ -534,6 +534,12 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户账户
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户账户
|
||||
*/
|
||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||
@Override
|
||||
public String selectUserNameById(Long userId) {
|
||||
@@ -542,6 +548,12 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getUserName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户昵称
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 用户昵称
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(cacheNames = CacheNames.SYS_NICKNAME, key = "#userId")
|
||||
public String selectNicknameById(Long userId) {
|
||||
@@ -550,4 +562,30 @@ public class SysUserServiceImpl implements ISysUserService {
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getNickName();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户手机号
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户手机号
|
||||
*/
|
||||
@Override
|
||||
public String selectPhonenumberById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getPhonenumber).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getPhonenumber();
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户ID查询用户邮箱
|
||||
*
|
||||
* @param userId 用户id
|
||||
* @return 用户邮箱
|
||||
*/
|
||||
@Override
|
||||
public String selectEmailById(Long userId) {
|
||||
SysUser sysUser = baseMapper.selectOne(new LambdaQueryWrapper<SysUser>()
|
||||
.select(SysUser::getEmail).eq(SysUser::getUserId, userId));
|
||||
return ObjectUtil.isNull(sysUser) ? null : sysUser.getEmail();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user