优化代码格式
This commit is contained in:
parent
e7b6dac49f
commit
3bedaa7ddc
@ -74,6 +74,7 @@ public class CaptchaController
|
|||||||
AbstractCaptcha captcha = SpringUtils.getBean(captchaProperties.getCategory().getClazz());
|
AbstractCaptcha captcha = SpringUtils.getBean(captchaProperties.getCategory().getClazz());
|
||||||
captcha.setGenerator(codeGenerator);
|
captcha.setGenerator(codeGenerator);
|
||||||
captcha.createCode();
|
captcha.createCode();
|
||||||
|
// 如果是数学验证码,使用SpEL表达式处理验证码结果
|
||||||
String code = captcha.getCode();
|
String code = captcha.getCode();
|
||||||
if (isMath) {
|
if (isMath) {
|
||||||
ExpressionParser parser = new SpelExpressionParser();
|
ExpressionParser parser = new SpelExpressionParser();
|
||||||
|
@ -13,10 +13,19 @@ import lombok.Data;
|
|||||||
@AutoMapper(target = SysTenantVo.class)
|
@AutoMapper(target = SysTenantVo.class)
|
||||||
public class TenantListVo {
|
public class TenantListVo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 租户编号
|
||||||
|
*/
|
||||||
private String tenantId;
|
private String tenantId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业名称
|
||||||
|
*/
|
||||||
private String companyName;
|
private String companyName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 域名
|
||||||
|
*/
|
||||||
private String domain;
|
private String domain;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -109,6 +109,12 @@ public class LoginHelper {
|
|||||||
return Convert.toLong(getExtra(DEPT_KEY));
|
return Convert.toLong(getExtra(DEPT_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前 Token 的扩展信息
|
||||||
|
*
|
||||||
|
* @param key 键值
|
||||||
|
* @return 对应的扩展数据
|
||||||
|
*/
|
||||||
private static Object getExtra(String key) {
|
private static Object getExtra(String key) {
|
||||||
try {
|
try {
|
||||||
return StpUtil.getExtra(key);
|
return StpUtil.getExtra(key);
|
||||||
@ -142,12 +148,17 @@ public class LoginHelper {
|
|||||||
return UserConstants.SUPER_ADMIN_ID.equals(userId);
|
return UserConstants.SUPER_ADMIN_ID.equals(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否为超级管理员
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
public static boolean isSuperAdmin() {
|
public static boolean isSuperAdmin() {
|
||||||
return isSuperAdmin(getUserId());
|
return isSuperAdmin(getUserId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否为超级管理员
|
* 是否为租户管理员
|
||||||
*
|
*
|
||||||
* @param rolePermission 角色权限标识组
|
* @param rolePermission 角色权限标识组
|
||||||
* @return 结果
|
* @return 结果
|
||||||
@ -160,6 +171,12 @@ public class LoginHelper {
|
|||||||
return Convert.toBool(isTenantAdmin(getLoginUser().getRolePermission()));
|
return Convert.toBool(isTenantAdmin(getLoginUser().getRolePermission()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查当前用户是否已登录
|
||||||
|
*
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
public static boolean isLogin() {
|
public static boolean isLogin() {
|
||||||
return getLoginUser() != null;
|
return getLoginUser() != null;
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public interface ISysOssConfigService extends IBaseService<SysOssConfig> {
|
|||||||
* 根据新增业务对象插入对象存储配置
|
* 根据新增业务对象插入对象存储配置
|
||||||
*
|
*
|
||||||
* @param bo 对象存储配置新增业务对象
|
* @param bo 对象存储配置新增业务对象
|
||||||
* @return
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
Boolean insertByBo(SysOssConfigBo bo);
|
Boolean insertByBo(SysOssConfigBo bo);
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public interface ISysOssConfigService extends IBaseService<SysOssConfig> {
|
|||||||
* 根据编辑业务对象修改对象存储配置
|
* 根据编辑业务对象修改对象存储配置
|
||||||
*
|
*
|
||||||
* @param bo 对象存储配置编辑业务对象
|
* @param bo 对象存储配置编辑业务对象
|
||||||
* @return
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
Boolean updateByBo(SysOssConfigBo bo);
|
Boolean updateByBo(SysOssConfigBo bo);
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ public interface ISysOssConfigService extends IBaseService<SysOssConfig> {
|
|||||||
*
|
*
|
||||||
* @param ids 主键集合
|
* @param ids 主键集合
|
||||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||||
* @return
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
|
@ -20,18 +20,61 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public interface ISysOssService extends IBaseService<SysOss> {
|
public interface ISysOssService extends IBaseService<SysOss> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询OSS对象存储列表
|
||||||
|
*
|
||||||
|
* @param sysOss OSS对象存储分页查询对象
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss);
|
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据一组 ossIds 获取对应的 SysOssVo 列表
|
||||||
|
*
|
||||||
|
* @param ossIds 一组文件在数据库中的唯一标识集合
|
||||||
|
* @return 包含 SysOssVo 对象的列表
|
||||||
|
*/
|
||||||
List<SysOssVo> listSysOssByIds(Collection<Long> ossIds);
|
List<SysOssVo> listSysOssByIds(Collection<Long> ossIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ossId 从缓存或数据库中获取 SysOssVo 对象
|
||||||
|
*
|
||||||
|
* @param ossId 文件在数据库中的唯一标识
|
||||||
|
* @return SysOssVo 对象,包含文件信息
|
||||||
|
*/
|
||||||
SysOssVo getById(Long ossId);
|
SysOssVo getById(Long ossId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传 MultipartFile 到对象存储服务,并保存文件信息到数据库
|
||||||
|
*
|
||||||
|
* @param file 要上传的 MultipartFile 对象
|
||||||
|
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||||
|
*/
|
||||||
SysOssVo upload(MultipartFile file);
|
SysOssVo upload(MultipartFile file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件到对象存储服务,并保存文件信息到数据库
|
||||||
|
*
|
||||||
|
* @param file 要上传的文件对象
|
||||||
|
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||||
|
*/
|
||||||
SysOssVo upload(File file);
|
SysOssVo upload(File file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件下载方法,支持一次性下载完整文件
|
||||||
|
*
|
||||||
|
* @param ossId OSS对象ID
|
||||||
|
* @param response HttpServletResponse对象,用于设置响应头和向客户端发送文件内容
|
||||||
|
*/
|
||||||
void download(Long ossId, HttpServletResponse response) throws IOException;
|
void download(Long ossId, HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除OSS对象存储
|
||||||
|
*
|
||||||
|
* @param ids OSS对象ID串
|
||||||
|
* @param isValid 判断是否需要校验
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ public interface ISysUserService extends IBaseService<SysUser> {
|
|||||||
/**
|
/**
|
||||||
* 通过部门id查询当前部门所有用户
|
* 通过部门id查询当前部门所有用户
|
||||||
*
|
*
|
||||||
* @param deptId
|
* @param deptId 部门id
|
||||||
* @return 用户vo列表
|
* @return 用户vo列表
|
||||||
*/
|
*/
|
||||||
List<SysUserVo> selectUserListByDept(Long deptId);
|
List<SysUserVo> selectUserListByDept(Long deptId);
|
||||||
|
@ -71,10 +71,10 @@ public class SysLogininforServiceImpl extends BaseServiceImpl<SysLogininforMappe
|
|||||||
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
final UserAgent userAgent = UserAgentUtil.parse(request.getHeader("User-Agent"));
|
||||||
final String ip = ServletUtils.getClientIP(request);
|
final String ip = ServletUtils.getClientIP(request);
|
||||||
// 客户端信息
|
// 客户端信息
|
||||||
String clientid = request.getHeader(LoginHelper.CLIENT_KEY);
|
String clientId = request.getHeader(LoginHelper.CLIENT_KEY);
|
||||||
SysClient client = null;
|
SysClient client = null;
|
||||||
if (StringUtils.isNotBlank(clientid)) {
|
if (StringUtils.isNotBlank(clientId)) {
|
||||||
client = clientService.selectByClientId(clientid);
|
client = clientService.selectByClientId(clientId);
|
||||||
}
|
}
|
||||||
|
|
||||||
String address = AddressUtils.getRealAddressByIP(ip);
|
String address = AddressUtils.getRealAddressByIP(ip);
|
||||||
|
@ -69,6 +69,12 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return queryWrapper;
|
return queryWrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询OSS对象存储列表
|
||||||
|
*
|
||||||
|
* @param bo OSS对象存储分页查询对象
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo) {
|
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo) {
|
||||||
QueryWrapper queryWrapper = buildQueryWrapper(bo);
|
QueryWrapper queryWrapper = buildQueryWrapper(bo);
|
||||||
@ -78,6 +84,12 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return TableDataInfo.build(result);
|
return TableDataInfo.build(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据一组 ossIds 获取对应的 SysOssVo 列表
|
||||||
|
*
|
||||||
|
* @param ossIds 一组文件在数据库中的唯一标识集合
|
||||||
|
* @return 包含 SysOssVo 对象的列表
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<SysOssVo> listSysOssByIds(Collection<Long> ossIds) {
|
public List<SysOssVo> listSysOssByIds(Collection<Long> ossIds) {
|
||||||
List<SysOssVo> list = new ArrayList<>();
|
List<SysOssVo> list = new ArrayList<>();
|
||||||
@ -95,6 +107,12 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据一组 ossIds 获取对应文件的 URL 列表
|
||||||
|
*
|
||||||
|
* @param ossIds 以逗号分隔的 ossId 字符串
|
||||||
|
* @return 以逗号分隔的文件 URL 字符串
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String selectUrlByIds(String ossIds) {
|
public String selectUrlByIds(String ossIds) {
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
@ -112,7 +130,12 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return String.join(StringUtils.SEPARATOR, list);
|
return String.join(StringUtils.SEPARATOR, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据 ossId 从缓存或数据库中获取 SysOssVo 对象
|
||||||
|
*
|
||||||
|
* @param ossId 文件在数据库中的唯一标识
|
||||||
|
* @return SysOssVo 对象,包含文件信息
|
||||||
|
*/
|
||||||
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
|
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
|
||||||
@Override
|
@Override
|
||||||
public SysOssVo getById(Long ossId) {
|
public SysOssVo getById(Long ossId) {
|
||||||
@ -120,6 +143,12 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return ossMapper.selectOneWithRelationsByQueryAs(queryWrapper, SysOssVo.class);
|
return ossMapper.selectOneWithRelationsByQueryAs(queryWrapper, SysOssVo.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 文件下载方法,支持一次性下载完整文件
|
||||||
|
*
|
||||||
|
* @param ossId OSS对象ID
|
||||||
|
* @param response HttpServletResponse对象,用于设置响应头和向客户端发送文件内容
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void download(Long ossId, HttpServletResponse response) throws IOException {
|
public void download(Long ossId, HttpServletResponse response) throws IOException {
|
||||||
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
|
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
|
||||||
@ -138,6 +167,13 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传 MultipartFile 到对象存储服务,并保存文件信息到数据库
|
||||||
|
*
|
||||||
|
* @param file 要上传的 MultipartFile 对象
|
||||||
|
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||||
|
* @throws ServiceException 如果上传过程中发生异常,则抛出 ServiceException 异常
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysOssVo upload(MultipartFile file) {
|
public SysOssVo upload(MultipartFile file) {
|
||||||
String originalfileName = file.getOriginalFilename();
|
String originalfileName = file.getOriginalFilename();
|
||||||
@ -153,6 +189,12 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
return buildResultEntity(originalfileName, suffix, storage.getConfigKey(), uploadResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传文件到对象存储服务,并保存文件信息到数据库
|
||||||
|
*
|
||||||
|
* @param file 要上传的文件对象
|
||||||
|
* @return 上传成功后的 SysOssVo 对象,包含文件信息
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public SysOssVo upload(File file) {
|
public SysOssVo upload(File file) {
|
||||||
String originalfileName = file.getName();
|
String originalfileName = file.getName();
|
||||||
@ -175,6 +217,13 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
return this.matchingUrl(sysOssVo);
|
return this.matchingUrl(sysOssVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除OSS对象存储
|
||||||
|
*
|
||||||
|
* @param ids OSS对象ID串
|
||||||
|
* @param isValid 判断是否需要校验
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||||
if (isValid) {
|
if (isValid) {
|
||||||
@ -190,7 +239,7 @@ public class SysOssServiceImpl extends BaseServiceImpl<SysOssMapper, SysOss> imp
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 匹配Url
|
* 桶类型为 private 的URL 修改为临时URL时长为120s
|
||||||
*
|
*
|
||||||
* @param oss OSS对象
|
* @param oss OSS对象
|
||||||
* @return oss 匹配Url的OSS对象
|
* @return oss 匹配Url的OSS对象
|
||||||
|
@ -765,6 +765,12 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserMapper, SysUser>
|
|||||||
return successMsg.toString();
|
return successMsg.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过用户ID查询用户账户
|
||||||
|
*
|
||||||
|
* @param userId 用户ID
|
||||||
|
* @return 用户账户
|
||||||
|
*/
|
||||||
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
@Cacheable(cacheNames = CacheNames.SYS_USER_NAME, key = "#userId")
|
||||||
@Override
|
@Override
|
||||||
public String selectUserNameById(Long userId) {
|
public String selectUserNameById(Long userId) {
|
||||||
|
Loading…
Reference in New Issue
Block a user