!1 refactor(system): 重构系统模块中的数据查询和删除方法命名
Merge pull request !1 from Odboy/feature_v202512
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
- ~~常用的辅助类的类名, 以`Cs`开头~~
|
- ~~常用的辅助类的类名, 以`Cs`开头~~
|
||||||
- 常用的辅助类的类名, 以`Kit`开头。Kit有套件、装备等意思。
|
- 常用的辅助类的类名, 以`Kit`开头。Kit有套件、装备等意思。
|
||||||
- 枚举类名,以`Enum`结尾
|
- 枚举类名,以`Enum`结尾
|
||||||
|
- 内部调用一律声明this
|
||||||
- 拒绝过度包装
|
- 拒绝过度包装
|
||||||
- 命名规则(Mapper or Service)
|
- 命名规则(Mapper or Service)
|
||||||
- 简单查询:get + 名词
|
- 简单查询:get + 名词
|
||||||
@@ -32,6 +33,7 @@
|
|||||||
- 搜索(分页)功能:search + 名词
|
- 搜索(分页)功能:search + 名词
|
||||||
- 统计计数:count + By + 条件
|
- 统计计数:count + By + 条件
|
||||||
- 存在检查:exists + By + 条件
|
- 存在检查:exists + By + 条件
|
||||||
|
- 增删改:save/delete/update
|
||||||
- 例子: 查询分页、查询列表的方法
|
- 例子: 查询分页、查询列表的方法
|
||||||
- 分页:searchUser(args, page)
|
- 分页:searchUser(args, page)
|
||||||
- 列表:listUser + (args)
|
- 列表:listUser + (args)
|
||||||
@@ -44,6 +46,47 @@
|
|||||||
- 单个:getUser + by + (args)
|
- 单个:getUser + by + (args)
|
||||||
- 统计计数:count + By + (args)
|
- 统计计数:count + By + (args)
|
||||||
|
|
||||||
|
#### 编码规范:举例说明
|
||||||
|
|
||||||
|
1. getUser - 简单查询
|
||||||
|
核心: 获取单个特定实体。
|
||||||
|
|
||||||
|
- 输入: 通常是一个唯一标识符(如ID 123)。
|
||||||
|
- 筛选: 非常精确,只匹配一个。
|
||||||
|
- 返回: 单个对象或文档,包含该用户的完整/详细信息。
|
||||||
|
- 示例: getUser(123) -> 返回 {id: 123, name: “Alice”, email: “...”}
|
||||||
|
|
||||||
|
2. listUsers - 列表查询
|
||||||
|
核心: 获取一个符合简单条件的实体集合,通常是有限的、预定义的。
|
||||||
|
|
||||||
|
- 输入: 可能没有参数,或只有非常简单的过滤条件(如 status=‘active’)。
|
||||||
|
- 筛选: 简单、常规。
|
||||||
|
- 返回: 一个数组/列表,包含多个用户的基本信息(通常是摘要字段,非完整详情)。
|
||||||
|
- 通常不分页,或隐式返回所有符合条件的(数据量预期不大)。
|
||||||
|
- 示例: listUsers() -> 返回 [{id: 1, name: “Alice”}, {id: 2, name: “Bob”}]
|
||||||
|
- 示例: listUsers({role: ‘admin’}) -> 返回所有管理员用户的列表。
|
||||||
|
|
||||||
|
3. queryUsersByCondition - 复杂查询
|
||||||
|
核心: 基于多个、可能较复杂的条件进行筛选。
|
||||||
|
|
||||||
|
- 输入: 一个组合条件对象,可能涉及多个字段的比较(如 age > 18 AND department = ‘Sales’ AND joinDate < ‘2023-01-01’)。
|
||||||
|
- 筛选: 复杂、灵活,类似数据库的WHERE子句。
|
||||||
|
- 返回: 一个匹配条件的数组/列表。
|
||||||
|
- 分页: 可能分页,也可能不分页。关键是它的侧重点在于复杂的“筛选”能力,而非分页机制。(这是标准,但是对于此项目来说,定为不分页的,复杂条件的,列表查询服务)
|
||||||
|
- 示例: queryUsersByCondition({minAge: 18, department: ‘Sales’, hasCertification: true})
|
||||||
|
|
||||||
|
4. searchUsers - 搜索(分页)功能
|
||||||
|
核心: 针对大量数据进行模糊匹配、全文检索,并强制包含分页机制以管理性能。
|
||||||
|
|
||||||
|
- 输入:
|
||||||
|
- 搜索关键词(可能对多个字段进行模糊匹配)。
|
||||||
|
- 分页参数(pageNumber, pageSize 或 limit, offset)。
|
||||||
|
- 可能附加的其他过滤条件。
|
||||||
|
- 筛选: 通常包含文本搜索(如 name LIKE ‘%Al%’),结果可能按相关性排序。
|
||||||
|
- 返回: 一个分页响应对象,而不仅仅是数组。
|
||||||
|
- 包含:data(当前页的数据列表)、total(总匹配数)、page(当前页)、pageSize(每页大小)等元数据。
|
||||||
|
- 示例: searchUsers({keyword: ‘Al’, page: 1, pageSize: 20}) -> 返回 {data: […], total: 45, page: 1, pageSize: 20}
|
||||||
|
|
||||||
#### 主要特性
|
#### 主要特性
|
||||||
|
|
||||||
- 使用最新技术栈,社区资源丰富。
|
- 使用最新技术栈,社区资源丰富。
|
||||||
|
|||||||
@@ -4,22 +4,6 @@
|
|||||||
<div class="my-code">点击字典查看详情</div>
|
<div class="my-code">点击字典查看详情</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<!--工具栏-->
|
|
||||||
<div class="head-container">
|
|
||||||
<div v-if="crud.props.searchToggle">
|
|
||||||
<!-- 搜索 -->
|
|
||||||
<el-input
|
|
||||||
v-model="query.label"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
placeholder="输入字典标签查询"
|
|
||||||
style="width: 200px;"
|
|
||||||
class="filter-item"
|
|
||||||
@keyup.enter.native="toQuery"
|
|
||||||
/>
|
|
||||||
<rrOperation />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!--表单组件-->
|
<!--表单组件-->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
append-to-body
|
append-to-body
|
||||||
@@ -91,13 +75,12 @@
|
|||||||
import crudDictDetail from '@/api/system/dictDetail'
|
import crudDictDetail from '@/api/system/dictDetail'
|
||||||
import CRUD, { form, header, presenter } from '@crud/crud'
|
import CRUD, { form, header, presenter } from '@crud/crud'
|
||||||
import pagination from '@crud/Pagination'
|
import pagination from '@crud/Pagination'
|
||||||
import rrOperation from '@crud/RR.operation'
|
|
||||||
import udOperation from '@crud/UD.operation'
|
import udOperation from '@crud/UD.operation'
|
||||||
|
|
||||||
const defaultForm = { id: null, label: null, value: null, dictSort: 999 }
|
const defaultForm = { id: null, label: null, value: null, dictSort: 999 }
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { pagination, rrOperation, udOperation },
|
components: { pagination, udOperation },
|
||||||
cruds() {
|
cruds() {
|
||||||
return [
|
return [
|
||||||
CRUD({
|
CRUD({
|
||||||
|
|||||||
+6
-1
@@ -15,7 +15,12 @@
|
|||||||
*/
|
*/
|
||||||
package cn.odboy.annotation;
|
package cn.odboy.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于标记匿名访问方法
|
* 用于标记匿名访问方法
|
||||||
|
|||||||
+5
-2
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package cn.odboy.annotation;
|
package cn.odboy.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation for mapping HTTP {@code DELETE} requests onto specific handler methods. 支持匿名访问 DeleteMapping
|
* Annotation for mapping HTTP {@code DELETE} requests onto specific handler methods. 支持匿名访问 DeleteMapping
|
||||||
*
|
*
|
||||||
|
|||||||
+5
-2
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package cn.odboy.annotation;
|
package cn.odboy.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation for mapping HTTP {@code GET} requests onto specific handler methods.
|
* Annotation for mapping HTTP {@code GET} requests onto specific handler methods.
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
+5
-2
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package cn.odboy.annotation;
|
package cn.odboy.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation for mapping HTTP {@code PATCH} requests onto specific handler methods. 支持匿名访问 PatchMapping
|
* Annotation for mapping HTTP {@code PATCH} requests onto specific handler methods. 支持匿名访问 PatchMapping
|
||||||
*
|
*
|
||||||
|
|||||||
+5
-2
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package cn.odboy.annotation;
|
package cn.odboy.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation for mapping HTTP {@code POST} requests onto specific handler methods. 支持匿名访问 PostMapping
|
* Annotation for mapping HTTP {@code POST} requests onto specific handler methods. 支持匿名访问 PostMapping
|
||||||
*
|
*
|
||||||
|
|||||||
+5
-2
@@ -16,12 +16,15 @@
|
|||||||
|
|
||||||
package cn.odboy.annotation;
|
package cn.odboy.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Annotation for mapping HTTP {@code PUT} requests onto specific handler methods. 支持匿名访问 PutMapping
|
* Annotation for mapping HTTP {@code PUT} requests onto specific handler methods. 支持匿名访问 PutMapping
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -30,14 +30,12 @@ public class KitArgs {
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public static class FindByLongId extends KitObject {
|
public static class FindByLongId extends KitObject {
|
||||||
@NotNull(message = "id必填")
|
@NotNull(message = "id必填") private Long id;
|
||||||
private Long id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public static class DeleteById extends KitObject {
|
public static class DeleteById extends KitObject {
|
||||||
@NotNull(message = "id必填")
|
@NotNull(message = "id必填") private Long id;
|
||||||
private Long id;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-5
@@ -19,17 +19,15 @@ package cn.odboy.base;
|
|||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.util.Date;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class KitBaseCreateTimeTb extends KitObject {
|
public class KitBaseCreateTimeTb extends KitObject {
|
||||||
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) @TableField(fill = FieldFill.INSERT) private Date
|
||||||
@TableField(fill = FieldFill.INSERT)
|
createTime;
|
||||||
private Date createTime;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-7
@@ -19,21 +19,18 @@ package cn.odboy.base;
|
|||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.util.Date;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class KitBaseTimeTb extends KitObject {
|
public class KitBaseTimeTb extends KitObject {
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT) @Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date
|
||||||
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
createTime;
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE) @Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
||||||
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-4
@@ -19,17 +19,15 @@ package cn.odboy.base;
|
|||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.util.Date;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class KitBaseUpdateTimeTb extends KitObject {
|
public class KitBaseUpdateTimeTb extends KitObject {
|
||||||
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true) @TableField(fill = FieldFill.INSERT_UPDATE)
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-14
@@ -19,28 +19,23 @@ package cn.odboy.base;
|
|||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Date;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.springframework.data.annotation.CreatedBy;
|
import org.springframework.data.annotation.CreatedBy;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class KitBaseUserCreateTimeTb extends KitObject {
|
public class KitBaseUserCreateTimeTb extends KitObject {
|
||||||
|
|
||||||
@CreatedBy
|
@CreatedBy @TableField(fill = FieldFill.INSERT) @Schema(name = "创建人", hidden = true) private String createBy;
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
@Schema(name = "创建人", hidden = true)
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT) @Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date
|
||||||
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
createTime;
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@@ -58,10 +53,8 @@ public class KitBaseUserCreateTimeTb extends KitObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 分组校验 */
|
/* 分组校验 */
|
||||||
public @interface Create {
|
public @interface Create {}
|
||||||
}
|
|
||||||
|
|
||||||
/* 分组校验 */
|
/* 分组校验 */
|
||||||
public @interface Update {
|
public @interface Update {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-18
@@ -20,13 +20,12 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.util.Date;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.data.annotation.CreatedBy;
|
import org.springframework.data.annotation.CreatedBy;
|
||||||
import org.springframework.data.annotation.LastModifiedBy;
|
import org.springframework.data.annotation.LastModifiedBy;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 逻辑删除通用模型
|
* 逻辑删除通用模型
|
||||||
*
|
*
|
||||||
@@ -36,22 +35,13 @@ import java.util.Date;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class KitBaseUserTimeLogicTb extends KitObject {
|
public class KitBaseUserTimeLogicTb extends KitObject {
|
||||||
@CreatedBy
|
@CreatedBy @TableField(value = "create_by", fill = FieldFill.INSERT) @Schema(name = "创建人", hidden = true)
|
||||||
@TableField(value = "create_by", fill = FieldFill.INSERT)
|
|
||||||
@Schema(name = "创建人", hidden = true)
|
|
||||||
private String createBy;
|
private String createBy;
|
||||||
@LastModifiedBy
|
@LastModifiedBy @TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
|
||||||
@TableField(value = "update_by", fill = FieldFill.INSERT_UPDATE)
|
@Schema(name = "更新人", hidden = true) private String updateBy;
|
||||||
@Schema(name = "更新人", hidden = true)
|
@TableField(value = "create_time", fill = FieldFill.INSERT) @Schema(name = "创建时间", hidden = true) private Date
|
||||||
private String updateBy;
|
createTime;
|
||||||
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE) @Schema(name = "更新时间", hidden = true)
|
||||||
@Schema(name = "创建时间", hidden = true)
|
|
||||||
private Date createTime;
|
|
||||||
@TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
|
|
||||||
@Schema(name = "更新时间", hidden = true)
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
@Schema(name = "数据有效性", hidden = true)
|
@Schema(name = "数据有效性", hidden = true) @TableLogic @TableField("available") private Integer available;
|
||||||
@TableLogic
|
|
||||||
@TableField("available")
|
|
||||||
private Integer available;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-20
@@ -19,6 +19,8 @@ package cn.odboy.base;
|
|||||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||||
import com.baomidou.mybatisplus.annotation.TableField;
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.Date;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@@ -26,30 +28,20 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
|
|||||||
import org.springframework.data.annotation.CreatedBy;
|
import org.springframework.data.annotation.CreatedBy;
|
||||||
import org.springframework.data.annotation.LastModifiedBy;
|
import org.springframework.data.annotation.LastModifiedBy;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class KitBaseUserTimeTb extends KitObject {
|
public class KitBaseUserTimeTb extends KitObject {
|
||||||
|
|
||||||
@CreatedBy
|
@CreatedBy @TableField(fill = FieldFill.INSERT) @Schema(name = "创建人", hidden = true) private String createBy;
|
||||||
@TableField(fill = FieldFill.INSERT)
|
|
||||||
@Schema(name = "创建人", hidden = true)
|
|
||||||
private String createBy;
|
|
||||||
|
|
||||||
@LastModifiedBy
|
@LastModifiedBy @TableField(fill = FieldFill.INSERT_UPDATE) @Schema(name = "更新人", hidden = true) private String
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
updateBy;
|
||||||
@Schema(name = "更新人", hidden = true)
|
|
||||||
private String updateBy;
|
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT)
|
@TableField(fill = FieldFill.INSERT) @Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true) private Date
|
||||||
@Schema(name = "创建时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
createTime;
|
||||||
private Date createTime;
|
|
||||||
|
|
||||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
@TableField(fill = FieldFill.INSERT_UPDATE) @Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
||||||
@Schema(name = "更新时间: yyyy-MM-dd HH:mm:ss", hidden = true)
|
|
||||||
private Date updateTime;
|
private Date updateTime;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -68,10 +60,8 @@ public class KitBaseUserTimeTb extends KitObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* 分组校验 */
|
/* 分组校验 */
|
||||||
public @interface Create {
|
public @interface Create {}
|
||||||
}
|
|
||||||
|
|
||||||
/* 分组校验 */
|
/* 分组校验 */
|
||||||
public @interface Update {
|
public @interface Update {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,5 @@ import java.io.Serializable;
|
|||||||
* @date 2022-01-12
|
* @date 2022-01-12
|
||||||
*/
|
*/
|
||||||
public class KitObject implements Serializable {
|
public class KitObject implements Serializable {
|
||||||
@Serial
|
@Serial private static final long serialVersionUID = 1L;
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-10
@@ -19,12 +19,11 @@ package cn.odboy.base;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.Min;
|
import jakarta.validation.constraints.Min;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.io.Serializable;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据分页参数
|
* 数据分页参数
|
||||||
*
|
*
|
||||||
@@ -35,13 +34,9 @@ import java.io.Serializable;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class KitPageArgs<T> implements Serializable {
|
public class KitPageArgs<T> implements Serializable {
|
||||||
@NotNull(message = "参数page不能为空")
|
@NotNull(message = "参数page不能为空") @Min(value = 1, message = "参数page最小值为1")
|
||||||
@Min(value = 1, message = "参数page最小值为1")
|
@Schema(name = "页码", example = "1") private Integer page;
|
||||||
@Schema(name = "页码", example = "1")
|
@NotNull(message = "参数size不能为空") @Min(value = 1, message = "参数size最小值为1")
|
||||||
private Integer page;
|
@Schema(name = "每页数据量", example = "10") private Integer size;
|
||||||
@NotNull(message = "参数size不能为空")
|
|
||||||
@Min(value = 1, message = "参数size最小值为1")
|
|
||||||
@Schema(name = "每页数据量", example = "10")
|
|
||||||
private Integer size;
|
|
||||||
private T args;
|
private T args;
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -17,14 +17,13 @@
|
|||||||
package cn.odboy.base;
|
package cn.odboy.base;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结果封装类
|
* 结果封装类
|
||||||
*/
|
*/
|
||||||
|
|||||||
+5
-2
@@ -16,9 +16,12 @@
|
|||||||
|
|
||||||
package cn.odboy.base;
|
package cn.odboy.base;
|
||||||
|
|
||||||
import lombok.*;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 元数据选项
|
* 元数据选项
|
||||||
|
|||||||
+4
-4
@@ -17,14 +17,13 @@
|
|||||||
package cn.odboy.framework.context;
|
package cn.odboy.framework.context;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import java.net.InetAddress;
|
|
||||||
import java.net.UnknownHostException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 主要目的是输出应用的服务地址
|
* 主要目的是输出应用的服务地址
|
||||||
*
|
*
|
||||||
@@ -37,7 +36,8 @@ public class BootApplication {
|
|||||||
Environment env = application.getEnvironment();
|
Environment env = application.getEnvironment();
|
||||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||||
String port = env.getProperty("server.port");
|
String port = env.getProperty("server.port");
|
||||||
String path = StrUtil.isEmpty(env.getProperty("config.servlet.context-path")) ? "" : env.getProperty("config.servlet.context-path");
|
String path = StrUtil.isEmpty(env.getProperty("config.servlet.context-path")) ? ""
|
||||||
|
: env.getProperty("config.servlet.context-path");
|
||||||
log.info("""
|
log.info("""
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
\tApplication is running! Access URLs:
|
\tApplication is running! Access URLs:
|
||||||
|
|||||||
+3
-3
@@ -18,17 +18,17 @@
|
|||||||
package cn.odboy.framework.context;
|
package cn.odboy.framework.context;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Objects;
|
||||||
import org.springframework.web.context.request.RequestContextHolder;
|
import org.springframework.web.context.request.RequestContextHolder;
|
||||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取 HttpServletRequest
|
* 获取 HttpServletRequest
|
||||||
*/
|
*/
|
||||||
public class KitRequestHolder {
|
public class KitRequestHolder {
|
||||||
|
|
||||||
public static HttpServletRequest getHttpServletRequest() {
|
public static HttpServletRequest getHttpServletRequest() {
|
||||||
return ((ServletRequestAttributes)Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
|
return ((ServletRequestAttributes)Objects.requireNonNull(
|
||||||
|
RequestContextHolder.getRequestAttributes())).getRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -16,13 +16,12 @@
|
|||||||
|
|
||||||
package cn.odboy.framework.context;
|
package cn.odboy.framework.context;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.mozilla.javascript.Context;
|
import org.mozilla.javascript.Context;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本工具
|
* 脚本工具
|
||||||
*
|
*
|
||||||
|
|||||||
+7
-7
@@ -16,6 +16,9 @@
|
|||||||
|
|
||||||
package cn.odboy.framework.context;
|
package cn.odboy.framework.context;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
import org.springframework.beans.factory.DisposableBean;
|
import org.springframework.beans.factory.DisposableBean;
|
||||||
@@ -24,10 +27,6 @@ import org.springframework.context.ApplicationContextAware;
|
|||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@SuppressWarnings({"unchecked", "all"})
|
@SuppressWarnings({"unchecked", "all"})
|
||||||
public class KitSpringBeanHolder implements ApplicationContextAware, DisposableBean {
|
public class KitSpringBeanHolder implements ApplicationContextAware, DisposableBean {
|
||||||
@@ -109,8 +108,8 @@ public class KitSpringBeanHolder implements ApplicationContextAware, DisposableB
|
|||||||
*/
|
*/
|
||||||
private static void assertContextInjected() {
|
private static void assertContextInjected() {
|
||||||
if (applicationContext == null) {
|
if (applicationContext == null) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException("applicaitonContext属性未注入, 请在applicationContext" +
|
||||||
"applicaitonContext属性未注入, 请在applicationContext" + ".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder.");
|
".xml中定义SpringContextHolder或在SpringBoot启动类中注册SpringContextHolder.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +138,8 @@ public class KitSpringBeanHolder implements ApplicationContextAware, DisposableB
|
|||||||
@Override
|
@Override
|
||||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||||
if (KitSpringBeanHolder.applicationContext != null) {
|
if (KitSpringBeanHolder.applicationContext != null) {
|
||||||
log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" + KitSpringBeanHolder.applicationContext);
|
log.warn("SpringContextHolder中的ApplicationContext被覆盖, 原有ApplicationContext为:" +
|
||||||
|
KitSpringBeanHolder.applicationContext);
|
||||||
}
|
}
|
||||||
KitSpringBeanHolder.applicationContext = applicationContext;
|
KitSpringBeanHolder.applicationContext = applicationContext;
|
||||||
if (addCallback) {
|
if (addCallback) {
|
||||||
|
|||||||
+6
-1
@@ -16,7 +16,12 @@
|
|||||||
|
|
||||||
package cn.odboy.framework.logging;
|
package cn.odboy.framework.logging;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 统计执行时长
|
* 统计执行时长
|
||||||
|
|||||||
+6
-3
@@ -34,15 +34,18 @@ import org.springframework.stereotype.Component;
|
|||||||
@Component
|
@Component
|
||||||
public class ExecutionTimeStatisticsFaceAspect {
|
public class ExecutionTimeStatisticsFaceAspect {
|
||||||
@Around("@annotation(executionTimeStatisticsFace)")
|
@Around("@annotation(executionTimeStatisticsFace)")
|
||||||
public Object aroundFace(ProceedingJoinPoint joinPoint, ExecutionTimeStatisticsFace executionTimeStatisticsFace) throws Throwable {
|
public Object aroundFace(ProceedingJoinPoint joinPoint, ExecutionTimeStatisticsFace executionTimeStatisticsFace)
|
||||||
|
throws Throwable {
|
||||||
TimeInterval timeInterval = new TimeInterval();
|
TimeInterval timeInterval = new TimeInterval();
|
||||||
try {
|
try {
|
||||||
Object proceed = joinPoint.proceed();
|
Object proceed = joinPoint.proceed();
|
||||||
log.info("[{}] 接口执行成功,耗时: {} ms", executionTimeStatisticsFace.description(), timeInterval.intervalMs());
|
log.info("[{}] 接口执行成功,耗时: {} ms", executionTimeStatisticsFace.description(),
|
||||||
|
timeInterval.intervalMs());
|
||||||
return proceed;
|
return proceed;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
if (executionTimeStatisticsFace.showErrLog()) {
|
if (executionTimeStatisticsFace.showErrLog()) {
|
||||||
log.error("[{}] 接口执行失败,耗时: {} ms", executionTimeStatisticsFace.description(), timeInterval.intervalMs(), e);
|
log.error("[{}] 接口执行失败,耗时: {} ms", executionTimeStatisticsFace.description(),
|
||||||
|
timeInterval.intervalMs(), e);
|
||||||
}
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -31,8 +31,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
@RequestMapping("/healthCheck")
|
@RequestMapping("/healthCheck")
|
||||||
@Tag(name = "系统:健康检查接口")
|
@Tag(name = "系统:健康检查接口")
|
||||||
public class HealthCheckController {
|
public class HealthCheckController {
|
||||||
@Autowired
|
@Autowired private KitHealthCheckPointService kitHealthCheckPointService;
|
||||||
private KitHealthCheckPointService kitHealthCheckPointService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 就绪检查
|
* 就绪检查
|
||||||
|
|||||||
+2
-1
@@ -94,7 +94,8 @@ public enum DataTypeEnum {
|
|||||||
private String aliasPrefix;
|
private String aliasPrefix;
|
||||||
private String aliasSuffix;
|
private String aliasSuffix;
|
||||||
|
|
||||||
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, String aliasPrefix, String aliasSuffix) {
|
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix,
|
||||||
|
String aliasPrefix, String aliasSuffix) {
|
||||||
this.feature = feature;
|
this.feature = feature;
|
||||||
this.desc = desc;
|
this.desc = desc;
|
||||||
this.driver = driver;
|
this.driver = driver;
|
||||||
|
|||||||
+4
-3
@@ -55,13 +55,14 @@ public class MpCustomP6SpyLogger implements MessageFormattingStrategy {
|
|||||||
* @return 格式化后的sql
|
* @return 格式化后的sql
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared,
|
||||||
|
String sql, String url) {
|
||||||
// 去掉换行和多余空格
|
// 去掉换行和多余空格
|
||||||
if (StrUtil.isNotBlank(sql)) {
|
if (StrUtil.isNotBlank(sql)) {
|
||||||
sql = sql.replaceAll("\\s+", " ").trim();
|
sql = sql.replaceAll("\\s+", " ").trim();
|
||||||
}
|
}
|
||||||
// 格式化并加上颜色
|
// 格式化并加上颜色
|
||||||
return String.format("CuteJava - %s%s%s %s[%s] %sREVIEW_SQL [Interval: %dms]%s -> %s;", RED, now, RESET, GREEN, Thread.currentThread().getName(), BLUE,
|
return String.format("CuteJava - %s%s%s %s[%s] %sREVIEW_SQL [Interval: %dms]%s -> %s;", RED, now, RESET, GREEN,
|
||||||
elapsed, RESET, sql);
|
Thread.currentThread().getName(), BLUE, elapsed, RESET, sql);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -22,9 +22,8 @@ import com.baomidou.mybatisplus.core.injector.DefaultSqlInjector;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
import com.baomidou.mybatisplus.core.metadata.TableInfo;
|
||||||
import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
|
import com.baomidou.mybatisplus.extension.injector.methods.AlwaysUpdateSomeColumnById;
|
||||||
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
|
import com.baomidou.mybatisplus.extension.injector.methods.InsertBatchSomeColumn;
|
||||||
import org.apache.ibatis.session.Configuration;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.session.Configuration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量插入SQL注入器
|
* 批量插入SQL注入器
|
||||||
|
|||||||
+11
-5
@@ -19,9 +19,15 @@ package cn.odboy.framework.mybatisplus.config;
|
|||||||
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
import com.alibaba.druid.spring.boot3.autoconfigure.DruidDataSourceAutoConfigure;
|
||||||
import com.alibaba.druid.spring.boot3.autoconfigure.properties.DruidStatProperties;
|
import com.alibaba.druid.spring.boot3.autoconfigure.properties.DruidStatProperties;
|
||||||
import com.alibaba.druid.util.Utils;
|
import com.alibaba.druid.util.Utils;
|
||||||
import jakarta.servlet.*;
|
import jakarta.servlet.Filter;
|
||||||
|
import jakarta.servlet.FilterChain;
|
||||||
|
import jakarta.servlet.FilterConfig;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.ServletRequest;
|
||||||
|
import jakarta.servlet.ServletResponse;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
|
||||||
@@ -29,13 +35,12 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@SuppressWarnings({"unchecked", "all"})
|
@SuppressWarnings({"unchecked", "all"})
|
||||||
@ConditionalOnWebApplication
|
@ConditionalOnWebApplication
|
||||||
@AutoConfigureAfter(DruidDataSourceAutoConfigure.class)
|
@AutoConfigureAfter(DruidDataSourceAutoConfigure.class)
|
||||||
@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled", havingValue = "true", matchIfMissing = true)
|
@ConditionalOnProperty(name = "spring.datasource.druid.stat-view-servlet.enabled", havingValue = "true",
|
||||||
|
matchIfMissing = true)
|
||||||
public class RemoveDruidAdConfig {
|
public class RemoveDruidAdConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -62,7 +67,8 @@ public class RemoveDruidAdConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
|
||||||
|
throws IOException, ServletException {
|
||||||
HttpServletRequest httpRequest = (HttpServletRequest)request;
|
HttpServletRequest httpRequest = (HttpServletRequest)request;
|
||||||
HttpServletResponse httpResponse = (HttpServletResponse)response;
|
HttpServletResponse httpResponse = (HttpServletResponse)response;
|
||||||
if (httpRequest.getRequestURI().endsWith("js/common.js")) {
|
if (httpRequest.getRequestURI().endsWith("js/common.js")) {
|
||||||
|
|||||||
+2
-2
@@ -20,7 +20,6 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -69,7 +68,8 @@ public class KitMpAnyQUtil {
|
|||||||
return baseMapper.selectPage(page, queryWrapper);
|
return baseMapper.selectPage(page, queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T, M> Page<M> selectPage(BaseMapper<T> baseMapper, Page<T> page, Object queryParams, Class<M> mapperClazz) {
|
public static <T, M> Page<M> selectPage(BaseMapper<T> baseMapper, Page<T> page, Object queryParams,
|
||||||
|
Class<M> mapperClazz) {
|
||||||
QueryWrapper<T> queryWrapper = KitMpQUtil.build(queryParams);
|
QueryWrapper<T> queryWrapper = KitMpQUtil.build(queryParams);
|
||||||
Page<T> tPage = baseMapper.selectPage(page, queryWrapper);
|
Page<T> tPage = baseMapper.selectPage(page, queryWrapper);
|
||||||
Page<M> mapperTarget = new Page<>();
|
Page<M> mapperTarget = new Page<>();
|
||||||
|
|||||||
+31
-19
@@ -21,7 +21,12 @@ import cn.odboy.base.KitBaseUserTimeTb;
|
|||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
|
||||||
import com.baomidou.mybatisplus.generator.config.*;
|
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.GlobalConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.IDbQuery;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.OutputFile;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.PackageConfig;
|
||||||
|
import com.baomidou.mybatisplus.generator.config.StrategyConfig;
|
||||||
import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery;
|
import com.baomidou.mybatisplus.generator.config.querys.MySqlQuery;
|
||||||
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
import com.baomidou.mybatisplus.generator.config.rules.DateType;
|
||||||
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
import com.baomidou.mybatisplus.generator.config.rules.DbColumnType;
|
||||||
@@ -29,13 +34,12 @@ import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
|
|||||||
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
|
import com.baomidou.mybatisplus.generator.engine.AbstractTemplateEngine;
|
||||||
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;
|
||||||
import com.baomidou.mybatisplus.generator.keywords.MySqlKeyWordsHandler;
|
import com.baomidou.mybatisplus.generator.keywords.MySqlKeyWordsHandler;
|
||||||
import lombok.Data;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
import java.sql.Types;
|
import java.sql.Types;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 代码生成器入口
|
* 代码生成器入口
|
||||||
@@ -67,14 +71,16 @@ public class KitMpCmdGenUtil {
|
|||||||
private static Consumer<StrategyConfig.Builder> getEntityConfigConsumer() {
|
private static Consumer<StrategyConfig.Builder> getEntityConfigConsumer() {
|
||||||
return strategyConfigBuilder -> strategyConfigBuilder.entityBuilder().enableLombok()
|
return strategyConfigBuilder -> strategyConfigBuilder.entityBuilder().enableLombok()
|
||||||
// 如果不需要生成注解, 去掉.enableTableFieldAnnotation()
|
// 如果不需要生成注解, 去掉.enableTableFieldAnnotation()
|
||||||
.enableTableFieldAnnotation().enableFileOverride().naming(NamingStrategy.underline_to_camel).columnNaming(NamingStrategy.underline_to_camel)
|
.enableTableFieldAnnotation().enableFileOverride().naming(NamingStrategy.underline_to_camel)
|
||||||
.idType(IdType.AUTO);
|
.columnNaming(NamingStrategy.underline_to_camel).idType(IdType.AUTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<StrategyConfig.Builder> getStrategyConfigConsumer(List<String> tableNames) {
|
private static Consumer<StrategyConfig.Builder> getStrategyConfigConsumer(List<String> tableNames) {
|
||||||
return strategyConfigBuilder -> strategyConfigBuilder.enableCapitalMode().enableSkipView().disableSqlFilter().addInclude(tableNames)
|
return strategyConfigBuilder -> strategyConfigBuilder.enableCapitalMode().enableSkipView().disableSqlFilter()
|
||||||
|
.addInclude(tableNames)
|
||||||
// 实体类生成策略
|
// 实体类生成策略
|
||||||
.entityBuilder().superClass(KitBaseUserTimeTb.class).addIgnoreColumns("create_time", "update_time", "create_by", "update_by")
|
.entityBuilder().superClass(KitBaseUserTimeTb.class)
|
||||||
|
.addIgnoreColumns("create_time", "update_time", "create_by", "update_by")
|
||||||
// 开启生成实体时生成字段注解。
|
// 开启生成实体时生成字段注解。
|
||||||
// 会在实体类的属性前,添加[@TableField("nickname")]
|
// 会在实体类的属性前,添加[@TableField("nickname")]
|
||||||
.enableTableFieldAnnotation().disableSerialVersionUID()
|
.enableTableFieldAnnotation().disableSerialVersionUID()
|
||||||
@@ -99,13 +105,13 @@ public class KitMpCmdGenUtil {
|
|||||||
|
|
||||||
private static Consumer<GlobalConfig.Builder> getGlobalConfigConsumer() {
|
private static Consumer<GlobalConfig.Builder> getGlobalConfigConsumer() {
|
||||||
String outputDir = projectRootPath + "CodeGen";
|
String outputDir = projectRootPath + "CodeGen";
|
||||||
return globalConfigBuilder -> globalConfigBuilder.enableSwagger().outputDir(outputDir).author("codegen").commentDate("yyyy-MM-dd")
|
return globalConfigBuilder -> globalConfigBuilder.enableSwagger().outputDir(outputDir).author("codegen")
|
||||||
.dateType(DateType.TIME_PACK);
|
.commentDate("yyyy-MM-dd").dateType(DateType.TIME_PACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<StrategyConfig.Builder> getStrategyConfigConsumer() {
|
private static Consumer<StrategyConfig.Builder> getStrategyConfigConsumer() {
|
||||||
return strategyConfigBuilder -> strategyConfigBuilder.mapperBuilder().mapperAnnotation(Mapper.class).formatMapperFileName("%sMapper")
|
return strategyConfigBuilder -> strategyConfigBuilder.mapperBuilder().mapperAnnotation(Mapper.class)
|
||||||
.formatXmlFileName("%sMapper").entityBuilder().formatFileName("%sTb");
|
.formatMapperFileName("%sMapper").formatXmlFileName("%sMapper").entityBuilder().formatFileName("%sTb");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Consumer<DataSourceConfig.Builder> getDataSourceConfigConsumer() {
|
private static Consumer<DataSourceConfig.Builder> getDataSourceConfigConsumer() {
|
||||||
@@ -138,7 +144,8 @@ public class KitMpCmdGenUtil {
|
|||||||
this.parentModuleName = moduleName;
|
this.parentModuleName = moduleName;
|
||||||
// 1.数据库配置
|
// 1.数据库配置
|
||||||
DataSourceConfig.Builder dataSourceConfigBuilder =
|
DataSourceConfig.Builder dataSourceConfigBuilder =
|
||||||
new DataSourceConfig.Builder(this.databaseUrl, this.databaseUsername, this.databasePassword).driverClassName(this.driverClassName);
|
new DataSourceConfig.Builder(this.databaseUrl, this.databaseUsername,
|
||||||
|
this.databasePassword).driverClassName(this.driverClassName);
|
||||||
dataSourceConfigBuilder.dbQuery(DB_QUERY);
|
dataSourceConfigBuilder.dbQuery(DB_QUERY);
|
||||||
dataSourceConfigBuilder.keyWordsHandler(new MySqlKeyWordsHandler());
|
dataSourceConfigBuilder.keyWordsHandler(new MySqlKeyWordsHandler());
|
||||||
// 1.1.快速生成器
|
// 1.1.快速生成器
|
||||||
@@ -168,7 +175,8 @@ public class KitMpCmdGenUtil {
|
|||||||
fastAutoGenerator.strategyConfig(getStrategyConfigConsumer(tableNames));
|
fastAutoGenerator.strategyConfig(getStrategyConfigConsumer(tableNames));
|
||||||
if (tablePrefix != null) {
|
if (tablePrefix != null) {
|
||||||
// 表前缀, 可多个
|
// 表前缀, 可多个
|
||||||
fastAutoGenerator.strategyConfig(strategyConfigBuilder -> strategyConfigBuilder.addTablePrefix(tablePrefix));
|
fastAutoGenerator.strategyConfig(
|
||||||
|
strategyConfigBuilder -> strategyConfigBuilder.addTablePrefix(tablePrefix));
|
||||||
}
|
}
|
||||||
// 5.1.Entity策略配置
|
// 5.1.Entity策略配置
|
||||||
// 生成实体时生成字段的注解, 包括@TableId注解等
|
// 生成实体时生成字段的注解, 包括@TableId注解等
|
||||||
@@ -178,10 +186,13 @@ public class KitMpCmdGenUtil {
|
|||||||
fastAutoGenerator.strategyConfig(getEntityConfigConsumer());
|
fastAutoGenerator.strategyConfig(getEntityConfigConsumer());
|
||||||
// 5.2.Controller策略配置
|
// 5.2.Controller策略配置
|
||||||
// 开启生成@RestController控制器
|
// 开启生成@RestController控制器
|
||||||
fastAutoGenerator.strategyConfig(strategyConfigBuilder -> strategyConfigBuilder.controllerBuilder().enableRestStyle());
|
|
||||||
// 如果不需要生成Controller, fastAutoGenerator.templateConfig(templateConfig -> templateConfig.controller(""))。5.3.Service策略配置:格式化service接口和实现类的文件名称, 去掉默认的ServiceName前面的I
|
|
||||||
fastAutoGenerator.strategyConfig(
|
fastAutoGenerator.strategyConfig(
|
||||||
strategyConfigBuilder -> strategyConfigBuilder.serviceBuilder().formatServiceFileName("%sService").formatServiceImplFileName("%sServiceImpl"));
|
strategyConfigBuilder -> strategyConfigBuilder.controllerBuilder().enableRestStyle());
|
||||||
|
// 如果不需要生成Controller, fastAutoGenerator.templateConfig(templateConfig -> templateConfig.controller(""))。5.3
|
||||||
|
// .Service策略配置:格式化service接口和实现类的文件名称, 去掉默认的ServiceName前面的I
|
||||||
|
fastAutoGenerator.strategyConfig(
|
||||||
|
strategyConfigBuilder -> strategyConfigBuilder.serviceBuilder().formatServiceFileName("%sService")
|
||||||
|
.formatServiceImplFileName("%sServiceImpl"));
|
||||||
// 5.4.Mapper策略配置
|
// 5.4.Mapper策略配置
|
||||||
// 格式化 mapper文件名,格式化xml实现类文件名称
|
// 格式化 mapper文件名,格式化xml实现类文件名称
|
||||||
fastAutoGenerator.strategyConfig(getStrategyConfigConsumer());
|
fastAutoGenerator.strategyConfig(getStrategyConfigConsumer());
|
||||||
@@ -194,8 +205,9 @@ public class KitMpCmdGenUtil {
|
|||||||
if (StrUtil.isBlank(this.parentModuleName)) {
|
if (StrUtil.isBlank(this.parentModuleName)) {
|
||||||
throw new BadRequestException("模块名称必填");
|
throw new BadRequestException("模块名称必填");
|
||||||
}
|
}
|
||||||
return packageConfigBuilder -> packageConfigBuilder.parent(this.parentPackageName).moduleName(this.parentModuleName).entity("dal.dataobject")
|
return packageConfigBuilder -> packageConfigBuilder.parent(this.parentPackageName)
|
||||||
.mapper("dal.mysql").service("service").serviceImpl("service.impl").controller("controller")
|
.moduleName(this.parentModuleName).entity("dal.dataobject").mapper("dal.mysql").service("service")
|
||||||
|
.serviceImpl("service.impl").controller("controller")
|
||||||
.pathInfo(Collections.singletonMap(OutputFile.xml, mapperPath));
|
.pathInfo(Collections.singletonMap(OutputFile.xml, mapperPath));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+17
-15
@@ -29,10 +29,13 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
import jakarta.validation.constraints.NotNull;
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询条件创建工具
|
* 查询条件创建工具
|
||||||
@@ -77,7 +80,8 @@ public class KitMpQUtil {
|
|||||||
return StrUtil.toUnderlineCase(attributeName);
|
return StrUtil.toUnderlineCase(attributeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <R> void handleWrapper(KitMpQuery q, QueryWrapper<R> queryWrapper, String attributeName, Object fieldVal) {
|
private static <R> void handleWrapper(KitMpQuery q, QueryWrapper<R> queryWrapper, String attributeName,
|
||||||
|
Object fieldVal) {
|
||||||
switch (q.type()) {
|
switch (q.type()) {
|
||||||
case EQUAL -> queryWrapper.eq(attributeName, fieldVal);
|
case EQUAL -> queryWrapper.eq(attributeName, fieldVal);
|
||||||
case GREATER_THAN -> queryWrapper.ge(attributeName, fieldVal);
|
case GREATER_THAN -> queryWrapper.ge(attributeName, fieldVal);
|
||||||
@@ -97,7 +101,8 @@ public class KitMpQUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <R> void handleInOrNotQuery(boolean b, QueryWrapper<R> queryWrapper, String attributeName, Object fieldVal) {
|
private static <R> void handleInOrNotQuery(boolean b, QueryWrapper<R> queryWrapper, String attributeName,
|
||||||
|
Object fieldVal) {
|
||||||
Collection<?> wrapNotInVal = (Collection<?>)fieldVal;
|
Collection<?> wrapNotInVal = (Collection<?>)fieldVal;
|
||||||
if (CollectionUtil.isNotEmpty(wrapNotInVal)) {
|
if (CollectionUtil.isNotEmpty(wrapNotInVal)) {
|
||||||
Optional<?> anyValOptional = wrapNotInVal.stream().findAny();
|
Optional<?> anyValOptional = wrapNotInVal.stream().findAny();
|
||||||
@@ -122,7 +127,8 @@ public class KitMpQUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static <R> void handleBetweenQuery(QueryWrapper<R> queryWrapper, Object fieldVal, String finalAttributeName) {
|
private static <R> void handleBetweenQuery(QueryWrapper<R> queryWrapper, Object fieldVal,
|
||||||
|
String finalAttributeName) {
|
||||||
if (fieldVal instanceof List) {
|
if (fieldVal instanceof List) {
|
||||||
List<Object> between = new ArrayList<>((List<?>)fieldVal);
|
List<Object> between = new ArrayList<>((List<?>)fieldVal);
|
||||||
int minLength = 2;
|
int minLength = 2;
|
||||||
@@ -182,14 +188,10 @@ public class KitMpQUtil {
|
|||||||
|
|
||||||
@TableName("test_domain")
|
@TableName("test_domain")
|
||||||
private static class TestDomain {
|
private static class TestDomain {
|
||||||
@NotNull(groups = KitBaseUserTimeTb.Update.class)
|
@NotNull(groups = KitBaseUserTimeTb.Update.class) @TableId(value = "user_id", type = IdType.AUTO) private Long
|
||||||
@TableId(value = "user_id", type = IdType.AUTO)
|
id;
|
||||||
private Long id;
|
@TableField(value = "dept_id") private Long deptId;
|
||||||
@TableField(value = "dept_id")
|
@NotBlank private String username;
|
||||||
private Long deptId;
|
@NotBlank private String nickName;
|
||||||
@NotBlank
|
|
||||||
private String username;
|
|
||||||
@NotBlank
|
|
||||||
private String nickName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-5
@@ -26,15 +26,14 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import org.apache.ibatis.annotations.Param;
|
|
||||||
import org.springframework.data.domain.Pageable;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公共抽象Mapper接口类
|
* 公共抽象Mapper接口类
|
||||||
@@ -137,7 +136,8 @@ public interface KitMpMapper<E> extends BaseMapper<E> {
|
|||||||
* @param clazz 期望的对象类型
|
* @param clazz 期望的对象类型
|
||||||
* @return IPage<T>
|
* @return IPage<T>
|
||||||
*/
|
*/
|
||||||
default <T> KitPageResult<T> queryFeatureClazzPage(Pageable pageable, LambdaQueryWrapper<E> wrapper, Class<T> clazz) {
|
default <T> KitPageResult<T> queryFeatureClazzPage(Pageable pageable, LambdaQueryWrapper<E> wrapper,
|
||||||
|
Class<T> clazz) {
|
||||||
int pageNumber = pageable.getPageNumber();
|
int pageNumber = pageable.getPageNumber();
|
||||||
int pageSize = pageable.getPageSize();
|
int pageSize = pageable.getPageSize();
|
||||||
pageNumber = pageNumber <= 0 ? 1 : pageNumber;
|
pageNumber = pageNumber <= 0 ? 1 : pageNumber;
|
||||||
@@ -157,7 +157,8 @@ public interface KitMpMapper<E> extends BaseMapper<E> {
|
|||||||
* @param clazz 期望的对象类型
|
* @param clazz 期望的对象类型
|
||||||
* @return IPage<T>
|
* @return IPage<T>
|
||||||
*/
|
*/
|
||||||
default <T> KitPageResult<T> queryFeatureClazzPage(Pageable pageable, LambdaQueryChainWrapper<E> wrapper, Class<T> clazz) {
|
default <T> KitPageResult<T> queryFeatureClazzPage(Pageable pageable, LambdaQueryChainWrapper<E> wrapper,
|
||||||
|
Class<T> clazz) {
|
||||||
int pageNumber = pageable.getPageNumber();
|
int pageNumber = pageable.getPageNumber();
|
||||||
int pageSize = pageable.getPageSize();
|
int pageSize = pageable.getPageSize();
|
||||||
pageNumber = pageNumber <= 0 ? 1 : pageNumber;
|
pageNumber = pageNumber <= 0 ? 1 : pageNumber;
|
||||||
|
|||||||
+2
-2
@@ -21,7 +21,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -59,7 +58,8 @@ public interface KitMpService<T> extends IService<T> {
|
|||||||
|
|
||||||
KitPageResult<T> queryClazzPageByArgs(LambdaQueryWrapper<T> wrapper, IPage<T> pageable);
|
KitPageResult<T> queryClazzPageByArgs(LambdaQueryWrapper<T> wrapper, IPage<T> pageable);
|
||||||
|
|
||||||
<G> KitPageResult<G> queryFeatureClazzPageByArgs(LambdaQueryWrapper<T> wrapper, IPage<T> pageable, Class<G> targetClazz);
|
<G> KitPageResult<G> queryFeatureClazzPageByArgs(LambdaQueryWrapper<T> wrapper, IPage<T> pageable,
|
||||||
|
Class<G> targetClazz);
|
||||||
|
|
||||||
<G, Q> KitPageResult<G> queryFeatureClazzPageByArgs(Q criteria, IPage<T> pageable, Class<G> targetClazz);
|
<G, Q> KitPageResult<G> queryFeatureClazzPageByArgs(Q criteria, IPage<T> pageable, Class<G> targetClazz);
|
||||||
|
|
||||||
|
|||||||
+9
-6
@@ -27,11 +27,10 @@ import com.baomidou.mybatisplus.core.enums.SqlMethod;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import org.apache.ibatis.binding.MapperMethod;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.apache.ibatis.binding.MapperMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 公共抽象Mapper接口类
|
* 公共抽象Mapper接口类
|
||||||
@@ -138,7 +137,8 @@ public class KitMpServiceImpl<M extends KitMpMapper<T>, T> extends ServiceImpl<M
|
|||||||
*/
|
*/
|
||||||
public <G> List<G> queryFeatureClazzListByIds(List<Serializable> ids, Class<G> targetClazz) {
|
public <G> List<G> queryFeatureClazzListByIds(List<Serializable> ids, Class<G> targetClazz) {
|
||||||
List<T> entitys = this.listByIds(ids);
|
List<T> entitys = this.listByIds(ids);
|
||||||
return entitys == null || entitys.isEmpty() ? CollUtil.newArrayList() : BeanUtil.copyToList(entitys, targetClazz);
|
return entitys == null || entitys.isEmpty() ? CollUtil.newArrayList()
|
||||||
|
: BeanUtil.copyToList(entitys, targetClazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -209,18 +209,21 @@ public class KitMpServiceImpl<M extends KitMpMapper<T>, T> extends ServiceImpl<M
|
|||||||
* @param pageable 分页参数
|
* @param pageable 分页参数
|
||||||
* @param targetClazz 目标类型
|
* @param targetClazz 目标类型
|
||||||
*/
|
*/
|
||||||
public <G> KitPageResult<G> queryFeatureClazzPageByArgs(LambdaQueryWrapper<T> wrapper, IPage<T> pageable, Class<G> targetClazz) {
|
public <G> KitPageResult<G> queryFeatureClazzPageByArgs(LambdaQueryWrapper<T> wrapper, IPage<T> pageable,
|
||||||
|
Class<G> targetClazz) {
|
||||||
if (wrapper == null) {
|
if (wrapper == null) {
|
||||||
wrapper = new LambdaQueryWrapper<>();
|
wrapper = new LambdaQueryWrapper<>();
|
||||||
}
|
}
|
||||||
IPage<T> originPageData = baseMapper.selectPage(pageable, wrapper);
|
IPage<T> originPageData = baseMapper.selectPage(pageable, wrapper);
|
||||||
return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz), originPageData.getTotal());
|
return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz),
|
||||||
|
originPageData.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public <G, Q> KitPageResult<G> queryFeatureClazzPageByArgs(Q criteria, IPage<T> pageable, Class<G> targetClazz) {
|
public <G, Q> KitPageResult<G> queryFeatureClazzPageByArgs(Q criteria, IPage<T> pageable, Class<G> targetClazz) {
|
||||||
QueryWrapper<T> wrapper = KitMpQUtil.build(criteria);
|
QueryWrapper<T> wrapper = KitMpQUtil.build(criteria);
|
||||||
IPage<T> originPageData = baseMapper.selectPage(pageable, wrapper);
|
IPage<T> originPageData = baseMapper.selectPage(pageable, wrapper);
|
||||||
return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz), originPageData.getTotal());
|
return new KitPageResult<>(BeanUtil.copyToList(originPageData.getRecords(), targetClazz),
|
||||||
|
originPageData.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
public <Q> KitPageResult<T> queryClazzPageByArgs(Q criteria, IPage<T> pageable) {
|
public <Q> KitPageResult<T> queryClazzPageByArgs(Q criteria, IPage<T> pageable) {
|
||||||
|
|||||||
+6
-1
@@ -16,7 +16,12 @@
|
|||||||
|
|
||||||
package cn.odboy.framework.properties;
|
package cn.odboy.framework.properties;
|
||||||
|
|
||||||
import cn.odboy.framework.properties.model.*;
|
import cn.odboy.framework.properties.model.CaptchaModel;
|
||||||
|
import cn.odboy.framework.properties.model.ContentRsaEncodeSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.JwtAuthSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.StorageOSSModel;
|
||||||
|
import cn.odboy.framework.properties.model.ThreadPoolSettingModel;
|
||||||
|
import cn.odboy.framework.properties.model.UserLoginSettingModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|||||||
+6
-3
@@ -20,13 +20,16 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.odboy.base.KitObject;
|
import cn.odboy.base.KitObject;
|
||||||
import cn.odboy.constant.CaptchaCodeEnum;
|
import cn.odboy.constant.CaptchaCodeEnum;
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import com.wf.captcha.*;
|
import com.wf.captcha.ArithmeticCaptcha;
|
||||||
|
import com.wf.captcha.ChineseCaptcha;
|
||||||
|
import com.wf.captcha.ChineseGifCaptcha;
|
||||||
|
import com.wf.captcha.GifCaptcha;
|
||||||
|
import com.wf.captcha.SpecCaptcha;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
|
import java.awt.Font;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证码配置
|
* 验证码配置
|
||||||
*
|
*
|
||||||
|
|||||||
+4
-4
@@ -17,13 +17,12 @@
|
|||||||
package cn.odboy.framework.quartz.core;
|
package cn.odboy.framework.quartz.core;
|
||||||
|
|
||||||
import cn.odboy.framework.context.KitSpringBeanHolder;
|
import cn.odboy.framework.context.KitSpringBeanHolder;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.concurrent.Callable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 执行定时任务
|
* 执行定时任务
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +32,8 @@ public class QuartzRunnable implements Callable<Object> {
|
|||||||
private final Method method;
|
private final Method method;
|
||||||
private final String params;
|
private final String params;
|
||||||
|
|
||||||
public QuartzRunnable(String beanName, String methodName, String params) throws NoSuchMethodException, SecurityException {
|
public QuartzRunnable(String beanName, String methodName, String params)
|
||||||
|
throws NoSuchMethodException, SecurityException {
|
||||||
this.target = KitSpringBeanHolder.getBean(beanName);
|
this.target = KitSpringBeanHolder.getBean(beanName);
|
||||||
this.params = params;
|
this.params = params;
|
||||||
if (StringUtils.isNotBlank(params)) {
|
if (StringUtils.isNotBlank(params)) {
|
||||||
|
|||||||
+18
-7
@@ -21,17 +21,27 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.data.redis.connection.RedisConnection;
|
import org.springframework.data.redis.connection.RedisConnection;
|
||||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||||
import org.springframework.data.redis.core.*;
|
import org.springframework.data.redis.core.ConvertingCursor;
|
||||||
|
import org.springframework.data.redis.core.Cursor;
|
||||||
|
import org.springframework.data.redis.core.RedisCallback;
|
||||||
|
import org.springframework.data.redis.core.RedisConnectionUtils;
|
||||||
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
|
import org.springframework.data.redis.core.ScanOptions;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@SuppressWarnings({"unchecked", "all"})
|
@SuppressWarnings({"unchecked", "all"})
|
||||||
public class KitRedisHelper {
|
public class KitRedisHelper {
|
||||||
@@ -204,8 +214,8 @@ public class KitRedisHelper {
|
|||||||
public void scanDel(String pattern) {
|
public void scanDel(String pattern) {
|
||||||
ScanOptions options = ScanOptions.scanOptions().match(pattern).build();
|
ScanOptions options = ScanOptions.scanOptions().match(pattern).build();
|
||||||
try (Cursor<byte[]> cursor = redisTemplate.executeWithStickyConnection(
|
try (Cursor<byte[]> cursor = redisTemplate.executeWithStickyConnection(
|
||||||
(RedisCallback<Cursor<byte[]>>)connection -> (Cursor<byte[]>)new ConvertingCursor<>(connection.scan(options),
|
(RedisCallback<Cursor<byte[]>>)connection -> (Cursor<byte[]>)new ConvertingCursor<>(
|
||||||
redisTemplate.getKeySerializer()::deserialize))) {
|
connection.scan(options), redisTemplate.getKeySerializer()::deserialize))) {
|
||||||
while (cursor.hasNext()) {
|
while (cursor.hasNext()) {
|
||||||
redisTemplate.delete(cursor.next());
|
redisTemplate.delete(cursor.next());
|
||||||
}
|
}
|
||||||
@@ -293,7 +303,8 @@ public class KitRedisHelper {
|
|||||||
public List<Object> multiGet(List<String> keys) {
|
public List<Object> multiGet(List<String> keys) {
|
||||||
List list = redisTemplate.opsForValue().multiGet(Sets.newHashSet(keys));
|
List list = redisTemplate.opsForValue().multiGet(Sets.newHashSet(keys));
|
||||||
List resultList = Lists.newArrayList();
|
List resultList = Lists.newArrayList();
|
||||||
Optional.ofNullable(list).ifPresent(e -> list.forEach(ele -> Optional.ofNullable(ele).ifPresent(resultList::add)));
|
Optional.ofNullable(list)
|
||||||
|
.ifPresent(e -> list.forEach(ele -> Optional.ofNullable(ele).ifPresent(resultList::add)));
|
||||||
return resultList;
|
return resultList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-7
@@ -19,6 +19,10 @@ package cn.odboy.framework.redis;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONFactory;
|
import com.alibaba.fastjson2.JSONFactory;
|
||||||
import com.alibaba.fastjson2.JSONWriter;
|
import com.alibaba.fastjson2.JSONWriter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Duration;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.codec.digest.MurmurHash3;
|
import org.apache.commons.codec.digest.MurmurHash3;
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
@@ -39,11 +43,6 @@ import org.springframework.data.redis.serializer.RedisSerializer;
|
|||||||
import org.springframework.data.redis.serializer.SerializationException;
|
import org.springframework.data.redis.serializer.SerializationException;
|
||||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Configuration
|
@Configuration
|
||||||
@EnableCaching
|
@EnableCaching
|
||||||
@@ -53,7 +52,8 @@ public class RedisConfiguration {
|
|||||||
* 自动识别json对象白名单配置(仅允许解析的包名, 范围越小越安全)<br/> 未配置可能导致, 登录失败, 反复登录等问题
|
* 自动识别json对象白名单配置(仅允许解析的包名, 范围越小越安全)<br/> 未配置可能导致, 登录失败, 反复登录等问题
|
||||||
*/
|
*/
|
||||||
private static final String[] WHITELIST_STR =
|
private static final String[] WHITELIST_STR =
|
||||||
{"org.springframework", "cn.odboy.system.dal.dataobject", "cn.odboy.system.dal.model", "cn.odboy.task.dal.dataobject", "cn.odboy.task.dal.model",};
|
{"org.springframework", "cn.odboy.system.dal.dataobject", "cn.odboy.system.dal.model",
|
||||||
|
"cn.odboy.task.dal.dataobject", "cn.odboy.task.dal.model",};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置 redis 数据默认过期时间,默认2小时 设置@cacheable 序列化方式
|
* 设置 redis 数据默认过期时间,默认2小时 设置@cacheable 序列化方式
|
||||||
@@ -62,7 +62,8 @@ public class RedisConfiguration {
|
|||||||
public RedisCacheConfiguration redisCacheConfiguration() {
|
public RedisCacheConfiguration redisCacheConfiguration() {
|
||||||
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class);
|
FastJsonRedisSerializer<Object> fastJsonRedisSerializer = new FastJsonRedisSerializer<>(Object.class);
|
||||||
RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
|
RedisCacheConfiguration configuration = RedisCacheConfiguration.defaultCacheConfig();
|
||||||
configuration = configuration.serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer))
|
configuration = configuration.serializeValuesWith(
|
||||||
|
RedisSerializationContext.SerializationPair.fromSerializer(fastJsonRedisSerializer))
|
||||||
.entryTtl(Duration.ofHours(2));
|
.entryTtl(Duration.ofHours(2));
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-7
@@ -19,6 +19,12 @@ package cn.odboy.framework.server.config;
|
|||||||
import cn.odboy.framework.properties.AppProperties;
|
import cn.odboy.framework.properties.AppProperties;
|
||||||
import cn.odboy.framework.properties.model.ThreadPoolSettingModel;
|
import cn.odboy.framework.properties.model.ThreadPoolSettingModel;
|
||||||
import com.alibaba.ttl.TtlRunnable;
|
import com.alibaba.ttl.TtlRunnable;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.concurrent.ThreadFactory;
|
||||||
|
import java.util.concurrent.ThreadPoolExecutor;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -26,17 +32,13 @@ import org.springframework.scheduling.annotation.AsyncConfigurer;
|
|||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
|
|
||||||
import java.util.concurrent.*;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建自定义的线程池
|
* 创建自定义的线程池
|
||||||
*/
|
*/
|
||||||
@EnableAsync
|
@EnableAsync
|
||||||
@Configuration
|
@Configuration
|
||||||
public class AsyncTheadPoolConfig implements AsyncConfigurer {
|
public class AsyncTheadPoolConfig implements AsyncConfigurer {
|
||||||
@Autowired
|
@Autowired private AppProperties properties;
|
||||||
private AppProperties properties;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义线程池, 用法 @Async
|
* 自定义线程池, 用法 @Async
|
||||||
@@ -49,8 +51,10 @@ public class AsyncTheadPoolConfig implements AsyncConfigurer {
|
|||||||
// 自定义工厂
|
// 自定义工厂
|
||||||
ThreadFactory factory = r -> new Thread(r, "DefaultAsync-" + new AtomicInteger(1).getAndIncrement());
|
ThreadFactory factory = r -> new Thread(r, "DefaultAsync-" + new AtomicInteger(1).getAndIncrement());
|
||||||
// 自定义线程池
|
// 自定义线程池
|
||||||
return new ThreadPoolExecutor(asyncTaskPool.getCorePoolSize(), asyncTaskPool.getMaxPoolSize(), asyncTaskPool.getKeepAliveSeconds(), TimeUnit.SECONDS,
|
return new ThreadPoolExecutor(asyncTaskPool.getCorePoolSize(), asyncTaskPool.getMaxPoolSize(),
|
||||||
new ArrayBlockingQueue<>(asyncTaskPool.getQueueCapacity()), factory, new ThreadPoolExecutor.CallerRunsPolicy());
|
asyncTaskPool.getKeepAliveSeconds(), TimeUnit.SECONDS,
|
||||||
|
new ArrayBlockingQueue<>(asyncTaskPool.getQueueCapacity()), factory,
|
||||||
|
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+4
-4
@@ -16,19 +16,19 @@
|
|||||||
|
|
||||||
package cn.odboy.framework.server.converters;
|
package cn.odboy.framework.server.converters;
|
||||||
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DateStringArraysToListDateConverter implements Converter<String[], List<Date>> {
|
public class DateStringArraysToListDateConverter implements Converter<String[], List<Date>> {
|
||||||
private static final ThreadLocal<SimpleDateFormat> SDF = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
private static final ThreadLocal<SimpleDateFormat> SDF =
|
||||||
|
ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<Date> convert(String[] source) {
|
public List<Date> convert(String[] source) {
|
||||||
|
|||||||
+4
-4
@@ -17,16 +17,16 @@
|
|||||||
package cn.odboy.framework.server.converters;
|
package cn.odboy.framework.server.converters;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import org.springframework.core.convert.converter.Converter;
|
|
||||||
import org.springframework.stereotype.Component;
|
|
||||||
|
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import org.springframework.core.convert.converter.Converter;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DateStringToDateConverter implements Converter<String, Date> {
|
public class DateStringToDateConverter implements Converter<String, Date> {
|
||||||
private static final ThreadLocal<SimpleDateFormat> SDF = ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
private static final ThreadLocal<SimpleDateFormat> SDF =
|
||||||
|
ThreadLocal.withInitial(() -> new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Date convert(String source) {
|
public Date convert(String source) {
|
||||||
|
|||||||
+6
-10
@@ -21,6 +21,9 @@ import cn.odboy.framework.server.converters.DateStringToDateConverter;
|
|||||||
import com.alibaba.fastjson2.JSONWriter;
|
import com.alibaba.fastjson2.JSONWriter;
|
||||||
import com.alibaba.fastjson2.support.config.FastJsonConfig;
|
import com.alibaba.fastjson2.support.config.FastJsonConfig;
|
||||||
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
|
import com.alibaba.fastjson2.support.spring6.http.converter.FastJsonHttpMessageConverter;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
@@ -35,10 +38,6 @@ import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
|||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 跨越、静态资源映射、Http消息转换
|
* 跨越、静态资源映射、Http消息转换
|
||||||
*
|
*
|
||||||
@@ -48,12 +47,9 @@ import java.util.List;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public class ConfigurerAdapter implements WebMvcConfigurer {
|
public class ConfigurerAdapter implements WebMvcConfigurer {
|
||||||
@Autowired
|
@Autowired private DateStringArraysToListDateConverter dateStringArraysToListDateConverter;
|
||||||
private DateStringArraysToListDateConverter dateStringArraysToListDateConverter;
|
@Autowired private DateStringToDateConverter dateStringToDateConverter;
|
||||||
@Autowired
|
@Autowired private KitFileLocalUploadHelper fileUploadPathHelper;
|
||||||
private DateStringToDateConverter dateStringToDateConverter;
|
|
||||||
@Autowired
|
|
||||||
private KitFileLocalUploadHelper fileUploadPathHelper;
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public CorsFilter corsFilter() {
|
public CorsFilter corsFilter() {
|
||||||
|
|||||||
+6
-3
@@ -7,7 +7,8 @@ import org.springframework.boot.web.server.WebServerFactoryCustomizer;
|
|||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 解决启动io.undertow.websockets.jsr UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be used的警告
|
* 解决启动io.undertow.websockets.jsr UT026010: Buffer pool was not set on WebSocketDeploymentInfo, the default pool will be
|
||||||
|
* used的警告
|
||||||
*
|
*
|
||||||
* @author odboy
|
* @author odboy
|
||||||
* @date 2025-10-30
|
* @date 2025-10-30
|
||||||
@@ -34,8 +35,10 @@ public class UndertowWebSocketConfig implements WebServerFactoryCustomizer<Under
|
|||||||
|
|
||||||
factory.addDeploymentInfoCustomizers(deploymentInfo -> {
|
factory.addDeploymentInfoCustomizers(deploymentInfo -> {
|
||||||
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
|
WebSocketDeploymentInfo webSocketDeploymentInfo = new WebSocketDeploymentInfo();
|
||||||
webSocketDeploymentInfo.setBuffers(new DefaultByteBufferPool(false, bufferSize, maxPoolSize, threadLocalCacheSize));
|
webSocketDeploymentInfo.setBuffers(
|
||||||
deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo", webSocketDeploymentInfo);
|
new DefaultByteBufferPool(false, bufferSize, maxPoolSize, threadLocalCacheSize));
|
||||||
|
deploymentInfo.addServletContextAttribute("io.undertow.websockets.jsr.WebSocketDeploymentInfo",
|
||||||
|
webSocketDeploymentInfo);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-2
@@ -16,11 +16,10 @@
|
|||||||
|
|
||||||
package cn.odboy.framework.websocket.context;
|
package cn.odboy.framework.websocket.context;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* WebSocket客户端管理
|
* WebSocket客户端管理
|
||||||
|
|||||||
+9
-5
@@ -17,16 +17,19 @@
|
|||||||
package cn.odboy.framework.websocket.context;
|
package cn.odboy.framework.websocket.context;
|
||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import jakarta.websocket.*;
|
import jakarta.websocket.OnClose;
|
||||||
|
import jakarta.websocket.OnError;
|
||||||
|
import jakarta.websocket.OnMessage;
|
||||||
|
import jakarta.websocket.OnOpen;
|
||||||
|
import jakarta.websocket.Session;
|
||||||
import jakarta.websocket.server.PathParam;
|
import jakarta.websocket.server.PathParam;
|
||||||
import jakarta.websocket.server.ServerEndpoint;
|
import jakarta.websocket.server.ServerEndpoint;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
@ServerEndpoint("/websocket/{sid}")
|
@ServerEndpoint("/websocket/{sid}")
|
||||||
@@ -62,7 +65,8 @@ public class KitWsServer {
|
|||||||
KitWsMessage wsMessage = JSON.parseObject(message, KitWsMessage.class);
|
KitWsMessage wsMessage = JSON.parseObject(message, KitWsMessage.class);
|
||||||
String bizCode = wsMessage.getBizCode();
|
String bizCode = wsMessage.getBizCode();
|
||||||
Object data = wsMessage.getData();
|
Object data = wsMessage.getData();
|
||||||
log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode, JSON.toJSONString(data));
|
log.info("收到来 sid={} 的信息: message={}, bizCode={}, data={}", sid, message, bizCode,
|
||||||
|
JSON.toJSONString(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+13
-5
@@ -19,6 +19,13 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.odboy.annotation.AnonymousAccess;
|
import cn.odboy.annotation.AnonymousAccess;
|
||||||
import cn.odboy.constant.RequestMethodEnum;
|
import cn.odboy.constant.RequestMethodEnum;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
@@ -27,8 +34,6 @@ import org.springframework.web.servlet.mvc.condition.PathPatternsRequestConditio
|
|||||||
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
|
||||||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
|
||||||
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 匿名标记工具
|
* 匿名标记工具
|
||||||
*/
|
*/
|
||||||
@@ -42,7 +47,8 @@ public class KitAnonTagUtil {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static Map<String, Set<String>> getAnonymousUrl(final ApplicationContext applicationContext) {
|
public static Map<String, Set<String>> getAnonymousUrl(final ApplicationContext applicationContext) {
|
||||||
RequestMappingHandlerMapping requestMappingHandlerMapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
|
RequestMappingHandlerMapping requestMappingHandlerMapping =
|
||||||
|
applicationContext.getBean(RequestMappingHandlerMapping.class);
|
||||||
Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods();
|
Map<RequestMappingInfo, HandlerMethod> handlerMethodMap = requestMappingHandlerMapping.getHandlerMethods();
|
||||||
Map<String, java.util.Set<String>> anonymousUrls = new HashMap<>(8);
|
Map<String, java.util.Set<String>> anonymousUrls = new HashMap<>(8);
|
||||||
// 获取匿名标记
|
// 获取匿名标记
|
||||||
@@ -56,8 +62,10 @@ public class KitAnonTagUtil {
|
|||||||
HandlerMethod handlerMethod = infoEntry.getValue();
|
HandlerMethod handlerMethod = infoEntry.getValue();
|
||||||
AnonymousAccess anonymousAccess = handlerMethod.getMethodAnnotation(AnonymousAccess.class);
|
AnonymousAccess anonymousAccess = handlerMethod.getMethodAnnotation(AnonymousAccess.class);
|
||||||
if (null != anonymousAccess && infoEntry.getKey() != null) {
|
if (null != anonymousAccess && infoEntry.getKey() != null) {
|
||||||
List<RequestMethod> requestMethods = new ArrayList<>(infoEntry.getKey().getMethodsCondition().getMethods());
|
List<RequestMethod> requestMethods =
|
||||||
RequestMethodEnum request = RequestMethodEnum.find(requestMethods.isEmpty() ? RequestMethodEnum.ALL.getType() : requestMethods.get(0).name());
|
new ArrayList<>(infoEntry.getKey().getMethodsCondition().getMethods());
|
||||||
|
RequestMethodEnum request = RequestMethodEnum.find(
|
||||||
|
requestMethods.isEmpty() ? RequestMethodEnum.ALL.getType() : requestMethods.get(0).name());
|
||||||
PathPatternsRequestCondition pathPatternsCondition = infoEntry.getKey().getPathPatternsCondition();
|
PathPatternsRequestCondition pathPatternsCondition = infoEntry.getKey().getPathPatternsCondition();
|
||||||
if (pathPatternsCondition != null) {
|
if (pathPatternsCondition != null) {
|
||||||
switch (Objects.requireNonNull(request)) {
|
switch (Objects.requireNonNull(request)) {
|
||||||
|
|||||||
+1
-2
@@ -18,9 +18,8 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.codec.Base64Encoder;
|
import cn.hutool.core.codec.Base64Encoder;
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加密令牌生成工具
|
* 加密令牌生成工具
|
||||||
|
|||||||
+1
-2
@@ -17,10 +17,9 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 计算类
|
* 计算类
|
||||||
|
|||||||
+2
-3
@@ -19,11 +19,10 @@ package cn.odboy.util;
|
|||||||
import cn.hutool.http.useragent.UserAgent;
|
import cn.hutool.http.useragent.UserAgent;
|
||||||
import cn.hutool.http.useragent.UserAgentUtil;
|
import cn.hutool.http.useragent.UserAgentUtil;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 浏览器 相关
|
* 浏览器 相关
|
||||||
|
|||||||
+1
-2
@@ -17,11 +17,10 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类 相关
|
* 类 相关
|
||||||
|
|||||||
+1
-2
@@ -17,9 +17,8 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.io.Closeable;
|
import java.io.Closeable;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用于关闭各种连接, 缺啥补啥
|
* 用于关闭各种连接, 缺啥补啥
|
||||||
|
|||||||
+17
-8
@@ -18,15 +18,19 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.odboy.base.KitSelectOptionVo;
|
import cn.odboy.base.KitSelectOptionVo;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 集合工具
|
* 集合工具
|
||||||
@@ -61,7 +65,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
* @param <U> /
|
* @param <U> /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static <T, U extends Comparable<? super U>> List<T> streamAscSort(List<T> data, Function<? super T, ? extends U> keyExtractor) {
|
public static <T, U extends Comparable<? super U>> List<T> streamAscSort(List<T> data,
|
||||||
|
Function<? super T, ? extends U> keyExtractor) {
|
||||||
return data.stream().sorted(Comparator.comparing(keyExtractor)).toList();
|
return data.stream().sorted(Comparator.comparing(keyExtractor)).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -76,7 +81,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
* @param <U> /
|
* @param <U> /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static <T, U extends Comparable<? super U>> List<T> streamDescSort(List<T> data, Function<? super T, ? extends U> keyExtractor) {
|
public static <T, U extends Comparable<? super U>> List<T> streamDescSort(List<T> data,
|
||||||
|
Function<? super T, ? extends U> keyExtractor) {
|
||||||
return data.stream().sorted(Comparator.comparing(keyExtractor).reversed()).toList();
|
return data.stream().sorted(Comparator.comparing(keyExtractor).reversed()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +99,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
* @param <U> /
|
* @param <U> /
|
||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static <T, K, U> Map<K, U> streamToMap(List<T> data, Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends U> valueMapper) {
|
public static <T, K, U> Map<K, U> streamToMap(List<T> data, Function<? super T, ? extends K> keyMapper,
|
||||||
|
Function<? super T, ? extends U> valueMapper) {
|
||||||
// 根据key去重再并流
|
// 根据key去重再并流
|
||||||
return streamDistinct(data, keyMapper).stream().collect(Collectors.toMap(keyMapper, valueMapper));
|
return streamDistinct(data, keyMapper).stream().collect(Collectors.toMap(keyMapper, valueMapper));
|
||||||
}
|
}
|
||||||
@@ -185,7 +192,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
public static BigDecimal streamBigDecimalAvg(List<BigDecimal> data) {
|
public static BigDecimal streamBigDecimalAvg(List<BigDecimal> data) {
|
||||||
return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add).divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR);
|
return data.stream().filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add)
|
||||||
|
.divide(BigDecimal.valueOf(data.size()), 6, RoundingMode.FLOOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@@ -204,7 +212,8 @@ public final class KitCollUtil extends cn.hutool.core.collection.CollUtil {
|
|||||||
System.out.println(JSON.toJSONString(selectOptions2));
|
System.out.println(JSON.toJSONString(selectOptions2));
|
||||||
List<KitSelectOptionVo> selectOptions3 = KitCollUtil.streamDistinct(testData, KitSelectOptionVo::getValue);
|
List<KitSelectOptionVo> selectOptions3 = KitCollUtil.streamDistinct(testData, KitSelectOptionVo::getValue);
|
||||||
System.out.println(JSON.toJSONString(selectOptions3));
|
System.out.println(JSON.toJSONString(selectOptions3));
|
||||||
Map<String, String> selectMap1 = KitCollUtil.streamToMap(testData, KitSelectOptionVo::getValue, KitSelectOptionVo::getLabel);
|
Map<String, String> selectMap1 =
|
||||||
|
KitCollUtil.streamToMap(testData, KitSelectOptionVo::getValue, KitSelectOptionVo::getLabel);
|
||||||
System.out.println(JSON.toJSONString(selectMap1));
|
System.out.println(JSON.toJSONString(selectMap1));
|
||||||
// 这只是一个示范
|
// 这只是一个示范
|
||||||
BigDecimal total1 = KitCollUtil.streamBigDecimalAdd(testData, "value");
|
BigDecimal total1 = KitCollUtil.streamBigDecimalAdd(testData, "value");
|
||||||
|
|||||||
+1
-2
@@ -18,9 +18,8 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DatePattern;
|
import cn.hutool.core.date.DatePattern;
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 时间相关工具
|
* 时间相关工具
|
||||||
|
|||||||
+2
-3
@@ -16,14 +16,13 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
import javax.crypto.Cipher;
|
||||||
import javax.crypto.SecretKey;
|
import javax.crypto.SecretKey;
|
||||||
import javax.crypto.SecretKeyFactory;
|
import javax.crypto.SecretKeyFactory;
|
||||||
import javax.crypto.spec.DESKeySpec;
|
import javax.crypto.spec.DESKeySpec;
|
||||||
import javax.crypto.spec.IvParameterSpec;
|
import javax.crypto.spec.IvParameterSpec;
|
||||||
import java.nio.charset.StandardCharsets;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DES加密
|
* DES加密
|
||||||
|
|||||||
+11
-6
@@ -17,7 +17,6 @@
|
|||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,7 +95,8 @@ public final class KitDistributedIdUtil {
|
|||||||
* @param workerIdBits 机器 ID 所占位数
|
* @param workerIdBits 机器 ID 所占位数
|
||||||
* @param sequenceBits 序列号所占位数
|
* @param sequenceBits 序列号所占位数
|
||||||
*/
|
*/
|
||||||
public KitDistributedIdUtil(long dataCenterId, long workerId, long dataCenterIdBits, long workerIdBits, long sequenceBits) {
|
public KitDistributedIdUtil(long dataCenterId, long workerId, long dataCenterIdBits, long workerIdBits,
|
||||||
|
long sequenceBits) {
|
||||||
this.dataCenterIdBits = dataCenterIdBits;
|
this.dataCenterIdBits = dataCenterIdBits;
|
||||||
this.workerIdBits = workerIdBits;
|
this.workerIdBits = workerIdBits;
|
||||||
this.sequenceBits = sequenceBits;
|
this.sequenceBits = sequenceBits;
|
||||||
@@ -110,7 +110,8 @@ public final class KitDistributedIdUtil {
|
|||||||
this.timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;
|
this.timestampLeftShift = sequenceBits + workerIdBits + dataCenterIdBits;
|
||||||
|
|
||||||
if (dataCenterId > maxDataCenterId || dataCenterId < 0) {
|
if (dataCenterId > maxDataCenterId || dataCenterId < 0) {
|
||||||
throw new IllegalArgumentException("Data center ID can't be greater than " + maxDataCenterId + " or less than 0");
|
throw new IllegalArgumentException(
|
||||||
|
"Data center ID can't be greater than " + maxDataCenterId + " or less than 0");
|
||||||
}
|
}
|
||||||
if (workerId > maxWorkerId || workerId < 0) {
|
if (workerId > maxWorkerId || workerId < 0) {
|
||||||
throw new IllegalArgumentException("Worker ID can't be greater than " + maxWorkerId + " or less than 0");
|
throw new IllegalArgumentException("Worker ID can't be greater than " + maxWorkerId + " or less than 0");
|
||||||
@@ -154,7 +155,9 @@ public final class KitDistributedIdUtil {
|
|||||||
|
|
||||||
// 如果当前时间戳小于上一次生成 ID 的时间戳, 说明时钟回拨,抛出异常
|
// 如果当前时间戳小于上一次生成 ID 的时间戳, 说明时钟回拨,抛出异常
|
||||||
if (currentTimestamp < lastTimestamp.get()) {
|
if (currentTimestamp < lastTimestamp.get()) {
|
||||||
throw new BadRequestException("Clock moved backwards. Refusing to generate id for " + (lastTimestamp.get() - currentTimestamp) + " milliseconds");
|
throw new BadRequestException(
|
||||||
|
"Clock moved backwards. Refusing to generate id for " + (lastTimestamp.get() - currentTimestamp) +
|
||||||
|
" milliseconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastTimestampValue = lastTimestamp.get();
|
long lastTimestampValue = lastTimestamp.get();
|
||||||
@@ -165,12 +168,14 @@ public final class KitDistributedIdUtil {
|
|||||||
// 序列号溢出,等待下一毫秒
|
// 序列号溢出,等待下一毫秒
|
||||||
currentTimestamp = waitNextMillis(lastTimestampValue);
|
currentTimestamp = waitNextMillis(lastTimestampValue);
|
||||||
}
|
}
|
||||||
return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | (workerId << workerIdShift) | seq;
|
return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) |
|
||||||
|
(workerId << workerIdShift) | seq;
|
||||||
} else {
|
} else {
|
||||||
// 时间戳改变,重置序列号
|
// 时间戳改变,重置序列号
|
||||||
sequence.set(0L);
|
sequence.set(0L);
|
||||||
lastTimestamp.set(currentTimestamp);
|
lastTimestamp.set(currentTimestamp);
|
||||||
return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) | (workerId << workerIdShift);
|
return ((currentTimestamp - START_TIMESTAMP) << timestampLeftShift) | (dataCenterId << dataCenterIdShift) |
|
||||||
|
(workerId << workerIdShift);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+20
-12
@@ -26,13 +26,11 @@ import cn.odboy.framework.exception.BadRequestException;
|
|||||||
import jakarta.servlet.ServletOutputStream;
|
import jakarta.servlet.ServletOutputStream;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.experimental.UtilityClass;
|
import java.io.File;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import java.io.FileInputStream;
|
||||||
import org.apache.poi.util.IOUtils;
|
import java.io.IOException;
|
||||||
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
import java.io.InputStream;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import java.io.OutputStream;
|
||||||
|
|
||||||
import java.io.*;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
@@ -41,8 +39,16 @@ import java.util.Date;
|
|||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.util.IOUtils;
|
||||||
|
import org.apache.poi.xssf.streaming.SXSSFSheet;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import static cn.odboy.constant.SystemConst.*;
|
import static cn.odboy.constant.SystemConst.SYMBOL_ADD;
|
||||||
|
import static cn.odboy.constant.SystemConst.SYMBOL_AT;
|
||||||
|
import static cn.odboy.constant.SystemConst.SYMBOL_EQUAL;
|
||||||
|
import static cn.odboy.constant.SystemConst.SYMBOL_SUBTRACT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File工具类, 扩展 hutool 工具包
|
* File工具类, 扩展 hutool 工具包
|
||||||
@@ -189,8 +195,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
map.forEach((key, value) -> {
|
map.forEach((key, value) -> {
|
||||||
if (value instanceof String strValue) {
|
if (value instanceof String strValue) {
|
||||||
// 检查并处理以特殊字符开头的值
|
// 检查并处理以特殊字符开头的值
|
||||||
if (strValue.startsWith(SYMBOL_EQUAL) || strValue.startsWith(SYMBOL_ADD) || strValue.startsWith(SYMBOL_SUBTRACT) || strValue.startsWith(
|
if (strValue.startsWith(SYMBOL_EQUAL) || strValue.startsWith(SYMBOL_ADD) ||
|
||||||
SYMBOL_AT)) {
|
strValue.startsWith(SYMBOL_SUBTRACT) || strValue.startsWith(SYMBOL_AT)) {
|
||||||
// 添加单引号前缀
|
// 添加单引号前缀
|
||||||
strValue = "'" + strValue;
|
strValue = "'" + strValue;
|
||||||
}
|
}
|
||||||
@@ -322,7 +328,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
* @param response /
|
* @param response /
|
||||||
* @param file /
|
* @param file /
|
||||||
*/
|
*/
|
||||||
public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file, boolean deleteOnExit) {
|
public static void downloadFile(HttpServletRequest request, HttpServletResponse response, File file,
|
||||||
|
boolean deleteOnExit) {
|
||||||
response.setCharacterEncoding(request.getCharacterEncoding());
|
response.setCharacterEncoding(request.getCharacterEncoding());
|
||||||
response.setContentType("application/octet-stream");
|
response.setContentType("application/octet-stream");
|
||||||
FileInputStream fis = null;
|
FileInputStream fis = null;
|
||||||
@@ -379,7 +386,8 @@ public final class KitFileUtil extends cn.hutool.core.io.FileUtil {
|
|||||||
fileName = fileName.replaceAll("^\\.+/", "");
|
fileName = fileName.replaceAll("^\\.+/", "");
|
||||||
|
|
||||||
// 保留文件名中最后一个 "." 字符,过滤掉其他 "."
|
// 保留文件名中最后一个 "." 字符,过滤掉其他 "."
|
||||||
fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") + fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2");
|
fileName = fileName.replaceAll("^(.*)(\\.[^.]*)$", "$1").replaceAll("\\.", "") +
|
||||||
|
fileName.replaceAll("^(.*)(\\.[^.]*)$", "$2");
|
||||||
|
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,13 +17,12 @@
|
|||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import cn.odboy.framework.context.KitSpringBeanHolder;
|
import cn.odboy.framework.context.KitSpringBeanHolder;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
|
||||||
import net.dreamlu.mica.ip2region.core.IpInfo;
|
|
||||||
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.NetworkInterface;
|
import java.net.NetworkInterface;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import net.dreamlu.mica.ip2region.core.Ip2regionSearcher;
|
||||||
|
import net.dreamlu.mica.ip2region.core.IpInfo;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* IP地址 相关
|
* IP地址 相关
|
||||||
@@ -55,10 +54,12 @@ public final class KitIPUtil {
|
|||||||
try {
|
try {
|
||||||
InetAddress candidateAddress = null;
|
InetAddress candidateAddress = null;
|
||||||
// 遍历所有的网络接口
|
// 遍历所有的网络接口
|
||||||
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); interfaces.hasMoreElements(); ) {
|
for (Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
||||||
|
interfaces.hasMoreElements(); ) {
|
||||||
NetworkInterface anInterface = interfaces.nextElement();
|
NetworkInterface anInterface = interfaces.nextElement();
|
||||||
// 在所有的接口下再遍历IP
|
// 在所有的接口下再遍历IP
|
||||||
for (Enumeration<InetAddress> inetAddresses = anInterface.getInetAddresses(); inetAddresses.hasMoreElements(); ) {
|
for (Enumeration<InetAddress> inetAddresses = anInterface.getInetAddresses();
|
||||||
|
inetAddresses.hasMoreElements(); ) {
|
||||||
InetAddress inetAddr = inetAddresses.nextElement();
|
InetAddress inetAddr = inetAddresses.nextElement();
|
||||||
// 排除loopback类型地址
|
// 排除loopback类型地址
|
||||||
if (!inetAddr.isLoopbackAddress()) {
|
if (!inetAddr.isLoopbackAddress()) {
|
||||||
|
|||||||
+3
-6
@@ -18,10 +18,9 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.TypeReference;
|
import com.alibaba.fastjson2.TypeReference;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Json工具
|
* Json工具
|
||||||
@@ -32,13 +31,11 @@ import java.util.Map;
|
|||||||
@UtilityClass
|
@UtilityClass
|
||||||
public final class KitJsonUtil {
|
public final class KitJsonUtil {
|
||||||
public static <K, V> Map<K, V> toMap(String jsonStr, Class<K> kClass, Class<V> vClass) {
|
public static <K, V> Map<K, V> toMap(String jsonStr, Class<K> kClass, Class<V> vClass) {
|
||||||
return JSON.parseObject(jsonStr, new TypeReference<>() {
|
return JSON.parseObject(jsonStr, new TypeReference<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <V> List<V> toList(String jsonStr, Class<V> vClass) {
|
public static <V> List<V> toList(String jsonStr, Class<V> vClass) {
|
||||||
return JSON.parseObject(jsonStr, new TypeReference<>() {
|
return JSON.parseObject(jsonStr, new TypeReference<>() {});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
+6
-5
@@ -18,12 +18,11 @@ package cn.odboy.util;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import cn.odboy.base.KitBaseUserTimeTb;
|
import cn.odboy.base.KitBaseUserTimeTb;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List 工具
|
* List 工具
|
||||||
@@ -40,12 +39,14 @@ public final class KitListUtil {
|
|||||||
* @param classifier 对象T属性表达式, 比如: User::getName
|
* @param classifier 对象T属性表达式, 比如: User::getName
|
||||||
*/
|
*/
|
||||||
public static <T, K> List<T> distinctByArgs(List<T> items, Function<? super T, ? extends K> classifier) {
|
public static <T, K> List<T> distinctByArgs(List<T> items, Function<? super T, ? extends K> classifier) {
|
||||||
return items.stream().collect(Collectors.groupingBy(classifier)).values().stream().map(monitorItem -> monitorItem.iterator().next()).toList();
|
return items.stream().collect(Collectors.groupingBy(classifier)).values().stream()
|
||||||
|
.map(monitorItem -> monitorItem.iterator().next()).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* list转map, 保留新值 -> Map<String, User> userMap = items.stream().collect(Collectors.toMap(User::getName, user -> user)) <br> list转map, 保留旧值 -> Map<String,
|
* list转map, 保留新值 -> Map<String, User> userMap = items.stream().collect(Collectors.toMap(User::getName, user ->
|
||||||
* User> userMap = users.stream().collect(Collectors.toMap(User::getName, user -> user, (existing, replacement) -> existing));
|
* user)) <br> list转map, 保留旧值 -> Map<String, User> userMap = users.stream().collect(Collectors.toMap(User::getName,
|
||||||
|
* user -> user, (existing, replacement) -> existing));
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
List<KitBaseUserTimeTb> entities = new ArrayList<>();
|
List<KitBaseUserTimeTb> entities = new ArrayList<>();
|
||||||
|
|||||||
+1
-2
@@ -20,11 +20,10 @@ import cn.odboy.base.KitPageResult;
|
|||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页工具
|
* 分页工具
|
||||||
|
|||||||
+2
-1
@@ -34,7 +34,8 @@ import lombok.experimental.UtilityClass;
|
|||||||
public class KitResourceTemplateUtil {
|
public class KitResourceTemplateUtil {
|
||||||
public static String render(String moduleName, String filename, Dict params) {
|
public static String render(String moduleName, String filename, Dict params) {
|
||||||
String path = StrUtil.isBlank(moduleName) ? "template" : "template/" + moduleName;
|
String path = StrUtil.isBlank(moduleName) ? "template" : "template/" + moduleName;
|
||||||
TemplateEngine engine = TemplateUtil.createEngine(new TemplateConfig(path, TemplateConfig.ResourceMode.CLASSPATH));
|
TemplateEngine engine =
|
||||||
|
TemplateUtil.createEngine(new TemplateConfig(path, TemplateConfig.ResourceMode.CLASSPATH));
|
||||||
Template template = engine.getTemplate(filename);
|
Template template = engine.getTemplate(filename);
|
||||||
return template.render(params);
|
return template.render(params);
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-3
@@ -17,14 +17,13 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回值处理 工具
|
* 返回值处理 工具
|
||||||
|
|||||||
+9
-5
@@ -16,16 +16,20 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
|
|
||||||
import javax.crypto.Cipher;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.security.*;
|
import java.security.KeyFactory;
|
||||||
|
import java.security.KeyPair;
|
||||||
|
import java.security.KeyPairGenerator;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.PrivateKey;
|
||||||
|
import java.security.PublicKey;
|
||||||
import java.security.interfaces.RSAPrivateKey;
|
import java.security.interfaces.RSAPrivateKey;
|
||||||
import java.security.interfaces.RSAPublicKey;
|
import java.security.interfaces.RSAPublicKey;
|
||||||
import java.security.spec.PKCS8EncodedKeySpec;
|
import java.security.spec.PKCS8EncodedKeySpec;
|
||||||
import java.security.spec.X509EncodedKeySpec;
|
import java.security.spec.X509EncodedKeySpec;
|
||||||
|
import javax.crypto.Cipher;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.apache.commons.codec.binary.Base64;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rsa 工具类, 公钥私钥生成, 加解密
|
* Rsa 工具类, 公钥私钥生成, 加解密
|
||||||
|
|||||||
+8
-6
@@ -17,11 +17,10 @@
|
|||||||
|
|
||||||
package cn.odboy.util;
|
package cn.odboy.util;
|
||||||
|
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
|
* 字符串工具类, 继承org.apache.commons.lang3.StringUtils类
|
||||||
@@ -35,7 +34,8 @@ public final class KitStringUtil {
|
|||||||
/**
|
/**
|
||||||
* 驼峰命名法工具
|
* 驼峰命名法工具
|
||||||
*
|
*
|
||||||
* @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world"
|
* @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld"
|
||||||
|
* toUnderScoreCase("helloWorld") = "hello_world"
|
||||||
*/
|
*/
|
||||||
public static String toCamelCase(String s) {
|
public static String toCamelCase(String s) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
@@ -65,7 +65,8 @@ public final class KitStringUtil {
|
|||||||
/**
|
/**
|
||||||
* 驼峰命名法工具
|
* 驼峰命名法工具
|
||||||
*
|
*
|
||||||
* @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world"
|
* @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld"
|
||||||
|
* toUnderScoreCase("helloWorld") = "hello_world"
|
||||||
*/
|
*/
|
||||||
public static String toCapitalizeCamelCase(String s) {
|
public static String toCapitalizeCamelCase(String s) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
@@ -78,7 +79,8 @@ public final class KitStringUtil {
|
|||||||
/**
|
/**
|
||||||
* 驼峰命名法工具
|
* 驼峰命名法工具
|
||||||
*
|
*
|
||||||
* @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld" toUnderScoreCase("helloWorld") = "hello_world"
|
* @return toCamelCase(" hello_world ") == "helloWorld" toCapitalizeCamelCase("hello_world") == "HelloWorld"
|
||||||
|
* toUnderScoreCase("helloWorld") = "hello_world"
|
||||||
*/
|
*/
|
||||||
public static String toUnderScoreCase(String s) {
|
public static String toUnderScoreCase(String s) {
|
||||||
if (s == null) {
|
if (s == null) {
|
||||||
|
|||||||
+3
-3
@@ -22,10 +22,9 @@ import jakarta.validation.Validation;
|
|||||||
import jakarta.validation.Validator;
|
import jakarta.validation.Validator;
|
||||||
import jakarta.validation.ValidatorFactory;
|
import jakarta.validation.ValidatorFactory;
|
||||||
import jakarta.validation.groups.Default;
|
import jakarta.validation.groups.Default;
|
||||||
import lombok.experimental.UtilityClass;
|
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bean验证工具
|
* Bean验证工具
|
||||||
@@ -46,7 +45,8 @@ public final class KitValidUtil {
|
|||||||
public static <T> void validate(T object) {
|
public static <T> void validate(T object) {
|
||||||
Set<ConstraintViolation<T>> violations = VALIDATOR.validate(object, Default.class);
|
Set<ConstraintViolation<T>> violations = VALIDATOR.validate(object, Default.class);
|
||||||
if (!violations.isEmpty()) {
|
if (!violations.isEmpty()) {
|
||||||
throw new BadRequestException(violations.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining(",")));
|
throw new BadRequestException(
|
||||||
|
violations.stream().map(ConstraintViolation::getMessage).collect(Collectors.joining(",")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,27 +1,25 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>cutejava</artifactId>
|
<artifactId>cutejava</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<groupId>cn.odboy</groupId>
|
||||||
<version>1.4.1</version>
|
<version>1.4.1</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<artifactId>cutejava-module-system</artifactId>
|
||||||
<artifactId>cutejava-module-system</artifactId>
|
<name>核心模块</name>
|
||||||
<name>核心模块</name>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
<dependencies>
|
<groupId>cn.odboy</groupId>
|
||||||
<dependency>
|
<artifactId>cutejava-framework</artifactId>
|
||||||
<groupId>cn.odboy</groupId>
|
<version>1.4.1</version>
|
||||||
<artifactId>cutejava-framework</artifactId>
|
</dependency>
|
||||||
<version>1.4.1</version>
|
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
||||||
</dependency>
|
<dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/io.minio/minio -->
|
<groupId>io.minio</groupId>
|
||||||
<dependency>
|
<artifactId>minio</artifactId>
|
||||||
<groupId>io.minio</groupId>
|
<version>8.5.17</version>
|
||||||
<artifactId>minio</artifactId>
|
</dependency>
|
||||||
<version>8.5.17</version>
|
</dependencies>
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
+31
-37
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.constant;
|
package cn.odboy.system.constant;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -25,42 +24,37 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum SystemCaptchaBizEnum {
|
public enum SystemCaptchaBizEnum {
|
||||||
|
/* 通过手机号码重置邮箱 */
|
||||||
|
PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl",
|
||||||
|
"通过手机号码重置邮箱"), /* 通过旧邮箱重置邮箱 */
|
||||||
|
EMAIL_RESET_EMAIL_CODE("10001", "email_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过旧邮箱重置邮箱"),
|
||||||
|
/* 通过手机号码重置密码 */
|
||||||
|
PHONE_RESET_PWD_CODE("10002", "phone_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置密码"),
|
||||||
|
/* 通过邮箱重置密码 */
|
||||||
|
EMAIL_RESET_PWD_CODE("10003", "email_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过邮箱重置密码");
|
||||||
|
/**
|
||||||
|
* 业务编码
|
||||||
|
*/
|
||||||
|
private final String bizCode;
|
||||||
|
/**
|
||||||
|
* redis中的key
|
||||||
|
*/
|
||||||
|
private final String redisKey;
|
||||||
|
/**
|
||||||
|
* resources文件夹,template中的模版名称
|
||||||
|
*/
|
||||||
|
private final String templateName;
|
||||||
|
/**
|
||||||
|
* 业务描述
|
||||||
|
*/
|
||||||
|
private final String description;
|
||||||
|
|
||||||
/* 通过手机号码重置邮箱 */
|
public static SystemCaptchaBizEnum getByBizCode(String bizCode) {
|
||||||
PHONE_RESET_EMAIL_CODE("10000", "phone_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置邮箱"),
|
for (SystemCaptchaBizEnum value : SystemCaptchaBizEnum.values()) {
|
||||||
|
if (value.getBizCode().equals(bizCode)) {
|
||||||
/* 通过旧邮箱重置邮箱 */
|
return value;
|
||||||
EMAIL_RESET_EMAIL_CODE("10001", "email_reset_email_code_", "SystemEmailCaptchaTemplate.ftl", "通过旧邮箱重置邮箱"),
|
}
|
||||||
|
|
||||||
/* 通过手机号码重置密码 */
|
|
||||||
PHONE_RESET_PWD_CODE("10002", "phone_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过手机号码重置密码"),
|
|
||||||
|
|
||||||
/* 通过邮箱重置密码 */
|
|
||||||
EMAIL_RESET_PWD_CODE("10003", "email_reset_pwd_code_", "SystemEmailCaptchaTemplate.ftl", "通过邮箱重置密码");
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 业务编码
|
|
||||||
*/
|
|
||||||
private final String bizCode;
|
|
||||||
/**
|
|
||||||
* redis中的key
|
|
||||||
*/
|
|
||||||
private final String redisKey;
|
|
||||||
/**
|
|
||||||
* resources文件夹,template中的模版名称
|
|
||||||
*/
|
|
||||||
private final String templateName;
|
|
||||||
/**
|
|
||||||
* 业务描述
|
|
||||||
*/
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
public static SystemCaptchaBizEnum getByBizCode(String bizCode) {
|
|
||||||
for (SystemCaptchaBizEnum value : SystemCaptchaBizEnum.values()) {
|
|
||||||
if (value.getBizCode().equals(bizCode)) {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-20
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.constant;
|
package cn.odboy.system.constant;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
@@ -25,25 +24,19 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum SystemDataScopeEnum {
|
public enum SystemDataScopeEnum {
|
||||||
|
/* 全部的数据权限 */
|
||||||
|
ALL("全部", "全部的数据权限"), /* 自己部门的数据权限 */
|
||||||
|
THIS_LEVEL("本级", "自己部门的数据权限"), /* 自定义的数据权限 */
|
||||||
|
CUSTOMIZE("自定义", "自定义的数据权限");
|
||||||
|
private final String value;
|
||||||
|
private final String description;
|
||||||
|
|
||||||
/* 全部的数据权限 */
|
public static SystemDataScopeEnum find(String val) {
|
||||||
ALL("全部", "全部的数据权限"),
|
for (SystemDataScopeEnum dataScopeEnum : SystemDataScopeEnum.values()) {
|
||||||
|
if (dataScopeEnum.getValue().equals(val)) {
|
||||||
/* 自己部门的数据权限 */
|
return dataScopeEnum;
|
||||||
THIS_LEVEL("本级", "自己部门的数据权限"),
|
}
|
||||||
|
|
||||||
/* 自定义的数据权限 */
|
|
||||||
CUSTOMIZE("自定义", "自定义的数据权限");
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
private final String description;
|
|
||||||
|
|
||||||
public static SystemDataScopeEnum find(String val) {
|
|
||||||
for (SystemDataScopeEnum dataScopeEnum : SystemDataScopeEnum.values()) {
|
|
||||||
if (dataScopeEnum.getValue().equals(val)) {
|
|
||||||
return dataScopeEnum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -13,11 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.constant;
|
package cn.odboy.system.constant;
|
||||||
|
|
||||||
public interface TransferProtocolConst {
|
public interface TransferProtocolConst {
|
||||||
String PREFIX_HTTP = "http://";
|
|
||||||
String PREFIX_HTTPS = "https://";
|
String PREFIX_HTTP = "http://";
|
||||||
String PREFIX_HTTPS_BAD_REQUEST = "外链必须以http://或者https://开头";
|
String PREFIX_HTTPS = "https://";
|
||||||
|
String PREFIX_HTTPS_BAD_REQUEST = "外链必须以http://或者https://开头";
|
||||||
}
|
}
|
||||||
|
|||||||
+95
-91
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
@@ -35,8 +34,11 @@ import cn.odboy.system.framework.permission.core.handler.TokenProvider;
|
|||||||
import cn.odboy.system.framework.permission.core.handler.UserDetailsHandler;
|
import cn.odboy.system.framework.permission.core.handler.UserDetailsHandler;
|
||||||
import cn.odboy.util.KitRsaEncryptUtil;
|
import cn.odboy.util.KitRsaEncryptUtil;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@@ -51,105 +53,107 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 授权、根据token获取用户详细信息
|
* 授权、根据token获取用户详细信息
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/auth")
|
@RequestMapping("/auth")
|
||||||
@Tag(name = "系统:系统授权接口")
|
@Api(tags = "系统:系统授权接口")
|
||||||
public class SystemAuthController {
|
public class SystemAuthController {
|
||||||
@Autowired
|
|
||||||
private KitRedisHelper redisHelper;
|
|
||||||
@Autowired
|
|
||||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
|
||||||
@Autowired
|
|
||||||
private TokenProvider tokenProvider;
|
|
||||||
@Autowired
|
|
||||||
private AppProperties properties;
|
|
||||||
@Autowired
|
|
||||||
private PasswordEncoder passwordEncoder;
|
|
||||||
@Autowired
|
|
||||||
private UserDetailsHandler userDetailsService;
|
|
||||||
|
|
||||||
@Operation(summary = "登录授权")
|
@Autowired
|
||||||
@AnonymousPostMapping(value = "/login")
|
private KitRedisHelper redisHelper;
|
||||||
public ResponseEntity<Map<String, Object>> login(@Validated @RequestBody SystemUserLoginArgs loginRequest, HttpServletRequest request) throws Exception {
|
@Autowired
|
||||||
// 密码解密
|
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||||
String password = KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword());
|
@Autowired
|
||||||
// 查询验证码
|
private TokenProvider tokenProvider;
|
||||||
String code = redisHelper.get(loginRequest.getUuid(), String.class);
|
@Autowired
|
||||||
// 清除验证码
|
private AppProperties properties;
|
||||||
redisHelper.del(loginRequest.getUuid());
|
@Autowired
|
||||||
if (StrUtil.isBlank(code)) {
|
private PasswordEncoder passwordEncoder;
|
||||||
throw new BadRequestException("验证码不存在或已过期");
|
@Autowired
|
||||||
}
|
private UserDetailsHandler userDetailsService;
|
||||||
if (StrUtil.isBlank(loginRequest.getCode()) || !loginRequest.getCode().equalsIgnoreCase(code)) {
|
|
||||||
throw new BadRequestException("验证码错误");
|
|
||||||
}
|
|
||||||
// 获取用户信息
|
|
||||||
SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginRequest.getUsername());
|
|
||||||
// 验证用户密码
|
|
||||||
if (!passwordEncoder.matches(password, jwtUser.getPassword())) {
|
|
||||||
throw new BadRequestException("登录密码错误");
|
|
||||||
}
|
|
||||||
Authentication authentication = new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
|
||||||
SecurityContextHolder.getContext().setAuthentication(authentication);
|
|
||||||
// 生成令牌
|
|
||||||
String token = tokenProvider.createToken(jwtUser);
|
|
||||||
// 返回 token 与 用户信息
|
|
||||||
Map<String, Object> authInfo = new HashMap<>(2) {{
|
|
||||||
put("token", String.format("%s %s", SystemConst.TOKEN_PREFIX, token));
|
|
||||||
put("user", BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class));
|
|
||||||
}};
|
|
||||||
if (properties.getLogin().isSingle()) {
|
|
||||||
// 踢掉之前已经登录的token
|
|
||||||
systemUserOnlineInfoDAO.kickOutByUsername(loginRequest.getUsername());
|
|
||||||
}
|
|
||||||
// 保存在线信息
|
|
||||||
systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request);
|
|
||||||
// 返回登录信息
|
|
||||||
return ResponseEntity.ok(authInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "获取用户信息")
|
@ApiOperation("登录授权")
|
||||||
@PostMapping(value = "/info")
|
@AnonymousPostMapping(value = "/login")
|
||||||
public ResponseEntity<SystemUserInfoVo> getUserInfo() {
|
public ResponseEntity<Map<String, Object>> login(@Validated @RequestBody SystemUserLoginArgs loginRequest,
|
||||||
SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser();
|
HttpServletRequest request) throws Exception {
|
||||||
SystemUserInfoVo userInfoVo = BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class);
|
// 密码解密
|
||||||
return ResponseEntity.ok(userInfoVo);
|
String password =
|
||||||
|
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), loginRequest.getPassword());
|
||||||
|
// 查询验证码
|
||||||
|
String code = redisHelper.get(loginRequest.getUuid(), String.class);
|
||||||
|
// 清除验证码
|
||||||
|
redisHelper.del(loginRequest.getUuid());
|
||||||
|
if (StrUtil.isBlank(code)) {
|
||||||
|
throw new BadRequestException("验证码不存在或已过期");
|
||||||
}
|
}
|
||||||
|
if (StrUtil.isBlank(loginRequest.getCode()) || !loginRequest.getCode().equalsIgnoreCase(code)) {
|
||||||
|
throw new BadRequestException("验证码错误");
|
||||||
|
}
|
||||||
|
// 获取用户信息
|
||||||
|
SystemUserJwtVo jwtUser = userDetailsService.loadUserByUsername(loginRequest.getUsername());
|
||||||
|
// 验证用户密码
|
||||||
|
if (!passwordEncoder.matches(password, jwtUser.getPassword())) {
|
||||||
|
throw new BadRequestException("登录密码错误");
|
||||||
|
}
|
||||||
|
Authentication authentication =
|
||||||
|
new UsernamePasswordAuthenticationToken(jwtUser, null, jwtUser.getAuthorities());
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(authentication);
|
||||||
|
// 生成令牌
|
||||||
|
String token = tokenProvider.createToken(jwtUser);
|
||||||
|
// 返回 token 与 用户信息
|
||||||
|
Map<String, Object> authInfo = new HashMap<>(2) {{
|
||||||
|
put("token", String.format("%s %s", SystemConst.TOKEN_PREFIX, token));
|
||||||
|
put("user", BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class));
|
||||||
|
}};
|
||||||
|
if (properties.getLogin().isSingle()) {
|
||||||
|
// 踢掉之前已经登录的token
|
||||||
|
systemUserOnlineInfoDAO.kickOutByUsername(loginRequest.getUsername());
|
||||||
|
}
|
||||||
|
// 保存在线信息
|
||||||
|
systemUserOnlineInfoDAO.saveUserJwtModelByToken(jwtUser, token, request);
|
||||||
|
// 返回登录信息
|
||||||
|
return ResponseEntity.ok(authInfo);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "获取验证码")
|
@ApiOperation("获取用户信息")
|
||||||
@AnonymousPostMapping(value = "/captcha/getImage")
|
@PostMapping(value = "/info")
|
||||||
public ResponseEntity<Map<String, Object>> getCode() {
|
public ResponseEntity<SystemUserInfoVo> getUserInfo() {
|
||||||
// 获取运算的结果
|
SystemUserJwtVo jwtUser = (SystemUserJwtVo) KitSecurityHelper.getCurrentUser();
|
||||||
Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha();
|
SystemUserInfoVo userInfoVo = BeanUtil.copyProperties(jwtUser, SystemUserInfoVo.class);
|
||||||
String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID();
|
return ResponseEntity.ok(userInfoVo);
|
||||||
//当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型
|
}
|
||||||
String captchaValue = captcha.text();
|
|
||||||
if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() && captchaValue.contains(SystemConst.SYMBOL_DOT)) {
|
|
||||||
captchaValue = captchaValue.split("\\.")[0];
|
|
||||||
}
|
|
||||||
// 保存
|
|
||||||
redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), TimeUnit.MINUTES);
|
|
||||||
// 验证码信息
|
|
||||||
Map<String, Object> imgResult = new HashMap<>(2) {{
|
|
||||||
put("img", captcha.toBase64());
|
|
||||||
put("uuid", uuid);
|
|
||||||
}};
|
|
||||||
return ResponseEntity.ok(imgResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "退出登录")
|
@ApiOperation("获取验证码")
|
||||||
@AnonymousPostMapping(value = "/logout")
|
@AnonymousPostMapping(value = "/captcha/getImage")
|
||||||
public ResponseEntity<Void> logout(HttpServletRequest request) {
|
public ResponseEntity<Map<String, Object>> getCode() {
|
||||||
String token = tokenProvider.getToken(request);
|
// 获取运算的结果
|
||||||
systemUserOnlineInfoDAO.logoutByToken(token);
|
Captcha captcha = properties.getLogin().getCaptchaSetting().getCaptcha();
|
||||||
return ResponseEntity.ok(null);
|
String uuid = SystemCacheKey.CAPTCHA_LOGIN + IdUtil.simpleUUID();
|
||||||
|
//当验证码类型为 arithmetic时且长度 >= 2 时, captcha.text()的结果有几率为浮点型
|
||||||
|
String captchaValue = captcha.text();
|
||||||
|
if (captcha.getCharType() - 1 == CaptchaCodeEnum.ARITHMETIC.ordinal() &&
|
||||||
|
captchaValue.contains(SystemConst.SYMBOL_DOT)) {
|
||||||
|
captchaValue = captchaValue.split("\\.")[0];
|
||||||
}
|
}
|
||||||
|
// 保存
|
||||||
|
redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(),
|
||||||
|
TimeUnit.MINUTES);
|
||||||
|
// 验证码信息
|
||||||
|
Map<String, Object> imgResult = new HashMap<String, Object>(2) {{
|
||||||
|
put("img", captcha.toBase64());
|
||||||
|
put("uuid", uuid);
|
||||||
|
}};
|
||||||
|
return ResponseEntity.ok(imgResult);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("退出登录")
|
||||||
|
@AnonymousPostMapping(value = "/logout")
|
||||||
|
public ResponseEntity<Void> logout(HttpServletRequest request) {
|
||||||
|
String token = tokenProvider.getToken(request);
|
||||||
|
systemUserOnlineInfoDAO.logoutByToken(token);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-28
@@ -13,49 +13,53 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.framework.exception.BadRequestException;
|
import cn.odboy.framework.exception.BadRequestException;
|
||||||
import cn.odboy.system.constant.SystemCaptchaBizEnum;
|
import cn.odboy.system.constant.SystemCaptchaBizEnum;
|
||||||
import cn.odboy.system.dal.model.SystemCheckEmailCaptchaArgs;
|
import cn.odboy.system.dal.model.SystemCheckEmailCaptchaArgs;
|
||||||
import cn.odboy.system.service.SystemEmailService;
|
import cn.odboy.system.service.SystemEmailService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/captcha")
|
@RequestMapping("/api/captcha")
|
||||||
@Tag(name = "系统:验证码管理")
|
@Api(tags = "系统:验证码管理")
|
||||||
public class SystemCaptchaController {
|
public class SystemCaptchaController {
|
||||||
@Autowired
|
|
||||||
private SystemEmailService systemEmailService;
|
|
||||||
|
|
||||||
@Operation(summary = "重置邮箱, 发送验证码")
|
@Autowired
|
||||||
@PostMapping(value = "/sendResetEmailCaptcha")
|
private SystemEmailService systemEmailService;
|
||||||
public ResponseEntity<Void> sendResetEmailCaptcha(@RequestParam String email) {
|
|
||||||
systemEmailService.sendCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, email);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "重置密码,发送验证码")
|
@ApiOperation("重置邮箱, 发送验证码")
|
||||||
@PostMapping(value = "/sendResetPasswordCaptcha")
|
@PostMapping(value = "/sendResetEmailCaptcha")
|
||||||
public ResponseEntity<Void> sendResetPasswordCaptcha(@RequestParam String email) {
|
public ResponseEntity<Void> sendResetEmailCaptcha(@RequestParam String email) {
|
||||||
systemEmailService.sendCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_PWD_CODE, email);
|
systemEmailService.sendCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, email);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "验证码验证")
|
@ApiOperation("重置密码,发送验证码")
|
||||||
@PostMapping(value = "/checkEmailCaptcha")
|
@PostMapping(value = "/sendResetPasswordCaptcha")
|
||||||
public ResponseEntity<Void> checkEmailCaptcha(@Validated @RequestBody SystemCheckEmailCaptchaArgs args) {
|
public ResponseEntity<Void> sendResetPasswordCaptcha(@RequestParam String email) {
|
||||||
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
systemEmailService.sendCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_PWD_CODE, email);
|
||||||
if (biEnum == null) {
|
return ResponseEntity.ok(null);
|
||||||
throw new BadRequestException("不支持的业务");
|
}
|
||||||
}
|
|
||||||
systemEmailService.checkEmailCaptcha(biEnum, args.getEmail(), args.getCode());
|
@ApiOperation("验证码验证")
|
||||||
return ResponseEntity.ok(null);
|
@PostMapping(value = "/checkEmailCaptcha")
|
||||||
|
public ResponseEntity<Void> checkEmailCaptcha(@Validated @RequestBody SystemCheckEmailCaptchaArgs args) {
|
||||||
|
SystemCaptchaBizEnum biEnum = SystemCaptchaBizEnum.getByBizCode(args.getBizCode());
|
||||||
|
if (biEnum == null) {
|
||||||
|
throw new BadRequestException("不支持的业务");
|
||||||
}
|
}
|
||||||
|
systemEmailService.checkEmailCaptcha(biEnum, args.getEmail(), args.getCode());
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-18
@@ -13,12 +13,11 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.system.service.SystemDeptService;
|
import cn.odboy.system.service.SystemDeptService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -27,23 +26,24 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:组件数据源")
|
@Api(tags = "系统:组件数据源")
|
||||||
@RequestMapping("/api/component")
|
@RequestMapping("/api/component")
|
||||||
public class SystemComponentController {
|
public class SystemComponentController {
|
||||||
@Autowired
|
|
||||||
private SystemDeptService systemDeptService;
|
|
||||||
|
|
||||||
@Operation(summary = "查询部门下拉选择数据源")
|
@Autowired
|
||||||
@PostMapping(value = "/queryDeptSelectDataSource")
|
private SystemDeptService systemDeptService;
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<?> queryDeptSelectDataSource() {
|
|
||||||
return ResponseEntity.ok(systemDeptService.queryDeptSelectDataSource());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询部门下拉选择Pro数据源")
|
@ApiOperation("查询部门下拉选择数据源")
|
||||||
@PostMapping(value = "/queryDeptSelectProDataSource")
|
@PostMapping(value = "/queryDeptSelectDataSource")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity<?> queryDeptSelectProDataSource() {
|
public ResponseEntity<?> queryDeptSelectDataSource() {
|
||||||
return ResponseEntity.ok(systemDeptService.queryDeptSelectProDataSource());
|
return ResponseEntity.ok(systemDeptService.queryDeptSelectDataSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询部门下拉选择Pro数据源")
|
||||||
|
@PostMapping(value = "/queryDeptSelectProDataSource")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<?> queryDeptSelectProDataSource() {
|
||||||
|
return ResponseEntity.ok(systemDeptService.queryDeptSelectProDataSource());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+79
-73
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -23,93 +22,100 @@ import cn.odboy.system.dal.model.SystemCreateDeptArgs;
|
|||||||
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
|
import cn.odboy.system.dal.model.SystemQueryDeptArgs;
|
||||||
import cn.odboy.system.service.SystemDeptService;
|
import cn.odboy.system.service.SystemDeptService;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.util.ArrayList;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.LinkedHashSet;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import java.util.Set;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:部门管理")
|
@Api(tags = "系统:部门管理")
|
||||||
@RequestMapping("/api/dept")
|
@RequestMapping("/api/dept")
|
||||||
public class SystemDeptController {
|
public class SystemDeptController {
|
||||||
@Autowired
|
|
||||||
private SystemDeptService systemDeptService;
|
|
||||||
|
|
||||||
@Operation(summary = "导出部门数据")
|
@Autowired
|
||||||
@GetMapping(value = "/download")
|
private SystemDeptService systemDeptService;
|
||||||
@PreAuthorize("@el.check('dept:list')")
|
|
||||||
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs criteria) throws Exception {
|
|
||||||
systemDeptService.exportDeptExcel(systemDeptService.queryAllDept(criteria, false), response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询部门")
|
@ApiOperation("导出部门数据")
|
||||||
@PostMapping
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
@PreAuthorize("@el.check('dept:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
public void exportDept(HttpServletResponse response, SystemQueryDeptArgs criteria) throws Exception {
|
||||||
SystemQueryDeptArgs criteria = args.getArgs();
|
systemDeptService.exportDeptExcel(systemDeptService.queryAllDept(criteria, false), response);
|
||||||
List<SystemDeptTb> depts = systemDeptService.queryAllDept(criteria, true);
|
}
|
||||||
return ResponseEntity.ok(KitPageUtil.toPage(depts));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询部门:根据ID获取同级与上级数据")
|
@ApiOperation("查询部门")
|
||||||
@PostMapping("/queryDeptSuperiorTree")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('user:list','dept:list')")
|
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDeptSuperiorTree(@RequestBody List<Long> ids,
|
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDept(
|
||||||
@RequestParam(defaultValue = "false") Boolean exclude) {
|
@Validated @RequestBody KitPageArgs<SystemQueryDeptArgs> args) throws Exception {
|
||||||
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
SystemQueryDeptArgs criteria = args.getArgs();
|
||||||
for (Long id : ids) {
|
List<SystemDeptTb> depts = systemDeptService.queryAllDept(criteria, true);
|
||||||
// 同级数据
|
return ResponseEntity.ok(KitPageUtil.toPage(depts));
|
||||||
SystemDeptTb dept = systemDeptService.getDeptById(id);
|
}
|
||||||
// 上级数据
|
|
||||||
List<SystemDeptTb> depts = systemDeptService.querySuperiorDeptListByPid(dept, new ArrayList<>());
|
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
||||||
if (exclude) {
|
@PostMapping("/queryDeptSuperiorTree")
|
||||||
for (SystemDeptTb data : depts) {
|
@PreAuthorize("@el.check('user:list','dept:list')")
|
||||||
if (data.getId().equals(dept.getPid())) {
|
public ResponseEntity<KitPageResult<SystemDeptTb>> queryDeptSuperiorTree(@RequestBody List<Long> ids,
|
||||||
data.setSubCount(data.getSubCount() - 1);
|
@RequestParam(defaultValue = "false") Boolean exclude) {
|
||||||
}
|
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
||||||
}
|
for (Long id : ids) {
|
||||||
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
// 同级数据
|
||||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).toList();
|
SystemDeptTb dept = systemDeptService.getDeptById(id);
|
||||||
}
|
// 上级数据
|
||||||
deptSet.addAll(depts);
|
List<SystemDeptTb> depts = systemDeptService.querySuperiorDeptListByPid(dept, new ArrayList<>());
|
||||||
|
if (exclude) {
|
||||||
|
for (SystemDeptTb data : depts) {
|
||||||
|
if (data.getId().equals(dept.getPid())) {
|
||||||
|
data.setSubCount(data.getSubCount() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(systemDeptService.buildDeptTree(new ArrayList<>(deptSet)));
|
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||||
|
depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
deptSet.addAll(depts);
|
||||||
}
|
}
|
||||||
|
return ResponseEntity.ok(systemDeptService.buildDeptTree(new ArrayList<>(deptSet)));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "新增部门")
|
@ApiOperation("新增部门")
|
||||||
@PostMapping(value = "/saveDept")
|
@PostMapping(value = "/saveDept")
|
||||||
@PreAuthorize("@el.check('dept:add')")
|
@PreAuthorize("@el.check('dept:add')")
|
||||||
public ResponseEntity<Void> saveDept(@Validated @RequestBody SystemCreateDeptArgs args) {
|
public ResponseEntity<Void> saveDept(@Validated @RequestBody SystemCreateDeptArgs args) {
|
||||||
systemDeptService.saveDept(args);
|
systemDeptService.saveDept(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改部门")
|
@ApiOperation("修改部门")
|
||||||
@PostMapping(value = "/modifyDept")
|
@PostMapping(value = "/modifyDept")
|
||||||
@PreAuthorize("@el.check('dept:edit')")
|
@PreAuthorize("@el.check('dept:edit')")
|
||||||
public ResponseEntity<Void> modifyDept(@Validated(SystemDeptTb.Update.class) @RequestBody SystemDeptTb args) {
|
public ResponseEntity<Void> modifyDept(@Validated(SystemDeptTb.Update.class) @RequestBody SystemDeptTb args) {
|
||||||
systemDeptService.updateDept(args);
|
systemDeptService.updateDept(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除部门")
|
@ApiOperation("删除部门")
|
||||||
@PostMapping(value = "/removeDeptByIds")
|
@PostMapping(value = "/removeDeptByIds")
|
||||||
@PreAuthorize("@el.check('dept:del')")
|
@PreAuthorize("@el.check('dept:del')")
|
||||||
public ResponseEntity<Void> removeDeptByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> removeDeptByIds(@RequestBody Set<Long> ids) {
|
||||||
// 获取部门, 和其所有子部门
|
// 获取部门, 和其所有子部门
|
||||||
Set<SystemDeptTb> depts = systemDeptService.traverseDeptByIdWithPids(ids);
|
Set<SystemDeptTb> depts = systemDeptService.traverseDeptByIdWithPids(ids);
|
||||||
// 验证是否被角色或用户关联
|
// 验证是否被角色或用户关联
|
||||||
systemDeptService.verifyBindRelationByIds(depts);
|
systemDeptService.verifyBindRelationByIds(depts);
|
||||||
systemDeptService.removeDeptByIds(depts);
|
systemDeptService.removeDeptByIds(depts);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+60
-56
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -23,75 +22,80 @@ import cn.odboy.system.dal.model.SystemCreateDictArgs;
|
|||||||
import cn.odboy.system.dal.model.SystemQueryDictArgs;
|
import cn.odboy.system.dal.model.SystemQueryDictArgs;
|
||||||
import cn.odboy.system.service.SystemDictService;
|
import cn.odboy.system.service.SystemDictService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.io.IOException;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import java.util.Set;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:字典管理")
|
@Api(tags = "系统:字典管理")
|
||||||
@RequestMapping("/api/dict")
|
@RequestMapping("/api/dict")
|
||||||
public class SystemDictController {
|
public class SystemDictController {
|
||||||
@Autowired
|
|
||||||
private SystemDictService systemDictService;
|
|
||||||
|
|
||||||
@Operation(summary = "导出字典数据")
|
@Autowired
|
||||||
@GetMapping(value = "/download")
|
private SystemDictService systemDictService;
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
|
||||||
public void exportDict(HttpServletResponse response, SystemQueryDictArgs criteria) throws IOException {
|
|
||||||
systemDictService.exportDictExcel(systemDictService.queryDictByArgs(criteria), response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询字典")
|
@ApiOperation("导出字典数据")
|
||||||
@PostMapping(value = "/queryAllDict")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
public void exportDict(HttpServletResponse response, SystemQueryDictArgs criteria) throws IOException {
|
||||||
return ResponseEntity.ok(systemDictService.queryDictByArgs(new SystemQueryDictArgs()));
|
systemDictService.exportDictExcel(systemDictService.queryDictByArgs(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询字典")
|
@ApiOperation("查询字典")
|
||||||
@PostMapping
|
@PostMapping(value = "/queryAllDict")
|
||||||
@PreAuthorize("@el.check('dict:list')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemDictTb>> queryDictByArgs(@Validated @RequestBody KitPageArgs<SystemQueryDictArgs> args) {
|
public ResponseEntity<List<SystemDictTb>> queryAllDict() {
|
||||||
Page<SystemDictTb> page;
|
return ResponseEntity.ok(systemDictService.queryDictByArgs(new SystemQueryDictArgs()));
|
||||||
SystemQueryDictArgs criteria = args.getArgs();
|
}
|
||||||
if (args.getSize() != null) {
|
|
||||||
page = new Page<>(args.getPage(), args.getSize());
|
|
||||||
} else {
|
|
||||||
page = new Page<>(criteria.getPage(), criteria.getSize());
|
|
||||||
}
|
|
||||||
return ResponseEntity.ok(systemDictService.queryDictByArgs(criteria, page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "新增字典")
|
@ApiOperation("查询字典")
|
||||||
@PostMapping(value = "/saveDict")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('dict:add')")
|
@PreAuthorize("@el.check('dict:list')")
|
||||||
public ResponseEntity<Void> saveDict(@Validated @RequestBody SystemCreateDictArgs args) {
|
public ResponseEntity<KitPageResult<SystemDictTb>> queryDictByArgs(
|
||||||
systemDictService.saveDict(args);
|
@Validated @RequestBody KitPageArgs<SystemQueryDictArgs> args) {
|
||||||
return ResponseEntity.ok(null);
|
Page<SystemDictTb> page;
|
||||||
|
SystemQueryDictArgs criteria = args.getArgs();
|
||||||
|
if (args.getSize() != null) {
|
||||||
|
page = new Page<>(args.getPage(), args.getSize());
|
||||||
|
} else {
|
||||||
|
page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
}
|
}
|
||||||
|
return ResponseEntity.ok(systemDictService.queryDictByArgs(criteria, page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改字典")
|
@ApiOperation("新增字典")
|
||||||
@PostMapping(value = "/modifyDictById")
|
@PostMapping(value = "/saveDict")
|
||||||
@PreAuthorize("@el.check('dict:edit')")
|
@PreAuthorize("@el.check('dict:add')")
|
||||||
public ResponseEntity<Void> modifyDictById(@Validated(SystemDictTb.Update.class) @RequestBody SystemDictTb args) {
|
public ResponseEntity<Void> saveDict(@Validated @RequestBody SystemCreateDictArgs args) {
|
||||||
systemDictService.modifyDictById(args);
|
systemDictService.saveDict(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除字典")
|
@ApiOperation("修改字典")
|
||||||
@PostMapping(value = "/removeDictByIds")
|
@PostMapping(value = "/modifyDictById")
|
||||||
@PreAuthorize("@el.check('dict:del')")
|
@PreAuthorize("@el.check('dict:edit')")
|
||||||
public ResponseEntity<Void> removeDictByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> modifyDictById(@Validated(SystemDictTb.Update.class) @RequestBody SystemDictTb args) {
|
||||||
systemDictService.removeDictByIds(ids);
|
systemDictService.modifyDictById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除字典")
|
||||||
|
@PostMapping(value = "/removeDictByIds")
|
||||||
|
@PreAuthorize("@el.check('dict:del')")
|
||||||
|
public ResponseEntity<Void> removeDictByIds(@RequestBody Set<Long> ids) {
|
||||||
|
systemDictService.removeDictByIds(ids);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+61
-53
@@ -13,81 +13,89 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
import cn.odboy.base.KitPageResult;
|
import cn.odboy.base.KitPageResult;
|
||||||
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
|
import cn.odboy.system.dal.dataobject.SystemDictDetailTb;
|
||||||
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
|
import cn.odboy.system.dal.model.SystemCreateDictDetailArgs;
|
||||||
|
import cn.odboy.system.dal.model.SystemDictDetailVo;
|
||||||
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
|
import cn.odboy.system.dal.model.SystemQueryDictDetailArgs;
|
||||||
import cn.odboy.system.service.SystemDictDetailService;
|
import cn.odboy.system.service.SystemDictDetailService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.util.HashMap;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import java.util.Map;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:字典详情管理")
|
@Api(tags = "系统:字典详情管理")
|
||||||
@RequestMapping("/api/dictDetail")
|
@RequestMapping("/api/dictDetail")
|
||||||
public class SystemDictDetailController {
|
public class SystemDictDetailController {
|
||||||
@Autowired
|
|
||||||
private SystemDictDetailService systemDictDetailService;
|
|
||||||
|
|
||||||
@Operation(summary = "查询字典详情")
|
@Autowired
|
||||||
@PostMapping
|
private SystemDictDetailService systemDictDetailService;
|
||||||
public ResponseEntity<KitPageResult<SystemDictDetailTb>> queryDictDetailByCrud(@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
|
||||||
return queryDictDetailByArgs(args);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询字典详情")
|
@ApiOperation("查询字典详情")
|
||||||
@PostMapping(value = "/queryDictDetailByArgs")
|
@PostMapping
|
||||||
public ResponseEntity<KitPageResult<SystemDictDetailTb>> queryDictDetailByArgs(@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByCrud(
|
||||||
SystemQueryDictDetailArgs criteria = args.getArgs();
|
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||||
Page<SystemDictDetailTb> page = new Page<>(args.getPage(), args.getSize());
|
return queryDictDetailByArgs(args);
|
||||||
return ResponseEntity.ok(systemDictDetailService.queryDictDetailByArgs(criteria, page));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询多个字典详情")
|
@ApiOperation("查询字典详情")
|
||||||
@GetMapping(value = "/getDictDetailMaps")
|
@PostMapping(value = "/queryDictDetailByArgs")
|
||||||
public ResponseEntity<Map<String, List<SystemDictDetailTb>>> getDictDetailMaps(@RequestParam String dictName) {
|
public ResponseEntity<KitPageResult<SystemDictDetailVo>> queryDictDetailByArgs(
|
||||||
String[] names = dictName.split("[,, ]");
|
@Validated @RequestBody KitPageArgs<SystemQueryDictDetailArgs> args) {
|
||||||
Map<String, List<SystemDictDetailTb>> dictMap = new HashMap<>(16);
|
SystemQueryDictDetailArgs criteria = args.getArgs();
|
||||||
for (String name : names) {
|
Page<SystemDictDetailTb> page = new Page<>(args.getPage(), args.getSize());
|
||||||
dictMap.put(name, systemDictDetailService.queryDictDetailByName(name));
|
return ResponseEntity.ok(systemDictDetailService.queryDictDetailByArgs(criteria, page));
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(dictMap);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "新增字典详情")
|
@ApiOperation("查询多个字典详情")
|
||||||
@PostMapping(value = "/saveDictDetail")
|
@GetMapping(value = "/getDictDetailMaps")
|
||||||
@PreAuthorize("@el.check('dict:add')")
|
public ResponseEntity<Map<String, List<SystemDictDetailVo>>> getDictDetailMaps(@RequestParam String dictName) {
|
||||||
public ResponseEntity<Void> saveDictDetail(@Validated @RequestBody SystemCreateDictDetailArgs args) {
|
String[] names = dictName.split("[,, ]");
|
||||||
systemDictDetailService.saveDictDetail(args);
|
Map<String, List<SystemDictDetailVo>> dictMap = new HashMap<>(16);
|
||||||
return ResponseEntity.ok(null);
|
for (String name : names) {
|
||||||
|
dictMap.put(name, systemDictDetailService.queryDictDetailByName(name));
|
||||||
}
|
}
|
||||||
|
return ResponseEntity.ok(dictMap);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改字典详情")
|
@ApiOperation("新增字典详情")
|
||||||
@PostMapping(value = "/modifyDictDetailById")
|
@PostMapping(value = "/saveDictDetail")
|
||||||
@PreAuthorize("@el.check('dict:edit')")
|
@PreAuthorize("@el.check('dict:add')")
|
||||||
public ResponseEntity<Void> modifyDictDetailById(@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
public ResponseEntity<Void> saveDictDetail(@Validated @RequestBody SystemCreateDictDetailArgs args) {
|
||||||
systemDictDetailService.modifyDictDetailById(args);
|
systemDictDetailService.saveDictDetail(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除字典详情")
|
@ApiOperation("修改字典详情")
|
||||||
@PostMapping(value = "/removeDictDetailById")
|
@PostMapping(value = "/modifyDictDetailById")
|
||||||
@PreAuthorize("@el.check('dict:del')")
|
@PreAuthorize("@el.check('dict:edit')")
|
||||||
public ResponseEntity<Void> removeDictDetailById(@RequestBody SystemDictDetailTb args) {
|
public ResponseEntity<Void> modifyDictDetailById(
|
||||||
systemDictDetailService.removeDictDetailById(args.getId());
|
@Validated(SystemDictDetailTb.Update.class) @RequestBody SystemDictDetailTb args) {
|
||||||
return ResponseEntity.ok(null);
|
systemDictDetailService.modifyDictDetailById(args);
|
||||||
}
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("删除字典详情")
|
||||||
|
@PostMapping(value = "/removeDictDetailById")
|
||||||
|
@PreAuthorize("@el.check('dict:del')")
|
||||||
|
public ResponseEntity<Void> removeDictDetailById(@RequestBody SystemDictDetailTb args) {
|
||||||
|
systemDictDetailService.removeDictDetailById(args.getId());
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-23
@@ -13,14 +13,13 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.system.dal.dataobject.SystemEmailConfigTb;
|
import cn.odboy.system.dal.dataobject.SystemEmailConfigTb;
|
||||||
import cn.odboy.system.dal.model.SystemSendEmailArgs;
|
import cn.odboy.system.dal.model.SystemSendEmailArgs;
|
||||||
import cn.odboy.system.service.SystemEmailService;
|
import cn.odboy.system.service.SystemEmailService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -34,28 +33,30 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("api/email")
|
@RequestMapping("api/email")
|
||||||
@Tag(name = "工具:邮件管理")
|
@Api(tags = "工具:邮件管理")
|
||||||
public class SystemEmailController {
|
public class SystemEmailController {
|
||||||
@Autowired
|
|
||||||
private SystemEmailService systemEmailService;
|
|
||||||
|
|
||||||
@Operation(summary = "查询配置")
|
@Autowired
|
||||||
@PostMapping(value = "/getLastEmailConfig")
|
private SystemEmailService systemEmailService;
|
||||||
public ResponseEntity<SystemEmailConfigTb> getLastEmailConfig() {
|
|
||||||
return ResponseEntity.ok(systemEmailService.getLastEmailConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "配置邮件")
|
@ApiOperation("查询配置")
|
||||||
@PostMapping(value = "/modifyEmailConfig")
|
@PostMapping(value = "/getLastEmailConfig")
|
||||||
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig) throws Exception {
|
public ResponseEntity<SystemEmailConfigTb> getLastEmailConfig() {
|
||||||
systemEmailService.modifyEmailConfig(emailConfig);
|
return ResponseEntity.ok(systemEmailService.getLastEmailConfig());
|
||||||
return ResponseEntity.ok(null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "发送邮件")
|
@ApiOperation("配置邮件")
|
||||||
@PostMapping(value = "/sendEmail")
|
@PostMapping(value = "/modifyEmailConfig")
|
||||||
public ResponseEntity<Void> sendEmail(@Validated @RequestBody SystemSendEmailArgs sendEmailRequest) {
|
public ResponseEntity<Void> modifyEmailConfig(@Validated @RequestBody SystemEmailConfigTb emailConfig)
|
||||||
systemEmailService.sendEmail(sendEmailRequest);
|
throws Exception {
|
||||||
return ResponseEntity.ok(null);
|
systemEmailService.modifyEmailConfig(emailConfig);
|
||||||
}
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("发送邮件")
|
||||||
|
@PostMapping(value = "/sendEmail")
|
||||||
|
public ResponseEntity<Void> sendEmail(@Validated @RequestBody SystemSendEmailArgs sendEmailRequest) {
|
||||||
|
systemEmailService.sendEmail(sendEmailRequest);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-53
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -23,71 +22,77 @@ import cn.odboy.system.dal.model.SystemCreateJobArgs;
|
|||||||
import cn.odboy.system.dal.model.SystemQueryJobArgs;
|
import cn.odboy.system.dal.model.SystemQueryJobArgs;
|
||||||
import cn.odboy.system.service.SystemJobService;
|
import cn.odboy.system.service.SystemJobService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.io.IOException;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.Set;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:岗位管理")
|
@Api(tags = "系统:岗位管理")
|
||||||
@RequestMapping("/api/job")
|
@RequestMapping("/api/job")
|
||||||
public class SystemJobController {
|
public class SystemJobController {
|
||||||
@Autowired
|
|
||||||
private SystemJobService systemJobService;
|
|
||||||
|
|
||||||
@Operation(summary = "导出岗位数据")
|
@Autowired
|
||||||
@GetMapping(value = "/download")
|
private SystemJobService systemJobService;
|
||||||
@PreAuthorize("@el.check('job:list')")
|
|
||||||
public void exportJob(HttpServletResponse response, SystemQueryJobArgs criteria) throws IOException {
|
|
||||||
systemJobService.exportJobExcel(systemJobService.queryJobByArgs(criteria), response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询岗位")
|
@ApiOperation("导出岗位数据")
|
||||||
@PostMapping(value = "/queryAllEnableJob")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('job:list','user:list')")
|
@PreAuthorize("@el.check('job:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByArgs(@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
public void exportJob(HttpServletResponse response, SystemQueryJobArgs criteria) throws IOException {
|
||||||
SystemQueryJobArgs criteria = args.getArgs();
|
systemJobService.exportJobExcel(systemJobService.queryJobByArgs(criteria), response);
|
||||||
Page<SystemJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
}
|
||||||
return ResponseEntity.ok(systemJobService.queryJobByArgs(criteria, page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询岗位")
|
@ApiOperation("查询岗位")
|
||||||
@PostMapping
|
@PostMapping(value = "/queryAllEnableJob")
|
||||||
@PreAuthorize("@el.check('job:list','user:list')")
|
@PreAuthorize("@el.check('job:list','user:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByCrud(@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByArgs(
|
||||||
return queryJobByArgs(args);
|
@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||||
}
|
SystemQueryJobArgs criteria = args.getArgs();
|
||||||
|
Page<SystemJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
return ResponseEntity.ok(systemJobService.queryJobByArgs(criteria, page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "新增岗位")
|
@ApiOperation("查询岗位")
|
||||||
@PostMapping(value = "/saveJob")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('job:add')")
|
@PreAuthorize("@el.check('job:list','user:list')")
|
||||||
public ResponseEntity<Void> saveJob(@Validated @RequestBody SystemCreateJobArgs args) {
|
public ResponseEntity<KitPageResult<SystemJobTb>> queryJobByCrud(
|
||||||
systemJobService.saveJob(args);
|
@Validated @RequestBody KitPageArgs<SystemQueryJobArgs> args) {
|
||||||
return ResponseEntity.ok(null);
|
return queryJobByArgs(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改岗位")
|
@ApiOperation("新增岗位")
|
||||||
@PostMapping(value = "/modifyJobById")
|
@PostMapping(value = "/saveJob")
|
||||||
@PreAuthorize("@el.check('job:edit')")
|
@PreAuthorize("@el.check('job:add')")
|
||||||
public ResponseEntity<Void> modifyJobById(@Validated(SystemJobTb.Update.class) @RequestBody SystemJobTb args) {
|
public ResponseEntity<Void> saveJob(@Validated @RequestBody SystemCreateJobArgs args) {
|
||||||
systemJobService.modifyJobById(args);
|
systemJobService.saveJob(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除岗位")
|
@ApiOperation("修改岗位")
|
||||||
@PostMapping(value = "/removeJobByIds")
|
@PostMapping(value = "/modifyJobById")
|
||||||
@PreAuthorize("@el.check('job:del')")
|
@PreAuthorize("@el.check('job:edit')")
|
||||||
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> modifyJobById(@Validated(SystemJobTb.Update.class) @RequestBody SystemJobTb args) {
|
||||||
// 验证是否被用户关联
|
systemJobService.modifyJobById(args);
|
||||||
systemJobService.verifyBindRelationByIds(ids);
|
return ResponseEntity.ok(null);
|
||||||
systemJobService.removeJobByIds(ids);
|
}
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
@ApiOperation("删除岗位")
|
||||||
|
@PostMapping(value = "/removeJobByIds")
|
||||||
|
@PreAuthorize("@el.check('job:del')")
|
||||||
|
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||||
|
// 验证是否被用户关联
|
||||||
|
systemJobService.verifyBindRelationByIds(ids);
|
||||||
|
systemJobService.removeJobByIds(ids);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+58
-53
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -25,73 +24,79 @@ import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
|||||||
import cn.odboy.system.service.SystemLocalStorageService;
|
import cn.odboy.system.service.SystemLocalStorageService;
|
||||||
import cn.odboy.util.KitFileUtil;
|
import cn.odboy.util.KitFileUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "工具:本地存储管理")
|
@Api(tags = "工具:本地存储管理")
|
||||||
@RequestMapping("/api/localStorage")
|
@RequestMapping("/api/localStorage")
|
||||||
public class SystemLocalStorageController {
|
public class SystemLocalStorageController {
|
||||||
@Autowired
|
|
||||||
private SystemLocalStorageService localStorageService;
|
|
||||||
|
|
||||||
@Operation(summary = "查询文件")
|
@Autowired
|
||||||
@PostMapping
|
private SystemLocalStorageService localStorageService;
|
||||||
@PreAuthorize("@el.check('storage:list')")
|
|
||||||
public ResponseEntity<KitPageResult<SystemLocalStorageTb>> queryLocalStorage(@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
|
||||||
SystemQueryStorageArgs criteria = args.getArgs();
|
|
||||||
Page<SystemLocalStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
|
||||||
return ResponseEntity.ok(localStorageService.queryLocalStorage(criteria, page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "导出数据")
|
@ApiOperation("查询文件")
|
||||||
@GetMapping(value = "/download")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('storage:list')")
|
@PreAuthorize("@el.check('storage:list')")
|
||||||
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs criteria) throws IOException {
|
public ResponseEntity<KitPageResult<SystemLocalStorageTb>> queryLocalStorage(
|
||||||
localStorageService.exportLocalStorageExcel(localStorageService.queryLocalStorage(criteria), response);
|
@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
||||||
}
|
SystemQueryStorageArgs criteria = args.getArgs();
|
||||||
|
Page<SystemLocalStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
return ResponseEntity.ok(localStorageService.queryLocalStorage(criteria, page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "上传文件")
|
@ApiOperation("导出数据")
|
||||||
@PostMapping(value = "/uploadFile")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('storage:add')")
|
@PreAuthorize("@el.check('storage:list')")
|
||||||
public ResponseEntity<Void> uploadFile(@RequestParam String name, @RequestParam("file") MultipartFile file) {
|
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs criteria) throws IOException {
|
||||||
localStorageService.uploadFile(name, file);
|
localStorageService.exportLocalStorageExcel(localStorageService.queryLocalStorage(criteria), response);
|
||||||
return ResponseEntity.ok(null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "上传图片")
|
@ApiOperation("上传文件")
|
||||||
@PostMapping("/uploadPicture")
|
@PostMapping(value = "/uploadFile")
|
||||||
public ResponseEntity<SystemLocalStorageTb> uploadPicture(@RequestParam MultipartFile file) {
|
@PreAuthorize("@el.check('storage:add')")
|
||||||
// 判断文件是否为图片
|
public ResponseEntity<Void> uploadFile(@RequestParam String name, @RequestParam("file") MultipartFile file) {
|
||||||
String suffix = KitFileUtil.getSuffix(file.getOriginalFilename());
|
localStorageService.uploadFile(name, file);
|
||||||
if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) {
|
return ResponseEntity.ok(null);
|
||||||
throw new BadRequestException("只能上传图片");
|
}
|
||||||
}
|
|
||||||
SystemLocalStorageTb localStorage = localStorageService.uploadFile(null, file);
|
|
||||||
return ResponseEntity.ok(localStorage);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "修改文件")
|
@ApiOperation("上传图片")
|
||||||
@PostMapping(value = "/modifyLocalStorageById")
|
@PostMapping("/uploadPicture")
|
||||||
@PreAuthorize("@el.check('storage:edit')")
|
public ResponseEntity<SystemLocalStorageTb> uploadPicture(@RequestParam MultipartFile file) {
|
||||||
public ResponseEntity<Void> modifyLocalStorageById(@Validated @RequestBody SystemLocalStorageTb args) {
|
// 判断文件是否为图片
|
||||||
localStorageService.modifyLocalStorageById(args);
|
String suffix = KitFileUtil.getSuffix(file.getOriginalFilename());
|
||||||
return ResponseEntity.ok(null);
|
if (!FileTypeEnum.IMAGE.getCode().equals(KitFileUtil.getFileType(suffix))) {
|
||||||
|
throw new BadRequestException("只能上传图片");
|
||||||
}
|
}
|
||||||
|
SystemLocalStorageTb localStorage = localStorageService.uploadFile(null, file);
|
||||||
|
return ResponseEntity.ok(localStorage);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "多选删除")
|
@ApiOperation("修改文件")
|
||||||
@PostMapping(value = "/removeFileByIds")
|
@PostMapping(value = "/modifyLocalStorageById")
|
||||||
public ResponseEntity<Void> deleteFileByIds(@RequestBody Long[] ids) {
|
@PreAuthorize("@el.check('storage:edit')")
|
||||||
localStorageService.removeFileByIds(ids);
|
public ResponseEntity<Void> modifyLocalStorageById(@Validated @RequestBody SystemLocalStorageTb args) {
|
||||||
return ResponseEntity.ok(null);
|
localStorageService.modifyLocalStorageById(args);
|
||||||
}
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("多选删除")
|
||||||
|
@PostMapping(value = "/removeFileByIds")
|
||||||
|
public ResponseEntity<Void> deleteFileByIds(@RequestBody Long[] ids) {
|
||||||
|
localStorageService.removeFileByIds(ids);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+109
-99
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
@@ -27,124 +26,135 @@ import cn.odboy.system.dal.mysql.SystemMenuMapper;
|
|||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.system.service.SystemMenuService;
|
import cn.odboy.system.service.SystemMenuService;
|
||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.util.*;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.stream.Collectors;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:菜单管理")
|
@Api(tags = "系统:菜单管理")
|
||||||
@RequestMapping("/api/menu")
|
@RequestMapping("/api/menu")
|
||||||
public class SystemMenuController {
|
public class SystemMenuController {
|
||||||
@Autowired
|
|
||||||
private SystemMenuService systemMenuService;
|
|
||||||
@Autowired
|
|
||||||
private SystemMenuMapper systemMenuMapper;
|
|
||||||
|
|
||||||
@Operation(summary = "导出菜单数据")
|
@Autowired
|
||||||
@GetMapping(value = "/download")
|
private SystemMenuService systemMenuService;
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@Autowired
|
||||||
public void exportMenu(HttpServletResponse response, SystemQueryMenuArgs criteria) throws Exception {
|
private SystemMenuMapper systemMenuMapper;
|
||||||
systemMenuService.exportMenuExcel(systemMenuService.queryAllMenu(criteria, false), response);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping(value = "/buildMenus")
|
@ApiOperation("导出菜单数据")
|
||||||
@Operation(summary = "获取前端所需菜单")
|
@GetMapping(value = "/download")
|
||||||
public ResponseEntity<List<SystemMenuVo>> buildMenus() {
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuListByUserId(KitSecurityHelper.getCurrentUserId());
|
public void exportMenu(HttpServletResponse response, SystemQueryMenuArgs criteria) throws Exception {
|
||||||
List<SystemMenuTb> menus = systemMenuService.buildMenuTree(menuList);
|
systemMenuService.exportMenuExcel(systemMenuService.queryAllMenu(criteria, false), response);
|
||||||
return ResponseEntity.ok(systemMenuService.buildMenuVo(menus));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "返回全部的菜单")
|
@PostMapping(value = "/buildMenus")
|
||||||
@PostMapping(value = "/queryMenuListByPid")
|
@ApiOperation("获取前端所需菜单")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
public ResponseEntity<List<SystemMenuVo>> buildMenus() {
|
||||||
public ResponseEntity<List<SystemMenuTb>> queryMenuListByPid(@RequestParam Long pid) {
|
List<SystemMenuTb> menuList = systemMenuService.queryMenuListByUserId(KitSecurityHelper.getCurrentUserId());
|
||||||
return ResponseEntity.ok(systemMenuService.queryMenuByPid(pid));
|
List<SystemMenuTb> menus = systemMenuService.buildMenuTree(menuList);
|
||||||
}
|
return ResponseEntity.ok(systemMenuService.buildMenuVo(menus));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "根据菜单ID返回所有子节点ID, 包含自身ID")
|
@ApiOperation("返回全部的菜单")
|
||||||
@PostMapping(value = "/queryChildMenuSet")
|
@PostMapping(value = "/queryMenuListByPid")
|
||||||
@PreAuthorize("@el.check('menu:list','roles:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<Set<Long>> queryChildMenuSet(@RequestParam Long id) {
|
public ResponseEntity<List<SystemMenuTb>> queryMenuListByPid(@RequestParam Long pid) {
|
||||||
Set<SystemMenuTb> menuSet = new HashSet<>();
|
return ResponseEntity.ok(systemMenuService.queryMenuByPid(pid));
|
||||||
List<SystemMenuTb> menuList = systemMenuService.queryMenuByPid(id);
|
}
|
||||||
menuSet.add(systemMenuMapper.selectById(id));
|
|
||||||
menuSet = systemMenuService.queryChildMenu(menuList, menuSet);
|
|
||||||
Set<Long> ids = menuSet.stream().map(SystemMenuTb::getId).collect(Collectors.toSet());
|
|
||||||
return ResponseEntity.ok(ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping
|
@ApiOperation("根据菜单ID返回所有子节点ID, 包含自身ID")
|
||||||
@Operation(summary = "查询菜单")
|
@PostMapping(value = "/queryChildMenuSet")
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@PreAuthorize("@el.check('menu:list','roles:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenuByCrud(@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
public ResponseEntity<Set<Long>> queryChildMenuSet(@RequestParam Long id) {
|
||||||
return queryAllMenu(args);
|
Set<SystemMenuTb> menuSet = new HashSet<>();
|
||||||
}
|
List<SystemMenuTb> menuList = systemMenuService.queryMenuByPid(id);
|
||||||
|
menuSet.add(systemMenuMapper.selectById(id));
|
||||||
|
menuSet = systemMenuService.queryChildMenu(menuList, menuSet);
|
||||||
|
Set<Long> ids = menuSet.stream().map(SystemMenuTb::getId).collect(Collectors.toSet());
|
||||||
|
return ResponseEntity.ok(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping(value = "/queryMenuByArgs")
|
@PostMapping
|
||||||
@Operation(summary = "查询菜单")
|
@ApiOperation("查询菜单")
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenu(@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenuByCrud(
|
||||||
SystemQueryMenuArgs criteria = args.getArgs();
|
@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||||
List<SystemMenuTb> menuList = systemMenuService.queryAllMenu(criteria, true);
|
return queryAllMenu(args);
|
||||||
return ResponseEntity.ok(KitPageUtil.toPage(menuList));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "查询菜单:根据ID获取同级与上级数据")
|
@PostMapping(value = "/queryMenuByArgs")
|
||||||
@PostMapping("/queryMenuSuperior")
|
@ApiOperation("查询菜单")
|
||||||
@PreAuthorize("@el.check('menu:list')")
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
public ResponseEntity<List<SystemMenuTb>> queryMenuSuperior(@RequestBody List<Long> ids) {
|
public ResponseEntity<KitPageResult<SystemMenuTb>> queryAllMenu(
|
||||||
Set<SystemMenuTb> menus;
|
@Validated @RequestBody KitPageArgs<SystemQueryMenuArgs> args) throws Exception {
|
||||||
if (CollectionUtil.isNotEmpty(ids)) {
|
SystemQueryMenuArgs criteria = args.getArgs();
|
||||||
menus = new LinkedHashSet<>(systemMenuService.queryMenuByIds(ids));
|
List<SystemMenuTb> menuList = systemMenuService.queryAllMenu(criteria, true);
|
||||||
for (SystemMenuTb menu : menus) {
|
return ResponseEntity.ok(KitPageUtil.toPage(menuList));
|
||||||
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
}
|
||||||
for (SystemMenuTb data : menuList) {
|
|
||||||
if (data.getId().equals(menu.getPid())) {
|
@ApiOperation("查询菜单:根据ID获取同级与上级数据")
|
||||||
data.setSubCount(data.getSubCount() - 1);
|
@PostMapping("/queryMenuSuperior")
|
||||||
}
|
@PreAuthorize("@el.check('menu:list')")
|
||||||
}
|
public ResponseEntity<List<SystemMenuTb>> queryMenuSuperior(@RequestBody List<Long> ids) {
|
||||||
menus.addAll(menuList);
|
Set<SystemMenuTb> menus;
|
||||||
}
|
if (CollectionUtil.isNotEmpty(ids)) {
|
||||||
// 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
menus = new LinkedHashSet<>(systemMenuService.queryMenuByIds(ids));
|
||||||
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
for (SystemMenuTb menu : menus) {
|
||||||
return ResponseEntity.ok(systemMenuService.buildMenuTree(new ArrayList<>(menus)));
|
List<SystemMenuTb> menuList = systemMenuService.querySuperiorMenuList(menu, new ArrayList<>());
|
||||||
|
for (SystemMenuTb data : menuList) {
|
||||||
|
if (data.getId().equals(menu.getPid())) {
|
||||||
|
data.setSubCount(data.getSubCount() - 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return ResponseEntity.ok(systemMenuService.queryMenuByPid(null));
|
menus.addAll(menuList);
|
||||||
|
}
|
||||||
|
// 编辑菜单时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||||
|
menus = menus.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toSet());
|
||||||
|
return ResponseEntity.ok(systemMenuService.buildMenuTree(new ArrayList<>(menus)));
|
||||||
}
|
}
|
||||||
|
return ResponseEntity.ok(systemMenuService.queryMenuByPid(null));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "新增菜单")
|
@ApiOperation("新增菜单")
|
||||||
@PostMapping(value = "/saveMenu")
|
@PostMapping(value = "/saveMenu")
|
||||||
@PreAuthorize("@el.check('menu:add')")
|
@PreAuthorize("@el.check('menu:add')")
|
||||||
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb args) {
|
public ResponseEntity<Void> saveMenu(@Validated @RequestBody SystemMenuTb args) {
|
||||||
if (args.getId() != null) {
|
if (args.getId() != null) {
|
||||||
throw new BadRequestException("无效参数id");
|
throw new BadRequestException("无效参数id");
|
||||||
}
|
|
||||||
systemMenuService.saveMenu(args);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
}
|
||||||
|
systemMenuService.saveMenu(args);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改菜单")
|
@ApiOperation("修改菜单")
|
||||||
@PostMapping(value = "/modifyMenuById")
|
@PostMapping(value = "/modifyMenuById")
|
||||||
@PreAuthorize("@el.check('menu:edit')")
|
@PreAuthorize("@el.check('menu:edit')")
|
||||||
public ResponseEntity<Void> modifyMenuById(@Validated(SystemMenuTb.Update.class) @RequestBody SystemMenuTb args) {
|
public ResponseEntity<Void> modifyMenuById(@Validated(SystemMenuTb.Update.class) @RequestBody SystemMenuTb args) {
|
||||||
systemMenuService.modifyMenuById(args);
|
systemMenuService.modifyMenuById(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除菜单")
|
@ApiOperation("删除菜单")
|
||||||
@PostMapping(value = "/removeMenuByIds")
|
@PostMapping(value = "/removeMenuByIds")
|
||||||
@PreAuthorize("@el.check('menu:del')")
|
@PreAuthorize("@el.check('menu:del')")
|
||||||
public ResponseEntity<Void> removeMenuByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> removeMenuByIds(@RequestBody Set<Long> ids) {
|
||||||
systemMenuService.removeMenuByIds(ids);
|
systemMenuService.removeMenuByIds(ids);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+13
-14
@@ -13,12 +13,12 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.system.service.SystemMonitorService;
|
import cn.odboy.system.service.SystemMonitorService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.util.Map;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -26,19 +26,18 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统-服务监控管理")
|
@Api(tags = "系统-服务监控管理")
|
||||||
@RequestMapping("/api/monitor")
|
@RequestMapping("/api/monitor")
|
||||||
public class SystemMonitorController {
|
public class SystemMonitorController {
|
||||||
@Autowired
|
|
||||||
private SystemMonitorService systemMonitorService;
|
|
||||||
|
|
||||||
@PostMapping(value = "/queryServerMonitorInfo")
|
@Autowired
|
||||||
@Operation(summary = "查询服务监控")
|
private SystemMonitorService systemMonitorService;
|
||||||
@PreAuthorize("@el.check('monitor:list')")
|
|
||||||
public ResponseEntity<Map<String, Object>> queryServerMonitorInfo() {
|
@PostMapping(value = "/queryServerMonitorInfo")
|
||||||
return ResponseEntity.ok(systemMonitorService.queryServerMonitorInfo());
|
@ApiOperation("查询服务监控")
|
||||||
}
|
@PreAuthorize("@el.check('monitor:list')")
|
||||||
|
public ResponseEntity<Map<String, Object>> queryServerMonitorInfo() {
|
||||||
|
return ResponseEntity.ok(systemMonitorService.queryServerMonitorInfo());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+38
-33
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -23,49 +22,55 @@ import cn.odboy.system.dal.redis.SystemUserOnlineInfoDAO;
|
|||||||
import cn.odboy.util.KitDesEncryptUtil;
|
import cn.odboy.util.KitDesEncryptUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.io.IOException;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.Set;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/user/online")
|
@RequestMapping("/api/user/online")
|
||||||
@Tag(name = "系统:在线用户管理")
|
@Api(tags = "系统:在线用户管理")
|
||||||
public class SystemOnlineController {
|
public class SystemOnlineController {
|
||||||
@Autowired
|
|
||||||
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
|
||||||
|
|
||||||
@Operation(summary = "查询在线用户")
|
@Autowired
|
||||||
@PostMapping
|
private SystemUserOnlineInfoDAO systemUserOnlineInfoDAO;
|
||||||
@PreAuthorize("@el.check()")
|
|
||||||
public ResponseEntity<KitPageResult<SystemUserOnlineVo>> queryOnlineUser(@Validated @RequestBody KitPageArgs<SystemUserOnlineVo> args) {
|
|
||||||
IPage<SystemUserOnlineVo> page = new Page<>(args.getPage(), args.getSize());
|
|
||||||
return ResponseEntity.ok(systemUserOnlineInfoDAO.queryUserOnlineModelPage(args.getArgs(), page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "导出数据")
|
@ApiOperation("查询在线用户")
|
||||||
@GetMapping(value = "/download")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
|
public ResponseEntity<KitPageResult<SystemUserOnlineVo>> queryOnlineUser(
|
||||||
systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response);
|
@Validated @RequestBody KitPageArgs<SystemUserOnlineVo> args) {
|
||||||
}
|
IPage<SystemUserOnlineVo> page = new Page<>(args.getPage(), args.getSize());
|
||||||
|
return ResponseEntity.ok(systemUserOnlineInfoDAO.queryUserOnlineModelPage(args.getArgs(), page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "踢出用户")
|
@ApiOperation("导出数据")
|
||||||
@PostMapping(value = "/kickOutUser")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check()")
|
@PreAuthorize("@el.check()")
|
||||||
public ResponseEntity<Void> kickOutUser(@RequestBody Set<String> keys) throws Exception {
|
public void exportOnlineUser(HttpServletResponse response, String username) throws IOException {
|
||||||
for (String token : keys) {
|
systemUserOnlineInfoDAO.downloadUserOnlineModelExcel(
|
||||||
// 解密Key
|
systemUserOnlineInfoDAO.queryUserOnlineModelListByUsername(username), response);
|
||||||
token = KitDesEncryptUtil.desDecrypt(token);
|
}
|
||||||
systemUserOnlineInfoDAO.logoutByToken(token);
|
|
||||||
}
|
@ApiOperation("踢出用户")
|
||||||
return ResponseEntity.ok(null);
|
@PostMapping(value = "/kickOutUser")
|
||||||
|
@PreAuthorize("@el.check()")
|
||||||
|
public ResponseEntity<Void> kickOutUser(@RequestBody Set<String> keys) throws Exception {
|
||||||
|
for (String token : keys) {
|
||||||
|
// 解密Key
|
||||||
|
token = KitDesEncryptUtil.desDecrypt(token);
|
||||||
|
systemUserOnlineInfoDAO.logoutByToken(token);
|
||||||
}
|
}
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-36
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -23,55 +22,61 @@ import cn.odboy.system.dal.model.SystemOssStorageVo;
|
|||||||
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
import cn.odboy.system.dal.model.SystemQueryStorageArgs;
|
||||||
import cn.odboy.system.service.SystemOssStorageService;
|
import cn.odboy.system.service.SystemOssStorageService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "工具:OSS存储管理")
|
@Api(tags = "工具:OSS存储管理")
|
||||||
@RequestMapping("/api/ossStorage")
|
@RequestMapping("/api/ossStorage")
|
||||||
public class SystemOssStorageController {
|
public class SystemOssStorageController {
|
||||||
@Autowired
|
|
||||||
private SystemOssStorageService systemOssStorageService;
|
|
||||||
|
|
||||||
@Operation(summary = "查询文件")
|
@Autowired
|
||||||
@PostMapping
|
private SystemOssStorageService systemOssStorageService;
|
||||||
@PreAuthorize("@el.check('storage:list')")
|
|
||||||
public ResponseEntity<KitPageResult<SystemOssStorageVo>> queryOssStorage(@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
|
||||||
SystemQueryStorageArgs criteria = args.getArgs();
|
|
||||||
Page<SystemOssStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
|
||||||
return ResponseEntity.ok(systemOssStorageService.queryOssStorage(criteria, page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "导出数据")
|
@ApiOperation("查询文件")
|
||||||
@GetMapping(value = "/download")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('storage:list')")
|
@PreAuthorize("@el.check('storage:list')")
|
||||||
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs criteria) throws IOException {
|
public ResponseEntity<KitPageResult<SystemOssStorageVo>> queryOssStorage(
|
||||||
systemOssStorageService.exportOssStorageExcel(systemOssStorageService.queryOssStorage(criteria), response);
|
@Validated @RequestBody KitPageArgs<SystemQueryStorageArgs> args) {
|
||||||
}
|
SystemQueryStorageArgs criteria = args.getArgs();
|
||||||
|
Page<SystemOssStorageTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
return ResponseEntity.ok(systemOssStorageService.queryOssStorage(criteria, page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "上传文件")
|
@ApiOperation("导出数据")
|
||||||
@PostMapping(value = "/uploadFile")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('storage:add')")
|
@PreAuthorize("@el.check('storage:list')")
|
||||||
public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file) {
|
public void exportFile(HttpServletResponse response, SystemQueryStorageArgs criteria) throws IOException {
|
||||||
String fileUrl = systemOssStorageService.uploadFile(file);
|
systemOssStorageService.exportOssStorageExcel(systemOssStorageService.queryOssStorage(criteria), response);
|
||||||
return ResponseEntity.ok(fileUrl);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "多选删除")
|
@ApiOperation("上传文件")
|
||||||
@PostMapping(value = "/removeFileByIds")
|
@PostMapping(value = "/uploadFile")
|
||||||
public ResponseEntity<Void> removeFileByIds(@RequestBody Long[] ids) {
|
@PreAuthorize("@el.check('storage:add')")
|
||||||
systemOssStorageService.removeFileByIds(ids);
|
public ResponseEntity<String> uploadFile(@RequestParam("file") MultipartFile file) {
|
||||||
return ResponseEntity.ok(null);
|
String fileUrl = systemOssStorageService.uploadFile(file);
|
||||||
}
|
return ResponseEntity.ok(fileUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("多选删除")
|
||||||
|
@PostMapping(value = "/removeFileByIds")
|
||||||
|
public ResponseEntity<Void> removeFileByIds(@RequestBody Long[] ids) {
|
||||||
|
systemOssStorageService.removeFileByIds(ids);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+96
-89
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.odboy.base.KitPageArgs;
|
import cn.odboy.base.KitPageArgs;
|
||||||
@@ -26,115 +25,123 @@ import cn.odboy.system.dal.model.SystemQueryQuartzJobArgs;
|
|||||||
import cn.odboy.system.dal.model.SystemUpdateQuartzJobArgs;
|
import cn.odboy.system.dal.model.SystemUpdateQuartzJobArgs;
|
||||||
import cn.odboy.system.service.SystemQuartzJobService;
|
import cn.odboy.system.service.SystemQuartzJobService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import java.io.IOException;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.util.Set;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/quartzJob")
|
@RequestMapping("/api/quartzJob")
|
||||||
@Tag(name = "系统:定时任务管理")
|
@Api(tags = "系统:定时任务管理")
|
||||||
public class SystemQuartzJobController {
|
public class SystemQuartzJobController {
|
||||||
@Autowired
|
|
||||||
private SystemQuartzJobService systemQuartzJobService;
|
|
||||||
|
|
||||||
@Operation(summary = "查询定时任务")
|
@Autowired
|
||||||
@PostMapping
|
private SystemQuartzJobService systemQuartzJobService;
|
||||||
@PreAuthorize("@el.check('quartzJob:list')")
|
|
||||||
public ResponseEntity<KitPageResult<SystemQuartzJobTb>> queryQuartzJobByCrud(@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> args) {
|
|
||||||
SystemQueryQuartzJobArgs criteria = args.getArgs();
|
|
||||||
Page<SystemQuartzJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
|
||||||
return ResponseEntity.ok(systemQuartzJobService.queryQuartzJobByArgs(criteria, page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "导出任务数据")
|
@ApiOperation("查询定时任务")
|
||||||
@GetMapping(value = "/download")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('quartzJob:list')")
|
@PreAuthorize("@el.check('quartzJob:list')")
|
||||||
public void exportQuartzJob(HttpServletResponse response, SystemQueryQuartzJobArgs criteria) throws IOException {
|
public ResponseEntity<KitPageResult<SystemQuartzJobTb>> queryQuartzJobByCrud(
|
||||||
systemQuartzJobService.exportQuartzJobExcel(systemQuartzJobService.queryQuartzJobByArgs(criteria), response);
|
@Validated @RequestBody KitPageArgs<SystemQueryQuartzJobArgs> args) {
|
||||||
}
|
SystemQueryQuartzJobArgs criteria = args.getArgs();
|
||||||
|
Page<SystemQuartzJobTb> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
return ResponseEntity.ok(systemQuartzJobService.queryQuartzJobByArgs(criteria, page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "导出日志数据")
|
@ApiOperation("导出任务数据")
|
||||||
@GetMapping(value = "/logs/download")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('quartzJob:list')")
|
@PreAuthorize("@el.check('quartzJob:list')")
|
||||||
public void exportQuartzJobLog(HttpServletResponse response, SystemQueryQuartzJobArgs criteria) throws IOException {
|
public void exportQuartzJob(HttpServletResponse response, SystemQueryQuartzJobArgs criteria) throws IOException {
|
||||||
systemQuartzJobService.exportQuartzLogExcel(systemQuartzJobService.queryQuartzLogByArgs(criteria), response);
|
systemQuartzJobService.exportQuartzJobExcel(systemQuartzJobService.queryQuartzJobByArgs(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询任务执行日志")
|
@ApiOperation("导出日志数据")
|
||||||
@PostMapping(value = "/logs")
|
@GetMapping(value = "/logs/download")
|
||||||
@PreAuthorize("@el.check('quartzJob:list')")
|
@PreAuthorize("@el.check('quartzJob:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(SystemQueryQuartzJobArgs args) {
|
public void exportQuartzJobLog(HttpServletResponse response, SystemQueryQuartzJobArgs criteria) throws IOException {
|
||||||
Page<SystemQuartzLogTb> page = new Page<>(args.getPage(), args.getSize());
|
systemQuartzJobService.exportQuartzLogExcel(systemQuartzJobService.queryQuartzLogByArgs(criteria), response);
|
||||||
return ResponseEntity.ok(systemQuartzJobService.queryQuartzLogByArgs(args, page));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "新增定时任务")
|
@ApiOperation("查询任务执行日志")
|
||||||
@PostMapping(value = "/createQuartzJob")
|
@PostMapping(value = "/logs")
|
||||||
@PreAuthorize("@el.check('quartzJob:add')")
|
@PreAuthorize("@el.check('quartzJob:list')")
|
||||||
public ResponseEntity<Void> createQuartzJob(@Validated @RequestBody SystemQuartzJobTb args) {
|
public ResponseEntity<KitPageResult<SystemQuartzLogTb>> queryQuartzJobLog(SystemQueryQuartzJobArgs args) {
|
||||||
if (args.getId() != null) {
|
Page<SystemQuartzLogTb> page = new Page<>(args.getPage(), args.getSize());
|
||||||
throw new BadRequestException("无效参数id");
|
return ResponseEntity.ok(systemQuartzJobService.queryQuartzLogByArgs(args, page));
|
||||||
}
|
}
|
||||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
|
||||||
checkBean(args.getBeanName());
|
|
||||||
systemQuartzJobService.createJob(args);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "修改定时任务")
|
@ApiOperation("新增定时任务")
|
||||||
@PutMapping
|
@PostMapping(value = "/createQuartzJob")
|
||||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
@PreAuthorize("@el.check('quartzJob:add')")
|
||||||
public ResponseEntity<Void> updateQuartzJob(@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
public ResponseEntity<Void> createQuartzJob(@Validated @RequestBody SystemQuartzJobTb args) {
|
||||||
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
if (args.getId() != null) {
|
||||||
checkBean(args.getBeanName());
|
throw new BadRequestException("无效参数id");
|
||||||
systemQuartzJobService.modifyQuartzJobResumeCron(args);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
}
|
||||||
|
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
|
checkBean(args.getBeanName());
|
||||||
|
systemQuartzJobService.createJob(args);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "更改定时任务状态")
|
@ApiOperation("修改定时任务")
|
||||||
@PostMapping(value = "/switchQuartzJobStatus/{id}")
|
@PutMapping
|
||||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||||
public ResponseEntity<Void> switchQuartzJobStatus(@PathVariable Long id) {
|
public ResponseEntity<Void> updateQuartzJob(
|
||||||
systemQuartzJobService.switchQuartzJobStatus(systemQuartzJobService.getQuartzJobById(id));
|
@Validated(SystemQuartzJobTb.Update.class) @RequestBody SystemUpdateQuartzJobArgs args) {
|
||||||
return ResponseEntity.ok(null);
|
// 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
}
|
checkBean(args.getBeanName());
|
||||||
|
systemQuartzJobService.modifyQuartzJobResumeCron(args);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "执行定时任务")
|
@ApiOperation("更改定时任务状态")
|
||||||
@PostMapping(value = "/startQuartzJob/{id}")
|
@PostMapping(value = "/switchQuartzJobStatus/{id}")
|
||||||
@PreAuthorize("@el.check('quartzJob:edit')")
|
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||||
public ResponseEntity<Void> startQuartzJob(@PathVariable Long id) {
|
public ResponseEntity<Void> switchQuartzJobStatus(@PathVariable Long id) {
|
||||||
systemQuartzJobService.startQuartzJob(systemQuartzJobService.getQuartzJobById(id));
|
systemQuartzJobService.switchQuartzJobStatus(systemQuartzJobService.getQuartzJobById(id));
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "删除定时任务")
|
@ApiOperation("执行定时任务")
|
||||||
@PostMapping(value = "/removeJobByIds")
|
@PostMapping(value = "/startQuartzJob/{id}")
|
||||||
@PreAuthorize("@el.check('quartzJob:del')")
|
@PreAuthorize("@el.check('quartzJob:edit')")
|
||||||
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> startQuartzJob(@PathVariable Long id) {
|
||||||
systemQuartzJobService.removeJobByIds(ids);
|
systemQuartzJobService.startQuartzJob(systemQuartzJobService.getQuartzJobById(id));
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@ApiOperation("删除定时任务")
|
||||||
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
@PostMapping(value = "/removeJobByIds")
|
||||||
*
|
@PreAuthorize("@el.check('quartzJob:del')")
|
||||||
* @param beanName Bean名称
|
public ResponseEntity<Void> removeJobByIds(@RequestBody Set<Long> ids) {
|
||||||
*/
|
systemQuartzJobService.removeJobByIds(ids);
|
||||||
private void checkBean(String beanName) {
|
return ResponseEntity.ok(null);
|
||||||
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
}
|
||||||
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
|
||||||
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
/**
|
||||||
throw new BadRequestException("非法的 Bean,请重新输入!");
|
* 验证Bean是不是合法的, 合法的定时任务 Bean 需要用 @Service 定义
|
||||||
}
|
*
|
||||||
|
* @param beanName Bean名称
|
||||||
|
*/
|
||||||
|
private void checkBean(String beanName) {
|
||||||
|
// 避免调用攻击者可以从SpringContextHolder获得控制jdbcTemplate类
|
||||||
|
// 并使用getDeclaredMethod调用jdbcTemplate的queryForMap函数,执行任意sql命令。
|
||||||
|
if (!KitSpringBeanHolder.getAllServiceBeanName().contains(beanName)) {
|
||||||
|
throw new BadRequestException("非法的 Bean,请重新输入!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+102
-95
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.hutool.core.lang.Dict;
|
import cn.hutool.core.lang.Dict;
|
||||||
@@ -23,121 +22,129 @@ import cn.odboy.framework.exception.BadRequestException;
|
|||||||
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
||||||
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
|
import cn.odboy.system.dal.model.SystemCreateRoleArgs;
|
||||||
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
import cn.odboy.system.dal.model.SystemQueryRoleArgs;
|
||||||
|
import cn.odboy.system.dal.model.SystemRoleVo;
|
||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.system.service.SystemRoleService;
|
import cn.odboy.system.service.SystemRoleService;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import java.io.IOException;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import java.util.Collections;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import java.util.List;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@Tag(name = "系统:角色管理")
|
@Api(tags = "系统:角色管理")
|
||||||
@RequestMapping("/api/role")
|
@RequestMapping("/api/role")
|
||||||
public class SystemRoleController {
|
public class SystemRoleController {
|
||||||
@Autowired
|
|
||||||
private SystemRoleService systemRoleService;
|
|
||||||
|
|
||||||
@Operation(summary = "获取单个role")
|
@Autowired
|
||||||
@PostMapping(value = "/queryRoleById")
|
private SystemRoleService systemRoleService;
|
||||||
@PreAuthorize("@el.check('roles:list')")
|
|
||||||
public ResponseEntity<SystemRoleTb> queryRoleById(@RequestBody SystemRoleTb args) {
|
|
||||||
return ResponseEntity.ok(systemRoleService.getRoleById(args.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "导出角色数据")
|
@ApiOperation("获取单个role")
|
||||||
@GetMapping(value = "/download")
|
@PostMapping(value = "/queryRoleById")
|
||||||
@PreAuthorize("@el.check('role:list')")
|
@PreAuthorize("@el.check('roles:list')")
|
||||||
public void exportRole(HttpServletResponse response, SystemQueryRoleArgs criteria) throws IOException {
|
public ResponseEntity<SystemRoleTb> queryRoleById(@RequestBody SystemRoleTb args) {
|
||||||
systemRoleService.exportRoleExcel(systemRoleService.queryRoleByArgs(criteria), response);
|
return ResponseEntity.ok(systemRoleService.getRoleById(args.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "返回全部的角色")
|
@ApiOperation("导出角色数据")
|
||||||
@PostMapping(value = "/queryRoleList")
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
@PreAuthorize("@el.check('role:list')")
|
||||||
public ResponseEntity<List<SystemRoleTb>> queryRoleList() {
|
public void exportRole(HttpServletResponse response, SystemQueryRoleArgs criteria) throws IOException {
|
||||||
return ResponseEntity.ok(systemRoleService.queryAllRole());
|
systemRoleService.exportRoleExcel(systemRoleService.queryRoleByArgs(criteria), response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询角色")
|
@ApiOperation("返回全部的角色")
|
||||||
@PostMapping
|
@PostMapping(value = "/queryRoleList")
|
||||||
@PreAuthorize("@el.check('roles:list')")
|
@PreAuthorize("@el.check('roles:list','user:add','user:edit')")
|
||||||
public ResponseEntity<KitPageResult<SystemRoleTb>> queryRoleByArgs(@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> args) {
|
public ResponseEntity<List<SystemRoleTb>> queryRoleList() {
|
||||||
SystemQueryRoleArgs criteria = args.getArgs();
|
return ResponseEntity.ok(systemRoleService.queryAllRole());
|
||||||
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
}
|
||||||
return ResponseEntity.ok(systemRoleService.queryRoleByArgs(criteria, page));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "获取用户级别")
|
@ApiOperation("查询角色")
|
||||||
@PostMapping(value = "/queryRoleLevel")
|
@PostMapping
|
||||||
public ResponseEntity<Dict> queryRoleLevel() {
|
@PreAuthorize("@el.check('roles:list')")
|
||||||
return ResponseEntity.ok(Dict.create().set("level", checkRoleLevels(null)));
|
public ResponseEntity<KitPageResult<SystemRoleVo>> queryRoleByArgs(
|
||||||
}
|
@Validated @RequestBody KitPageArgs<SystemQueryRoleArgs> args) {
|
||||||
|
SystemQueryRoleArgs criteria = args.getArgs();
|
||||||
|
Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||||
|
return ResponseEntity.ok(systemRoleService.queryRoleByArgs(criteria, page));
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "新增角色")
|
@ApiOperation("获取用户级别")
|
||||||
@PostMapping(value = "/saveRole")
|
@PostMapping(value = "/queryRoleLevel")
|
||||||
@PreAuthorize("@el.check('roles:add')")
|
public ResponseEntity<Dict> queryRoleLevel() {
|
||||||
public ResponseEntity<Void> saveRole(@Validated @RequestBody SystemCreateRoleArgs args) {
|
return ResponseEntity.ok(Dict.create().set("level", checkRoleLevels(null)));
|
||||||
checkRoleLevels(args.getLevel());
|
}
|
||||||
systemRoleService.saveRole(args);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "修改角色")
|
@ApiOperation("新增角色")
|
||||||
@PostMapping(value = "/modifyRoleById")
|
@PostMapping(value = "/saveRole")
|
||||||
@PreAuthorize("@el.check('roles:edit')")
|
@PreAuthorize("@el.check('roles:add')")
|
||||||
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleTb args) {
|
public ResponseEntity<Void> saveRole(@Validated @RequestBody SystemCreateRoleArgs args) {
|
||||||
checkRoleLevels(args.getLevel());
|
checkRoleLevels(args.getLevel());
|
||||||
systemRoleService.modifyRoleById(args);
|
systemRoleService.saveRole(args);
|
||||||
return ResponseEntity.ok(null);
|
return ResponseEntity.ok(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改角色菜单")
|
@ApiOperation("修改角色")
|
||||||
@PostMapping(value = "/modifyBindMenuById")
|
@PostMapping(value = "/modifyRoleById")
|
||||||
@PreAuthorize("@el.check('roles:edit')")
|
@PreAuthorize("@el.check('roles:edit')")
|
||||||
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleTb args) {
|
public ResponseEntity<Void> modifyRoleById(@Validated(SystemRoleTb.Update.class) @RequestBody SystemRoleVo args) {
|
||||||
SystemRoleTb role = systemRoleService.getRoleById(args.getId());
|
checkRoleLevels(args.getLevel());
|
||||||
checkRoleLevels(role.getLevel());
|
systemRoleService.modifyRoleById(args);
|
||||||
systemRoleService.modifyBindMenuById(args);
|
return ResponseEntity.ok(null);
|
||||||
return ResponseEntity.ok(null);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除角色")
|
@ApiOperation("修改角色菜单")
|
||||||
@PostMapping(value = "/removeRoleByIds")
|
@PostMapping(value = "/modifyBindMenuById")
|
||||||
@PreAuthorize("@el.check('roles:del')")
|
@PreAuthorize("@el.check('roles:edit')")
|
||||||
public ResponseEntity<Void> removeRoleByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Void> modifyBindMenuById(@RequestBody SystemRoleVo args) {
|
||||||
for (Long id : ids) {
|
SystemRoleTb role = systemRoleService.getRoleById(args.getId());
|
||||||
SystemRoleTb role = systemRoleService.getRoleById(id);
|
checkRoleLevels(role.getLevel());
|
||||||
checkRoleLevels(role.getLevel());
|
systemRoleService.modifyBindMenuById(args);
|
||||||
}
|
return ResponseEntity.ok(null);
|
||||||
// 验证是否被用户关联
|
}
|
||||||
systemRoleService.verifyBindRelationByIds(ids);
|
|
||||||
systemRoleService.removeRoleByIds(ids);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@ApiOperation("删除角色")
|
||||||
* 检查用户的角色级别
|
@PostMapping(value = "/removeRoleByIds")
|
||||||
*
|
@PreAuthorize("@el.check('roles:del')")
|
||||||
* @return /
|
public ResponseEntity<Void> removeRoleByIds(@RequestBody Set<Long> ids) {
|
||||||
*/
|
for (Long id : ids) {
|
||||||
private int checkRoleLevels(Integer level) {
|
SystemRoleTb role = systemRoleService.getRoleById(id);
|
||||||
List<Integer> levels = systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).toList();
|
checkRoleLevels(role.getLevel());
|
||||||
int min = Collections.min(levels);
|
|
||||||
if (level != null) {
|
|
||||||
if (level < min) {
|
|
||||||
throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return min;
|
|
||||||
}
|
}
|
||||||
|
// 验证是否被用户关联
|
||||||
|
systemRoleService.verifyBindRelationByIds(ids);
|
||||||
|
systemRoleService.removeRoleByIds(ids);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查用户的角色级别
|
||||||
|
*
|
||||||
|
* @return /
|
||||||
|
*/
|
||||||
|
private int checkRoleLevels(Integer level) {
|
||||||
|
List<Integer> levels = systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
||||||
|
.map(SystemRoleTb::getLevel).collect(Collectors.toList());
|
||||||
|
int min = Collections.min(levels);
|
||||||
|
if (level != null) {
|
||||||
|
if (level < min) {
|
||||||
|
throw new BadRequestException("权限不足, 你的角色级别:" + min + ", 低于操作的角色级别:" + level);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return min;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+163
-155
@@ -13,7 +13,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package cn.odboy.system.controller;
|
package cn.odboy.system.controller;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
@@ -28,6 +27,7 @@ import cn.odboy.system.dal.dataobject.SystemRoleTb;
|
|||||||
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
import cn.odboy.system.dal.dataobject.SystemUserTb;
|
||||||
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
import cn.odboy.system.dal.model.SystemQueryUserArgs;
|
||||||
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
|
import cn.odboy.system.dal.model.SystemUpdateUserPasswordArgs;
|
||||||
|
import cn.odboy.system.dal.model.SystemUserVo;
|
||||||
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
import cn.odboy.system.framework.permission.core.KitSecurityHelper;
|
||||||
import cn.odboy.system.service.SystemDataService;
|
import cn.odboy.system.service.SystemDataService;
|
||||||
import cn.odboy.system.service.SystemDeptService;
|
import cn.odboy.system.service.SystemDeptService;
|
||||||
@@ -37,14 +37,14 @@ import cn.odboy.system.service.SystemUserService;
|
|||||||
import cn.odboy.util.KitPageUtil;
|
import cn.odboy.util.KitPageUtil;
|
||||||
import cn.odboy.util.KitRsaEncryptUtil;
|
import cn.odboy.util.KitRsaEncryptUtil;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -61,176 +61,184 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
@Tag(name = "系统:用户管理")
|
@Api(tags = "系统:用户管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/user")
|
@RequestMapping("/api/user")
|
||||||
public class SystemUserController {
|
public class SystemUserController {
|
||||||
@Autowired private PasswordEncoder passwordEncoder;
|
|
||||||
@Autowired private SystemUserService systemUserService;
|
|
||||||
@Autowired private SystemDataService systemDataService;
|
|
||||||
@Autowired private SystemDeptService systemDeptService;
|
|
||||||
@Autowired private SystemRoleService systemRoleService;
|
|
||||||
@Autowired private SystemEmailService systemEmailService;
|
|
||||||
@Autowired private AppProperties properties;
|
|
||||||
|
|
||||||
@Operation(summary = "导出用户数据")
|
@Autowired
|
||||||
@GetMapping(value = "/download")
|
private PasswordEncoder passwordEncoder;
|
||||||
@PreAuthorize("@el.check('user:list')")
|
@Autowired
|
||||||
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs criteria) throws IOException {
|
private SystemUserService systemUserService;
|
||||||
systemUserService.exportUserExcel(systemUserService.queryUserByArgs(criteria), response);
|
@Autowired
|
||||||
}
|
private SystemDataService systemDataService;
|
||||||
|
@Autowired
|
||||||
|
private SystemDeptService systemDeptService;
|
||||||
|
@Autowired
|
||||||
|
private SystemRoleService systemRoleService;
|
||||||
|
@Autowired
|
||||||
|
private SystemEmailService systemEmailService;
|
||||||
|
@Autowired
|
||||||
|
private AppProperties properties;
|
||||||
|
|
||||||
@Operation(summary = "查询用户")
|
@ApiOperation("导出用户数据")
|
||||||
@PostMapping
|
@GetMapping(value = "/download")
|
||||||
@PreAuthorize("@el.check('user:list')")
|
@PreAuthorize("@el.check('user:list')")
|
||||||
public ResponseEntity<KitPageResult<SystemUserTb>> queryUserByArgs(
|
public void exportUserExcel(HttpServletResponse response, SystemQueryUserArgs criteria) throws IOException {
|
||||||
@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
systemUserService.exportUserExcel(systemUserService.queryUserByArgs(criteria), response);
|
||||||
Page<SystemUserTb> page = new Page<>(args.getPage(), args.getSize());
|
}
|
||||||
SystemQueryUserArgs criteria = args.getArgs();
|
|
||||||
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
|
||||||
criteria.getDeptIds().add(criteria.getDeptId());
|
|
||||||
// 先查找是否存在子节点
|
|
||||||
List<SystemDeptTb> data = systemDeptService.queryDeptByPid(criteria.getDeptId());
|
|
||||||
// 然后把子节点的ID都加入到集合中
|
|
||||||
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data));
|
|
||||||
}
|
|
||||||
// 数据权限
|
|
||||||
List<Long> dataScopes = systemDataService.findDeptIdListByArgs(
|
|
||||||
systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername()));
|
|
||||||
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
|
||||||
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
|
||||||
// 取交集
|
|
||||||
criteria.getDeptIds().retainAll(dataScopes);
|
|
||||||
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
|
||||||
return ResponseEntity.ok(systemUserService.queryUserByArgs(criteria, page));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 否则取并集
|
|
||||||
criteria.getDeptIds().addAll(dataScopes);
|
|
||||||
return ResponseEntity.ok(systemUserService.queryUserByArgs(criteria, page));
|
|
||||||
}
|
|
||||||
return ResponseEntity.ok(KitPageUtil.emptyData());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "新增用户")
|
@ApiOperation("查询用户")
|
||||||
@PostMapping(value = "/saveUser")
|
@PostMapping
|
||||||
@PreAuthorize("@el.check('user:add')")
|
@PreAuthorize("@el.check('user:list')")
|
||||||
public ResponseEntity<Object> saveUser(@Validated @RequestBody SystemUserTb args) {
|
public ResponseEntity<KitPageResult<SystemUserVo>> queryUserByArgs(
|
||||||
checkLevel(args);
|
@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
||||||
// 默认密码 123456
|
Page<SystemUserTb> page = new Page<>(args.getPage(), args.getSize());
|
||||||
args.setPassword(passwordEncoder.encode("123456"));
|
SystemQueryUserArgs criteria = args.getArgs();
|
||||||
systemUserService.saveUser(args);
|
if (!ObjectUtils.isEmpty(criteria.getDeptId())) {
|
||||||
return ResponseEntity.ok(null);
|
criteria.getDeptIds().add(criteria.getDeptId());
|
||||||
|
// 先查找是否存在子节点
|
||||||
|
List<SystemDeptTb> data = systemDeptService.queryDeptByPid(criteria.getDeptId());
|
||||||
|
// 然后把子节点的ID都加入到集合中
|
||||||
|
criteria.getDeptIds().addAll(systemDeptService.queryChildDeptIdListByDeptIds(data));
|
||||||
}
|
}
|
||||||
|
// 数据权限
|
||||||
|
List<Long> dataScopes = systemDataService.findDeptIdListByArgs(
|
||||||
|
systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername()));
|
||||||
|
// criteria.getDeptIds() 不为空并且数据权限不为空则取交集
|
||||||
|
if (!CollectionUtils.isEmpty(criteria.getDeptIds()) && !CollectionUtils.isEmpty(dataScopes)) {
|
||||||
|
// 取交集
|
||||||
|
criteria.getDeptIds().retainAll(dataScopes);
|
||||||
|
if (!CollectionUtil.isEmpty(criteria.getDeptIds())) {
|
||||||
|
return ResponseEntity.ok(systemUserService.queryUserByArgs(criteria, page));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 否则取并集
|
||||||
|
criteria.getDeptIds().addAll(dataScopes);
|
||||||
|
return ResponseEntity.ok(systemUserService.queryUserByArgs(criteria, page));
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok(KitPageUtil.emptyData());
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改用户")
|
@ApiOperation("新增用户")
|
||||||
@PostMapping(value = "/modifyUserById")
|
@PostMapping(value = "/saveUser")
|
||||||
@PreAuthorize("@el.check('user:edit')")
|
@PreAuthorize("@el.check('user:add')")
|
||||||
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
public ResponseEntity<Object> saveUser(@Validated @RequestBody SystemUserVo args) {
|
||||||
checkLevel(args);
|
checkLevel(args);
|
||||||
systemUserService.modifyUserById(args);
|
// 默认密码 123456
|
||||||
return ResponseEntity.ok(null);
|
args.setPassword(passwordEncoder.encode("123456"));
|
||||||
}
|
systemUserService.saveUser(args);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改用户:个人中心")
|
@ApiOperation("修改用户")
|
||||||
@PostMapping(value = "modifyUserCenterInfoById")
|
@PostMapping(value = "/modifyUserById")
|
||||||
public ResponseEntity<Object> modifyUserCenterInfoById(
|
@PreAuthorize("@el.check('user:edit')")
|
||||||
@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
public ResponseEntity<Object> modifyUserById(@Validated(SystemUserTb.Update.class) @RequestBody SystemUserVo args) {
|
||||||
if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) {
|
checkLevel(args);
|
||||||
throw new BadRequestException("不能修改他人资料");
|
systemUserService.modifyUserById(args);
|
||||||
}
|
return ResponseEntity.ok(null);
|
||||||
systemUserService.modifyUserCenterInfoById(args);
|
}
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除用户")
|
@ApiOperation("修改用户:个人中心")
|
||||||
@PostMapping(value = "/removeUserByIds")
|
@PostMapping(value = "modifyUserCenterInfoById")
|
||||||
@PreAuthorize("@el.check('user:del')")
|
public ResponseEntity<Object> modifyUserCenterInfoById(
|
||||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
@Validated(SystemUserTb.Update.class) @RequestBody SystemUserTb args) {
|
||||||
for (Long id : ids) {
|
if (!args.getId().equals(KitSecurityHelper.getCurrentUserId())) {
|
||||||
Integer currentLevel = Collections.min(
|
throw new BadRequestException("不能修改他人资料");
|
||||||
systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
|
||||||
.map(SystemRoleTb::getLevel).toList());
|
|
||||||
Integer optLevel =
|
|
||||||
Collections.min(systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel).toList());
|
|
||||||
if (currentLevel > optLevel) {
|
|
||||||
throw new BadRequestException(
|
|
||||||
"角色权限不足, 不能删除:" + systemUserService.getUserById(id).getUsername());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
systemUserService.removeUserByIds(ids);
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
}
|
||||||
|
systemUserService.modifyUserCenterInfoById(args);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改密码")
|
@ApiOperation("删除用户")
|
||||||
@PostMapping(value = "/modifyUserPasswordByUsername")
|
@PostMapping(value = "/removeUserByIds")
|
||||||
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody SystemUpdateUserPasswordArgs passVo)
|
@PreAuthorize("@el.check('user:del')")
|
||||||
throws Exception {
|
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||||
String oldPass =
|
for (Long id : ids) {
|
||||||
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
Integer currentLevel = Collections.min(
|
||||||
String newPass =
|
systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
||||||
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
.map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||||
SystemUserTb user = systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
Integer optLevel = Collections.min(
|
||||||
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel)
|
||||||
throw new BadRequestException("修改失败,旧密码错误");
|
.collect(Collectors.toList()));
|
||||||
}
|
if (currentLevel > optLevel) {
|
||||||
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
throw new BadRequestException(
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
"角色权限不足, 不能删除:" + systemUserService.getUserById(id).getUsername());
|
||||||
}
|
}
|
||||||
systemUserService.modifyUserPasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass));
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
}
|
||||||
|
systemUserService.removeUserByIds(ids);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "重置密码")
|
@ApiOperation("修改密码")
|
||||||
@PostMapping(value = "/resetUserPasswordByIds")
|
@PostMapping(value = "/modifyUserPasswordByUsername")
|
||||||
public ResponseEntity<Object> resetUserPasswordByIds(@RequestBody Set<Long> ids) {
|
public ResponseEntity<Object> modifyUserPasswordByUsername(@RequestBody SystemUpdateUserPasswordArgs passVo)
|
||||||
String defaultPwd = passwordEncoder.encode("123456");
|
throws Exception {
|
||||||
systemUserService.resetUserPasswordByIds(ids, defaultPwd);
|
String oldPass =
|
||||||
return ResponseEntity.ok(null);
|
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getOldPass());
|
||||||
|
String newPass =
|
||||||
|
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), passVo.getNewPass());
|
||||||
|
SystemUserTb user = systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
||||||
|
if (!passwordEncoder.matches(oldPass, user.getPassword())) {
|
||||||
|
throw new BadRequestException("修改失败,旧密码错误");
|
||||||
}
|
}
|
||||||
|
if (passwordEncoder.matches(newPass, user.getPassword())) {
|
||||||
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
|
}
|
||||||
|
systemUserService.modifyUserPasswordByUsername(user.getUsername(), passwordEncoder.encode(newPass));
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改头像")
|
@ApiOperation("重置密码")
|
||||||
@PostMapping(value = "/modifyUserAvatar")
|
@PostMapping(value = "/resetUserPasswordByIds")
|
||||||
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
public ResponseEntity<Object> resetUserPasswordByIds(@RequestBody Set<Long> ids) {
|
||||||
return ResponseEntity.ok(systemUserService.modifyUserAvatar(avatar));
|
String defaultPwd = passwordEncoder.encode("123456");
|
||||||
}
|
systemUserService.resetUserPasswordByIds(ids, defaultPwd);
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "修改邮箱")
|
@ApiOperation("修改头像")
|
||||||
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
@PostMapping(value = "/modifyUserAvatar")
|
||||||
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb args)
|
public ResponseEntity<Object> modifyUserAvatar(@RequestParam MultipartFile avatar) {
|
||||||
throws Exception {
|
return ResponseEntity.ok(systemUserService.modifyUserAvatar(avatar));
|
||||||
String password =
|
}
|
||||||
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword());
|
|
||||||
SystemUserTb user = systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
|
||||||
if (!passwordEncoder.matches(password, user.getPassword())) {
|
|
||||||
throw new BadRequestException("密码错误");
|
|
||||||
}
|
|
||||||
systemEmailService.checkEmailCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
|
||||||
systemUserService.modifyUserEmailByUsername(user.getUsername(), args.getEmail());
|
|
||||||
return ResponseEntity.ok(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
@ApiOperation("修改邮箱")
|
||||||
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
|
@PostMapping(value = "/modifyUserEmailByUsername/{code}")
|
||||||
*
|
public ResponseEntity<Object> modifyUserEmailByUsername(@PathVariable String code, @RequestBody SystemUserTb args)
|
||||||
* @param args /
|
throws Exception {
|
||||||
*/
|
String password =
|
||||||
private void checkLevel(SystemUserTb args) {
|
KitRsaEncryptUtil.decryptByPrivateKey(properties.getRsa().getPrivateKey(), args.getPassword());
|
||||||
Integer currentLevel = Collections.min(
|
SystemUserTb user = systemUserService.getUserByUsername(KitSecurityHelper.getCurrentUsername());
|
||||||
systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
if (!passwordEncoder.matches(password, user.getPassword())) {
|
||||||
.map(SystemRoleTb::getLevel).toList());
|
throw new BadRequestException("密码错误");
|
||||||
Integer optLevel = systemRoleService.getDeptLevelByRoles(args.getRoles());
|
|
||||||
if (currentLevel > optLevel) {
|
|
||||||
throw new BadRequestException("角色权限不足");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
systemEmailService.checkEmailCaptcha(SystemCaptchaBizEnum.EMAIL_RESET_EMAIL_CODE, args.getEmail(), code);
|
||||||
|
systemUserService.modifyUserEmailByUsername(user.getUsername(), args.getEmail());
|
||||||
|
return ResponseEntity.ok(null);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("查询用户基础数据")
|
/**
|
||||||
@PostMapping(value = "/queryUserMetadataOptions")
|
* 如果当前用户的角色级别低于创建用户的角色级别,则抛出权限不足的错误
|
||||||
@PreAuthorize("@el.check('user:list')")
|
*
|
||||||
public ResponseEntity<List<KitSelectOptionVo>> queryUserMetadataOptions(
|
* @param args /
|
||||||
@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
*/
|
||||||
List<KitSelectOptionVo> collect = systemUserService.queryUserMetadataOptions(args);
|
private void checkLevel(SystemUserVo args) {
|
||||||
return ResponseEntity.ok(collect);
|
Integer currentLevel = Collections.min(
|
||||||
|
systemRoleService.queryRoleByUsersId(KitSecurityHelper.getCurrentUserId()).stream()
|
||||||
|
.map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||||
|
Integer optLevel = systemRoleService.getDeptLevelByRoles(args.getRoles());
|
||||||
|
if (currentLevel > optLevel) {
|
||||||
|
throw new BadRequestException("角色权限不足");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation("查询用户基础数据")
|
||||||
|
@PostMapping(value = "/queryUserMetadataOptions")
|
||||||
|
@PreAuthorize("@el.check('user:list')")
|
||||||
|
public ResponseEntity<List<KitSelectOptionVo>> queryUserMetadataOptions(@Validated @RequestBody KitPageArgs<SystemQueryUserArgs> args) {
|
||||||
|
List<KitSelectOptionVo> collect = systemUserService.queryUserMetadataOptions(args);
|
||||||
|
return ResponseEntity.ok(collect);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+52
-38
@@ -22,11 +22,11 @@ import com.baomidou.mybatisplus.annotation.TableField;
|
|||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
|
||||||
import jakarta.validation.constraints.NotNull;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@@ -34,46 +34,60 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_dept")
|
@TableName("system_dept")
|
||||||
public class SystemDeptTb extends KitBaseUserTimeTb {
|
public class SystemDeptTb extends KitBaseUserTimeTb {
|
||||||
@NotNull(groups = Update.class) @TableId(value = "dept_id", type = IdType.AUTO)
|
|
||||||
@ApiModelProperty(value = "ID", hidden = true) private Long id;
|
|
||||||
@TableField(exist = false) @JSONField(serialize = false) @ApiModelProperty(value = "角色") private Set<SystemRoleTb>
|
|
||||||
roles;
|
|
||||||
@TableField(exist = false) @ApiModelProperty(value = "子部门") private List<SystemDeptTb> children;
|
|
||||||
@ApiModelProperty(value = "排序") private Integer deptSort;
|
|
||||||
@NotBlank @ApiModelProperty(value = "部门名称") private String name;
|
|
||||||
@NotNull @ApiModelProperty(value = "是否启用") private Boolean enabled;
|
|
||||||
@ApiModelProperty(value = "上级部门") private Long pid;
|
|
||||||
@ApiModelProperty(value = "子节点数目", hidden = true) private Integer subCount = 0;
|
|
||||||
|
|
||||||
@Override
|
@NotNull(groups = Update.class)
|
||||||
public boolean equals(Object o) {
|
@TableId(value = "dept_id", type = IdType.AUTO)
|
||||||
if (this == o) {
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
return true;
|
private Long id;
|
||||||
}
|
@TableField(exist = false)
|
||||||
if (o == null || getClass() != o.getClass()) {
|
@JSONField(serialize = false)
|
||||||
return false;
|
@ApiModelProperty(value = "角色")
|
||||||
}
|
private Set<SystemRoleTb> roles;
|
||||||
SystemDeptTb dept = (SystemDeptTb)o;
|
@TableField(exist = false)
|
||||||
return Objects.equals(id, dept.id) && Objects.equals(name, dept.name);
|
@ApiModelProperty(value = "子部门")
|
||||||
}
|
private List<SystemDeptTb> children;
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer deptSort;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "部门名称")
|
||||||
|
private String name;
|
||||||
|
@NotNull
|
||||||
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
private Boolean enabled;
|
||||||
|
@ApiModelProperty(value = "上级部门")
|
||||||
|
private Long pid;
|
||||||
|
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||||
|
private Integer subCount = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
return Objects.hash(id, name);
|
if (this == o) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SystemDeptTb dept = (SystemDeptTb) o;
|
||||||
|
return Objects.equals(id, dept.id) && Objects.equals(name, dept.name);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否有子节点")
|
@Override
|
||||||
public Boolean getHasChildren() {
|
public int hashCode() {
|
||||||
return subCount > 0;
|
return Objects.hash(id, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否为叶子")
|
@ApiModelProperty(value = "是否有子节点")
|
||||||
public Boolean getLeaf() {
|
public Boolean getHasChildren() {
|
||||||
return subCount <= 0;
|
return subCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "标签名称")
|
@ApiModelProperty(value = "是否为叶子")
|
||||||
public String getLabel() {
|
public Boolean getLeaf() {
|
||||||
return name;
|
return subCount <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标签名称")
|
||||||
|
public String getLabel() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+14
-7
@@ -29,11 +29,18 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_dict_detail")
|
@TableName("system_dict_detail")
|
||||||
public class SystemDictDetailTb extends KitBaseUserTimeTb {
|
public class SystemDictDetailTb extends KitBaseUserTimeTb {
|
||||||
@NotNull(groups = Update.class) @ApiModelProperty(value = "ID", hidden = true)
|
|
||||||
@TableId(value = "id", type = IdType.AUTO) private Long id;
|
@NotNull(groups = Update.class)
|
||||||
@TableField(value = "dict_id") @ApiModelProperty(hidden = true) private Long dictId;
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
@TableField(exist = false) @ApiModelProperty(value = "字典") private SystemDictTb dict;
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
@ApiModelProperty(value = "字典标签") private String label;
|
private Long id;
|
||||||
@ApiModelProperty(value = "字典值") private String value;
|
@TableField(value = "dict_id")
|
||||||
@ApiModelProperty(value = "排序") private Integer dictSort = 999;
|
@ApiModelProperty(hidden = true)
|
||||||
|
private Long dictId;
|
||||||
|
@ApiModelProperty(value = "字典标签")
|
||||||
|
private String label;
|
||||||
|
@ApiModelProperty(value = "字典值")
|
||||||
|
private String value;
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer dictSort = 999;
|
||||||
}
|
}
|
||||||
+11
-4
@@ -31,8 +31,15 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_dict")
|
@TableName("system_dict")
|
||||||
public class SystemDictTb extends KitBaseUserTimeTb {
|
public class SystemDictTb extends KitBaseUserTimeTb {
|
||||||
@NotNull(groups = Update.class) @ApiModelProperty(value = "ID", hidden = true)
|
|
||||||
@TableId(value = "id", type = IdType.AUTO) private Long id;
|
@NotNull(groups = Update.class)
|
||||||
@NotBlank @ApiModelProperty(value = "名称") private String name;
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
@ApiModelProperty(value = "描述") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String description;
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "名称")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(value = "描述")
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String description;
|
||||||
}
|
}
|
||||||
+18
-6
@@ -30,10 +30,22 @@ import lombok.EqualsAndHashCode;
|
|||||||
@TableName("system_email_config")
|
@TableName("system_email_config")
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class SystemEmailConfigTb extends KitObject {
|
public class SystemEmailConfigTb extends KitObject {
|
||||||
@TableId("config_id") private Long id;
|
|
||||||
@NotBlank @ApiModelProperty(value = "邮件服务器SMTP地址") private String host;
|
@TableId("config_id")
|
||||||
@NotBlank @ApiModelProperty(value = "邮件服务器 SMTP 端口") private String port;
|
private Long id;
|
||||||
@NotBlank @ApiModelProperty(value = "发件者用户名") private String user;
|
@NotBlank
|
||||||
@NotBlank @ApiModelProperty(value = "密码") private String password;
|
@ApiModelProperty(value = "邮件服务器SMTP地址")
|
||||||
@NotBlank @ApiModelProperty(value = "收件人") private String fromUser;
|
private String host;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "邮件服务器 SMTP 端口")
|
||||||
|
private String port;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "发件者用户名")
|
||||||
|
private String user;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "密码")
|
||||||
|
private String password;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "收件人")
|
||||||
|
private String fromUser;
|
||||||
}
|
}
|
||||||
|
|||||||
+28
-19
@@ -30,26 +30,35 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_job")
|
@TableName("system_job")
|
||||||
public class SystemJobTb extends KitBaseUserTimeTb {
|
public class SystemJobTb extends KitBaseUserTimeTb {
|
||||||
@NotNull(groups = Update.class) @TableId(value = "id", type = IdType.AUTO)
|
|
||||||
@ApiModelProperty(value = "ID", hidden = true) private Long id;
|
|
||||||
@NotBlank @ApiModelProperty(value = "岗位名称") private String name;
|
|
||||||
@NotNull @ApiModelProperty(value = "岗位排序") private Long jobSort;
|
|
||||||
@NotNull @ApiModelProperty(value = "是否启用") private Boolean enabled;
|
|
||||||
|
|
||||||
@Override
|
@NotNull(groups = Update.class)
|
||||||
public boolean equals(Object o) {
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
if (this == o) {
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
return true;
|
private Long id;
|
||||||
}
|
@NotBlank
|
||||||
if (o == null || getClass() != o.getClass()) {
|
@ApiModelProperty(value = "岗位名称")
|
||||||
return false;
|
private String name;
|
||||||
}
|
@NotNull
|
||||||
SystemJobTb job = (SystemJobTb)o;
|
@ApiModelProperty(value = "岗位排序")
|
||||||
return Objects.equals(id, job.id);
|
private Long jobSort;
|
||||||
}
|
@NotNull
|
||||||
|
@ApiModelProperty(value = "是否启用")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
return Objects.hash(id);
|
if (this == o) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SystemJobTb job = (SystemJobTb) o;
|
||||||
|
return Objects.equals(id, job.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+21
-11
@@ -29,16 +29,26 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_local_storage")
|
@TableName("system_local_storage")
|
||||||
public class SystemLocalStorageTb extends KitBaseUserTimeTb {
|
public class SystemLocalStorageTb extends KitBaseUserTimeTb {
|
||||||
@TableId(value = "id", type = IdType.AUTO) @ApiModelProperty(value = "ID", hidden = true) private Long id;
|
|
||||||
@ApiModelProperty(value = "真实文件名") private String realName;
|
|
||||||
@ApiModelProperty(value = "文件名") private String name;
|
|
||||||
@ApiModelProperty(value = "后缀") private String suffix;
|
|
||||||
@ApiModelProperty(value = "路径") private String path;
|
|
||||||
@ApiModelProperty(value = "类型") private String type;
|
|
||||||
@ApiModelProperty(value = "大小") private String size;
|
|
||||||
@ApiModelProperty(value = "日期分组") private String dateGroup;
|
|
||||||
|
|
||||||
public void copy(SystemLocalStorageTb source) {
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
}
|
private Long id;
|
||||||
|
@ApiModelProperty(value = "真实文件名")
|
||||||
|
private String realName;
|
||||||
|
@ApiModelProperty(value = "文件名")
|
||||||
|
private String name;
|
||||||
|
@ApiModelProperty(value = "后缀")
|
||||||
|
private String suffix;
|
||||||
|
@ApiModelProperty(value = "路径")
|
||||||
|
private String path;
|
||||||
|
@ApiModelProperty(value = "类型")
|
||||||
|
private String type;
|
||||||
|
@ApiModelProperty(value = "大小")
|
||||||
|
private String size;
|
||||||
|
@ApiModelProperty(value = "日期分组")
|
||||||
|
private String dateGroup;
|
||||||
|
|
||||||
|
public void copy(SystemLocalStorageTb source) {
|
||||||
|
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+64
-44
@@ -33,54 +33,74 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_menu")
|
@TableName("system_menu")
|
||||||
public class SystemMenuTb extends KitBaseUserTimeTb {
|
public class SystemMenuTb extends KitBaseUserTimeTb {
|
||||||
@NotNull(groups = {Update.class}) @TableId(value = "menu_id", type = IdType.AUTO)
|
|
||||||
@ApiModelProperty(value = "ID", hidden = true) private Long id;
|
|
||||||
@TableField(exist = false) @JSONField(serialize = false) @ApiModelProperty(value = "菜单角色")
|
|
||||||
private Set<SystemRoleTb> roles;
|
|
||||||
@TableField(exist = false) private List<SystemMenuTb> children;
|
|
||||||
@ApiModelProperty(value = "菜单标题") private String title;
|
|
||||||
@TableField(value = "name") @ApiModelProperty(value = "菜单组件名称") private String componentName;
|
|
||||||
@ApiModelProperty(value = "排序") private Integer menuSort = 999;
|
|
||||||
@ApiModelProperty(value = "组件路径") private String component;
|
|
||||||
@ApiModelProperty(value = "路由地址") private String path;
|
|
||||||
@ApiModelProperty(value = "菜单类型,目录、菜单、按钮") private Integer type;
|
|
||||||
@ApiModelProperty(value = "权限标识") private String permission;
|
|
||||||
@ApiModelProperty(value = "菜单图标") private String icon;
|
|
||||||
@ApiModelProperty(value = "缓存") private Boolean cache;
|
|
||||||
@ApiModelProperty(value = "是否隐藏") private Boolean hidden;
|
|
||||||
@ApiModelProperty(value = "上级菜单") private Long pid;
|
|
||||||
@ApiModelProperty(value = "子节点数目", hidden = true) private Integer subCount = 0;
|
|
||||||
@ApiModelProperty(value = "外链菜单") private Boolean iFrame;
|
|
||||||
|
|
||||||
@Override
|
@NotNull(groups = {Update.class})
|
||||||
public boolean equals(Object o) {
|
@TableId(value = "menu_id", type = IdType.AUTO)
|
||||||
if (this == o) {
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
return true;
|
private Long id;
|
||||||
}
|
@TableField(exist = false)
|
||||||
if (o == null || getClass() != o.getClass()) {
|
@JSONField(serialize = false)
|
||||||
return false;
|
@ApiModelProperty(value = "菜单角色")
|
||||||
}
|
private Set<SystemRoleTb> roles;
|
||||||
SystemMenuTb menu = (SystemMenuTb)o;
|
@TableField(exist = false)
|
||||||
return Objects.equals(id, menu.id);
|
private List<SystemMenuTb> children;
|
||||||
}
|
@ApiModelProperty(value = "菜单标题")
|
||||||
|
private String title;
|
||||||
|
@TableField(value = "name")
|
||||||
|
@ApiModelProperty(value = "菜单组件名称")
|
||||||
|
private String componentName;
|
||||||
|
@ApiModelProperty(value = "排序")
|
||||||
|
private Integer menuSort = 999;
|
||||||
|
@ApiModelProperty(value = "组件路径")
|
||||||
|
private String component;
|
||||||
|
@ApiModelProperty(value = "路由地址")
|
||||||
|
private String path;
|
||||||
|
@ApiModelProperty(value = "菜单类型,目录、菜单、按钮")
|
||||||
|
private Integer type;
|
||||||
|
@ApiModelProperty(value = "权限标识")
|
||||||
|
private String permission;
|
||||||
|
@ApiModelProperty(value = "菜单图标")
|
||||||
|
private String icon;
|
||||||
|
@ApiModelProperty(value = "缓存")
|
||||||
|
private Boolean cache;
|
||||||
|
@ApiModelProperty(value = "是否隐藏")
|
||||||
|
private Boolean hidden;
|
||||||
|
@ApiModelProperty(value = "上级菜单")
|
||||||
|
private Long pid;
|
||||||
|
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||||
|
private Integer subCount = 0;
|
||||||
|
@ApiModelProperty(value = "外链菜单")
|
||||||
|
private Boolean iFrame;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public boolean equals(Object o) {
|
||||||
return Objects.hash(id);
|
if (this == o) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
SystemMenuTb menu = (SystemMenuTb) o;
|
||||||
|
return Objects.equals(id, menu.id);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否有子节点")
|
@Override
|
||||||
public Boolean getHasChildren() {
|
public int hashCode() {
|
||||||
return subCount > 0;
|
return Objects.hash(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否为叶子")
|
@ApiModelProperty(value = "是否有子节点")
|
||||||
public Boolean getLeaf() {
|
public Boolean getHasChildren() {
|
||||||
return subCount <= 0;
|
return subCount > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty(value = "标签名称")
|
@ApiModelProperty(value = "是否为叶子")
|
||||||
public String getLabel() {
|
public Boolean getLeaf() {
|
||||||
return title;
|
return subCount <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "标签名称")
|
||||||
|
public String getLabel() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+57
-44
@@ -42,48 +42,61 @@ import lombok.ToString;
|
|||||||
@TableName("system_operation_log")
|
@TableName("system_operation_log")
|
||||||
@ApiModel(value = "SystemOperationLog对象", description = "审计日志")
|
@ApiModel(value = "SystemOperationLog对象", description = "审计日志")
|
||||||
public class SystemOperationLogTb extends KitObject {
|
public class SystemOperationLogTb extends KitObject {
|
||||||
/**
|
|
||||||
* id
|
/**
|
||||||
*/
|
* id
|
||||||
@ApiModelProperty("id") @TableId(value = "id", type = IdType.AUTO) private Long id;
|
*/
|
||||||
/**
|
@ApiModelProperty("id")
|
||||||
* 业务名称
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
*/
|
private Long id;
|
||||||
@TableField("biz_name") private String bizName;
|
/**
|
||||||
/**
|
* 业务名称
|
||||||
* 业务方法
|
*/
|
||||||
*/
|
@TableField("biz_name")
|
||||||
@TableField("method") private String method;
|
private String bizName;
|
||||||
/**
|
/**
|
||||||
* 业务参数
|
* 业务方法
|
||||||
*/
|
*/
|
||||||
@TableField("params") private String params;
|
@TableField("method")
|
||||||
/**
|
private String method;
|
||||||
* 访问来源IP
|
/**
|
||||||
*/
|
* 业务参数
|
||||||
@TableField("request_ip") private String requestIp;
|
*/
|
||||||
/**
|
@TableField("params")
|
||||||
* 执行时间
|
private String params;
|
||||||
*/
|
/**
|
||||||
@TableField("execute_time") private Long executeTime;
|
* 访问来源IP
|
||||||
/**
|
*/
|
||||||
* 用户名
|
@TableField("request_ip")
|
||||||
*/
|
private String requestIp;
|
||||||
@TableField("username") private String username;
|
/**
|
||||||
/**
|
* 执行时间
|
||||||
* 访问来源地址
|
*/
|
||||||
*/
|
@TableField("execute_time")
|
||||||
@TableField("address") private String address;
|
private Long executeTime;
|
||||||
/**
|
/**
|
||||||
* 浏览器信息
|
* 用户名
|
||||||
*/
|
*/
|
||||||
@TableField("browser_info") private String browserInfo;
|
@TableField("username")
|
||||||
/**
|
private String username;
|
||||||
* 异常详情
|
/**
|
||||||
*/
|
* 访问来源地址
|
||||||
@TableField("exception_detail") private String exceptionDetail;
|
*/
|
||||||
/**
|
@TableField("address")
|
||||||
* 创建时间
|
private String address;
|
||||||
*/
|
/**
|
||||||
@TableField(value = "create_time", fill = FieldFill.INSERT) private Date createTime;
|
* 浏览器信息
|
||||||
|
*/
|
||||||
|
@TableField("browser_info")
|
||||||
|
private String browserInfo;
|
||||||
|
/**
|
||||||
|
* 异常详情
|
||||||
|
*/
|
||||||
|
@TableField("exception_detail")
|
||||||
|
private String exceptionDetail;
|
||||||
|
/**
|
||||||
|
* 创建时间
|
||||||
|
*/
|
||||||
|
@TableField(value = "create_time", fill = FieldFill.INSERT)
|
||||||
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-13
@@ -38,17 +38,44 @@ import lombok.Setter;
|
|||||||
@TableName("system_oss_storage")
|
@TableName("system_oss_storage")
|
||||||
@ApiModel(value = "SystemOssStorage对象", description = "OSS存储")
|
@ApiModel(value = "SystemOssStorage对象", description = "OSS存储")
|
||||||
public class SystemOssStorageTb extends KitBaseUserTimeTb {
|
public class SystemOssStorageTb extends KitBaseUserTimeTb {
|
||||||
@ApiModelProperty("ID") @TableId(value = "id", type = IdType.AUTO) private Long id;
|
|
||||||
@TableField("service_type") @ApiModelProperty("类型,比如minio") private String serviceType;
|
@ApiModelProperty("ID")
|
||||||
@TableField("endpoint") @ApiModelProperty("服务地址") private String endpoint;
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
@TableField("bucket_name") @ApiModelProperty("存储桶名称") private String bucketName;
|
private Long id;
|
||||||
@TableField("file_name") @ApiModelProperty("完整文件名称") private String fileName;
|
@TableField("service_type")
|
||||||
@TableField("file_size") @ApiModelProperty("文件大小, 单位:字节") private Long fileSize;
|
@ApiModelProperty("类型,比如minio")
|
||||||
@TableField("file_mime") @ApiModelProperty("文件类型") private String fileMime;
|
private String serviceType;
|
||||||
@ApiModelProperty("短文件名") @TableField("file_prefix") private String filePrefix;
|
@TableField("endpoint")
|
||||||
@ApiModelProperty("文件后缀") @TableField("file_suffix") private String fileSuffix;
|
@ApiModelProperty("服务地址")
|
||||||
@TableField("file_md5") @ApiModelProperty("文件md5") private String fileMd5;
|
private String endpoint;
|
||||||
@TableField("file_url") @ApiModelProperty("文件链接") private String fileUrl;
|
@TableField("bucket_name")
|
||||||
@TableField("file_code") @ApiModelProperty("文件编码") private String fileCode;
|
@ApiModelProperty("存储桶名称")
|
||||||
@TableField("object_name") @ApiModelProperty("对象路径") private String objectName;
|
private String bucketName;
|
||||||
|
@TableField("file_name")
|
||||||
|
@ApiModelProperty("完整文件名称")
|
||||||
|
private String fileName;
|
||||||
|
@TableField("file_size")
|
||||||
|
@ApiModelProperty("文件大小, 单位:字节")
|
||||||
|
private Long fileSize;
|
||||||
|
@TableField("file_mime")
|
||||||
|
@ApiModelProperty("文件类型")
|
||||||
|
private String fileMime;
|
||||||
|
@ApiModelProperty("短文件名")
|
||||||
|
@TableField("file_prefix")
|
||||||
|
private String filePrefix;
|
||||||
|
@ApiModelProperty("文件后缀")
|
||||||
|
@TableField("file_suffix")
|
||||||
|
private String fileSuffix;
|
||||||
|
@TableField("file_md5")
|
||||||
|
@ApiModelProperty("文件md5")
|
||||||
|
private String fileMd5;
|
||||||
|
@TableField("file_url")
|
||||||
|
@ApiModelProperty("文件链接")
|
||||||
|
private String fileUrl;
|
||||||
|
@TableField("file_code")
|
||||||
|
@ApiModelProperty("文件编码")
|
||||||
|
private String fileCode;
|
||||||
|
@TableField("object_name")
|
||||||
|
@ApiModelProperty("对象路径")
|
||||||
|
private String objectName;
|
||||||
}
|
}
|
||||||
|
|||||||
+36
-15
@@ -31,19 +31,40 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_quartz_job")
|
@TableName("system_quartz_job")
|
||||||
public class SystemQuartzJobTb extends KitBaseUserTimeTb {
|
public class SystemQuartzJobTb extends KitBaseUserTimeTb {
|
||||||
public static final String JOB_KEY = "JOB_KEY";
|
|
||||||
@TableId(value = "id", type = IdType.AUTO) @NotNull(groups = {Update.class}) private Long id;
|
public static final String JOB_KEY = "JOB_KEY";
|
||||||
@TableField(exist = false) @ApiModelProperty(value = "用于子任务唯一标识", hidden = true) private String uuid;
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
@ApiModelProperty(value = "定时器名称") private String jobName;
|
@NotNull(groups = {Update.class})
|
||||||
@NotBlank @ApiModelProperty(value = "Bean名称") private String beanName;
|
private Long id;
|
||||||
@NotBlank @ApiModelProperty(value = "方法名称") private String methodName;
|
@TableField(exist = false)
|
||||||
@ApiModelProperty(value = "参数") private String params;
|
@ApiModelProperty(value = "用于子任务唯一标识", hidden = true)
|
||||||
@NotBlank @ApiModelProperty(value = "cron表达式") private String cronExpression;
|
private String uuid;
|
||||||
@ApiModelProperty(value = "状态:暂停或启动") private Boolean isPause = false;
|
@ApiModelProperty(value = "定时器名称")
|
||||||
@ApiModelProperty(value = "负责人") private String personInCharge;
|
private String jobName;
|
||||||
@ApiModelProperty(value = "报警邮箱") private String email;
|
@NotBlank
|
||||||
@ApiModelProperty(value = "子任务") private String subTask;
|
@ApiModelProperty(value = "Bean名称")
|
||||||
@ApiModelProperty(value = "失败后暂停") private Boolean pauseAfterFailure;
|
private String beanName;
|
||||||
@NotBlank @ApiModelProperty(value = "备注") @TableField(updateStrategy = FieldStrategy.ALWAYS) private String
|
@NotBlank
|
||||||
description;
|
@ApiModelProperty(value = "方法名称")
|
||||||
|
private String methodName;
|
||||||
|
@ApiModelProperty(value = "参数")
|
||||||
|
private String params;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "cron表达式")
|
||||||
|
private String cronExpression;
|
||||||
|
@ApiModelProperty(value = "状态:暂停或启动")
|
||||||
|
private Boolean isPause = false;
|
||||||
|
@ApiModelProperty(value = "负责人")
|
||||||
|
private String personInCharge;
|
||||||
|
@ApiModelProperty(value = "报警邮箱")
|
||||||
|
private String email;
|
||||||
|
@ApiModelProperty(value = "子任务")
|
||||||
|
private String subTask;
|
||||||
|
@ApiModelProperty(value = "失败后暂停")
|
||||||
|
private Boolean pauseAfterFailure;
|
||||||
|
@NotBlank
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
@TableField(updateStrategy = FieldStrategy.ALWAYS)
|
||||||
|
private String
|
||||||
|
description;
|
||||||
}
|
}
|
||||||
+23
-10
@@ -30,14 +30,27 @@ import lombok.EqualsAndHashCode;
|
|||||||
@TableName("system_quartz_log")
|
@TableName("system_quartz_log")
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class SystemQuartzLogTb extends KitObject {
|
public class SystemQuartzLogTb extends KitObject {
|
||||||
@TableId(value = "id", type = IdType.AUTO) @ApiModelProperty(value = "ID", hidden = true) private Long id;
|
|
||||||
@ApiModelProperty(value = "任务名称", hidden = true) private String jobName;
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
@ApiModelProperty(value = "bean名称", hidden = true) private String beanName;
|
@ApiModelProperty(value = "ID", hidden = true)
|
||||||
@ApiModelProperty(value = "方法名称", hidden = true) private String methodName;
|
private Long id;
|
||||||
@ApiModelProperty(value = "参数", hidden = true) private String params;
|
@ApiModelProperty(value = "任务名称", hidden = true)
|
||||||
@ApiModelProperty(value = "cron表达式", hidden = true) private String cronExpression;
|
private String jobName;
|
||||||
@ApiModelProperty(value = "状态", hidden = true) private Boolean isSuccess;
|
@ApiModelProperty(value = "bean名称", hidden = true)
|
||||||
@ApiModelProperty(value = "异常详情", hidden = true) private String exceptionDetail;
|
private String beanName;
|
||||||
@ApiModelProperty(value = "执行耗时", hidden = true) private Long time;
|
@ApiModelProperty(value = "方法名称", hidden = true)
|
||||||
@TableField(fill = FieldFill.INSERT) @ApiModelProperty(value = "创建时间", hidden = true) private Date createTime;
|
private String methodName;
|
||||||
|
@ApiModelProperty(value = "参数", hidden = true)
|
||||||
|
private String params;
|
||||||
|
@ApiModelProperty(value = "cron表达式", hidden = true)
|
||||||
|
private String cronExpression;
|
||||||
|
@ApiModelProperty(value = "状态", hidden = true)
|
||||||
|
private Boolean isSuccess;
|
||||||
|
@ApiModelProperty(value = "异常详情", hidden = true)
|
||||||
|
private String exceptionDetail;
|
||||||
|
@ApiModelProperty(value = "执行耗时", hidden = true)
|
||||||
|
private Long time;
|
||||||
|
@TableField(fill = FieldFill.INSERT)
|
||||||
|
@ApiModelProperty(value = "创建时间", hidden = true)
|
||||||
|
private Date createTime;
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-2
@@ -25,6 +25,9 @@ import lombok.Setter;
|
|||||||
@Setter
|
@Setter
|
||||||
@TableName("system_roles_depts")
|
@TableName("system_roles_depts")
|
||||||
public class SystemRoleDeptTb extends KitObject {
|
public class SystemRoleDeptTb extends KitObject {
|
||||||
@TableField(value = "role_id") private Long roleId;
|
|
||||||
@TableField(value = "dept_id") private Long deptId;
|
@TableField(value = "role_id")
|
||||||
|
private Long roleId;
|
||||||
|
@TableField(value = "dept_id")
|
||||||
|
private Long deptId;
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user