From 5c46216594f30ab93470c280bc58633552c07304 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 13 Feb 2025 10:48:04 +0800 Subject: [PATCH] LoginUser --- .../com/bonus/system/api/model/LoginUser.java | 85 +++++++++++++++++++ .../gateway/config/GlobalCorsConfig.java | 33 +++++++ 2 files changed, 118 insertions(+) create mode 100644 bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java diff --git a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/model/LoginUser.java b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/model/LoginUser.java index d335a6f..cbb2856 100644 --- a/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/model/LoginUser.java +++ b/bonus-api/bonus-api-system/src/main/java/com/bonus/system/api/model/LoginUser.java @@ -3,6 +3,8 @@ package com.bonus.system.api.model; import java.io.Serializable; import java.util.Set; import com.bonus.system.api.domain.SysUser; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; /** * 用户信息 @@ -58,6 +60,25 @@ public class LoginUser implements Serializable */ private SysUser sysUser; + + @ApiModelProperty("人员id") + @JsonFormat(shape = JsonFormat.Shape.STRING) + private Long custId; + @ApiModelProperty("人员姓名") + private String custName; + @ApiModelProperty("人员编号") + private String custNum; + @ApiModelProperty("人脸照片地址") + private String custPhotoUrl; + @ApiModelProperty("电话号码") + private String mobile; + @ApiModelProperty("登录密码") + private String pwd; + @ApiModelProperty("") + private Long expireIn; + @ApiModelProperty("是否登录") + private boolean isLogin; + public String getToken() { return token; @@ -147,4 +168,68 @@ public class LoginUser implements Serializable { this.sysUser = sysUser; } + + public Long getCustId() { + return custId; + } + + public void setCustId(Long custId) { + this.custId = custId; + } + + public String getCustName() { + return custName; + } + + public void setCustName(String custName) { + this.custName = custName; + } + + public String getCustNum() { + return custNum; + } + + public void setCustNum(String custNum) { + this.custNum = custNum; + } + + public String getCustPhotoUrl() { + return custPhotoUrl; + } + + public void setCustPhotoUrl(String custPhotoUrl) { + this.custPhotoUrl = custPhotoUrl; + } + + public String getMobile() { + return mobile; + } + + public void setMobile(String mobile) { + this.mobile = mobile; + } + + public String getPwd() { + return pwd; + } + + public void setPwd(String pwd) { + this.pwd = pwd; + } + + public Long getExpireIn() { + return expireIn; + } + + public void setExpireIn(Long expireIn) { + this.expireIn = expireIn; + } + + public boolean isLogin() { + return isLogin; + } + + public void setLogin(boolean login) { + isLogin = login; + } } diff --git a/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java b/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java new file mode 100644 index 0000000..223ee47 --- /dev/null +++ b/bonus-gateway/src/main/java/com/bonus/gateway/config/GlobalCorsConfig.java @@ -0,0 +1,33 @@ +package com.bonus.gateway.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.cors.CorsConfiguration; +import org.springframework.web.cors.reactive.CorsWebFilter; +import org.springframework.web.cors.reactive.UrlBasedCorsConfigurationSource; +import org.springframework.web.util.pattern.PathPatternParser; + +/** + * Description: 全局跨域配置 + */ +@Configuration +public class GlobalCorsConfig { + @Bean + public CorsWebFilter corsFilter() { + // 创建一个新的CorsConfiguration对象,用于配置跨域请求 + CorsConfiguration config = new CorsConfiguration(); + // 允许所有的HTTP请求方法(GET, POST, PUT, DELETE等) + config.addAllowedMethod("*"); + // 允许所有的域名发起的请求 比如http://localhost:8080、 + config.addAllowedOrigin("*"); + // 允许所有的域名发起的请求(支持正则表达式) 比如http://localhost:8080 + config.addAllowedOriginPattern("*"); + // 允许所有的请求头部信息 比如token、Content-Type + config.addAllowedHeader("*"); + // 创建一个UrlBasedCorsConfigurationSource对象,并使用PathPatternParser进行路径匹配 + UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser()); + // 注册跨域配置,应用于所有的URL路径 + source.registerCorsConfiguration("/**", config); + return new CorsWebFilter(source); + } +} \ No newline at end of file