Commit 81dd91f5 authored by zhengjie's avatar zhengjie
Browse files

[代码优化](v2.6):由于系统现在默认使用 fastjson 序列化,导致了 @JsonIgnore 失效,现使用 @JSONField(serialize = false) 替换

close https://github.com/elunez/eladmin/issues/548
parent 98838542
...@@ -73,6 +73,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer { ...@@ -73,6 +73,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
@Override @Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
// 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter(); FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
List<MediaType> supportMediaTypeList = new ArrayList<>(); List<MediaType> supportMediaTypeList = new ArrayList<>();
supportMediaTypeList.add(MediaType.APPLICATION_JSON_UTF8); supportMediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package me.zhengjie.modules.security.service.dto; package me.zhengjie.modules.security.service.dto;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.alibaba.fastjson.annotation.JSONField;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.modules.system.service.dto.UserDto;
...@@ -37,7 +37,7 @@ public class JwtUserDto implements UserDetails { ...@@ -37,7 +37,7 @@ public class JwtUserDto implements UserDetails {
private final List<Long> dataScopes; private final List<Long> dataScopes;
@JsonIgnore @JSONField(serialize = false)
private final List<GrantedAuthority> authorities; private final List<GrantedAuthority> authorities;
public Set<String> getRoles() { public Set<String> getRoles() {
...@@ -45,37 +45,37 @@ public class JwtUserDto implements UserDetails { ...@@ -45,37 +45,37 @@ public class JwtUserDto implements UserDetails {
} }
@Override @Override
@JsonIgnore @JSONField(serialize = false)
public String getPassword() { public String getPassword() {
return user.getPassword(); return user.getPassword();
} }
@Override @Override
@JsonIgnore @JSONField(serialize = false)
public String getUsername() { public String getUsername() {
return user.getUsername(); return user.getUsername();
} }
@JsonIgnore @JSONField(serialize = false)
@Override @Override
public boolean isAccountNonExpired() { public boolean isAccountNonExpired() {
return true; return true;
} }
@JsonIgnore @JSONField(serialize = false)
@Override @Override
public boolean isAccountNonLocked() { public boolean isAccountNonLocked() {
return true; return true;
} }
@JsonIgnore @JSONField(serialize = false)
@Override @Override
public boolean isCredentialsNonExpired() { public boolean isCredentialsNonExpired() {
return true; return true;
} }
@Override @Override
@JsonIgnore @JSONField(serialize = false)
public boolean isEnabled() { public boolean isEnabled() {
return user.getEnabled(); return user.getEnabled();
} }
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -44,7 +44,7 @@ public class Dept extends BaseEntity implements Serializable { ...@@ -44,7 +44,7 @@ public class Dept extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@JsonIgnore @JSONField(serialize = false)
@ManyToMany(mappedBy = "depts") @ManyToMany(mappedBy = "depts")
@ApiModelProperty(value = "角色") @ApiModelProperty(value = "角色")
private Set<Role> roles; private Set<Role> roles;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -44,7 +44,7 @@ public class Menu extends BaseEntity implements Serializable { ...@@ -44,7 +44,7 @@ public class Menu extends BaseEntity implements Serializable {
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
@JsonIgnore @JSONField(serialize = false)
@ManyToMany(mappedBy = "menus") @ManyToMany(mappedBy = "menus")
@ApiModelProperty(value = "菜单角色") @ApiModelProperty(value = "菜单角色")
private Set<Role> roles; private Set<Role> roles;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package me.zhengjie.modules.system.domain; package me.zhengjie.modules.system.domain;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.alibaba.fastjson.annotation.JSONField;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
...@@ -47,7 +47,7 @@ public class Role extends BaseEntity implements Serializable { ...@@ -47,7 +47,7 @@ public class Role extends BaseEntity implements Serializable {
@ApiModelProperty(value = "ID", hidden = true) @ApiModelProperty(value = "ID", hidden = true)
private Long id; private Long id;
@JsonIgnore @JSONField(serialize = false)
@ManyToMany(mappedBy = "roles") @ManyToMany(mappedBy = "roles")
@ApiModelProperty(value = "用户", hidden = true) @ApiModelProperty(value = "用户", hidden = true)
private Set<User> users; private Set<User> users;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
*/ */
package me.zhengjie.modules.system.service.dto; package me.zhengjie.modules.system.service.dto;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.alibaba.fastjson.annotation.JSONField;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import me.zhengjie.base.BaseDTO; import me.zhengjie.base.BaseDTO;
...@@ -55,12 +55,12 @@ public class UserDto extends BaseDTO implements Serializable { ...@@ -55,12 +55,12 @@ public class UserDto extends BaseDTO implements Serializable {
private String avatarPath; private String avatarPath;
@JsonIgnore @JSONField(serialize = false)
private String password; private String password;
private Boolean enabled; private Boolean enabled;
@JsonIgnore @JSONField(serialize = false)
private Boolean isAdmin = false; private Boolean isAdmin = false;
private Date pwdResetTime; private Date pwdResetTime;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment