feat: 全局格式化代码

This commit is contained in:
evo
2025-12-06 14:38:41 +08:00
parent 96c53390aa
commit 7c7d5838cd
538 changed files with 21132 additions and 14160 deletions

View File

@@ -112,6 +112,14 @@ public class SysMenu extends BaseEntity {
@TableField(exist = false)
private List<SysMenu> children = new ArrayList<>();
/**
* 内链域名特殊字符替换
*/
public static String innerLinkReplaceEach(String path) {
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, "."},
new String[]{"", "", "", "/"});
}
/**
* 获取路由名称
*/
@@ -135,7 +143,7 @@ public class SysMenu extends BaseEntity {
}
// 非外链并且是一级目录(类型为目录)
if (0L == getParentId() && UserConstants.TYPE_DIR.equals(getMenuType())
&& UserConstants.NO_FRAME.equals(getIsFrame())) {
&& UserConstants.NO_FRAME.equals(getIsFrame())) {
routerPath = "/" + this.path;
}
// 非外链并且是一级目录(类型为菜单)
@@ -180,12 +188,4 @@ public class SysMenu extends BaseEntity {
public boolean isParentView() {
return getParentId() != 0L && UserConstants.TYPE_DIR.equals(menuType);
}
/**
* 内链域名特殊字符替换
*/
public static String innerLinkReplaceEach(String path) {
return StringUtils.replaceEach(path, new String[]{Constants.HTTP, Constants.HTTPS, Constants.WWW, "."},
new String[]{"", "", "", "/"});
}
}

View File

@@ -127,6 +127,14 @@ public class SysUser extends TenantEntity {
* 用户等级
*/
private String userGrade;
/**
* 知识库角色组类型role/roleGroup
*/
private String kroleGroupType;
/**
* 知识库角色组idrole/roleGroup
*/
private String kroleGroupIds;
public SysUser(Long userId) {
this.userId = userId;
@@ -136,14 +144,4 @@ public class SysUser extends TenantEntity {
return UserConstants.SUPER_ADMIN_ID.equals(this.userId);
}
/**
* 知识库角色组类型role/roleGroup
*/
private String kroleGroupType;
/**
* 知识库角色组idrole/roleGroup
*/
private String kroleGroupIds;
}

View File

@@ -24,43 +24,43 @@ public class ChatConfigBo extends BaseEntity {
/**
* 主键
*/
@NotNull(message = "主键不能为空", groups = { EditGroup.class })
@NotNull(message = "主键不能为空", groups = {EditGroup.class})
private Long id;
/**
* 配置类型
*/
@NotBlank(message = "配置类型不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "配置类型不能为空", groups = {AddGroup.class, EditGroup.class})
private String category;
/**
* 配置名称
*/
@NotBlank(message = "配置名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "配置名称不能为空", groups = {AddGroup.class, EditGroup.class})
private String configName;
/**
* 配置值
*/
@NotBlank(message = "配置值不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "配置值不能为空", groups = {AddGroup.class, EditGroup.class})
private String configValue;
/**
* 说明
*/
@NotBlank(message = "说明不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "说明不能为空", groups = {AddGroup.class, EditGroup.class})
private String configDict;
/**
* 备注
*/
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "备注不能为空", groups = {AddGroup.class, EditGroup.class})
private String remark;
/**
* 更新IP
*/
@NotBlank(message = "更新IP不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "更新IP不能为空", groups = {AddGroup.class, EditGroup.class})
private String updateIp;

View File

@@ -25,27 +25,27 @@ public class SysConfigBo extends BaseEntity {
/**
* 参数主键
*/
@NotNull(message = "参数主键不能为空", groups = { EditGroup.class })
@NotNull(message = "参数主键不能为空", groups = {EditGroup.class})
private Long configId;
/**
* 参数名称
*/
@NotBlank(message = "参数名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "参数名称不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "参数名称不能超过{max}个字符")
private String configName;
/**
* 参数键名
*/
@NotBlank(message = "参数键名不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "参数键名不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "参数键名长度不能超过{max}个字符")
private String configKey;
/**
* 参数键值
*/
@NotBlank(message = "参数键值不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "参数键值不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 500, message = "参数键值长度不能超过{max}个字符")
private String configValue;

View File

@@ -26,7 +26,7 @@ public class SysDeptBo extends BaseEntity {
/**
* 部门id
*/
@NotNull(message = "部门id不能为空", groups = { EditGroup.class })
@NotNull(message = "部门id不能为空", groups = {EditGroup.class})
private Long deptId;
/**
@@ -37,7 +37,7 @@ public class SysDeptBo extends BaseEntity {
/**
* 部门名称
*/
@NotBlank(message = "部门名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "部门名称不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 30, message = "部门名称长度不能超过{max}个字符")
private String deptName;

View File

@@ -25,7 +25,7 @@ public class SysDictDataBo extends BaseEntity {
/**
* 字典编码
*/
@NotNull(message = "字典编码不能为空", groups = { EditGroup.class })
@NotNull(message = "字典编码不能为空", groups = {EditGroup.class})
private Long dictCode;
/**
@@ -36,21 +36,21 @@ public class SysDictDataBo extends BaseEntity {
/**
* 字典标签
*/
@NotBlank(message = "字典标签不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "字典标签不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "字典标签长度不能超过{max}个字符")
private String dictLabel;
/**
* 字典键值
*/
@NotBlank(message = "字典键值不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "字典键值不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "字典键值长度不能超过{max}个字符")
private String dictValue;
/**
* 字典类型
*/
@NotBlank(message = "字典类型不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "字典类型不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "字典类型长度不能超过{max}个字符")
private String dictType;

View File

@@ -26,20 +26,20 @@ public class SysDictTypeBo extends BaseEntity {
/**
* 字典主键
*/
@NotNull(message = "字典主键不能为空", groups = { EditGroup.class })
@NotNull(message = "字典主键不能为空", groups = {EditGroup.class})
private Long dictId;
/**
* 字典名称
*/
@NotBlank(message = "字典名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "字典名称不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "字典类型名称长度不能超过{max}个字符")
private String dictName;
/**
* 字典类型
*/
@NotBlank(message = "字典类型不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "字典类型不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "字典类型类型长度不能超过{max}个字符")
@Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
private String dictType;

View File

@@ -26,7 +26,7 @@ public class SysMenuBo extends BaseEntity {
/**
* 菜单ID
*/
@NotNull(message = "菜单ID不能为空", groups = { EditGroup.class })
@NotNull(message = "菜单ID不能为空", groups = {EditGroup.class})
private Long menuId;
/**
@@ -37,14 +37,14 @@ public class SysMenuBo extends BaseEntity {
/**
* 菜单名称
*/
@NotBlank(message = "菜单名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "菜单名称不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 50, message = "菜单名称长度不能超过{max}个字符")
private String menuName;
/**
* 显示顺序
*/
@NotNull(message = "显示顺序不能为空", groups = { AddGroup.class, EditGroup.class })
@NotNull(message = "显示顺序不能为空", groups = {AddGroup.class, EditGroup.class})
private Integer orderNum;
/**
@@ -77,7 +77,7 @@ public class SysMenuBo extends BaseEntity {
/**
* 菜单类型M目录 C菜单 F按钮
*/
@NotBlank(message = "菜单类型不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "菜单类型不能为空", groups = {AddGroup.class, EditGroup.class})
private String menuType;
/**

View File

@@ -26,14 +26,14 @@ public class SysNoticeBo extends BaseEntity {
/**
* 公告ID
*/
@NotNull(message = "公告ID不能为空", groups = { EditGroup.class })
@NotNull(message = "公告ID不能为空", groups = {EditGroup.class})
private Long noticeId;
/**
* 公告标题
*/
@Xss(message = "公告标题不能包含脚本字符")
@NotBlank(message = "公告标题不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "公告标题不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 50, message = "公告标题不能超过{max}个字符")
private String noticeTitle;

View File

@@ -24,31 +24,31 @@ public class SysNoticeStateBo extends BaseEntity {
/**
* ID
*/
@NotNull(message = "ID不能为空", groups = { EditGroup.class })
@NotNull(message = "ID不能为空", groups = {EditGroup.class})
private Long id;
/**
* 用户ID
*/
@NotNull(message = "用户ID不能为空", groups = { AddGroup.class, EditGroup.class })
@NotNull(message = "用户ID不能为空", groups = {AddGroup.class, EditGroup.class})
private Long userId;
/**
* 公告ID
*/
@NotNull(message = "公告ID不能为空", groups = { AddGroup.class, EditGroup.class })
@NotNull(message = "公告ID不能为空", groups = {AddGroup.class, EditGroup.class})
private Long noticeId;
/**
* 阅读状态0未读 1已读
*/
@NotBlank(message = "阅读状态0未读 1已读不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "阅读状态0未读 1已读不能为空", groups = {AddGroup.class, EditGroup.class})
private String readStatus;
/**
* 备注
*/
@NotBlank(message = "备注不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "备注不能为空", groups = {AddGroup.class, EditGroup.class})
private String remark;

View File

@@ -19,8 +19,8 @@ import java.util.Map;
@Data
@AutoMappers({
@AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false),
@AutoMapper(target = OperLogEvent.class)
@AutoMapper(target = SysOperLog.class, reverseConvertGenerate = false),
@AutoMapper(target = OperLogEvent.class)
})
public class SysOperLogBo {

View File

@@ -25,27 +25,27 @@ public class SysPostBo extends BaseEntity {
/**
* 岗位ID
*/
@NotNull(message = "岗位ID不能为空", groups = { EditGroup.class })
@NotNull(message = "岗位ID不能为空", groups = {EditGroup.class})
private Long postId;
/**
* 岗位编码
*/
@NotBlank(message = "岗位编码不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "岗位编码不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 64, message = "岗位编码长度不能超过{max}个字符")
private String postCode;
/**
* 岗位名称
*/
@NotBlank(message = "岗位名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "岗位名称不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 50, message = "岗位名称长度不能超过{max}个字符")
private String postName;
/**
* 显示顺序
*/
@NotNull(message = "显示顺序不能为空", groups = { AddGroup.class, EditGroup.class })
@NotNull(message = "显示顺序不能为空", groups = {AddGroup.class, EditGroup.class})
private Integer postSort;
/**

View File

@@ -28,27 +28,27 @@ public class SysRoleBo extends BaseEntity {
/**
* 角色ID
*/
@NotNull(message = "角色ID不能为空", groups = { EditGroup.class })
@NotNull(message = "角色ID不能为空", groups = {EditGroup.class})
private Long roleId;
/**
* 角色名称
*/
@NotBlank(message = "角色名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "角色名称不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 30, message = "角色名称长度不能超过{max}个字符")
private String roleName;
/**
* 角色权限字符串
*/
@NotBlank(message = "角色权限字符串不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "角色权限字符串不能为空", groups = {AddGroup.class, EditGroup.class})
@Size(min = 0, max = 100, message = "权限字符长度不能超过{max}个字符")
private String roleKey;
/**
* 显示顺序
*/
@NotNull(message = "显示顺序不能为空", groups = { AddGroup.class, EditGroup.class })
@NotNull(message = "显示顺序不能为空", groups = {AddGroup.class, EditGroup.class})
private Integer roleSort;
/**

View File

@@ -26,7 +26,7 @@ public class SysTenantBo extends BaseEntity {
/**
* id
*/
@NotNull(message = "id不能为空", groups = { EditGroup.class })
@NotNull(message = "id不能为空", groups = {EditGroup.class})
private Long id;
/**
@@ -37,31 +37,31 @@ public class SysTenantBo extends BaseEntity {
/**
* 联系人
*/
@NotBlank(message = "联系人不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "联系人不能为空", groups = {AddGroup.class, EditGroup.class})
private String contactUserName;
/**
* 联系电话
*/
@NotBlank(message = "联系电话不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "联系电话不能为空", groups = {AddGroup.class, EditGroup.class})
private String contactPhone;
/**
* 企业名称
*/
@NotBlank(message = "企业名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "企业名称不能为空", groups = {AddGroup.class, EditGroup.class})
private String companyName;
/**
* 用户名(创建系统用户)
*/
@NotBlank(message = "用户名不能为空", groups = { AddGroup.class })
@NotBlank(message = "用户名不能为空", groups = {AddGroup.class})
private String username;
/**
* 密码(创建系统用户)
*/
@NotBlank(message = "密码不能为空", groups = { AddGroup.class })
@NotBlank(message = "密码不能为空", groups = {AddGroup.class})
private String password;
/**
@@ -92,7 +92,7 @@ public class SysTenantBo extends BaseEntity {
/**
* 租户套餐编号
*/
@NotNull(message = "租户套餐不能为空", groups = { AddGroup.class })
@NotNull(message = "租户套餐不能为空", groups = {AddGroup.class})
private Long packageId;
/**

View File

@@ -25,13 +25,13 @@ public class SysTenantPackageBo extends BaseEntity {
/**
* 租户套餐id
*/
@NotNull(message = "租户套餐id不能为空", groups = { EditGroup.class })
@NotNull(message = "租户套餐id不能为空", groups = {EditGroup.class})
private Long packageId;
/**
* 套餐名称
*/
@NotBlank(message = "套餐名称不能为空", groups = { AddGroup.class, EditGroup.class })
@NotBlank(message = "套餐名称不能为空", groups = {AddGroup.class, EditGroup.class})
private String packageName;
/**

View File

@@ -134,6 +134,14 @@ public class SysUserBo extends BaseEntity {
* 用户余额
*/
private Double userBalance;
/**
* 知识库角色组类型role/roleGroup
*/
private String kroleGroupType;
/**
* 知识库角色组idrole/roleGroup
*/
private String kroleGroupIds;
public SysUserBo(Long userId) {
this.userId = userId;
@@ -143,14 +151,4 @@ public class SysUserBo extends BaseEntity {
return UserConstants.SUPER_ADMIN_ID.equals(this.userId);
}
/**
* 知识库角色组类型role/roleGroup
*/
private String kroleGroupType;
/**
* 知识库角色组idrole/roleGroup
*/
private String kroleGroupIds;
}

View File

@@ -1,4 +1,5 @@
package org.ruoyi.system.domain.bo;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
@@ -7,7 +8,7 @@ import java.io.Serializable;
/**
* 用户密码修改bo
* 用户密码修改bo
*
* @author ageerle@163.com
* date 2025/3/9

View File

@@ -18,7 +18,7 @@ import java.io.Serializable;
*/
@Data
@ExcelIgnoreUnannotated
@AutoMapper(target = ChatConfig.class)
@AutoMapper(target = ChatConfig.class)
public class ChatConfigVo implements Serializable {
@Serial

View File

@@ -13,7 +13,6 @@ import java.io.Serializable;
import java.util.Date;
/**
* 系统访问记录视图对象 sys_logininfor
*

View File

@@ -8,8 +8,6 @@ import java.io.Serial;
import java.io.Serializable;
/**
* 通知公告视图对象 sys_notice
*

View File

@@ -13,7 +13,6 @@ import java.io.Serializable;
import java.util.Date;
/**
* 岗位信息视图对象 sys_post
*

View File

@@ -27,12 +27,12 @@ public interface SysDeptMapper extends BaseMapperPlus<SysDept, SysDeptVo> {
* @return 部门信息集合
*/
@DataPermission({
@DataColumn(key = "deptName", value = "dept_id")
@DataColumn(key = "deptName", value = "dept_id")
})
List<SysDeptVo> selectDeptList(@Param(Constants.WRAPPER) Wrapper<SysDept> queryWrapper);
@DataPermission({
@DataColumn(key = "deptName", value = "dept_id")
@DataColumn(key = "deptName", value = "dept_id")
})
SysDeptVo selectDeptById(Long deptId);

View File

@@ -19,9 +19,9 @@ public interface SysDictDataMapper extends BaseMapperPlus<SysDictData, SysDictDa
default List<SysDictDataVo> selectDictDataByType(String dictType) {
return selectVoList(
new LambdaQueryWrapper<SysDictData>()
.eq(SysDictData::getStatus, UserConstants.DICT_NORMAL)
.eq(SysDictData::getDictType, dictType)
.orderByAsc(SysDictData::getDictSort));
new LambdaQueryWrapper<SysDictData>()
.eq(SysDictData::getStatus, UserConstants.DICT_NORMAL)
.eq(SysDictData::getDictType, dictType)
.orderByAsc(SysDictData::getDictSort));
}
}

View File

@@ -58,10 +58,10 @@ public interface SysMenuMapper extends BaseMapperPlus<SysMenu, SysMenuVo> {
*/
default List<SysMenu> selectMenuTreeAll() {
LambdaQueryWrapper<SysMenu> lqw = new LambdaQueryWrapper<SysMenu>()
.in(SysMenu::getMenuType, UserConstants.TYPE_DIR, UserConstants.TYPE_MENU)
.eq(SysMenu::getStatus, UserConstants.MENU_NORMAL)
.orderByAsc(SysMenu::getParentId)
.orderByAsc(SysMenu::getOrderNum);
.in(SysMenu::getMenuType, UserConstants.TYPE_DIR, UserConstants.TYPE_MENU)
.eq(SysMenu::getStatus, UserConstants.MENU_NORMAL)
.orderByAsc(SysMenu::getParentId)
.orderByAsc(SysMenu::getOrderNum);
return this.selectList(lqw);
}

View File

@@ -22,7 +22,7 @@ import java.util.List;
public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id")
@DataColumn(key = "deptName", value = "d.dept_id")
})
Page<SysRoleVo> selectPageRoleList(@Param("page") Page<SysRole> page, @Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper);
@@ -33,12 +33,12 @@ public interface SysRoleMapper extends BaseMapperPlus<SysRole, SysRoleVo> {
* @return 角色数据集合信息
*/
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id")
@DataColumn(key = "deptName", value = "d.dept_id")
})
List<SysRoleVo> selectRoleList(@Param(Constants.WRAPPER) Wrapper<SysRole> queryWrapper);
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id")
@DataColumn(key = "deptName", value = "d.dept_id")
})
SysRoleVo selectRoleById(Long roleId);

View File

@@ -24,8 +24,8 @@ import java.util.List;
public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
Page<SysUserVo> selectPageUserList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
@@ -36,8 +36,8 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
* @return 用户信息集合信息
*/
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
List<SysUserVo> selectUserList(@Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
@@ -48,8 +48,8 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
* @return 用户信息集合信息
*/
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
Page<SysUserVo> selectAllocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
@@ -60,8 +60,8 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
* @return 用户信息集合信息
*/
@DataPermission({
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
@DataColumn(key = "deptName", value = "d.dept_id"),
@DataColumn(key = "userName", value = "u.user_id")
})
Page<SysUserVo> selectUnallocatedList(@Param("page") Page<SysUser> page, @Param(Constants.WRAPPER) Wrapper<SysUser> queryWrapper);
@@ -161,7 +161,6 @@ public interface SysUserMapper extends BaseMapperPlus<SysUser, SysUserVo> {
* 小程序 -修改用户信息
*
* @param user
*
*/
void updateXcxUser(SysUserBo user);
}

View File

@@ -35,6 +35,7 @@ public interface ISysConfigService {
/**
* 获取注册开关
*
* @param tenantId 租户id
* @return true开启false关闭
*/

View File

@@ -16,13 +16,12 @@ import java.util.List;
public interface ISysDictTypeService {
/**
* Select all dictionary types based on the specified conditions
*
* @param dictType The business object containing query conditions for dictionary types
* @return TableDataInfo containing a list of SysDictTypeVo objects that match the query criteria
*/
/**
* Select all dictionary types based on the specified conditions
*
* @param dictType The business object containing query conditions for dictionary types
* @return TableDataInfo containing a list of SysDictTypeVo objects that match the query criteria
*/
TableDataInfo<SysDictTypeVo> selectAll(SysDictTypeBo dictType);
TableDataInfo<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageQuery pageQuery);

View File

@@ -46,5 +46,5 @@ public interface ISysLogininforService {
*/
void cleanLogininfor();
void recordLogininfor(LogininforEvent logininforEvent);
void recordLogininfor(LogininforEvent logininforEvent);
}

View File

@@ -17,7 +17,6 @@ public interface ISysNoticeService {
TableDataInfo<SysNoticeVo> selectPageNoticeList(SysNoticeBo notice, PageQuery pageQuery);
/**
* 查询公告信息
*

View File

@@ -52,5 +52,6 @@ public interface ISysOperLogService {
* 清空操作日志
*/
void cleanOperLog();
void recordOper(OperLogEvent operLogEvent);
void recordOper(OperLogEvent operLogEvent);
}

View File

@@ -18,29 +18,29 @@ import java.util.List;
*/
public interface ISysOssService {
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery);
TableDataInfo<SysOssVo> queryPageList(SysOssBo sysOss, PageQuery pageQuery);
List<SysOssVo> listByIds(Collection<Long> ossIds);
List<SysOssVo> listByIds(Collection<Long> ossIds);
SysOssVo getById(Long ossId);
SysOssVo getById(Long ossId);
SysOssVo upload(MultipartFile file);
SysOssVo upload(MultipartFile file);
void download(Long ossId, HttpServletResponse response) throws IOException;
void download(Long ossId, HttpServletResponse response) throws IOException;
MultipartFile downloadByFile(Long ossId) throws IOException;
MultipartFile downloadByFile(Long ossId) throws IOException;
String downloadByByte(Long ossId) throws IOException;
String downloadByByte(Long ossId) throws IOException;
String downloadToTempPath(Long ossId) throws IOException;
String downloadToTempPath(Long ossId) throws IOException;
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
/**
* 根据文件路径删除文件
*
* @param filePath 文件路径
* @return 是否删除成功
*/
boolean deleteFile(String filePath);
/**
* 根据文件路径删除文件
*
* @param filePath 文件路径
* @return 是否删除成功
*/
boolean deleteFile(String filePath);
}

View File

@@ -12,7 +12,7 @@ public interface ISysPermissionService {
/**
* 获取角色数据权限
*
* @param userId 用户id
* @param userId 用户id
* @return 角色权限信息
*/
Set<String> getRolePermission(Long userId);
@@ -20,7 +20,7 @@ public interface ISysPermissionService {
/**
* 获取菜单数据权限
*
* @param userId 用户id
* @param userId 用户id
* @return 菜单权限信息
*/
Set<String> getMenuPermission(Long userId);

View File

@@ -1,7 +1,6 @@
package org.ruoyi.system.service;
import org.ruoyi.core.page.PageQuery;
import org.ruoyi.core.page.TableDataInfo;
import org.ruoyi.system.domain.bo.SysTenantBo;

View File

@@ -53,9 +53,9 @@ public interface ISysUserService {
/**
* 通过OpenId查询用户
*
* @Date 2023/5/18
* @param openId
* @return SysUserVo
* @Date 2023/5/18
**/
SysUserVo selectUserByOpenId(String openId);
@@ -140,10 +140,10 @@ public interface ISysUserService {
/**
* 注册用户信息
*
* @Date 2023/5/18
* @param user
* @param tenantId
* @return SysUser
* @Date 2023/5/18
**/
SysUser registerUser(SysUserBo user, String tenantId);
@@ -159,7 +159,6 @@ public interface ISysUserService {
* 小程序 - 修改用户信息
*
* @param user 用户信息
*
*/
SysUserVo updateXcxUser(SysUserBo user);
@@ -210,7 +209,6 @@ public interface ISysUserService {
int resetUserPwd(Long userId, String password);
/**
* 通过用户ID删除用户
*

View File

@@ -36,12 +36,12 @@ public class ChatConfigServiceImpl implements ConfigService, IChatConfigService
/**
* 根据配置类型和配置key获取值
*
* @param category 分类
* @param category 分类
* @param configKey key名称
* @return
*/
@Override
public String getConfigValue(String category,String configKey) {
public String getConfigValue(String category, String configKey) {
ChatConfigBo bo = new ChatConfigBo();
bo.setCategory(category);
bo.setConfigName(configKey);
@@ -54,7 +54,7 @@ public class ChatConfigServiceImpl implements ConfigService, IChatConfigService
* 查询配置信息
*/
@Override
public ChatConfigVo queryById(Long id){
public ChatConfigVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
@@ -114,7 +114,7 @@ public class ChatConfigServiceImpl implements ConfigService, IChatConfigService
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(ChatConfig entity){
private void validEntityBeforeSave(ChatConfig entity) {
//TODO 做一些数据校验,如唯一约束
}
@@ -123,7 +123,7 @@ public class ChatConfigServiceImpl implements ConfigService, IChatConfigService
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;

View File

@@ -69,7 +69,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
@Override
public String selectConfigByKey(String configKey) {
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
.eq(SysConfig::getConfigKey, configKey));
.eq(SysConfig::getConfigKey, configKey));
if (ObjectUtil.isNotNull(retConfig)) {
return retConfig.getConfigValue();
}
@@ -78,14 +78,15 @@ public class SysConfigServiceImpl implements ISysConfigService {
/**
* 获取注册开关
*
* @param tenantId 租户id
* @return true开启false关闭
*/
@Override
public boolean selectRegisterEnabled(String tenantId) {
SysConfig retConfig = baseMapper.selectOne(new LambdaQueryWrapper<SysConfig>()
.eq(SysConfig::getConfigKey, "sys.account.registerUser")
.eq(TenantHelper.isEnable(),SysConfig::getTenantId, tenantId));
.eq(SysConfig::getConfigKey, "sys.account.registerUser")
.eq(TenantHelper.isEnable(), SysConfig::getTenantId, tenantId));
if (ObjectUtil.isNull(retConfig)) {
return false;
}
@@ -111,7 +112,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
lqw.eq(StringUtils.isNotBlank(bo.getConfigType()), SysConfig::getConfigType, bo.getConfigType());
lqw.like(StringUtils.isNotBlank(bo.getConfigKey()), SysConfig::getConfigKey, bo.getConfigKey());
lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
SysConfig::getCreateTime, params.get("beginTime"), params.get("endTime"));
return lqw;
}
@@ -151,7 +152,7 @@ public class SysConfigServiceImpl implements ISysConfigService {
row = baseMapper.updateById(config);
} else {
row = baseMapper.update(config, new LambdaQueryWrapper<SysConfig>()
.eq(SysConfig::getConfigKey, config.getConfigKey()));
.eq(SysConfig::getConfigKey, config.getConfigKey()));
}
if (row > 0) {
return config.getConfigValue();

View File

@@ -33,9 +33,9 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
@Override
public String getRoleCustom(Long roleId) {
List<SysRoleDept> list = roleDeptMapper.selectList(
new LambdaQueryWrapper<SysRoleDept>()
.select(SysRoleDept::getDeptId)
.eq(SysRoleDept::getRoleId, roleId));
new LambdaQueryWrapper<SysRoleDept>()
.select(SysRoleDept::getDeptId)
.eq(SysRoleDept::getRoleId, roleId));
if (CollUtil.isNotEmpty(list)) {
return StreamUtils.join(list, rd -> Convert.toStr(rd.getDeptId()));
}
@@ -55,13 +55,13 @@ public class SysDataScopeServiceImpl implements ISysDataScopeService {
@Override
public String getDeptAndChild(Long deptId) {
List<SysDept> deptList = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId)
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
.select(SysDept::getDeptId)
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
List<Long> ids = StreamUtils.toList(deptList, SysDept::getDeptId);
ids.add(deptId);
List<SysDept> list = deptMapper.selectList(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptId)
.in(SysDept::getDeptId, ids));
.select(SysDept::getDeptId)
.in(SysDept::getDeptId, ids));
if (CollUtil.isNotEmpty(list)) {
return StreamUtils.join(list, d -> Convert.toStr(d.getDeptId()));
}

View File

@@ -98,10 +98,10 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return CollUtil.newArrayList();
}
return TreeBuildUtils.build(depts, (dept, tree) ->
tree.setId(dept.getDeptId())
.setParentId(dept.getParentId())
.setName(dept.getDeptName())
.setWeight(dept.getOrderNum()));
tree.setId(dept.getDeptId())
.setParentId(dept.getParentId())
.setName(dept.getDeptName())
.setWeight(dept.getOrderNum()));
}
/**
@@ -130,7 +130,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
return null;
}
SysDeptVo parentDept = baseMapper.selectVoOne(new LambdaQueryWrapper<SysDept>()
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
.select(SysDept::getDeptName).eq(SysDept::getDeptId, dept.getParentId()));
dept.setParentName(ObjectUtil.isNotNull(parentDept) ? parentDept.getDeptName() : null);
return dept;
}
@@ -162,8 +162,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public long selectNormalChildrenDeptById(Long deptId) {
return baseMapper.selectCount(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
.eq(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
}
/**
@@ -175,7 +175,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public boolean hasChildByDeptId(Long deptId) {
return baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getParentId, deptId));
.eq(SysDept::getParentId, deptId));
}
/**
@@ -187,7 +187,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public boolean checkDeptExistUser(Long deptId) {
return userMapper.exists(new LambdaQueryWrapper<SysUser>()
.eq(SysUser::getDeptId, deptId));
.eq(SysUser::getDeptId, deptId));
}
/**
@@ -199,9 +199,9 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
@Override
public boolean checkDeptNameUnique(SysDeptBo dept) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDept>()
.eq(SysDept::getDeptName, dept.getDeptName())
.eq(SysDept::getParentId, dept.getParentId())
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
.eq(SysDept::getDeptName, dept.getDeptName())
.eq(SysDept::getParentId, dept.getParentId())
.ne(ObjectUtil.isNotNull(dept.getDeptId()), SysDept::getDeptId, dept.getDeptId()));
return !exist;
}
@@ -266,7 +266,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
}
int result = baseMapper.updateById(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
&& !StringUtils.equals(UserConstants.DEPT_NORMAL, dept.getAncestors())) {
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
@@ -282,8 +282,8 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors);
baseMapper.update(null, new LambdaUpdateWrapper<SysDept>()
.set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
.set(SysDept::getStatus, UserConstants.DEPT_NORMAL)
.in(SysDept::getDeptId, Arrays.asList(deptIds)));
}
/**
@@ -295,7 +295,7 @@ public class SysDeptServiceImpl implements ISysDeptService, DeptService {
*/
private void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
List<SysDept> children = baseMapper.selectList(new LambdaQueryWrapper<SysDept>()
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
.apply(DataBaseHelper.findInSet(deptId, "ancestors")));
List<SysDept> list = new ArrayList<>();
for (SysDept child : children) {
SysDept dept = new SysDept();

View File

@@ -71,10 +71,10 @@ public class SysDictDataServiceImpl implements ISysDictDataService {
@Override
public String selectDictLabel(String dictType, String dictValue) {
return baseMapper.selectOne(new LambdaQueryWrapper<SysDictData>()
.select(SysDictData::getDictLabel)
.eq(SysDictData::getDictType, dictType)
.eq(SysDictData::getDictValue, dictValue))
.getDictLabel();
.select(SysDictData::getDictLabel)
.eq(SysDictData::getDictType, dictType)
.eq(SysDictData::getDictValue, dictValue))
.getDictLabel();
}
/**

View File

@@ -63,6 +63,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
rspData.setTotal(list.size()); // 总数为列表大小
return rspData;
}
@Override
public TableDataInfo<SysDictTypeVo> selectPageDictTypeList(SysDictTypeBo dictType, PageQuery pageQuery) {
LambdaQueryWrapper<SysDictType> lqw = buildQueryWrapper(dictType);
@@ -89,7 +90,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
lqw.like(StringUtils.isNotBlank(bo.getDictType()), SysDictType::getDictType, bo.getDictType());
lqw.eq(StringUtils.isNotBlank(bo.getStatus()), SysDictType::getStatus, bo.getStatus());
lqw.between(params.get("beginTime") != null && params.get("endTime") != null,
SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"));
SysDictType::getCreateTime, params.get("beginTime"), params.get("endTime"));
return lqw;
}
@@ -109,7 +110,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
* @param dictType 字典类型
* @return 字典数据集合信息
*/
// @Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
// @Cacheable(cacheNames = CacheNames.SYS_DICT, key = "#dictType")
@Override
public List<SysDictDataVo> selectDictDataByType(String dictType) {
List<SysDictDataVo> dictDatas = dictDataMapper.selectDictDataByType(dictType);
@@ -152,7 +153,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
for (Long dictId : dictIds) {
SysDictType dictType = baseMapper.selectById(dictId);
if (dictDataMapper.exists(new LambdaQueryWrapper<SysDictData>()
.eq(SysDictData::getDictType, dictType.getDictType()))) {
.eq(SysDictData::getDictType, dictType.getDictType()))) {
throw new ServiceException(String.format("%1$s已分配,不能删除", dictType.getDictName()));
}
CacheUtils.evict(CacheNames.SYS_DICT, dictType.getDictType());
@@ -198,8 +199,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
SysDictType dict = MapstructUtils.convert(bo, SysDictType.class);
SysDictType oldDict = baseMapper.selectById(dict.getDictId());
dictDataMapper.update(null, new LambdaUpdateWrapper<SysDictData>()
.set(SysDictData::getDictType, dict.getDictType())
.eq(SysDictData::getDictType, oldDict.getDictType()));
.set(SysDictData::getDictType, dict.getDictType())
.eq(SysDictData::getDictType, oldDict.getDictType()));
int row = baseMapper.updateById(dict);
if (row > 0) {
CacheUtils.evict(CacheNames.SYS_DICT, oldDict.getDictType());
@@ -217,8 +218,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
@Override
public boolean checkDictTypeUnique(SysDictTypeBo dictType) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysDictType>()
.eq(SysDictType::getDictType, dictType.getDictType())
.ne(ObjectUtil.isNotNull(dictType.getDictId()), SysDictType::getDictId, dictType.getDictId()));
.eq(SysDictType::getDictType, dictType.getDictType())
.ne(ObjectUtil.isNotNull(dictType.getDictId()), SysDictType::getDictId, dictType.getDictId()));
return !exist;
}
@@ -243,8 +244,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictValue, SysDictDataVo::getDictLabel);
if (StringUtils.containsAny(dictValue, separator)) {
return Arrays.stream(dictValue.split(separator))
.map(v -> map.getOrDefault(v, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
.map(v -> map.getOrDefault(v, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
} else {
return map.getOrDefault(dictValue, StringUtils.EMPTY);
}
@@ -271,8 +272,8 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService, DictService
Map<String, String> map = StreamUtils.toMap(datas, SysDictDataVo::getDictLabel, SysDictDataVo::getDictValue);
if (StringUtils.containsAny(dictLabel, separator)) {
return Arrays.stream(dictLabel.split(separator))
.map(l -> map.getOrDefault(l, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
.map(l -> map.getOrDefault(l, StringUtils.EMPTY))
.collect(Collectors.joining(separator));
} else {
return map.getOrDefault(dictLabel, StringUtils.EMPTY);
}

View File

@@ -97,11 +97,11 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
public TableDataInfo<SysLogininforVo> selectPageLogininforList(SysLogininforBo logininfor, PageQuery pageQuery) {
Map<String, Object> params = logininfor.getParams();
LambdaQueryWrapper<SysLogininfor> lqw = new LambdaQueryWrapper<SysLogininfor>()
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"));
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"));
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
pageQuery.setOrderByColumn("info_id");
pageQuery.setIsAsc("desc");
@@ -132,12 +132,12 @@ public class SysLogininforServiceImpl implements ISysLogininforService {
public List<SysLogininforVo> selectLogininforList(SysLogininforBo logininfor) {
Map<String, Object> params = logininfor.getParams();
return baseMapper.selectVoList(new LambdaQueryWrapper<SysLogininfor>()
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"))
.orderByDesc(SysLogininfor::getInfoId));
.like(StringUtils.isNotBlank(logininfor.getIpaddr()), SysLogininfor::getIpaddr, logininfor.getIpaddr())
.eq(StringUtils.isNotBlank(logininfor.getStatus()), SysLogininfor::getStatus, logininfor.getStatus())
.like(StringUtils.isNotBlank(logininfor.getUserName()), SysLogininfor::getUserName, logininfor.getUserName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysLogininfor::getLoginTime, params.get("beginTime"), params.get("endTime"))
.orderByDesc(SysLogininfor::getInfoId));
}
/**

View File

@@ -68,19 +68,19 @@ public class SysMenuServiceImpl implements ISysMenuService {
// 管理员显示所有菜单信息
if (LoginHelper.isSuperAdmin(userId)) {
menuList = baseMapper.selectVoList(new LambdaQueryWrapper<SysMenu>()
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
.orderByAsc(SysMenu::getParentId)
.orderByAsc(SysMenu::getOrderNum));
.like(StringUtils.isNotBlank(menu.getMenuName()), SysMenu::getMenuName, menu.getMenuName())
.eq(StringUtils.isNotBlank(menu.getVisible()), SysMenu::getVisible, menu.getVisible())
.eq(StringUtils.isNotBlank(menu.getStatus()), SysMenu::getStatus, menu.getStatus())
.orderByAsc(SysMenu::getParentId)
.orderByAsc(SysMenu::getOrderNum));
} else {
QueryWrapper<SysMenu> wrapper = Wrappers.query();
wrapper.eq("sur.user_id", userId)
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
.orderByAsc("m.parent_id")
.orderByAsc("m.order_num");
.like(StringUtils.isNotBlank(menu.getMenuName()), "m.menu_name", menu.getMenuName())
.eq(StringUtils.isNotBlank(menu.getVisible()), "m.visible", menu.getVisible())
.eq(StringUtils.isNotBlank(menu.getStatus()), "m.status", menu.getStatus())
.orderByAsc("m.parent_id")
.orderByAsc("m.order_num");
List<SysMenu> list = baseMapper.selectMenuListByUserId(wrapper);
menuList = MapstructUtils.convert(list, SysMenuVo.class);
}
@@ -169,11 +169,15 @@ public class SysMenuServiceImpl implements ISysMenuService {
if (tenantPackage.getMenuCheckStrictly()) {
parentIds = baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
.select(SysMenu::getParentId)
.in(SysMenu::getMenuId, menuIds), x -> {return Convert.toLong(x);});
.in(SysMenu::getMenuId, menuIds), x -> {
return Convert.toLong(x);
});
}
return baseMapper.selectObjs(new LambdaQueryWrapper<SysMenu>()
.in(SysMenu::getMenuId, menuIds)
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), x -> {return Convert.toLong(x);});
.notIn(CollUtil.isNotEmpty(parentIds), SysMenu::getMenuId, parentIds), x -> {
return Convert.toLong(x);
});
}
/**
@@ -239,10 +243,10 @@ public class SysMenuServiceImpl implements ISysMenuService {
return CollUtil.newArrayList();
}
return TreeBuildUtils.build(menus, (menu, tree) ->
tree.setId(menu.getMenuId())
.setParentId(menu.getParentId())
.setName(menu.getMenuName())
.setWeight(menu.getOrderNum()));
tree.setId(menu.getMenuId())
.setParentId(menu.getParentId())
.setName(menu.getMenuName())
.setWeight(menu.getOrderNum()));
}
/**
@@ -322,9 +326,9 @@ public class SysMenuServiceImpl implements ISysMenuService {
@Override
public boolean checkMenuNameUnique(SysMenuBo menu) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysMenu>()
.eq(SysMenu::getMenuName, menu.getMenuName())
.eq(SysMenu::getParentId, menu.getParentId())
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
.eq(SysMenu::getMenuName, menu.getMenuName())
.eq(SysMenu::getParentId, menu.getParentId())
.ne(ObjectUtil.isNotNull(menu.getMenuId()), SysMenu::getMenuId, menu.getMenuId()));
return !exist;
}

View File

@@ -66,7 +66,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
*/
@Override
public SysNotice getNotice(SysNoticeBo notice) {
if(!StpUtil.isLogin()){
if (!StpUtil.isLogin()) {
return null;
}
@@ -81,7 +81,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
SysNoticeState sysNoticeState = states.isEmpty() ? null : states.get(0); // 取第一条记录
if (sysNoticeState != null) {
return baseMapper.selectById(sysNoticeState.getNoticeId());
}else {
} else {
return null;
}
}
@@ -109,7 +109,7 @@ public class SysNoticeServiceImpl implements ISysNoticeService {
// 插入公告
int insert = baseMapper.insert(notice);
// 公告类型1通知 2公告
if("1".equals(bo.getNoticeType())){
if ("1".equals(bo.getNoticeType())) {
// 将之前通知全部设为已读
noticeStateMapper.readAllNotice();
// 插入通知阅读状态

View File

@@ -35,7 +35,7 @@ public class SysNoticeStateServiceImpl implements ISysNoticeStateService {
* 查询用户阅读状态
*/
@Override
public SysNoticeStateVo queryById(Long id){
public SysNoticeStateVo queryById(Long id) {
return baseMapper.selectVoById(id);
}
@@ -95,7 +95,7 @@ public class SysNoticeStateServiceImpl implements ISysNoticeStateService {
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(SysNoticeState entity){
private void validEntityBeforeSave(SysNoticeState entity) {
//TODO 做一些数据校验,如唯一约束
}
@@ -104,7 +104,7 @@ public class SysNoticeStateServiceImpl implements ISysNoticeStateService {
*/
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if(isValid){
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;

View File

@@ -54,19 +54,19 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
public TableDataInfo<SysOperLogVo> selectPageOperLogList(SysOperLogBo operLog, PageQuery pageQuery) {
Map<String, Object> params = operLog.getParams();
LambdaQueryWrapper<SysOperLog> lqw = new LambdaQueryWrapper<SysOperLog>()
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
SysOperLog::getBusinessType, operLog.getBusinessType())
.func(f -> {
if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
}
})
.eq(operLog.getStatus() != null,
SysOperLog::getStatus, operLog.getStatus())
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"));
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
SysOperLog::getBusinessType, operLog.getBusinessType())
.func(f -> {
if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
}
})
.eq(operLog.getStatus() != null,
SysOperLog::getStatus, operLog.getStatus())
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"));
if (StringUtils.isBlank(pageQuery.getOrderByColumn())) {
pageQuery.setOrderByColumn("oper_id");
pageQuery.setIsAsc("desc");
@@ -97,20 +97,20 @@ public class SysOperLogServiceImpl implements ISysOperLogService {
public List<SysOperLogVo> selectOperLogList(SysOperLogBo operLog) {
Map<String, Object> params = operLog.getParams();
return baseMapper.selectVoList(new LambdaQueryWrapper<SysOperLog>()
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
SysOperLog::getBusinessType, operLog.getBusinessType())
.func(f -> {
if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
}
})
.eq(operLog.getStatus() != null && operLog.getStatus() > 0,
SysOperLog::getStatus, operLog.getStatus())
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"))
.orderByDesc(SysOperLog::getOperId));
.like(StringUtils.isNotBlank(operLog.getTitle()), SysOperLog::getTitle, operLog.getTitle())
.eq(operLog.getBusinessType() != null && operLog.getBusinessType() > 0,
SysOperLog::getBusinessType, operLog.getBusinessType())
.func(f -> {
if (ArrayUtil.isNotEmpty(operLog.getBusinessTypes())) {
f.in(SysOperLog::getBusinessType, Arrays.asList(operLog.getBusinessTypes()));
}
})
.eq(operLog.getStatus() != null && operLog.getStatus() > 0,
SysOperLog::getStatus, operLog.getStatus())
.like(StringUtils.isNotBlank(operLog.getOperName()), SysOperLog::getOperName, operLog.getOperName())
.between(params.get("beginTime") != null && params.get("endTime") != null,
SysOperLog::getOperTime, params.get("beginTime"), params.get("endTime"))
.orderByDesc(SysOperLog::getOperId));
}
/**

View File

@@ -53,8 +53,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
@Override
public void init() {
List<SysOssConfig> list = TenantHelper.ignore(() ->
baseMapper.selectList(
new LambdaQueryWrapper<SysOssConfig>().orderByAsc(TenantEntity::getTenantId))
baseMapper.selectList(
new LambdaQueryWrapper<SysOssConfig>().orderByAsc(TenantEntity::getTenantId))
);
Map<String, List<SysOssConfig>> map = StreamUtils.groupByKey(list, SysOssConfig::getTenantId);
try {
@@ -128,7 +128,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
*/
private void validEntityBeforeSave(SysOssConfig entity) {
if (StringUtils.isNotEmpty(entity.getConfigKey())
&& !checkConfigKeyUnique(entity)) {
&& !checkConfigKeyUnique(entity)) {
throw new ServiceException("操作配置'" + entity.getConfigKey() + "'失败, 配置key已存在!");
}
}
@@ -148,7 +148,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
boolean flag = baseMapper.deleteBatchIds(ids) > 0;
if (flag) {
list.forEach(sysOssConfig ->
CacheUtils.evict(CacheNames.SYS_OSS_CONFIG, sysOssConfig.getConfigKey()));
CacheUtils.evict(CacheNames.SYS_OSS_CONFIG, sysOssConfig.getConfigKey()));
}
return flag;
}
@@ -159,8 +159,8 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
private boolean checkConfigKeyUnique(SysOssConfig sysOssConfig) {
long ossConfigId = ObjectUtil.isNull(sysOssConfig.getOssConfigId()) ? -1L : sysOssConfig.getOssConfigId();
SysOssConfig info = baseMapper.selectOne(new LambdaQueryWrapper<SysOssConfig>()
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
.select(SysOssConfig::getOssConfigId, SysOssConfig::getConfigKey)
.eq(SysOssConfig::getConfigKey, sysOssConfig.getConfigKey()));
if (ObjectUtil.isNotNull(info) && info.getOssConfigId() != ossConfigId) {
return false;
}
@@ -175,7 +175,7 @@ public class SysOssConfigServiceImpl implements ISysOssConfigService {
public int updateOssConfigStatus(SysOssConfigBo bo) {
SysOssConfig sysOssConfig = MapstructUtils.convert(bo, SysOssConfig.class);
int row = baseMapper.update(null, new LambdaUpdateWrapper<SysOssConfig>()
.set(SysOssConfig::getStatus, "1"));
.set(SysOssConfig::getStatus, "1"));
row += baseMapper.updateById(sysOssConfig);
if (row > 0) {
RedisUtils.setCacheObject(OssConstant.DEFAULT_CONFIG_KEY, sysOssConfig.getConfigKey());

View File

@@ -46,211 +46,214 @@ import java.util.*;
@Service
public class SysOssServiceImpl implements ISysOssService, OssService {
private final SysOssMapper baseMapper;
private final SysOssMapper baseMapper;
@Override
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
List<SysOssVo> filterResult = StreamUtils.toList(result.getRecords(), this::matchingUrl);
result.setRecords(filterResult);
return TableDataInfo.build(result);
}
@Override
public List<SysOssVo> listByIds(Collection<Long> ossIds) {
List<SysOssVo> list = new ArrayList<>();
for (Long id : ossIds) {
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
if (ObjectUtil.isNotNull(vo)) {
list.add(this.matchingUrl(vo));
}
}
return list;
}
@Override
public String selectUrlByIds(String ossIds) {
List<String> list = new ArrayList<>();
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
if (ObjectUtil.isNotNull(vo)) {
list.add(this.matchingUrl(vo).getUrl());
}
}
return String.join(StringUtils.SEPARATOR, list);
}
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName());
lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName,
bo.getOriginalName());
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix());
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
return lqw;
}
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
@Override
public SysOssVo getById(Long ossId) {
return baseMapper.selectVoById(ossId);
}
@Override
public void download(Long ossId, HttpServletResponse response) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
int available = inputStream.available();
IoUtil.copy(inputStream, response.getOutputStream(), available);
response.setContentLength(available);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public String downloadByByte(Long ossId) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
@Override
public TableDataInfo<SysOssVo> queryPageList(SysOssBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<SysOss> lqw = buildQueryWrapper(bo);
Page<SysOssVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
List<SysOssVo> filterResult = StreamUtils.toList(result.getRecords(), this::matchingUrl);
result.setRecords(filterResult);
return TableDataInfo.build(result);
}
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
// 读取输入流中的所有字节
byte[] bytes = IoUtil.readBytes(inputStream);
// 将字节数组转换为Base64编码的字符串
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public MultipartFile downloadByFile(Long ossId) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
@Override
public List<SysOssVo> listByIds(Collection<Long> ossIds) {
List<SysOssVo> list = new ArrayList<>();
for (Long id : ossIds) {
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
if (ObjectUtil.isNotNull(vo)) {
list.add(this.matchingUrl(vo));
}
}
return list;
}
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
byte[] content = IoUtil.readBytes(inputStream);
return new MockMultipartFile(
sysOss.getFileName(),
sysOss.getOriginalName(),
MediaType.APPLICATION_OCTET_STREAM_VALUE,
content
);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public SysOssVo upload(MultipartFile file) {
String originalfileName = file.getOriginalFilename();
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."),
originalfileName.length());
OssClient storage = OssFactory.instance();
UploadResult uploadResult;
try {
uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
} catch (IOException e) {
throw new ServiceException(e.getMessage());
}
// 保存文件信息
SysOss oss = new SysOss();
oss.setUrl(uploadResult.getUrl());
oss.setFileSuffix(suffix);
oss.setFileName(uploadResult.getFilename());
oss.setOriginalName(originalfileName);
oss.setService(storage.getConfigKey());
baseMapper.insert(oss);
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
return this.matchingUrl(sysOssVo);
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
// 做一些业务上的校验,判断是否需要校验
}
List<SysOss> list = baseMapper.selectBatchIds(ids);
for (SysOss sysOss : list) {
OssClient storage = OssFactory.instance(sysOss.getService());
storage.delete(sysOss.getUrl());
}
return baseMapper.deleteBatchIds(ids) > 0;
}
/**
* 匹配Url
*
* @param oss OSS对象
* @return oss 匹配Url的OSS对象
*/
private SysOssVo matchingUrl(SysOssVo oss) {
OssClient storage = OssFactory.instance(oss.getService());
// 仅修改桶类型为 private 的URL临时URL时长为120s
if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) {
oss.setUrl(storage.getPrivateUrl(oss.getFileName(), 120));
}
return oss;
}
@Override
public String downloadToTempPath(Long ossId) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
@Override
public String selectUrlByIds(String ossIds) {
List<String> list = new ArrayList<>();
for (Long id : StringUtils.splitTo(ossIds, Convert::toLong)) {
SysOssVo vo = SpringUtils.getAopProxy(this).getById(id);
if (ObjectUtil.isNotNull(vo)) {
list.add(this.matchingUrl(vo).getUrl());
}
}
return String.join(StringUtils.SEPARATOR, list);
}
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
// 创建临时文件
String suffix = StringUtils.isNotEmpty(sysOss.getFileSuffix()) ? sysOss.getFileSuffix() : "";
java.io.File tempFile = java.io.File.createTempFile("download_", suffix);
// 确保临时文件在JVM退出时删除
tempFile.deleteOnExit();
// 将输入流内容写入临时文件
cn.hutool.core.io.FileUtil.writeFromStream(inputStream, tempFile);
// 返回临时文件的绝对路径
return tempFile.getAbsolutePath();
} catch (Exception e) {
throw new ServiceException(e.getMessage());
private LambdaQueryWrapper<SysOss> buildQueryWrapper(SysOssBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<SysOss> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getFileName()), SysOss::getFileName, bo.getFileName());
lqw.like(StringUtils.isNotBlank(bo.getOriginalName()), SysOss::getOriginalName,
bo.getOriginalName());
lqw.eq(StringUtils.isNotBlank(bo.getFileSuffix()), SysOss::getFileSuffix, bo.getFileSuffix());
lqw.eq(StringUtils.isNotBlank(bo.getUrl()), SysOss::getUrl, bo.getUrl());
lqw.between(params.get("beginCreateTime") != null && params.get("endCreateTime") != null,
SysOss::getCreateTime, params.get("beginCreateTime"), params.get("endCreateTime"));
lqw.eq(ObjectUtil.isNotNull(bo.getCreateBy()), SysOss::getCreateBy, bo.getCreateBy());
lqw.eq(StringUtils.isNotBlank(bo.getService()), SysOss::getService, bo.getService());
return lqw;
}
}
/**
* 根据文件路径删除文件
*
* @param filePath 文件路径
* @return 是否删除成功
*/
@Override
public boolean deleteFile(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return false;
@Cacheable(cacheNames = CacheNames.SYS_OSS, key = "#ossId")
@Override
public SysOssVo getById(Long ossId) {
return baseMapper.selectVoById(ossId);
}
try {
java.io.File file = new java.io.File(filePath);
if (file.exists() && file.isFile()) {
return file.delete();
}
return false;
} catch (Exception e) {
throw new ServiceException("删除文件失败: " + e.getMessage());
@Override
public void download(Long ossId, HttpServletResponse response) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
FileUtils.setAttachmentResponseHeader(response, sysOss.getOriginalName());
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE + "; charset=UTF-8");
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
int available = inputStream.available();
IoUtil.copy(inputStream, response.getOutputStream(), available);
response.setContentLength(available);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public String downloadByByte(Long ossId) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
// 读取输入流中的所有字节
byte[] bytes = IoUtil.readBytes(inputStream);
// 将字节数组转换为Base64编码的字符串
return Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public MultipartFile downloadByFile(Long ossId) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
byte[] content = IoUtil.readBytes(inputStream);
return new MockMultipartFile(
sysOss.getFileName(),
sysOss.getOriginalName(),
MediaType.APPLICATION_OCTET_STREAM_VALUE,
content
);
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
@Override
public SysOssVo upload(MultipartFile file) {
String originalfileName = file.getOriginalFilename();
String suffix = StringUtils.substring(originalfileName, originalfileName.lastIndexOf("."),
originalfileName.length());
OssClient storage = OssFactory.instance();
UploadResult uploadResult;
try {
uploadResult = storage.uploadSuffix(file.getBytes(), suffix, file.getContentType());
} catch (IOException e) {
throw new ServiceException(e.getMessage());
}
// 保存文件信息
SysOss oss = new SysOss();
oss.setUrl(uploadResult.getUrl());
oss.setFileSuffix(suffix);
oss.setFileName(uploadResult.getFilename());
oss.setOriginalName(originalfileName);
oss.setService(storage.getConfigKey());
baseMapper.insert(oss);
SysOssVo sysOssVo = MapstructUtils.convert(oss, SysOssVo.class);
return this.matchingUrl(sysOssVo);
}
@Override
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
if (isValid) {
// 做一些业务上的校验,判断是否需要校验
}
List<SysOss> list = baseMapper.selectBatchIds(ids);
for (SysOss sysOss : list) {
OssClient storage = OssFactory.instance(sysOss.getService());
storage.delete(sysOss.getUrl());
}
return baseMapper.deleteBatchIds(ids) > 0;
}
/**
* 匹配Url
*
* @param oss OSS对象
* @return oss 匹配Url的OSS对象
*/
private SysOssVo matchingUrl(SysOssVo oss) {
OssClient storage = OssFactory.instance(oss.getService());
// 仅修改桶类型为 private 的URL临时URL时长为120s
if (AccessPolicyType.PRIVATE == storage.getAccessPolicy()) {
oss.setUrl(storage.getPrivateUrl(oss.getFileName(), 120));
}
return oss;
}
@Override
public String downloadToTempPath(Long ossId) throws IOException {
SysOssVo sysOss = SpringUtils.getAopProxy(this).getById(ossId);
if (ObjectUtil.isNull(sysOss)) {
throw new ServiceException("文件数据不存在!");
}
OssClient storage = OssFactory.instance();
try (InputStream inputStream = storage.getObjectContent(sysOss.getUrl())) {
// 创建临时文件
String suffix = StringUtils.isNotEmpty(sysOss.getFileSuffix()) ? sysOss.getFileSuffix() : "";
java.io.File tempFile = java.io.File.createTempFile("download_", suffix);
// 确保临时文件在JVM退出时删除
tempFile.deleteOnExit();
// 将输入流内容写入临时文件
cn.hutool.core.io.FileUtil.writeFromStream(inputStream, tempFile);
// 返回临时文件的绝对路径
return tempFile.getAbsolutePath();
} catch (Exception e) {
throw new ServiceException(e.getMessage());
}
}
/**
* 根据文件路径删除文件
*
* @param filePath 文件路径
* @return 是否删除成功
*/
@Override
public boolean deleteFile(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return false;
}
try {
java.io.File file = new java.io.File(filePath);
if (file.exists() && file.isFile()) {
return file.delete();
}
return false;
} catch (Exception e) {
throw new ServiceException("删除文件失败: " + e.getMessage());
}
}
}
}

View File

@@ -26,7 +26,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
/**
* 获取角色数据权限
*
* @param userId 用户id
* @param userId 用户id
* @return 角色权限信息
*/
@Override
@@ -44,7 +44,7 @@ public class SysPermissionServiceImpl implements ISysPermissionService {
/**
* 获取菜单数据权限
*
* @param userId 用户id
* @param userId 用户id
* @return 菜单权限信息
*/
@Override

View File

@@ -104,8 +104,8 @@ public class SysPostServiceImpl implements ISysPostService {
@Override
public boolean checkPostNameUnique(SysPostBo post) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
.eq(SysPost::getPostName, post.getPostName())
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
.eq(SysPost::getPostName, post.getPostName())
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
return !exist;
}
@@ -118,8 +118,8 @@ public class SysPostServiceImpl implements ISysPostService {
@Override
public boolean checkPostCodeUnique(SysPostBo post) {
boolean exist = baseMapper.exists(new LambdaQueryWrapper<SysPost>()
.eq(SysPost::getPostCode, post.getPostCode())
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
.eq(SysPost::getPostCode, post.getPostCode())
.ne(ObjectUtil.isNotNull(post.getPostId()), SysPost::getPostId, post.getPostId()));
return !exist;
}

Some files were not shown because too many files have changed in this diff Show More