init...
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
package com.hongliang.videotask.CustomEnum;
|
||||
|
||||
public enum RecordStatusEnum {
|
||||
NORMAL,
|
||||
DELETE
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.hongliang.videotask.CustomEnum;
|
||||
|
||||
public enum UserTypeEnum {
|
||||
SUPER_ADMIN, //超级管理员
|
||||
SYSTEM_ADMIN, //系统管理员
|
||||
USER, //普通用户
|
||||
INTERFACE_USER, //接口用户
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hongliang.videotask;
|
||||
|
||||
import cn.dev33.satoken.SaManager;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
@MapperScan("com.hongliang.videotask.mappers")
|
||||
public class VideoTaskApplication {
|
||||
public static void main(String[] args) throws JsonProcessingException {
|
||||
SpringApplication.run(VideoTaskApplication.class, args);
|
||||
System.out.println("启动成功,Sa-Token 配置如下:" + SaManager.getConfig());
|
||||
}
|
||||
}
|
||||
13
src/main/java/com/hongliang/videotask/bean/LoginBean.java
Normal file
13
src/main/java/com/hongliang/videotask/bean/LoginBean.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.hongliang.videotask.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class LoginBean {
|
||||
private String username;
|
||||
private String password;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.hongliang.videotask.bean;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class LoginResultBean {
|
||||
private Integer userid;
|
||||
private String username;
|
||||
private String name;
|
||||
private String access_token;
|
||||
private String expire_datetime;
|
||||
}
|
||||
17
src/main/java/com/hongliang/videotask/bean/UserBean.java
Normal file
17
src/main/java/com/hongliang/videotask/bean/UserBean.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.hongliang.videotask.bean;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class UserBean {
|
||||
private Integer id;
|
||||
private String username;
|
||||
private String name;
|
||||
private String createdate;
|
||||
private String updatedate;
|
||||
}
|
||||
15
src/main/java/com/hongliang/videotask/common/Response.java
Normal file
15
src/main/java/com/hongliang/videotask/common/Response.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.hongliang.videotask.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Response {
|
||||
private int code;
|
||||
private String msg;
|
||||
private Object data;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.hongliang.videotask.common;
|
||||
|
||||
|
||||
/*
|
||||
* Controller返回的状态码
|
||||
* */
|
||||
public class ResponseCode {
|
||||
public static Integer OK = 200; //正常
|
||||
public static Integer LOGIN_ERROR=8001; //登录错误
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.hongliang.videotask.controller;
|
||||
|
||||
import cn.dev33.satoken.stp.StpUtil;
|
||||
import com.hongliang.videotask.bean.LoginBean;
|
||||
import com.hongliang.videotask.bean.LoginResultBean;
|
||||
import com.hongliang.videotask.common.Response;
|
||||
import com.hongliang.videotask.common.ResponseCode;
|
||||
import com.hongliang.videotask.service.impl.LoginServiceImpl;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserControl {
|
||||
@Resource
|
||||
private LoginServiceImpl loginService;
|
||||
|
||||
@GetMapping("hello")
|
||||
public ResponseEntity<?> hello(){
|
||||
return ResponseEntity.ok(new Response(200,"ok","hello world!"));
|
||||
}
|
||||
|
||||
@PostMapping("login")
|
||||
public ResponseEntity<?> login(@RequestBody LoginBean loginBean){
|
||||
LoginResultBean loginResultBean= loginService.Login(loginBean.getUsername(),loginBean.getPassword());
|
||||
if (loginResultBean==null){
|
||||
return ResponseEntity.ok(new Response(ResponseCode.LOGIN_ERROR,"用户名或密码错误",null));
|
||||
}else{
|
||||
StpUtil.login(loginResultBean.getUserid()); //saToken登录
|
||||
//获取token
|
||||
loginResultBean.setAccess_token(StpUtil.getTokenInfo().tokenValue);
|
||||
//获取过期时间
|
||||
LocalDateTime now=LocalDateTime.now();
|
||||
LocalDateTime newTime=now.plusSeconds(StpUtil.getTokenInfo().getTokenTimeout());
|
||||
loginResultBean.setExpire_datetime(newTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||
return ResponseEntity.ok(new Response(ResponseCode.OK,"登录成功",loginResultBean));
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("islogin")
|
||||
public ResponseEntity<?> isLogin(){
|
||||
return ResponseEntity.ok(new Response(ResponseCode.OK,StpUtil.isLogin()?"已登录":"未登录",StpUtil.isLogin()));
|
||||
}
|
||||
|
||||
@PostMapping("logout")
|
||||
public ResponseEntity<?> logout(){
|
||||
return ResponseEntity.ok(new Response(ResponseCode.OK,"成功退出",null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.hongliang.videotask.mappers;
|
||||
|
||||
import com.hongliang.videotask.bean.LoginResultBean;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LoginMapper {
|
||||
@Select("select *,id as userid from users where username=#{username} and password=#{password}")
|
||||
LoginResultBean Login(String username,String password);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.hongliang.videotask.mappers;
|
||||
|
||||
import com.hongliang.videotask.bean.UserBean;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserMapper {
|
||||
/**
|
||||
* 根据用户ID获取用户信息
|
||||
* @param id 用户ID
|
||||
* @return UserBean
|
||||
*/
|
||||
@Select("select * from users where id=#{id}")
|
||||
UserBean GetUserByID(int id);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.hongliang.videotask.service;
|
||||
|
||||
import com.hongliang.videotask.bean.LoginResultBean;
|
||||
|
||||
public interface LoginService {
|
||||
LoginResultBean Login(String username,String password);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.hongliang.videotask.service;
|
||||
|
||||
import com.hongliang.videotask.bean.UserBean;
|
||||
|
||||
public interface UserService {
|
||||
UserBean GetUserByID(int id);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.hongliang.videotask.service.impl;
|
||||
|
||||
import com.hongliang.videotask.bean.LoginResultBean;
|
||||
import com.hongliang.videotask.mappers.LoginMapper;
|
||||
import com.hongliang.videotask.service.LoginService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LoginServiceImpl implements LoginService {
|
||||
@Autowired
|
||||
private LoginMapper loginMapper;
|
||||
|
||||
@Override
|
||||
public LoginResultBean Login(String username, String password){
|
||||
return this.loginMapper.Login(username,password);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.hongliang.videotask.service.impl;
|
||||
|
||||
import com.hongliang.videotask.bean.UserBean;
|
||||
import com.hongliang.videotask.mappers.UserMapper;
|
||||
import com.hongliang.videotask.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public UserBean GetUserByID(int id){
|
||||
return this.userMapper.GetUserByID(id);
|
||||
}
|
||||
}
|
||||
72
src/main/java/com/hongliang/videotask/utils/AES.java
Normal file
72
src/main/java/com/hongliang/videotask/utils/AES.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.hongliang.videotask.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
|
||||
public class AES {
|
||||
private static final String AES_ALGORITHM = "AES";
|
||||
// AES加密模式为CBC,填充方式为PKCS5Padding
|
||||
private static final String AES_TRANSFORMATION = "AES/CBC/PKCS5Padding";
|
||||
// AES密钥为16位
|
||||
private static final String AES_KEY = "1234567890123456";
|
||||
// AES初始化向量为16位
|
||||
private static final String AES_IV = "abcdefghijklmnop";
|
||||
|
||||
/**
|
||||
* AES加密
|
||||
*
|
||||
* @param data 待加密的数据
|
||||
* @return 加密后的数据,使用Base64编码
|
||||
*/
|
||||
public static String encrypt(String data) throws Exception {
|
||||
// 将AES密钥转换为SecretKeySpec对象
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(AES_KEY.getBytes(), AES_ALGORITHM);
|
||||
// 将AES初始化向量转换为IvParameterSpec对象
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(AES_IV.getBytes());
|
||||
// 根据加密算法获取加密器
|
||||
Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION);
|
||||
// 初始化加密器,设置加密模式、密钥和初始化向量
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
// 加密数据
|
||||
byte[] encryptedData = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
// 对加密后的数据使用Base64编码
|
||||
return Base64.getEncoder().encodeToString(encryptedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* AES解密
|
||||
*
|
||||
* @param encryptedData 加密后的数据,使用Base64编码
|
||||
* @return 解密后的数据
|
||||
*/
|
||||
public static String decrypt(String encryptedData) throws Exception {
|
||||
// 将AES密钥转换为SecretKeySpec对象
|
||||
SecretKeySpec secretKeySpec = new SecretKeySpec(AES_KEY.getBytes(), AES_ALGORITHM);
|
||||
// 将AES初始化向量转换为IvParameterSpec对象
|
||||
IvParameterSpec ivParameterSpec = new IvParameterSpec(AES_IV.getBytes());
|
||||
// 根据加密算法获取解密器
|
||||
Cipher cipher = Cipher.getInstance(AES_TRANSFORMATION);
|
||||
// 初始化解密器,设置解密模式、密钥和初始化向量
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKeySpec, ivParameterSpec);
|
||||
// 对加密后的数据使用Base64解码
|
||||
byte[] decodedData = Base64.getDecoder().decode(encryptedData);
|
||||
// 解密数据
|
||||
byte[] decryptedData = cipher.doFinal(decodedData);
|
||||
// 返回解密后的数据
|
||||
return new String(decryptedData, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// String data = "Hello World";
|
||||
//
|
||||
// String encryptedData = encrypt(data);
|
||||
// System.out.println("加密后的数据:" + encryptedData);
|
||||
//
|
||||
// String decryptedData = decrypt(encryptedData);
|
||||
// System.out.println("解密后的数据:" + decryptedData);
|
||||
// }
|
||||
}
|
||||
|
||||
76
src/main/java/com/hongliang/videotask/utils/DES.java
Normal file
76
src/main/java/com/hongliang/videotask/utils/DES.java
Normal file
@@ -0,0 +1,76 @@
|
||||
package com.hongliang.videotask.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.SecretKeyFactory;
|
||||
import javax.crypto.spec.DESKeySpec;
|
||||
import java.security.spec.KeySpec;
|
||||
import java.util.Base64;
|
||||
|
||||
public class DES {
|
||||
private static final String DES_ALGORITHM = "DES";
|
||||
|
||||
/**
|
||||
* DES加密
|
||||
*
|
||||
* @param data 待加密的数据
|
||||
* @param key 密钥,长度必须为8位
|
||||
* @return 加密后的数据,使用Base64编码
|
||||
*/
|
||||
public static String encrypt(String data, String key) throws Exception {
|
||||
// 根据密钥生成密钥规范
|
||||
KeySpec keySpec = new DESKeySpec(key.getBytes());
|
||||
// 根据密钥规范生成密钥工厂
|
||||
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(DES_ALGORITHM);
|
||||
// 根据密钥工厂和密钥规范生成密钥
|
||||
SecretKey secretKey = secretKeyFactory.generateSecret(keySpec);
|
||||
|
||||
// 根据加密算法获取加密器
|
||||
Cipher cipher = Cipher.getInstance(DES_ALGORITHM);
|
||||
// 初始化加密器,设置加密模式和密钥
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
// 加密数据
|
||||
byte[] encryptedData = cipher.doFinal(data.getBytes());
|
||||
// 对加密后的数据进行Base64编码
|
||||
return Base64.getEncoder().encodeToString(encryptedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* DES解密
|
||||
*
|
||||
* @param encryptedData 加密后的数据,使用Base64编码
|
||||
* @param key 密钥,长度必须为8位
|
||||
* @return 解密后的数据
|
||||
*/
|
||||
public static String decrypt(String encryptedData, String key) throws Exception {
|
||||
// 根据密钥生成密钥规范
|
||||
KeySpec keySpec = new DESKeySpec(key.getBytes());
|
||||
// 根据密钥规范生成密钥工厂
|
||||
SecretKeyFactory secretKeyFactory = SecretKeyFactory.getInstance(DES_ALGORITHM);
|
||||
// 根据密钥工厂和密钥规范生成密钥
|
||||
SecretKey secretKey = secretKeyFactory.generateSecret(keySpec);
|
||||
|
||||
// 对加密后的数据进行Base64解码
|
||||
byte[] decodedData = Base64.getDecoder().decode(encryptedData);
|
||||
// 根据加密算法获取解密器
|
||||
Cipher cipher = Cipher.getInstance(DES_ALGORITHM);
|
||||
// 初始化解密器,设置解密模式和密钥
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||
// 解密数据
|
||||
byte[] decryptedData = cipher.doFinal(decodedData);
|
||||
// 将解密后的数据转换为字符串
|
||||
return new String(decryptedData);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// String data = "Hello World";
|
||||
// String key = "12345678";
|
||||
//
|
||||
// String encryptedData = encrypt(data, key);
|
||||
// System.out.println("加密后的数据:" + encryptedData);
|
||||
//
|
||||
// String decryptedData = decrypt(encryptedData, key);
|
||||
// System.out.println("解密后的数据:" + decryptedData);
|
||||
// }
|
||||
}
|
||||
|
||||
27
src/main/java/com/hongliang/videotask/utils/MD5.java
Normal file
27
src/main/java/com/hongliang/videotask/utils/MD5.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.hongliang.videotask.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Formatter;
|
||||
|
||||
public class MD5 {
|
||||
private static final String MD5_ALGORITHM = "MD5";
|
||||
public static String encrypt(String data) throws Exception {
|
||||
// 获取MD5算法实例
|
||||
MessageDigest messageDigest = MessageDigest.getInstance(MD5_ALGORITHM);
|
||||
// 计算散列值
|
||||
byte[] digest = messageDigest.digest(data.getBytes());
|
||||
Formatter formatter = new Formatter();
|
||||
// 补齐前导0,并格式化
|
||||
for (byte b : digest) {
|
||||
formatter.format("%02x", b);
|
||||
}
|
||||
return formatter.toString();
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// String data = "Hello World";
|
||||
// String encryptedData = encrypt(data);
|
||||
// System.out.println("加密后的数据:" + encryptedData);
|
||||
// }
|
||||
}
|
||||
|
||||
65
src/main/java/com/hongliang/videotask/utils/RSA.java
Normal file
65
src/main/java/com/hongliang/videotask/utils/RSA.java
Normal file
@@ -0,0 +1,65 @@
|
||||
package com.hongliang.videotask.utils;
|
||||
|
||||
import javax.crypto.Cipher;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.*;
|
||||
import java.util.Base64;
|
||||
|
||||
public class RSA {
|
||||
private static final String RSA_ALGORITHM = "RSA";
|
||||
|
||||
/**
|
||||
* 生成RSA密钥对
|
||||
*
|
||||
* @return RSA密钥对
|
||||
*/
|
||||
public static KeyPair generateKeyPair() throws NoSuchAlgorithmException {
|
||||
KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(RSA_ALGORITHM);
|
||||
keyPairGenerator.initialize(2048); // 密钥大小为2048位
|
||||
return keyPairGenerator.generateKeyPair();
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用公钥加密数据
|
||||
*
|
||||
* @param data 待加密的数据
|
||||
* @param publicKey 公钥
|
||||
* @return 加密后的数据
|
||||
*/
|
||||
public static String encrypt(String data, PublicKey publicKey) throws Exception {
|
||||
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
|
||||
byte[] encryptedData = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64.getEncoder().encodeToString(encryptedData);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用私钥解密数据
|
||||
*
|
||||
* @param encryptedData 加密后的数据
|
||||
* @param privateKey 私钥
|
||||
* @return 解密后的数据
|
||||
*/
|
||||
public static String decrypt(String encryptedData, PrivateKey privateKey) throws Exception {
|
||||
byte[] decodedData = Base64.getDecoder().decode(encryptedData);
|
||||
Cipher cipher = Cipher.getInstance(RSA_ALGORITHM);
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
byte[] decryptedData = cipher.doFinal(decodedData);
|
||||
return new String(decryptedData, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// KeyPair keyPair = generateKeyPair();
|
||||
// PublicKey publicKey = keyPair.getPublic();
|
||||
// PrivateKey privateKey = keyPair.getPrivate();
|
||||
//
|
||||
// String data = "Hello World";
|
||||
//
|
||||
// String encryptedData = encrypt(data, publicKey);
|
||||
// System.out.println("加密后的数据:" + encryptedData);
|
||||
//
|
||||
// String decryptedData = decrypt(encryptedData, privateKey);
|
||||
// System.out.println("解密后的数据:" + decryptedData);
|
||||
// }
|
||||
}
|
||||
|
||||
25
src/main/java/com/hongliang/videotask/utils/SHA256.java
Normal file
25
src/main/java/com/hongliang/videotask/utils/SHA256.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package com.hongliang.videotask.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
|
||||
public class SHA256 {
|
||||
private static final String SHA_256_ALGORITHM = "SHA-256";
|
||||
public static String encrypt(String data) throws Exception {
|
||||
//获取SHA-256算法实例
|
||||
MessageDigest messageDigest = MessageDigest.getInstance(SHA_256_ALGORITHM);
|
||||
//计算散列值
|
||||
byte[] digest = messageDigest.digest(data.getBytes());
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
//将byte数组转换为15进制字符串
|
||||
for (byte b : digest) {
|
||||
stringBuilder.append(Integer.toHexString((b & 0xFF) | 0x100), 1, 3);
|
||||
}
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
// public static void main(String[] args) throws Exception {
|
||||
// String data = "Hello World";
|
||||
// String encryptedData = encrypt(data);
|
||||
// System.out.println("加密后的数据:" + encryptedData);
|
||||
// }
|
||||
}
|
||||
75
src/main/resources/application-dev.properties
Normal file
75
src/main/resources/application-dev.properties
Normal file
@@ -0,0 +1,75 @@
|
||||
#配置端口号
|
||||
server.port=8426
|
||||
|
||||
#返回json的全局时间格式
|
||||
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||
spring.jackson.time-zone=GMT+8
|
||||
|
||||
############## Sa-Token 配置 (文档: https://sa-token.cc) ##############
|
||||
# token 名称(同时也是 cookie 名称)
|
||||
sa-token.token-name=x-access-token
|
||||
# token 有效期(单位:秒) 默认30天,-1 代表永久有效
|
||||
sa-token.timeout=2592000
|
||||
# token 最低活跃频率(单位:秒),如果 token 超过此时间没有访问系统就会被冻结,默认-1 代表不限制,永不冻结
|
||||
sa-token.active-timeout=-1
|
||||
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
|
||||
sa-token.is-concurrent=true
|
||||
# 在多人登录同一账号时,是否共用一个 token (为 true 时所有登录共用一个 token, 为 false 时每次登录新建一个 token)
|
||||
sa-token.is-share=true
|
||||
# token 风格(默认可取值:uuid、simple-uuid、random-32、random-64、random-128、tik)
|
||||
sa-token.token-style=uuid
|
||||
# 是否输出操作日志
|
||||
sa-token.is-log=true
|
||||
# token前缀
|
||||
sa-token.token-prefix=Bearer
|
||||
# 是否从header中读取token
|
||||
sa-token.is-read-header=true
|
||||
|
||||
|
||||
#=============================druid_config==========================
|
||||
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
|
||||
### 人大金仓连接k8######
|
||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||
spring.datasource.url=jdbc:mysql://localhost:3306/videotask?characterEncoding=utf-8
|
||||
spring.datasource.username=videotask
|
||||
spring.datasource.password=123456
|
||||
# 初始化大小,最小,最大
|
||||
#spring.datasource.druid.initial-size=5
|
||||
#spring.datasource.druid.min-idle= 3
|
||||
#spring.datasource.druid.max-active= 20
|
||||
## 配置获取连接等待超时的时间
|
||||
#spring.datasource.druid.max-wait= 60000
|
||||
## 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒,下面是:1分钟
|
||||
#spring.datasource.druid.time-between-eviction-runs-millis= 60000
|
||||
## 配置一个连接在池中最小生存的时间,单位是毫秒,下面是:5分钟
|
||||
#spring.datasource.druid.min-evictable-idle-time-millis= 300000
|
||||
## 打开PSCache,并且指定每个连接上PSCache的大小
|
||||
#spring.datasource.druid.pool-prepared-statements= true
|
||||
#spring.datasource.druid.max-pool-prepared-statement-per-connection-size=20
|
||||
## 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
|
||||
#spring.datasource.druid.filters=stat
|
||||
## asyncInit是1.1.4中新增加的配置,如果有initialSize数量较多时,打开会加快应用启动时间
|
||||
#spring.datasource.druid.asyncInit=true
|
||||
## 验证连接是否可用,使用的SQL语句
|
||||
#spring.datasource.druid.validation-query=select 1
|
||||
## 指明连接是否被空闲连接回收器(如果有)进行检验.如果检测失败,则连接将被从池中去除.
|
||||
#spring.datasource.druid.test-while-idle=true
|
||||
#spring.datasource.druid.stat-view-servlet.login-username=druid_admin
|
||||
#spring.datasource.druid.stat-view-servlet.login-password=1qaz2wsx#EDC
|
||||
spring.datasource.druid.initial-size=5
|
||||
spring.datasource.druid.min-idle=5
|
||||
spring.datasource.druid.max-active=20
|
||||
spring.datasource.druid.max-wait=60000
|
||||
spring.datasource.druid.test-while-idle=true
|
||||
spring.datasource.druid.time-between-eviction-runs-millis=60000
|
||||
spring.datasource.druid.min-evictable-idle-time-millis=30000
|
||||
spring.datasource.druid.validation-query=select 'x'
|
||||
spring.datasource.druid.test-on-borrow=false
|
||||
spring.datasource.druid.test-on-return=false
|
||||
spring.datasource.druid.pool-prepared-statements=true
|
||||
spring.datasource.druid.max-pool-prepared-statement-per-connection-size=20
|
||||
spring.datasource.druid.filters=stat
|
||||
spring.datasource.druid.connection-properties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500
|
||||
spring.datasource.druid.use-global-data-source-stat=true
|
||||
spring.datasource.druid.stat-view-servlet.login-username=druid_admin
|
||||
spring.datasource.druid.stat-view-servlet.login-password=1qaz2wsx#EDC
|
||||
0
src/main/resources/application-prod.properties
Normal file
0
src/main/resources/application-prod.properties
Normal file
1
src/main/resources/application.properties
Normal file
1
src/main/resources/application.properties
Normal file
@@ -0,0 +1 @@
|
||||
spring.profiles.active=dev
|
||||
17
src/test/java/AESTest.java
Normal file
17
src/test/java/AESTest.java
Normal file
@@ -0,0 +1,17 @@
|
||||
import com.hongliang.videotask.utils.AES;
|
||||
import org.junit.Test;
|
||||
|
||||
public class AESTest {
|
||||
@Test
|
||||
public void AES(){
|
||||
String data="123456";
|
||||
try{
|
||||
String strEncrypt=AES.encrypt(data);
|
||||
System.out.println("加密后:"+strEncrypt);
|
||||
System.out.println("解密后:"+AES.decrypt(strEncrypt));
|
||||
}catch (Exception e){
|
||||
System.out.println(e.toString());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
8
src/test/java/LoginTest.java
Normal file
8
src/test/java/LoginTest.java
Normal file
@@ -0,0 +1,8 @@
|
||||
import org.junit.Test;
|
||||
|
||||
public class LoginTest {
|
||||
@Test
|
||||
public void testAdd(){
|
||||
System.out.println("this is a test!");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user