mirror of https://github.com/elunez/eladmin
[代码优化](v2.6):由于系统现在默认使用 fastjson 序列化,导致了 @JsonIgnore 失效,现使用 @JSONField(serialize = false) 替换
close https://github.com/elunez/eladmin/issues/548pull/562/head
parent
9883854211
commit
81dd91f573
|
@ -73,6 +73,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
|||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
// 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换
|
||||
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
|
||||
List<MediaType> supportMediaTypeList = new ArrayList<>();
|
||||
supportMediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
|
|
@ -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<Long> dataScopes;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
private final List<GrantedAuthority> authorities;
|
||||
|
||||
public Set<String> 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();
|
||||
}
|
||||
|
|
|
@ -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<Role> roles;
|
||||
|
|
|
@ -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<Role> roles;
|
||||
|
|
|
@ -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<User> users;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue