From 74a763bdbe18cfc4fd3ff55b1511228af40c2c73 Mon Sep 17 00:00:00 2001 From: yuanjunbin Date: Thu, 5 Oct 2023 18:01:06 +0800 Subject: [PATCH] update --- .../resources/application-dev.yml.bak | 22 ---- .../moxianchengbao/utils/JWTUtils.java.bak | 100 ------------------ 2 files changed, 122 deletions(-) delete mode 100644 stock-forcast-backend/resources/application-dev.yml.bak delete mode 100644 stock-forcast-backend/src/main/java/org/moxianchengbao/utils/JWTUtils.java.bak diff --git a/stock-forcast-backend/resources/application-dev.yml.bak b/stock-forcast-backend/resources/application-dev.yml.bak deleted file mode 100644 index 0cf8b64..0000000 --- a/stock-forcast-backend/resources/application-dev.yml.bak +++ /dev/null @@ -1,22 +0,0 @@ -spring: - datasource: - username: root - password: root - url: jdbc:mysql://127.0.0.1:3306/moxianchengbao?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=UTF-8 - driver-class-name: com.mysql.cj.jdbc.Driver - - -server: - port: 8081 - -mybatis-plus: - global-config: - db-config: - logic-delete-field: isDelete # 全局逻辑删除的实体字段名(since 3.3.0,配置后可以忽略不配置步骤2) - logic-delete-value: true # 逻辑已删除值(默认为 1) - logic-not-delete-value: false # 逻辑未删除值(默认为 0) - - type-aliases-package: org.moxianchengbao.pojo.entity # 哪一个包里面的类可以在mapper文件中直接简写为类名 - mapper-locations: classpath:/mapper/*.xml # 找mapper文件的位置,第一个位置不需要斜杠,classpath表示从resources开始 -# configuration: - diff --git a/stock-forcast-backend/src/main/java/org/moxianchengbao/utils/JWTUtils.java.bak b/stock-forcast-backend/src/main/java/org/moxianchengbao/utils/JWTUtils.java.bak deleted file mode 100644 index 3619c03..0000000 --- a/stock-forcast-backend/src/main/java/org/moxianchengbao/utils/JWTUtils.java.bak +++ /dev/null @@ -1,100 +0,0 @@ - package org.moxianchengbao.utils; - -import com.auth0.jwt.JWT; -import com.auth0.jwt.JWTCreator; -import com.auth0.jwt.algorithms.Algorithm; -import com.auth0.jwt.interfaces.Claim; -import com.auth0.jwt.interfaces.DecodedJWT; - -import java.util.*; - -/** - * JWT工具类 - * @Author moxianchengbao - */ - - -public class JWTUtils { - - //自定义签名密钥 - private static final String SIG = "HIUDe9%^#&dsf4%#4tr115&*&*wer6grfvewfw"; - - /** - * 生成token - * @param map 自定义数据 - * @return String - */ - - public static String getToken(Map map){ - Algorithm alg = Algorithm.HMAC256(SIG); //自定义签名密钥 - Calendar ins = Calendar.getInstance(); - ins.add(Calendar.DATE,1); //默认过期时间为1天 -// ins.add(Calendar.SECOND,30); - //jwt builder - JWTCreator.Builder builder = JWT.create(); - builder.withIssuedAt(new Date()); - //payload - map.forEach((k,v)->{ - builder.withClaim(k,v); - }); - //signature - String token = builder.withExpiresAt(ins.getTime()).sign(alg); - - return token; - } - - /** - * 获取token信息 - * @param token - * @return DecodedJWT - */ - public static DecodedJWT getTokenInfo(String token){ - DecodedJWT verify = JWT.require(Algorithm.HMAC256(SIG)).build().verify(token); - return verify; - } - - /** - * @Author DragonOne - * @Date 2022/3/7 11:16 - * @墨水记忆 www.tothefor.com - * @属性 检验token合法性 - * @作用 80 - */ - public static boolean checkToken(String token){ - boolean flag = false; - try{ - getTokenInfo(token); - flag=true; - }catch (Exception e){ - flag=false; - }finally { - return flag; - } - } - /** - * @Author DragonOne - * @Date 2022/3/13 12:16 - * @墨水记忆 www.tothefor.com - * @属性 通过token获取用户名 - * @作用 80 - */ - public static String getNameByToken(String token){ - DecodedJWT tokenInfo = getTokenInfo(token); - String username = tokenInfo.getClaim("username").asString(); - return username; - } - - /** - * @Author DragonOne - * @Date 2022/3/13 12:16 - * @墨水记忆 www.tothefor.com - * @属性 通过token获取用户id - * @作用 80 - */ - public static String getIdByToken(String token){ - DecodedJWT tokenInfo = getTokenInfo(token); - String userid = tokenInfo.getClaim("userid").asString(); - return userid; - } - -}