diff --git a/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java b/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java index 3a338d71..e76512b7 100644 --- a/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java +++ b/eladmin-system/src/main/java/me/zhengjie/config/ConfigurerAdapter.java @@ -73,6 +73,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer { @Override public void configureMessageConverters(List> converters) { + // 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换 FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); List supportMediaTypeList = new ArrayList<>(); supportMediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java index 0a59a5dc..00f4372c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/JwtUserDto.java @@ -15,7 +15,7 @@ */ package me.zhengjie.modules.security.service.dto; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import lombok.AllArgsConstructor; import lombok.Getter; import me.zhengjie.modules.system.service.dto.UserDto; @@ -37,7 +37,7 @@ public class JwtUserDto implements UserDetails { private final List dataScopes; - @JsonIgnore + @JSONField(serialize = false) private final List authorities; public Set getRoles() { @@ -45,37 +45,37 @@ public class JwtUserDto implements UserDetails { } @Override - @JsonIgnore + @JSONField(serialize = false) public String getPassword() { return user.getPassword(); } @Override - @JsonIgnore + @JSONField(serialize = false) public String getUsername() { return user.getUsername(); } - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isAccountNonExpired() { return true; } - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isAccountNonLocked() { return true; } - @JsonIgnore + @JSONField(serialize = false) @Override public boolean isCredentialsNonExpired() { return true; } @Override - @JsonIgnore + @JSONField(serialize = false) public boolean isEnabled() { return user.getEnabled(); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java index 1ca7f178..9f28af21 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Dept.java @@ -15,7 +15,7 @@ */ package me.zhengjie.modules.system.domain; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; @@ -44,7 +44,7 @@ public class Dept extends BaseEntity implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @JsonIgnore + @JSONField(serialize = false) @ManyToMany(mappedBy = "depts") @ApiModelProperty(value = "角色") private Set roles; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java index c5f80385..b2ea225d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Menu.java @@ -15,7 +15,7 @@ */ package me.zhengjie.modules.system.domain; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; @@ -44,7 +44,7 @@ public class Menu extends BaseEntity implements Serializable { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; - @JsonIgnore + @JSONField(serialize = false) @ManyToMany(mappedBy = "menus") @ApiModelProperty(value = "菜单角色") private Set roles; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java index 0dffa3c4..8b3ad19e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/Role.java @@ -15,7 +15,7 @@ */ package me.zhengjie.modules.system.domain; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; @@ -47,7 +47,7 @@ public class Role extends BaseEntity implements Serializable { @ApiModelProperty(value = "ID", hidden = true) private Long id; - @JsonIgnore + @JSONField(serialize = false) @ManyToMany(mappedBy = "roles") @ApiModelProperty(value = "用户", hidden = true) private Set users; diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java index 4af03b98..923e2d42 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserDto.java @@ -15,7 +15,7 @@ */ package me.zhengjie.modules.system.service.dto; -import com.fasterxml.jackson.annotation.JsonIgnore; +import com.alibaba.fastjson.annotation.JSONField; import lombok.Getter; import lombok.Setter; import me.zhengjie.base.BaseDTO; @@ -55,12 +55,12 @@ public class UserDto extends BaseDTO implements Serializable { private String avatarPath; - @JsonIgnore + @JSONField(serialize = false) private String password; private Boolean enabled; - @JsonIgnore + @JSONField(serialize = false) private Boolean isAdmin = false; private Date pwdResetTime;