格式化代码
This commit is contained in:
parent
71a01cfd87
commit
73b2ddae7d
|
@ -1,8 +1,10 @@
|
||||||
package com.example.catchTheLetters.config;
|
package com.example.catchTheLetters.config;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -18,7 +20,7 @@ public class WebMvcConfig {
|
||||||
public WebMvcConfigurer corsConfigurer() {
|
public WebMvcConfigurer corsConfigurer() {
|
||||||
return new WebMvcConfigurer() {
|
return new WebMvcConfigurer() {
|
||||||
@Override
|
@Override
|
||||||
public void addCorsMappings(org.springframework.web.servlet.config.annotation.CorsRegistry registry) {
|
public void addCorsMappings(@NotNull CorsRegistry registry) {
|
||||||
registry
|
registry
|
||||||
.addMapping("/**")
|
.addMapping("/**")
|
||||||
.allowedOriginPatterns("*") // 允许所有域
|
.allowedOriginPatterns("*") // 允许所有域
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证控制器
|
* 认证控制器
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关卡控制器
|
* 关卡控制器
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关卡类
|
* 关卡类
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关卡结算信息类
|
* 关卡结算信息类
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户类
|
* 用户类
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数据表版本类(用于Realm对MongoDB的数据表版本进行同步检测,版本号不同则进行同步)
|
* 数据表版本类(用于Realm对MongoDB的数据表版本进行同步检测,版本号不同则进行同步)
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 登录信息类
|
* 登录信息类
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -6,6 +6,7 @@ import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册信息类
|
* 注册信息类
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
|
|
|
@ -8,11 +8,13 @@ import com.example.catchTheLetters.utils.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 认证服务接口
|
* 认证服务接口
|
||||||
|
*
|
||||||
* @author spyn
|
* @author spyn
|
||||||
*/
|
*/
|
||||||
public interface AuthService {
|
public interface AuthService {
|
||||||
/**
|
/**
|
||||||
* 登录
|
* 登录
|
||||||
|
*
|
||||||
* @param loginDto 登录信息
|
* @param loginDto 登录信息
|
||||||
* @return token
|
* @return token
|
||||||
*/
|
*/
|
||||||
|
@ -20,6 +22,7 @@ public interface AuthService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注销
|
* 注销
|
||||||
|
*
|
||||||
* @param token token
|
* @param token token
|
||||||
* @return 是否成功
|
* @return 是否成功
|
||||||
*/
|
*/
|
||||||
|
@ -27,6 +30,7 @@ public interface AuthService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证token
|
* 验证token
|
||||||
|
*
|
||||||
* @param token token
|
* @param token token
|
||||||
* @return 用户信息(不可以包含密码)
|
* @return 用户信息(不可以包含密码)
|
||||||
*/
|
*/
|
||||||
|
@ -34,6 +38,7 @@ public interface AuthService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 注册
|
* 注册
|
||||||
|
*
|
||||||
* @param registerDto 注册信息
|
* @param registerDto 注册信息
|
||||||
* @return token
|
* @return token
|
||||||
*/
|
*/
|
||||||
|
@ -41,6 +46,7 @@ public interface AuthService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
|
*
|
||||||
* @param id 用户id
|
* @param id 用户id
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
|
@ -48,6 +54,7 @@ public interface AuthService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名获取信息
|
* 通过用户名获取信息
|
||||||
|
*
|
||||||
* @param username 用户名
|
* @param username 用户名
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,8 +22,10 @@ import java.util.Map;
|
||||||
@Component
|
@Component
|
||||||
public class JwtUtil {
|
public class JwtUtil {
|
||||||
public static final Integer EXPIRE_TIME = 1; // 1天
|
public static final Integer EXPIRE_TIME = 1; // 1天
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成token
|
* 生成token
|
||||||
|
*
|
||||||
* @param map 传入map
|
* @param map 传入map
|
||||||
* @param expired token存储时间
|
* @param expired token存储时间
|
||||||
* @return token
|
* @return token
|
||||||
|
@ -44,6 +46,7 @@ public class JwtUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证token合法性 || 获取token信息方法
|
* 验证token合法性 || 获取token信息方法
|
||||||
|
*
|
||||||
* @param token 传入token
|
* @param token 传入token
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -53,6 +56,7 @@ public class JwtUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取payload
|
* 获取payload
|
||||||
|
*
|
||||||
* @param token 传入token
|
* @param token 传入token
|
||||||
* @return 返回payload
|
* @return 返回payload
|
||||||
*/
|
*/
|
||||||
|
@ -80,6 +84,7 @@ public class JwtUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 判断token是否过期
|
* 判断token是否过期
|
||||||
|
*
|
||||||
* @return true:过期 false:没过期
|
* @return true:过期 false:没过期
|
||||||
*/
|
*/
|
||||||
public Boolean isTokenExpired(String token) {
|
public Boolean isTokenExpired(String token) {
|
||||||
|
|
Loading…
Reference in New Issue