✨ 新增BladeView视图序列化机制,支持按角色动态控制JSON输出字段
This commit is contained in:
parent
b75c9ebddb
commit
18d58b89e4
|
|
@ -3,6 +3,8 @@ package org.springblade.desk.vo;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.tool.jackson.BladeView;
|
||||
import org.springblade.core.tool.jackson.Views;
|
||||
import org.springblade.desk.entity.Notice;
|
||||
|
||||
/**
|
||||
|
|
@ -14,6 +16,7 @@ import org.springblade.desk.entity.Notice;
|
|||
@EqualsAndHashCode(callSuper = true)
|
||||
public class NoticeVO extends Notice {
|
||||
|
||||
@BladeView(Views.Summary.class)
|
||||
@Schema(description = "通知类型名")
|
||||
private String categoryName;
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
|||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.springblade.core.tool.jackson.BladeView;
|
||||
import org.springblade.core.tool.jackson.Views;
|
||||
import org.springblade.system.user.entity.User;
|
||||
|
||||
import java.io.Serial;
|
||||
|
|
@ -45,20 +47,24 @@ public class UserVO extends User {
|
|||
/**
|
||||
* 角色名
|
||||
*/
|
||||
@BladeView(Views.Summary.class)
|
||||
private String roleName;
|
||||
|
||||
/**
|
||||
* 部门名
|
||||
*/
|
||||
@BladeView(Views.Summary.class)
|
||||
private String deptName;
|
||||
|
||||
/**
|
||||
* 岗位名
|
||||
*/
|
||||
@BladeView(Views.Detail.class)
|
||||
private String postName;
|
||||
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
@BladeView(Views.Detail.class)
|
||||
private String sexName;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import org.springblade.core.boot.ctrl.BladeController;
|
|||
import org.springblade.core.mp.support.Condition;
|
||||
import org.springblade.core.mp.support.Query;
|
||||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.jackson.BladeView;
|
||||
import org.springblade.core.tool.jackson.Views;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.desk.entity.Notice;
|
||||
import org.springblade.desk.service.INoticeService;
|
||||
|
|
@ -56,6 +58,7 @@ public class NoticeController extends BladeController implements CacheNames {
|
|||
* 详情
|
||||
*/
|
||||
@GetMapping("/detail")
|
||||
@BladeView(Views.Detail.class)
|
||||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "详情", description = "传入notice")
|
||||
public R<NoticeVO> detail(Notice notice) {
|
||||
|
|
@ -67,6 +70,7 @@ public class NoticeController extends BladeController implements CacheNames {
|
|||
* 分页
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@BladeView(Views.Summary.class)
|
||||
@Parameters({
|
||||
@Parameter(name = "category", description = "公告类型", in = ParameterIn.QUERY, schema = @Schema(type = "integer")),
|
||||
@Parameter(name = "title", description = "公告标题", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ import org.springblade.core.secure.utils.SecureUtil;
|
|||
import org.springblade.core.tool.api.R;
|
||||
import org.springblade.core.tool.constant.BladeConstant;
|
||||
import org.springblade.core.tool.constant.RoleConstant;
|
||||
import org.springblade.core.tool.jackson.BladeView;
|
||||
import org.springblade.core.tool.jackson.Views;
|
||||
import org.springblade.core.tool.utils.Func;
|
||||
import org.springblade.core.tool.utils.StringUtil;
|
||||
import org.springblade.system.excel.UserExcel;
|
||||
|
|
@ -83,6 +85,7 @@ public class UserController {
|
|||
@ApiOperationSupport(order = 1)
|
||||
@Operation(summary = "查看详情", description = "传入id")
|
||||
@GetMapping("/detail")
|
||||
@BladeView(Views.Admin.class)
|
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
|
||||
public R<UserVO> detail(User user) {
|
||||
User detail = userService.getOne(Condition.getQueryWrapper(user));
|
||||
|
|
@ -95,6 +98,7 @@ public class UserController {
|
|||
@ApiOperationSupport(order = 2)
|
||||
@Operation(summary = "查看详情", description = "传入id")
|
||||
@GetMapping("/info")
|
||||
@BladeView
|
||||
public R<UserVO> info(BladeUser user) {
|
||||
User detail = userService.getById(user.getUserId());
|
||||
return R.data(UserWrapper.build().entityVO(detail));
|
||||
|
|
@ -104,6 +108,7 @@ public class UserController {
|
|||
* 用户列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
@BladeView(Views.Admin.class)
|
||||
@Parameters({
|
||||
@Parameter(name = "account", description = "账号名", in = ParameterIn.QUERY, schema = @Schema(type = "string")),
|
||||
@Parameter(name = "realName", description = "姓名", in = ParameterIn.QUERY, schema = @Schema(type = "string"))
|
||||
|
|
@ -202,6 +207,7 @@ public class UserController {
|
|||
* @return
|
||||
*/
|
||||
@GetMapping("/user-list")
|
||||
@BladeView(Views.Admin.class)
|
||||
@ApiOperationSupport(order = 10)
|
||||
@PreAuth(RoleConstant.HAS_ROLE_ADMIN)
|
||||
@Operation(summary = "用户列表", description = "传入user")
|
||||
|
|
|
|||
|
|
@ -94,6 +94,24 @@ blade:
|
|||
sign-key: ${BLADE_TOKEN_SIGN_KEY}
|
||||
#使用 @org.springblade.test.SignKeyGenerator 获取
|
||||
aes-key: ${BLADE_TOKEN_CRYPTO_KEY}
|
||||
#jackson配置
|
||||
jackson:
|
||||
#null自动转空值
|
||||
null-to-empty: true
|
||||
#大数字自动转字符串
|
||||
big-num-to-string: true
|
||||
#支持text文本请求,与报文加密同时开启
|
||||
support-text-plain: false
|
||||
#视图配置
|
||||
view:
|
||||
#动态模式的默认视图
|
||||
default-view: summary
|
||||
#角色→视图映射
|
||||
role-mapping:
|
||||
administrator: administrator
|
||||
admin: admin
|
||||
user: detail
|
||||
guest: summary
|
||||
xss:
|
||||
enabled: true
|
||||
skip-url:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user