diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/AuthorizationController.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/AuthorizationController.java index 1dd7e4fb8..23a3bd2d4 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/AuthorizationController.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/AuthorizationController.java @@ -19,6 +19,10 @@ package org.hswebframework.web.authorization.basic.web; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.SneakyThrows; import org.hswebframework.web.authorization.Authentication; import org.hswebframework.web.authorization.ReactiveAuthenticationManager; @@ -34,6 +38,7 @@ import org.hswebframework.web.authorization.simple.PlainTextUsernamePasswordAuth import org.hswebframework.web.logging.AccessLogger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; +import org.springframework.data.repository.query.Param; import org.springframework.http.MediaType; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; @@ -47,6 +52,7 @@ import java.util.function.Function; */ @RestController @RequestMapping("${hsweb.web.mappings.authorize:authorize}") +@Tag(name = "授权接口") public class AuthorizationController { @@ -58,7 +64,7 @@ public class AuthorizationController { @GetMapping("/me") @Authorize - @ApiOperation("当前登录用户权限信息") + @Operation(summary = "当前登录用户权限信息") public Mono me() { return Authentication.currentReactive() .switchIfEmpty(Mono.error(UnAuthorizedException::new)); @@ -68,7 +74,8 @@ public class AuthorizationController { @ApiOperation("用户名密码登录,json方式") @Authorize(ignore = true) @AccessLogger(ignore = true) - public Mono> authorizeByJson(@ApiParam(example = "{\"username\":\"admin\",\"password\":\"admin\"}") + @Operation(summary = "登录",description = "必要参数:username,password.根据配置不同,其他参数也不同,如:验证码等.") + public Mono> authorizeByJson(@Parameter(example = "{\"username\":\"admin\",\"password\":\"admin\"}") @RequestBody Mono> parameter) { return doLogin(parameter); } diff --git a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/ReactiveUserTokenController.java b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/ReactiveUserTokenController.java index 15c9a4855..1316853c2 100644 --- a/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/ReactiveUserTokenController.java +++ b/hsweb-authorization/hsweb-authorization-basic/src/main/java/org/hswebframework/web/authorization/basic/web/ReactiveUserTokenController.java @@ -1,6 +1,7 @@ package org.hswebframework.web.authorization.basic.web; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.authorization.Authentication; import org.hswebframework.web.authorization.ReactiveAuthenticationManager; import org.hswebframework.web.authorization.annotation.Authorize; @@ -24,6 +25,7 @@ import reactor.core.publisher.Mono; @RequestMapping @Authorize @Resource(id = "user-token", name = "用户令牌信息管理") +@Tag(name = "用户令牌管理") public class ReactiveUserTokenController { private UserTokenManager userTokenManager; @@ -43,7 +45,7 @@ public class ReactiveUserTokenController { @GetMapping("/user-token/reset") @Authorize(merge = false) - @ApiOperation("重置当前用户的令牌") + @Operation(summary = "重置当前用户的令牌") public Mono resetToken() { return ContextUtils.reactiveContext() .map(context -> context.get(ContextKey.of(ParsedToken.class)).orElseThrow(UnAuthorizedException::new)) @@ -52,7 +54,7 @@ public class ReactiveUserTokenController { } @PutMapping("/user-token/check") - @ApiOperation("检查所有已过期的token并移除") + @Operation(summary = "检查所有已过期的token并移除") @SaveAction public Mono checkExpiredToken() { return userTokenManager @@ -61,63 +63,63 @@ public class ReactiveUserTokenController { } @GetMapping("/user-token/token/{token}") - @ApiOperation("根据token获取令牌信息") + @Operation(summary = "根据token获取令牌信息") @QueryAction public Mono getByToken(@PathVariable String token) { return userTokenManager.getByToken(token); } @GetMapping("/user-token/user/{userId}") - @ApiOperation("根据用户ID获取全部令牌信息") + @Operation(summary = "根据用户ID获取全部令牌信息") @QueryAction public Flux getByUserId(@PathVariable String userId) { return userTokenManager.getByUserId(userId); } @GetMapping("/user-token/user/{userId}/logged") - @ApiOperation("根据用户ID判断用户是否已经登录") + @Operation(summary = "根据用户ID判断用户是否已经登录") @QueryAction public Mono userIsLoggedIn(@PathVariable String userId) { return userTokenManager.userIsLoggedIn(userId); } @GetMapping("/user-token/token/{token}/logged") - @ApiOperation("根据令牌判断用户是否已经登录") + @Operation(summary = "根据令牌判断用户是否已经登录") @QueryAction public Mono tokenIsLoggedIn(@PathVariable String token) { return userTokenManager.tokenIsLoggedIn(token); } @GetMapping("/user-token/user/total") - @ApiOperation("获取当前已经登录的用户数量") + @Operation(summary = "获取当前已经登录的用户数量") @Authorize(merge = false) public Mono totalUser() { return userTokenManager.totalUser(); } @GetMapping("/user-token/token/total") - @ApiOperation("获取当前已经登录的令牌数量") + @Operation(summary = "获取当前已经登录的令牌数量") @Authorize(merge = false) public Mono totalToken() { return userTokenManager.totalToken(); } @GetMapping("/user-token") - @ApiOperation("获取全部用户令牌信息") + @Operation(summary = "获取全部用户令牌信息") @QueryAction public Flux allLoggedUser() { return userTokenManager.allLoggedUser(); } @DeleteMapping("/user-token/user/{userId}") - @ApiOperation("根据用户id将用户踢下线") + @Operation(summary = "根据用户id将用户踢下线") @SaveAction public Mono signOutByUserId(@PathVariable String userId) { return userTokenManager.signOutByUserId(userId); } @DeleteMapping("/user-token/token/{token}") - @ApiOperation("根据令牌将用户踢下线") + @Operation(summary = "根据令牌将用户踢下线") @SaveAction public Mono signOutByToken(@PathVariable String token) { return userTokenManager.signOutByToken(token); @@ -126,35 +128,35 @@ public class ReactiveUserTokenController { @SaveAction @PutMapping("/user-token/user/{userId}/{state}") - @ApiOperation("根据用户id更新用户令牌状态") + @Operation(summary = "根据用户id更新用户令牌状态") public Mono changeUserState(@PathVariable String userId, @PathVariable TokenState state) { return userTokenManager.changeUserState(userId, state); } @PutMapping("/user-token/token/{token}/{state}") - @ApiOperation("根据令牌更新用户令牌状态") + @Operation(summary = "根据令牌更新用户令牌状态") @SaveAction public Mono changeTokenState(@PathVariable String token, @PathVariable TokenState state) { return userTokenManager.changeTokenState(token, state); } - - @PostMapping("/user-token/{token}/{type}/{userId}/{maxInactiveInterval}") - @ApiOperation("将用户设置为登录") - @SaveAction - public Mono signIn(@PathVariable String token, @PathVariable String type, @PathVariable String userId, @PathVariable long maxInactiveInterval) { - return userTokenManager.signIn(token, type, userId, maxInactiveInterval); - } +// +// @PostMapping("/user-token/{token}/{type}/{userId}/{maxInactiveInterval}") +// @Operation(summary = "将用户设置为登录") +// @SaveAction +// public Mono signIn(@PathVariable String token, @PathVariable String type, @PathVariable String userId, @PathVariable long maxInactiveInterval) { +// return userTokenManager.signIn(token, type, userId, maxInactiveInterval); +// } @GetMapping("/user-token/{token}/touch") - @ApiOperation("更新token有效期") + @Operation(summary = "更新token有效期") @SaveAction public Mono touch(@PathVariable String token) { return userTokenManager.touch(token); } @GetMapping("/user-auth/{userId}") - @ApiOperation("根据用户id获取用户的权限信息") + @Operation(summary = "根据用户id获取权限信息") @SaveAction public Mono userAuthInfo(@PathVariable String userId) { return authenticationManager.getByUserId(userId); diff --git a/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/GenericTreeSortSupportEntity.java b/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/GenericTreeSortSupportEntity.java index b29aa7624..aedfce11a 100644 --- a/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/GenericTreeSortSupportEntity.java +++ b/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/GenericTreeSortSupportEntity.java @@ -19,6 +19,7 @@ package org.hswebframework.web.api.crud.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import org.hswebframework.ezorm.rdb.mapping.annotation.Comment; @@ -37,6 +38,7 @@ public abstract class GenericTreeSortSupportEntity extends GenericEntity */ @Column(name = "parent_id", length = 32) @Comment("父级ID") + @Schema(description = "父节点ID") private PK parentId; /** @@ -45,6 +47,7 @@ public abstract class GenericTreeSortSupportEntity extends GenericEntity */ @Column(name = "path", length = 128) @Comment("树路径") + @Schema(description = "树结构路径") private String path; /** @@ -52,10 +55,12 @@ public abstract class GenericTreeSortSupportEntity extends GenericEntity */ @Column(name = "sort_index", precision = 32) @Comment("排序序号") + @Schema(description = "排序序号") private Long sortIndex; @Column(name = "_level", precision = 32) @Comment("树层级") + @Schema(description = "树层级") private Integer level; diff --git a/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java b/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java index b4e168d0c..93982d43d 100644 --- a/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java +++ b/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java @@ -66,17 +66,17 @@ public class MethodInterceptorHolder { argMap); } - private String id; + private final String id; - private Method method; + private final Method method; - private Object target; + private final Object target; - private Object[] arguments; + private final Object[] arguments; - private String[] argumentsNames; + private final String[] argumentsNames; - private Map namedArguments; + private final Map namedArguments; public T findMethodAnnotation(Class annClass) { diff --git a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java index b9c6a8bd0..c0b91a8c7 100644 --- a/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java +++ b/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java @@ -4,6 +4,7 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.aop.MethodInterceptorHolder; import org.hswebframework.web.logging.LoggerDefine; +import org.springframework.core.annotation.AnnotatedElementUtils; import org.springframework.core.annotation.AnnotationUtils; import org.springframework.util.StringUtils; @@ -22,7 +23,7 @@ public class Swagger3AccessLoggerParser implements AccessLoggerParser { @Override public LoggerDefine parse(MethodInterceptorHolder holder) { Tag api = holder.findAnnotation(Tag.class); - Operation operation = holder.findAnnotation(Operation.class); + Operation operation = AnnotatedElementUtils.findMergedAnnotation(holder.getMethod(),Operation.class); String action = ""; if (api != null) { action = action.concat(api.name()); diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ActionEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ActionEntity.java index be59e548f..f468dd118 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ActionEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ActionEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import org.hswebframework.web.api.crud.entity.Entity; @@ -13,11 +14,15 @@ import java.util.Map; @EqualsAndHashCode(of = "action") public class ActionEntity implements Entity { + @Schema(description = "操作标识,如: add,query") private String action; + @Schema(description = "名称") private String name; + @Schema(description = "说明") private String describe; + @Schema(description = "其他配置") private Map properties; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/AuthorizationSettingEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/AuthorizationSettingEntity.java index 0c8ab0d41..e07059b88 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/AuthorizationSettingEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/AuthorizationSettingEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType; @@ -31,48 +32,58 @@ public class AuthorizationSettingEntity implements Entity { @Column(length = 32, nullable = false, updatable = false) @Comment("权限ID") @NotBlank(message = "权限ID不能为空",groups = CreateGroup.class) + @Schema(description = "权限ID") private String permission; @Column(name = "dimension_type",length = 32, nullable = false,updatable = false) @Comment("维度类型")//如:user,role @NotBlank(message = "维度不能为空",groups = CreateGroup.class) + @Schema(description = "维度类型,如: user,role") private String dimensionType; @Column(name = "dimension_type_name", length = 64) @Comment("维度类型名称")//如:用户,角色 + @Schema(description = "维度类型名称,如: 用户,角色") private String dimensionTypeName; @Column(name = "dimension_target", length = 32, updatable = false) @Comment("维度目标")//具体的某个维度实例ID @NotBlank(message = "维度目标不能为空",groups = CreateGroup.class) + @Schema(description = "维度目标,如: 用户的ID,角色的ID") private String dimensionTarget; @Column(name = "dimension_target_name", length = 64) @Comment("维度目标名称")//维度实例名称.如: 用户名. 角色名 + @Schema(description = "维度类型,如: 用户名,角色名") private String dimensionTargetName; @Column(name = "state", nullable = false) @Comment("状态") @NotNull(message = "状态不能为空",groups = CreateGroup.class) + @Schema(description = "状态,0禁用,1启用") private Byte state; @Column @ColumnType(jdbcType = JDBCType.CLOB) @JsonCodec @Comment("可操作权限") + @Schema(description = "授权可对此权限进行的操作") private Set actions; @Column(name = "data_accesses") @ColumnType(jdbcType = JDBCType.CLOB) @JsonCodec @Comment("数据权限") + @Schema(description = "数据权限配置") private List dataAccesses; @Column @Comment("优先级") + @Schema(description = "冲突时,合并优先级") private Integer priority; @Column @Comment("是否合并") + @Schema(description = "冲突时,是否合并") private Boolean merge; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DataAccessEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DataAccessEntity.java index c8fad2ef4..0264782c6 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DataAccessEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DataAccessEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; @@ -11,12 +12,16 @@ import java.util.Set; @Setter public class DataAccessEntity { + @Schema(description = "操作标识") private String action; + @Schema(description = "数据权限类型") private String type; + @Schema(description = "说明") private String describe; + @Schema(description = "配置") private Map config; public Map toMap(){ diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionEntity.java index 944327e10..be53968f5 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType; @@ -23,21 +24,26 @@ public class DimensionEntity extends GenericTreeSortSupportEntity { @Comment("维度类型ID") @Column(length = 32,name = "type_id") + @Schema(description = "维度类型ID") private String typeId; @Comment("维度名称") @Column(length = 32) + @Schema(description = "维度名称") private String name; @Comment("描述") @Column(length = 256) + @Schema(description = "说明") private String describe; @Column @ColumnType(jdbcType = JDBCType.LONGVARCHAR) @Comment("其他配置") @JsonCodec + @Schema(description = "其他配置") private Map properties; + @Schema(description = "子节点") private List children; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionTypeEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionTypeEntity.java index 0b3ac5cbb..216c45b6d 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionTypeEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionTypeEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import org.hswebframework.ezorm.rdb.mapping.annotation.Comment; @@ -20,10 +21,12 @@ public class DimensionTypeEntity extends GenericEntity implements Dimens @Comment("维度类型名称") @Column(length = 32, nullable = false) @NotBlank(message = "名称不能为空", groups = CreateGroup.class) + @Schema(description = "类型名称") private String name; @Comment("维度类型描述") @Column(length = 256) + @Schema(description = "说明") private String describe; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java index 9ad3f087e..9008e09ee 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/DimensionUserEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType; @@ -12,6 +13,7 @@ import org.hswebframework.web.system.authorization.api.enums.DimensionUserFeatur import javax.persistence.Column; import javax.persistence.Index; import javax.persistence.Table; +import javax.validation.constraints.NotBlank; import java.sql.JDBCType; @Getter @@ -26,35 +28,44 @@ public class DimensionUserEntity extends GenericEntity { @Comment("维度类型ID") @Column(name = "dimension_type_id", nullable = false, length = 32) + @Schema(description = "维度类型ID,如: org,tenant") private String dimensionTypeId; @Comment("维度ID") @Column(name = "dimension_id", nullable = false, length = 32) + @Schema(description = "维度ID") private String dimensionId; @Comment("维度名称") @Column(name = "dimension_name", nullable = false) + @NotBlank(message = "[dimensionName]不能为空") + @Schema(description = "维度名称") private String dimensionName; @Comment("用户ID") @Column(name = "user_id", nullable = false, length = 32) + @Schema(description = "用户ID") private String userId; - @Comment("用户ID") + @Comment("用户名") @Column(name = "user_name", nullable = false) + @Schema(description = "用户名") private String userName; @Comment("关系") @Column(length = 32) + @Schema(description = "维度关系") private String relation; @Column(name = "relation_name") @Comment("关系名称") + @Schema(description = "维度关系名称") private String relationName; @Column(name = "features") @ColumnType(jdbcType = JDBCType.NUMERIC, javaType = Long.class) @EnumCodec(toMask = true) + @Schema(description = "其他功能") private DimensionUserFeature[] features; public boolean hasFeature(DimensionUserFeature feature) { diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/OptionalField.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/OptionalField.java index 045720fd4..57835eafc 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/OptionalField.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/OptionalField.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.Getter; @@ -11,9 +12,13 @@ import java.util.Map; @Data @EqualsAndHashCode(of = "name") public class OptionalField implements Entity { + + @Schema(description = "字段名") private String name; + @Schema(description = "说明") private String describe; + @Schema(description = "其他配置") private Map properties; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ParentPermission.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ParentPermission.java index 3581e8cdd..d9f4c4f2b 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ParentPermission.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/ParentPermission.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import org.hswebframework.web.api.crud.entity.Entity; @@ -11,12 +12,16 @@ public class ParentPermission implements Entity { private static final long serialVersionUID = -7099575758680437572L; + @Schema(description = "关联限标识") private String permission; + @Schema(description = "前置操作") private Set preActions; + @Schema(description = "关联操作") private Set actions; + @Schema(description = "其他配置") private Map properties; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/PermissionEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/PermissionEntity.java index ad8c0482d..23c89b341 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/PermissionEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/PermissionEntity.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.api.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType; import org.hswebframework.ezorm.rdb.mapping.annotation.Comment; @@ -23,38 +24,45 @@ public class PermissionEntity extends GenericEntity { @Column @Comment("权限名称") + @Schema(description = "权限名称") private String name; @Column @Comment("说明") + @Schema(description = "说明") private String describe; @Column(nullable = false) @Comment("状态") + @Schema(description = "状态") private Byte status; @Column @ColumnType(jdbcType = JDBCType.LONGVARCHAR) @JsonCodec @Comment("可选操作") + @Schema(description = "可选操作") private List actions; @Column(name = "optional_fields") @ColumnType(jdbcType = JDBCType.LONGVARCHAR) @JsonCodec @Comment("可操作的字段") + @Schema(description = "可操作字段") private List optionalFields; @Column @ColumnType(jdbcType = JDBCType.LONGVARCHAR) @JsonCodec @Comment("关联权限") + @Schema(description = "关联权限") private List parents; @Column @ColumnType(jdbcType = JDBCType.LONGVARCHAR) @JsonCodec @Comment("其他配置") + @Schema(description = "其他配置") private Map properties; } diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/UserEntity.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/UserEntity.java index 32e520699..40995f406 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/UserEntity.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/entity/UserEntity.java @@ -1,6 +1,8 @@ package org.hswebframework.web.system.authorization.api.entity; import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.Hidden; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue; @@ -24,35 +26,43 @@ public class UserEntity extends GenericEntity implements RecordCreationE @Column(length = 128, nullable = false) @NotBlank(message = "姓名不能为空", groups = CreateGroup.class) + @Schema(description = "姓名") private String name; @Column(length = 128, nullable = false, updatable = false) @NotBlank(message = "用户名不能为空", groups = CreateGroup.class) + @Schema(description = "用户名") private String username; @Column(nullable = false) @ToString.Ignore(cover = false) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) @NotBlank(message = "密码不能为空", groups = CreateGroup.class) + @Schema(description = "密码") private String password; @Column(nullable = false) @ToString.Ignore(cover = false) @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) + @Hidden private String salt; @Column + @Schema(description = "用户类型") private String type; @Column @DefaultValue("1") + @Schema(description = "用户状态") private Byte status; @Column(name = "creator_id", updatable = false) + @Hidden private String creatorId; @Column(name = "create_time", updatable = false) @DefaultValue(generator = "current_time") + @Hidden private Long createTime; @Override diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/enums/DimensionUserFeature.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/enums/DimensionUserFeature.java index c069c708b..2d40010aa 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/enums/DimensionUserFeature.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-api/src/main/java/org/hswebframework/web/system/authorization/api/enums/DimensionUserFeature.java @@ -10,7 +10,7 @@ public enum DimensionUserFeature implements EnumDict { mergeChildrenPermission("合并子级维度权限") ; - private String text; + private final String text; @Override public String getValue() { diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/DimensionTypeResponse.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/DimensionTypeResponse.java index 465e034dc..ae40f1423 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/DimensionTypeResponse.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/DimensionTypeResponse.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.defaults.webflux; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,8 +13,10 @@ import org.hswebframework.web.authorization.DimensionType; @NoArgsConstructor public class DimensionTypeResponse { + @Schema(description = "类型ID") private String id; + @Schema(description = "类型名称") private String name; public static DimensionTypeResponse of(DimensionType type) { diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxAuthorizationSettingController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxAuthorizationSettingController.java index bd7b8e5b7..1162ee232 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxAuthorizationSettingController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxAuthorizationSettingController.java @@ -1,11 +1,10 @@ package org.hswebframework.web.system.authorization.defaults.webflux; -import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.authorization.annotation.Authorize; import org.hswebframework.web.authorization.annotation.Resource; import org.hswebframework.web.crud.service.ReactiveCrudService; -import org.hswebframework.web.crud.web.reactive.ReactiveCrudController; import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController; import org.hswebframework.web.system.authorization.api.entity.AuthorizationSettingEntity; import org.hswebframework.web.system.authorization.defaults.service.DefaultAuthorizationSettingService; @@ -17,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/autz-setting") @Authorize @Resource(id = "autz-setting",name = "权限分配",group = "system") +@Tag(name = "权限分配") public class WebFluxAuthorizationSettingController implements ReactiveServiceCrudController { @Autowired diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionController.java index ad752120a..024982dd9 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionController.java @@ -1,5 +1,6 @@ package org.hswebframework.web.system.authorization.defaults.webflux; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.authorization.annotation.Authorize; import org.hswebframework.web.authorization.annotation.Resource; import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/dimension") @Authorize @Resource(id = "dimension", name = "权限维度管理", group = "system") +@Tag(name = "权限维度管理") public class WebFluxDimensionController implements ReactiveServiceCrudController , ReactiveTreeServiceQueryController { diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionTypeController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionTypeController.java index 9b4801438..95d60038f 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionTypeController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionTypeController.java @@ -1,5 +1,8 @@ package org.hswebframework.web.system.authorization.defaults.webflux; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.ezorm.rdb.mapping.ReactiveRepository; import org.hswebframework.web.api.crud.entity.QueryParamEntity; import org.hswebframework.web.authorization.DimensionProvider; @@ -25,6 +28,7 @@ import java.util.List; @RequestMapping("/dimension-type") @Authorize @Resource(id = "dimension", name = "权限维度管理", group = "system") +@Tag(name = "权限维度类型管理") public class WebFluxDimensionTypeController implements ReactiveCrudController { @Autowired @@ -35,6 +39,7 @@ public class WebFluxDimensionTypeController implements ReactiveCrudController findAllType() { return Flux.fromIterable(dimensionProviders) .flatMap(DimensionProvider::getAllType) diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionUserController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionUserController.java index 4abb31953..29be550fc 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionUserController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxDimensionUserController.java @@ -1,5 +1,8 @@ package org.hswebframework.web.system.authorization.defaults.webflux; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.authorization.annotation.Authorize; import org.hswebframework.web.authorization.annotation.DeleteAction; import org.hswebframework.web.authorization.annotation.Resource; @@ -18,6 +21,7 @@ import reactor.core.publisher.Mono; @RequestMapping("/dimension-user") @Authorize @Resource(id = "dimension", name = "权限维度管理", group = "system") +@Tag(name = "权限维度用户关联管理") public class WebFluxDimensionUserController implements ReactiveServiceCrudController { @Autowired @@ -31,7 +35,11 @@ public class WebFluxDimensionUserController implements ReactiveServiceCrudContro @DeleteAction @DeleteMapping("/user/{userId}/dimension/{dimensionId}") - public Mono deleteByUserAndDimensionId(@PathVariable String userId, @PathVariable String dimensionId) { + @Operation(summary = "解除用户关联的指定维度") + public Mono deleteByUserAndDimensionId(@PathVariable + @Parameter(description = "用户ID") String userId, + @PathVariable + @Parameter(description = "维度ID") String dimensionId) { return dimensionUserService .createDelete() .where(DimensionUserEntity::getUserId, userId) @@ -41,7 +49,9 @@ public class WebFluxDimensionUserController implements ReactiveServiceCrudContro @DeleteAction @DeleteMapping("/user/{userId}") - public Mono deleteByUserId(@PathVariable String userId) { + @Operation(summary = "解除用户关联的全部维度") + public Mono deleteByUserId(@PathVariable + @Parameter(description = "用户ID") String userId) { return dimensionUserService .createDelete() .where(DimensionUserEntity::getUserId, userId) @@ -50,7 +60,9 @@ public class WebFluxDimensionUserController implements ReactiveServiceCrudContro @DeleteAction @DeleteMapping("/dimension/{dimensionId}") - public Mono deleteByDimension(@PathVariable String dimensionId) { + @Operation(summary = "解除全部用户关联的指定维度") + public Mono deleteByDimension(@PathVariable + @Parameter(description = "维度ID") String dimensionId) { return dimensionUserService .createDelete() .where(DimensionUserEntity::getDimensionId, dimensionId) diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxPermissionController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxPermissionController.java index 5265e8af4..bb9ba1788 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxPermissionController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxPermissionController.java @@ -1,5 +1,8 @@ package org.hswebframework.web.system.authorization.defaults.webflux; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.commons.collections.CollectionUtils; import org.hswebframework.web.authorization.annotation.Authorize; import org.hswebframework.web.authorization.annotation.QueryAction; @@ -17,8 +20,9 @@ import java.util.List; @RestController @RequestMapping("/permission") @Authorize -@Resource(id = "permission",name = "权限管理",group = "system") -public class WebFluxPermissionController implements ReactiveServiceCrudController { +@Resource(id = "permission", name = "权限管理", group = "system") +@Tag(name = "权限管理") +public class WebFluxPermissionController implements ReactiveServiceCrudController { @Autowired private DefaultPermissionService permissionService; @@ -30,7 +34,8 @@ public class WebFluxPermissionController implements ReactiveServiceCrudControlle @PutMapping("/status/{status}") @QueryAction - public Mono changePermissionState(@PathVariable Byte status, @RequestBody List idList) { + @Operation(summary = "批量修改权限状态") + public Mono changePermissionState(@PathVariable @Parameter(description = "状态值:0禁用,1启用.") Byte status, @RequestBody List idList) { return Mono.just(idList) .filter(CollectionUtils::isNotEmpty) diff --git a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxUserController.java b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxUserController.java index 65fc0885f..2cbc23d94 100644 --- a/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxUserController.java +++ b/hsweb-system/hsweb-system-authorization/hsweb-system-authorization-default/src/main/java/org/hswebframework/web/system/authorization/defaults/webflux/WebFluxUserController.java @@ -1,5 +1,8 @@ package org.hswebframework.web.system.authorization.defaults.webflux; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.Getter; import lombok.Setter; import org.hswebframework.web.authorization.Authentication; @@ -20,6 +23,7 @@ import reactor.core.publisher.Mono; @RequestMapping("/user") @Authorize @Resource(id = "user", name = "系统用户", group = "system") +@Tag(name = "用户管理") public class WebFluxUserController implements ReactiveServiceQueryController { @Autowired @@ -27,6 +31,7 @@ public class WebFluxUserController implements ReactiveServiceQueryController saveUser(@RequestBody Mono user) { return Authentication .currentReactive() @@ -39,20 +44,37 @@ public class WebFluxUserController implements ReactiveServiceQueryController updateLoginUserInfo(@RequestBody UserEntity request) { + return Authentication + .currentReactive() + .switchIfEmpty(Mono.error(UnAuthorizedException::new)) + .map(Authentication::getUser) + .map(User::getId) + .flatMap(userId -> reactiveUserService.updateById(userId, Mono.just(request)).map(integer -> integer > 0)); + } + @PutMapping("/{id:.+}/{state}") @SaveAction - public Mono changeState(@PathVariable String id, @PathVariable Byte state) { + @Operation(summary = "修改用户状态") + public Mono changeState(@PathVariable @Parameter(description = "用户ID") String id, + @PathVariable @Parameter(description = "状态,0禁用,1启用") Byte state) { return reactiveUserService.changeState(Mono.just(id), state); } @DeleteMapping("/{id:.+}") @DeleteAction + @Operation(summary = "删除用户") public Mono deleteUser(@PathVariable String id) { return reactiveUserService.deleteUser(id); } @PutMapping("/passwd") @Authorize(merge = false) + @Operation(summary = "修改当前用户密码") public Mono changePassword(@RequestBody ChangePasswordRequest request) { return Authentication .currentReactive() @@ -62,16 +84,6 @@ public class WebFluxUserController implements ReactiveServiceQueryController reactiveUserService.changePassword(userId, request.getOldPassword(), request.getNewPassword())); } - @PutMapping("/me") - @Authorize(merge = false) - public Mono updateLoginUserInfo(@RequestBody UserEntity request) { - return Authentication - .currentReactive() - .switchIfEmpty(Mono.error(UnAuthorizedException::new)) - .map(Authentication::getUser) - .map(User::getId) - .flatMap(userId -> reactiveUserService.updateById(userId, Mono.just(request)).map(integer -> integer > 0)); - } @Override public DefaultReactiveUserService getService() { diff --git a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryEntity.java b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryEntity.java index 37d522991..4dd1a001a 100644 --- a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryEntity.java +++ b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryEntity.java @@ -1,24 +1,26 @@ /* * Copyright 2019 http://www.hswebframework.org - * + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - * + * */ package org.hswebframework.web.dictionary.entity; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; +import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue; import org.hswebframework.web.api.crud.entity.GenericEntity; import org.hswebframework.web.api.crud.entity.RecordCreationEntity; import org.hswebframework.web.dict.DictDefine; @@ -41,29 +43,36 @@ public class DictionaryEntity extends GenericEntity implements RecordCre //字典名称 @Column(nullable = false) @NotBlank(message = "名称不能为空") - private String name; + @Schema(description = "字典名称") + private String name; //分类 - @Column(length = 32,name = "classified") - private String classified; + @Column(length = 32, name = "classified") + @Schema(description = "分类标识") + private String classified; //说明 @Column - private String describe; + @Schema(description = "说明") + private String describe; //创建时间 @Column(name = "create_time") - private Long createTime; + @Schema(description = "创建时间") + private Long createTime; //创建人id @Column(name = "creator_id") - private String creatorId; + @Schema(description = "创建人ID") + private String creatorId; //状态 @Column(name = "status") - private Byte status; + @DefaultValue("1") + @Schema(description = "状态,0禁用,1启用") + private Byte status; //字段选项 private List items; - public DictDefine toDictDefine(){ - return DefaultDictDefine + public DictDefine toDictDefine() { + return DefaultDictDefine .builder() .id(this.getId()) .alias(this.getName()) diff --git a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryItemEntity.java b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryItemEntity.java index 0f9fa477f..09d417b23 100644 --- a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryItemEntity.java +++ b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/entity/DictionaryItemEntity.java @@ -17,8 +17,10 @@ package org.hswebframework.web.dictionary.entity; import com.alibaba.fastjson.JSONObject; +import io.swagger.v3.oas.annotations.media.Schema; import lombok.Getter; import lombok.Setter; +import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue; import org.hswebframework.web.api.crud.entity.GenericTreeSortSupportEntity; import org.hswebframework.web.dict.EnumDict; @@ -40,31 +42,41 @@ import java.util.List; public class DictionaryItemEntity extends GenericTreeSortSupportEntity implements EnumDict { //字典id @Column(name = "dict_id", length = 32, updatable = false, nullable = false) + @Schema(description = "数据字典ID") private String dictId; //名称 @Column + @Schema(description = "选项名称") private String name; //字典值 @Column + @Schema(description = "值") private String value; //字典文本 @Column + @Schema(description = "文本内容") private String text; //字典值类型 @Column(name = "value_type") + @Schema(description = "值类型") private String valueType; //是否启用 @Column + @Schema(description = "状态,0禁用,1启用") + @DefaultValue("1") private Byte status; //说明 @Column + @Schema(description = "说明") private String describe; //快速搜索码 @Column(name = "search_code") + @Schema(description = "检索码") private String searchCode; @Column(name = "ordinal", nullable = false, updatable = false) + @Schema(description = "序列号,同一个字典中的选项不能重复,且不能修改.") private Integer ordinal; @Override @@ -72,6 +84,7 @@ public class DictionaryItemEntity extends GenericTreeSortSupportEntity i return ordinal == null ? 0 : ordinal; } + @Schema(description = "子节点") private List children; @Override diff --git a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryController.java b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryController.java index 504fc1c38..639a15fe2 100644 --- a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryController.java +++ b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryController.java @@ -1,5 +1,8 @@ package org.hswebframework.web.dictionary.webflux; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.authorization.annotation.Authorize; import org.hswebframework.web.authorization.annotation.Resource; import org.hswebframework.web.crud.service.ReactiveCrudService; @@ -20,6 +23,7 @@ import reactor.core.publisher.Flux; @RestController @RequestMapping("/dictionary") @Resource(id = "dictionary", name = "数据字典") +@Tag(name = "数据字典管理") public class WebfluxDictionaryController implements ReactiveServiceCrudController { @Autowired @@ -35,6 +39,7 @@ public class WebfluxDictionaryController implements ReactiveServiceCrudControlle @GetMapping("/{id:.+}/items") @Authorize(merge = false) + @Operation(summary = "获取数据字段的所有选项") public Flux> getItemDefineById(@PathVariable String id) { return repository.getDefine(id) .flatMapIterable(DictDefine::getItems); @@ -42,6 +47,7 @@ public class WebfluxDictionaryController implements ReactiveServiceCrudControlle @GetMapping("/_all") @Authorize(merge = false) + @Schema(description = "获取全部数据字典") public Flux getAllDict() { return repository.getAllDefine(); } diff --git a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryItemController.java b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryItemController.java index 796e89a00..66440b7fa 100644 --- a/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryItemController.java +++ b/hsweb-system/hsweb-system-dictionary/src/main/java/org/hswebframework/web/dictionary/webflux/WebfluxDictionaryItemController.java @@ -1,5 +1,6 @@ package org.hswebframework.web.dictionary.webflux; +import io.swagger.v3.oas.annotations.tags.Tag; import org.hswebframework.web.authorization.annotation.Resource; import org.hswebframework.web.crud.service.ReactiveCrudService; import org.hswebframework.web.crud.web.reactive.ReactiveServiceCrudController; @@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/dictionary-item") @Resource(id = "dictionary", name = "数据字典") +@Tag(name = "数据字典选项管理") public class WebfluxDictionaryItemController implements ReactiveServiceCrudController { @Autowired diff --git a/hsweb-system/hsweb-system-file/pom.xml b/hsweb-system/hsweb-system-file/pom.xml index 31934c016..f5546fa34 100644 --- a/hsweb-system/hsweb-system-file/pom.xml +++ b/hsweb-system/hsweb-system-file/pom.xml @@ -28,6 +28,12 @@ org.springframework.boot spring-boot-autoconfigure + + + io.swagger.core.v3 + swagger-annotations + + org.springframework.boot spring-boot-starter-webflux diff --git a/hsweb-system/hsweb-system-file/src/main/java/org/hswebframework/web/file/web/ReactiveFileController.java b/hsweb-system/hsweb-system-file/src/main/java/org/hswebframework/web/file/web/ReactiveFileController.java index 4abbb2767..4fb8909ec 100644 --- a/hsweb-system/hsweb-system-file/src/main/java/org/hswebframework/web/file/web/ReactiveFileController.java +++ b/hsweb-system/hsweb-system-file/src/main/java/org/hswebframework/web/file/web/ReactiveFileController.java @@ -1,5 +1,9 @@ package org.hswebframework.web.file.web; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.enums.ParameterStyle; +import io.swagger.v3.oas.annotations.tags.Tag; import lombok.SneakyThrows; import lombok.extern.slf4j.Slf4j; import org.hswebframework.web.authorization.annotation.Resource; @@ -21,15 +25,18 @@ import java.io.File; @Resource(id = "file", name = "文件上传") @Slf4j @RequestMapping("/file") +@Tag(name = "文件上传") public class ReactiveFileController { @Autowired private FileUploadProperties properties; - @ResourceAction(id = "upload-static", name = "静态文件") @PostMapping("/static") @SneakyThrows - public Mono uploadStatic(@RequestPart("file") Part part) { + @ResourceAction(id = "upload-static", name = "静态文件") + @Operation(summary = "上传静态文件") + public Mono uploadStatic(@RequestPart("file") + @Parameter(name = "file", description = "文件", style = ParameterStyle.FORM) Part part) { FileUploadProperties.StaticFileInfo name; if (part instanceof FilePart) { FilePart filePart = ((FilePart) part);