完成对Redis的构建及邮件登陆的操作,晚上功能组建,进行补丁修正

This commit is contained in:
筱锋xiao_lfeng 2024-01-16 14:51:28 +08:00
parent f2b8ffdbf5
commit 4690a28ab0
Signed by: XiaoLFeng
GPG Key ID: F693AA12AABBFA87
60 changed files with 557 additions and 36 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
.mvn/wrapper/maven-wrapper.jar vendored Normal file → Executable file
View File

0
.mvn/wrapper/maven-wrapper.properties vendored Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
doc/OrganizeInternalOA-ConfigTableConfig.md Normal file → Executable file
View File

0
doc/OrganizeInternalOA-SQL.md Normal file → Executable file
View File

0
mysql/organize_oa.sql Normal file → Executable file
View File

13
pom.xml Normal file → Executable file
View File

@ -98,11 +98,19 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Redis -->
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.8.0</version>
</dependency>
<!-- SpringBoot Redis -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
<!-- Jetbrains -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
@ -119,6 +127,11 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
<!-- SpringBoot Thymeleaf -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
</dependencies>
<build>

View File

View File

@ -5,6 +5,7 @@ import com.jsl.oa.utils.ResultUtil;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
@ -59,7 +60,7 @@ public class UserControllerAspect {
* @param request HttpServletRequest对象
* @return {@link Boolean}
*/
public Boolean checkTimestamp(HttpServletRequest request) {
public Boolean checkTimestamp(@NotNull HttpServletRequest request) {
// 获取请求头中的时间戳
String getTimestamp = request.getHeader("Timestamp");
// 判断是否为空

View File

@ -0,0 +1,19 @@
package com.jsl.oa.common.constant;
import lombok.Getter;
/**
*
*/
@Getter
public enum BusinessConstants {
BUSINESS_LOGIN("login:", "登陆实现");
private final String value;
private final String description;
BusinessConstants(String value, String description) {
this.value = value;
this.description = description;
}
}

View File

@ -0,0 +1,27 @@
package com.jsl.oa.common.constant;
import com.jsl.oa.utils.EmailRedisUtil;
/**
* <h1>Redis常量类</h1>
* <hr/>
* 用于存放Redis常量
*
* @version v1.1.0
* @since v1.1.0
* @see EmailRedisUtil
* @author 筱锋xiao_lfeng
*/
public class RedisConstant {
/*
* 类型分类
*/
public static final String TYPE_USER = "user:"; // 用户相关
public static final String TYPE_EMAIL = "mail:"; // 邮件相关
/*
* 表分类
*/
public static final String TABLE_USER = "user:"; // 用户表
public static final String TABLE_EMAIL = "code:"; // 邮箱验证码
}

0
src/main/java/com/jsl/oa/config/JwtFilter.java Normal file → Executable file
View File

0
src/main/java/com/jsl/oa/config/MailConfiguration.java Normal file → Executable file
View File

View File

@ -0,0 +1,46 @@
package com.jsl.oa.config.redis;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
import org.springframework.data.redis.serializer.RedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;
/**
* <h1>Redis配置类</h1>
* <hr/>
* 用于配置Redis
*
* @author 筱锋xiao_lfeng
* @version v1.1.0
* @since v1.1.0
*/
@Configuration
public class RedisConfiguration {
@Bean
public JedisConnectionFactory jedisConnectionFactory() {
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration("localhost");
return new JedisConnectionFactory(config);
}
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(connectionFactory);
// 配置Redis编码格式
RedisSerializer<String> stringSerializer = new StringRedisSerializer();
RedisSerializer<Object> jsonSerializer = new GenericJackson2JsonRedisSerializer();
redisTemplate.setKeySerializer(stringSerializer);
redisTemplate.setValueSerializer(jsonSerializer);
redisTemplate.setHashKeySerializer(stringSerializer);
redisTemplate.setHashValueSerializer(jsonSerializer);
return redisTemplate;
}
}

View File

@ -0,0 +1,59 @@
package com.jsl.oa.config.redis;
import com.jsl.oa.common.constant.BusinessConstants;
import lombok.RequiredArgsConstructor;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import java.util.concurrent.TimeUnit;
@RequiredArgsConstructor
public abstract class RedisOperating<R> {
protected final RedisTemplate<String, R> redisTemplate;
protected final StringRedisTemplate stringRedisTemplate;
public abstract Long getExpiredAt(BusinessConstants businessConstants, String field);
public abstract Boolean delData(BusinessConstants businessConstants, String field);
public abstract R getData(BusinessConstants businessConstants, String field);
public abstract Boolean setData(BusinessConstants businessConstants, String field, R value, Integer time);
/**
* <h2>获取Redis中元素过期时间</h2>
* <hr/>
* 基础方法用于添加String元素到Redis<br/>
*
* @param key 索引
* @return 返回过期时间
*/
public Long getExpiredAt(String key) {
return redisTemplate.getExpire(key);
}
/**
* <h2>基础添加String元素到Redis</h2>
* <hr/>
* 基础方法用于添加String元素到Redis<br/>
* 默认处理时间单位时间秒
*
* @param key
* @param value
*/
public void set(String key, String value, Integer time) {
stringRedisTemplate.opsForValue().set(key, value);
stringRedisTemplate.expire(key, time, TimeUnit.SECONDS);
}
/**
* <h2>基础添加元素到Redis</h2>
* <hr/>
* 基础方法用于添加元素元素到Redis<br/>
* 默认处理时间单位时间秒
*
* @param key
* @param value
*/
public void set(String key, R value, Integer time) {
redisTemplate.opsForValue().set(key, value);
redisTemplate.expire(key, time, TimeUnit.SECONDS);
}
}

0
src/main/java/com/jsl/oa/config/shiro/MyRealm.java Normal file → Executable file
View File

View File

View File

@ -84,11 +84,24 @@ public class AuthController {
* @author 筱锋xiao_lfeng
* @since v1.1.0
*/
@GetMapping("/auth/login/email")
public BaseResponse authLoginByEmail(@RequestParam String email) {
@GetMapping("/auth/login/email/code")
public BaseResponse authLoginSendEmailCode(@RequestParam String email) {
if (email != null) {
if (Pattern.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", email)) {
return authService.authLoginByEmail(email);
return authService.authLoginSendEmailCode(email);
} else {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
}
} else {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
}
}
@GetMapping("/auth/login/email")
public BaseResponse authLoginByEmail(@RequestParam String email, @RequestParam Integer code) {
if (email != null && code != null) {
if (Pattern.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", email)) {
return authService.authLoginByEmail(email, code);
} else {
return ResultUtil.error(ErrorCode.PARAMETER_ERROR);
}

View File

View File

View File

View File

View File

0
src/main/java/com/jsl/oa/dao/UserDAO.java Normal file → Executable file
View File

View File

View File

@ -14,6 +14,12 @@ import java.util.regex.Pattern;
@ControllerAdvice
public class ProcessException {
@ExceptionHandler(value = Exception.class)
public ResponseEntity<BaseResponse> businessException(@NotNull Exception e) {
e.printStackTrace();
return ResultUtil.error("Exception", 500, "服务器异常");
}
@ExceptionHandler(value = HttpRequestMethodNotSupportedException.class)
public ResponseEntity<BaseResponse> businessMethodNotAllowedException() {
return ResultUtil.error("MethodNotAllowed", 405, "请求方法错误");

0
src/main/java/com/jsl/oa/mapper/UserMapper.java Normal file → Executable file
View File

0
src/main/java/com/jsl/oa/model/doData/ConfigDO.java Normal file → Executable file
View File

View File

View File

0
src/main/java/com/jsl/oa/model/doData/ProjectDO.java Normal file → Executable file
View File

View File

View File

0
src/main/java/com/jsl/oa/model/doData/RoleDO.java Normal file → Executable file
View File

View File

0
src/main/java/com/jsl/oa/model/doData/RoleUserDO.java Normal file → Executable file
View File

0
src/main/java/com/jsl/oa/model/doData/UserDO.java Normal file → Executable file
View File

View File

0
src/main/java/com/jsl/oa/model/voData/UserLockVO.java Normal file → Executable file
View File

0
src/main/java/com/jsl/oa/model/voData/UserLoginVO.java Normal file → Executable file
View File

View File

View File

20
src/main/java/com/jsl/oa/services/AuthService.java Normal file → Executable file
View File

@ -36,13 +36,23 @@ public interface AuthService {
BaseResponse authLogin(UserLoginVO userLoginVO);
/**
* <h2>用户登出</h2>
* <h2>邮箱登陆</h2>
* <hr/>
* 用户登出服务类操作
* 用户邮箱登陆服务类操作
*
* @param email 用户邮箱
* @param email 邮箱
* @param code 验证码
* @return {@link BaseResponse}
* @author 筱锋xiao_lfeng
*/
BaseResponse authLoginByEmail(String email);
BaseResponse authLoginByEmail(String email, Integer code);
/**
* <h2>发送邮箱验证码</h2>
* <hr/>
* 用户邮箱登陆服务类操作
*
* @param email 邮箱
* @return {@link BaseResponse}
*/
BaseResponse authLoginSendEmailCode(String email);
}

45
src/main/java/com/jsl/oa/services/MailService.java Normal file → Executable file
View File

@ -1,8 +1,47 @@
package com.jsl.oa.services;
import javax.mail.MessagingException;
/**
* <h1>邮件服务接口</h1>
* <hr/>
* 用于发送邮件
*
* @author 筱锋xiao_lfeng
* @version v1.1.0
* @since v1.1.0
*/
public interface MailService {
void sendMail() throws MessagingException;
/**
* <h2>发送邮件通用模板</h2>
* <hr/>
* 更为广泛的内容发送用于发送普通文本邮件
*
* @param sendTo 收件人
* @param subject 主题
* @param text 内容
* @return 是否发送成功
*/
boolean sendMail(String sendTo, String subject, String text);
/**
* <h2>发送邮件通用模板</h2>
* <hr/>
* 发送邮件通用模板用于发送具有模板HTML邮件
*
* @param sendTo 收件人
* @param model 模板
* @return 是否发送成功
*/
boolean sendMail(String sendTo, String model);
/**
* <h2>邮件登陆模块</h2>
* <hr/>
* 用于发送用户登陆邮件
*
* @param email 邮箱
* @param code 验证码
* @return 是否发送成功
*/
boolean sendMailAboutUserLogin(String email, Integer code);
}

0
src/main/java/com/jsl/oa/services/UserService.java Normal file → Executable file
View File

View File

@ -1,34 +1,40 @@
package com.jsl.oa.services.impl;
import com.jsl.oa.model.doData.UserDO;
import com.jsl.oa.model.voData.UserLoginVO;
import com.jsl.oa.model.voData.UserReturnBackVO;
import com.jsl.oa.model.voData.UserRegisterVO;
import com.jsl.oa.common.constant.BusinessConstants;
import com.jsl.oa.exception.BusinessException;
import com.jsl.oa.mapper.UserMapper;
import com.jsl.oa.model.doData.UserDO;
import com.jsl.oa.model.voData.UserLoginVO;
import com.jsl.oa.model.voData.UserRegisterVO;
import com.jsl.oa.model.voData.UserReturnBackVO;
import com.jsl.oa.services.AuthService;
import com.jsl.oa.services.MailService;
import com.jsl.oa.utils.*;
import lombok.RequiredArgsConstructor;
import org.jetbrains.annotations.NotNull;
import org.mindrot.jbcrypt.BCrypt;
import org.springframework.stereotype.Service;
import java.util.regex.Pattern;
/**
* <h1>用户认证服务实现类</h1>
* <hr/>
* 用户认证服务实现类包含用户注册用户登录用户登出接口
*
* @since v1.0.0
* @version v1.1.0
* @see AuthService
* @since v1.0.0
*/
@Service
@RequiredArgsConstructor
public class AuthServiceImpl implements AuthService {
private final UserMapper userMapper;
private final MailService mailService;
private final EmailRedisUtil<Integer> emailRedisUtil;
@Override
public BaseResponse authRegister(UserRegisterVO userRegisterVO) {
public BaseResponse authRegister(@NotNull UserRegisterVO userRegisterVO) {
// 检查用户说是否存在
UserDO getUserByUsername = userMapper.getUserInfoByUsername(userRegisterVO.getUsername());
// 用户名已存在
@ -63,7 +69,20 @@ public class AuthServiceImpl implements AuthService {
@Override
public BaseResponse authLogin(@NotNull UserLoginVO userLoginVO) {
// 检查用户是否存在
UserDO userDO = userMapper.getUserInfoByUsername(userLoginVO.getUser());
UserDO userDO;
if (Pattern.matches("^[0-9A-Za-z_]{3,40}$", userLoginVO.getUser())) {
// 是否为用户名
userDO = userMapper.getUserInfoByUsername(userLoginVO.getUser());
} else if (Pattern.matches("^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\\d{8}$", userLoginVO.getUser())) {
// 是否为手机号
userDO = userMapper.getUserInfoByPhone(userLoginVO.getUser());
} else if (Pattern.matches("^\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*$", userLoginVO.getUser())) {
// 是否为邮箱
return ResultUtil.error(ErrorCode.EMAIL_LOGIN_NOT_SUPPORT);
} else {
// 工号
userDO = userMapper.getUserByJobId(userLoginVO.getUser());
}
if (userDO != null) {
// 获取用户并登陆
if (BCrypt.checkpw(userLoginVO.getPassword(), userDO.getPassword())) {
@ -88,8 +107,55 @@ public class AuthServiceImpl implements AuthService {
}
@Override
public BaseResponse authLoginByEmail(String email) {
return null;
public BaseResponse authLoginByEmail(String email, Integer code) {
// 获取验证码是否有效
Integer redisCode = emailRedisUtil.getData(BusinessConstants.BUSINESS_LOGIN, email);
if (redisCode != null) {
if (redisCode.equals(code)) {
// 删除验证码
if (emailRedisUtil.delData(BusinessConstants.BUSINESS_LOGIN, email)) {
// 邮箱获取用户
UserDO userDO = userMapper.getUserInfoByEmail(email);
// 授权 Token
String token = JwtUtil.generateToken(userDO.getUsername());
UserReturnBackVO userReturnBackVO = new UserReturnBackVO();
userReturnBackVO.setAddress(userDO.getAddress())
.setAge(userDO.getAge())
.setEmail(userDO.getEmail())
.setJobId(userDO.getJobId())
.setPhone(userDO.getPhone())
.setSex(userDO.getSex())
.setUsername(userDO.getUsername())
.setToken(token);
return ResultUtil.success("登陆成功", userReturnBackVO);
} else {
return ResultUtil.error(ErrorCode.DATABASE_DELETE_ERROR);
}
}
}
return ResultUtil.error(ErrorCode.VERIFICATION_INVALID);
}
}
@Override
public BaseResponse authLoginSendEmailCode(String email) {
// 获取用户信息
UserDO userDO = userMapper.getUserInfoByEmail(email);
if (userDO != null) {
// 生成验证码
Integer code = Processing.createCode();
// 存储验证码
if (emailRedisUtil.setData(BusinessConstants.BUSINESS_LOGIN, email, code, 5)) {
// 发送邮件
if (mailService.sendMailAboutUserLogin(email, code)) {
return ResultUtil.success("验证码已发送");
} else {
return ResultUtil.error(ErrorCode.EMAIL_LOGIN_NOT_SUPPORT);
}
} else {
return ResultUtil.error(ErrorCode.DATABASE_INSERT_ERROR);
}
} else {
return ResultUtil.error(ErrorCode.USER_NOT_EXIST);
}
}
}

View File

@ -6,42 +6,80 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
/**
* <h1>邮件服务实现类</h1>
* <hr/>
* 用于发送邮件
*
* @since v1.1.0
* @version v1.1.0
* @author 筱锋xiao_lfeng
* @see MailService
* @see JavaMailSender
* @see MimeMessageHelper
*/
@Service
@RequiredArgsConstructor
public class MailServiceImpl implements MailService {
private final JavaMailSender javaMailSender;
private final TemplateEngine templateEngine;
@Value("${spring.mail.username}")
private String from;
@Override
public void sendMail() {
public boolean sendMail(String sendTo, String subject, String text) {
//发送多媒体邮件
try {
MimeMessage message = javaMailSender.createMimeMessage();
//第二个参数控制着附件上传
MimeMessageHelper helper = new MimeMessageHelper(message, true);
helper.setFrom(from);
String to = "lfengzeng@vip.qq.com";
helper.setTo(to);
String subject = "springboot测试邮件";
helper.setTo(sendTo);
helper.setSubject(subject);
//第二个参数表示以 html 语法解析文本
String text = "你好:这是一封测试邮件。请坚持下去。加油!";
helper.setText(text, true);
javaMailSender.send(message);
} catch (Exception e) {
return true;
} catch (MessagingException e) {
//TODO: 10001-发送邮件失败处理
return false;
}
}
@Override
public boolean sendMail(String sendTo, String model) {
return false;
}
@Override
public boolean sendMailAboutUserLogin(String email, Integer code) {
// 发送邮件带HTML模块部分
try {
MimeMessage message = javaMailSender.createMimeMessage();
MimeMessageHelper mimeMessage = new MimeMessageHelper(message, true);
mimeMessage.setFrom(from);
mimeMessage.setTo(email);
mimeMessage.setSubject("用户登陆邮件");
Context context = new Context();
context.setVariable("code", code);
context.setVariable("email", email);
String emailContent = templateEngine.process("/mail/user-login.html", context);
mimeMessage.setText(emailContent, true);
javaMailSender.send(message);
return true;
} catch (MessagingException e) {
//TODO: 10001-发送邮件失败处理
return false;
}
}
}

View File

0
src/main/java/com/jsl/oa/utils/BaseResponse.java Normal file → Executable file
View File

View File

@ -0,0 +1,92 @@
package com.jsl.oa.utils;
import com.jsl.oa.common.constant.BusinessConstants;
import com.jsl.oa.common.constant.RedisConstant;
import com.jsl.oa.config.redis.RedisConfiguration;
import com.jsl.oa.config.redis.RedisOperating;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import java.util.concurrent.TimeUnit;
/**
* <h1>Redis工具类</h1>
* <hr/>
* 用于操作Redis
*
* @author 筱锋xiao_lfeng
* @version v1.1.0
* @see RedisConfiguration
* @see com.jsl.oa.common.constant.RedisConstant
* @since v1.1.0
*/
@Component
public class EmailRedisUtil<R> extends RedisOperating<R> {
public EmailRedisUtil(RedisTemplate<String, R> redisTemplate, StringRedisTemplate stringRedisTemplate) {
super(redisTemplate, stringRedisTemplate);
}
/**
* <h2>获取邮箱验证码过期时间</h2>
* <hr/>
* 用于 AuthController 中的 authLoginByEmail 方法<br/>
* 用于获取邮箱验证码过期时间
*
* @param email 邮箱
* @return 返回邮箱验证码过期时间戳
*/
@Override
public Long getExpiredAt(@NotNull BusinessConstants businessConstants, String email) {
String key = RedisConstant.TYPE_EMAIL + RedisConstant.TABLE_EMAIL + businessConstants.getValue() + email;
return redisTemplate.getExpire(key);
}
/**
* <h2>删除邮箱验证码</h2>
* <hr/>
* 用于 AuthController 中的 authLoginByEmail 方法<br/>
* 用于删除邮箱验证码
*
* @param email 邮箱
* @return 返回是否删除成功
*/
public Boolean delData(@NotNull BusinessConstants businessConstants, String email) {
String key = RedisConstant.TYPE_EMAIL + RedisConstant.TABLE_EMAIL + businessConstants.getValue() + email;
return redisTemplate.delete(key);
}
/**
* <h2>获取邮箱验证码</h2>
* <hr/>
* 用于 AuthController 中的 authLoginByEmail 方法<br/>
* 用于获取邮箱验证码
*
* @param email 邮箱
* @return 返回邮箱验证码
*/
public R getData(@NotNull BusinessConstants businessConstants, String email) {
String key = RedisConstant.TYPE_EMAIL + RedisConstant.TABLE_EMAIL + businessConstants.getValue() + email;
return redisTemplate.opsForValue().get(key);
}
/**
* <h2>设置邮箱验证码</h2>
* <hr/>
* 用于 AuthController 中的 authLoginByEmail 方法<br/>
* 用于设置邮箱验证码
*
* @param email 邮箱
* @param value 验证码
* @return 返回是否添加成功
*/
public Boolean setData(@NotNull BusinessConstants businessConstants, String email, R value, Integer time) {
// 处理数据
String key = RedisConstant.TYPE_EMAIL + RedisConstant.TABLE_EMAIL + businessConstants.getValue() + email;
redisTemplate.opsForValue().set(key, value);
redisTemplate.expire(key, time, TimeUnit.MINUTES);
return true;
}
}

2
src/main/java/com/jsl/oa/utils/ErrorCode.java Normal file → Executable file
View File

@ -12,6 +12,8 @@ public enum ErrorCode {
USER_NOT_EXIST("UserNotExist", 40015, "用户不存在"),
UNAUTHORIZED("Unauthorized", 40100, "未授权"),
TOKEN_EXPIRED("TokenExpired", 40101, "Token已过期"),
VERIFICATION_INVALID("VerificationInvalid", 40102, "验证码无效"),
EMAIL_LOGIN_NOT_SUPPORT("EmailLoginNotSupport", 40300, "请使用邮箱登陆"),
DATABASE_INSERT_ERROR("DatabaseInsertError", 50010, "数据库插入错误"),
DATABASE_UPDATE_ERROR("DatabaseUpdateError", 50011, "数据库更新错误"),
DATABASE_DELETE_ERROR("DatabaseDeleteError", 50012, "数据库删除错误");

0
src/main/java/com/jsl/oa/utils/JwtUtil.java Normal file → Executable file
View File

4
src/main/java/com/jsl/oa/utils/Processing.java Normal file → Executable file
View File

@ -77,13 +77,13 @@ public class Processing {
/**
*
*/
public static @NotNull String createCode() {
public static @NotNull Integer createCode() {
StringBuilder stringBuilder = new StringBuilder();
// 生成验证码
Random random = new Random();
for (int i = 0; i < 6; i++) {
stringBuilder.append(random.nextInt(10));
}
return stringBuilder.toString();
return Integer.valueOf(stringBuilder.toString());
}
}

0
src/main/java/com/jsl/oa/utils/ResultUtil.java Normal file → Executable file
View File

0
src/main/resources/.gitkeep Normal file → Executable file
View File

0
src/main/resources/application.yml Normal file → Executable file
View File

0
src/main/resources/com/jsl/oa/mapper/UserMapper.xml Normal file → Executable file
View File

View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-cn">
<head>
<title>登录邮件模板</title>
<style>
body {
font-family: 'Arial', sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
width: 80%;
margin: 0 auto;
overflow: hidden;
}
header {
background: #ffffff;
padding: 10px 0;
box-shadow: 0 5px 5px #888888;
}
header img {
width: 100px;
height: auto;
}
.main {
padding: 20px 0;
}
.main h2 {
color: #333;
}
.main p {
color: #555;
}
.code {
background: #4CAF50;
color: #ffffff;
padding: 10px;
text-align: center;
font-size: 24px;
margin: 20px 0;
}
footer {
background: #ffffff;
padding: 10px 0;
box-shadow: 0 -5px 5px #888888;
}
footer p {
text-align: center;
color: #888;
}
</style>
</head>
<body>
<div class="container">
<header>
<!--<img src="path/to/your/logo.png" alt="Logo">-->
测试
</header>
<div class="main">
<h2>登录您的账户</h2>
<p>
你好,<b th:text="${email}">[收件人]</b>
<br>
使用以下验证码登录您的账户:
</p>
<div class="code" th:text="${code}">000000</div>
<p>
如果您未请求此验证码,请忽略此邮件。
<br>
感谢您使用我们的服务。
</p>
</div>
<footer>
<p>© 2024 您的公司。保留所有权利。</p>
</footer>
</div>
</body>
</html>

View File