From 96bf3891d660587f290bbb546d799a1a576dddc2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=86=B7=E8=B0=83?= <3084898776@qq.com>
Date: Thu, 1 Aug 2024 09:33:03 +0800
Subject: [PATCH] =?UTF-8?q?=E6=97=A5=E8=80=8313?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 38 ++
.idea/$PROJECT_FILE$ | 11 +
.idea/.gitignore | 8 +
.idea/encodings.xml | 12 +
.idea/inspectionProfiles/Project_Default.xml | 5 +
.idea/misc.xml | 30 ++
.idea/qaplug_profiles.xml | 465 ++++++++++++++++++
.idea/uiDesigner.xml | 124 +++++
bwie-common/pom.xml | 66 +++
.../com/bwie/common/config/RedisConfig.java | 40 ++
.../com/bwie/common/constants/Constants.java | 18 +
.../bwie/common/constants/JwtConstants.java | 29 ++
.../common/constants/RabbitMQConstants.java | 5 +
.../bwie/common/constants/TokenConstants.java | 24 +
.../java/com/bwie/common/domain/User.java | 34 ++
.../common/domain/response/JwtResponse.java | 9 +
.../com/bwie/common/result/PageResult.java | 34 ++
.../java/com/bwie/common/result/Result.java | 76 +++
.../com/bwie/common/utils/GenCodeUtils.java | 86 ++++
.../java/com/bwie/common/utils/JwtUtils.java | 115 +++++
.../com/bwie/common/utils/StringUtils.java | 67 +++
bwie-user/pom.xml | 39 ++
.../java/com/bwie/user/UserApplication.java | 14 +
.../bwie/user/controller/UserController.java | 24 +
.../java/com/bwie/user/mapper/UserMapper.java | 12 +
.../com/bwie/user/service/UserService.java | 13 +
.../user/service/impl/UserServiceImpl.java | 41 ++
bwie-user/src/main/resources/application.yml | 17 +
pom.xml | 60 +++
29 files changed, 1516 insertions(+)
create mode 100644 .gitignore
create mode 100644 .idea/$PROJECT_FILE$
create mode 100644 .idea/.gitignore
create mode 100644 .idea/encodings.xml
create mode 100644 .idea/inspectionProfiles/Project_Default.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/qaplug_profiles.xml
create mode 100644 .idea/uiDesigner.xml
create mode 100644 bwie-common/pom.xml
create mode 100644 bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constants/Constants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/User.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/result/PageResult.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/result/Result.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/GenCodeUtils.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java
create mode 100644 bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java
create mode 100644 bwie-user/pom.xml
create mode 100644 bwie-user/src/main/java/com/bwie/user/UserApplication.java
create mode 100644 bwie-user/src/main/java/com/bwie/user/controller/UserController.java
create mode 100644 bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java
create mode 100644 bwie-user/src/main/java/com/bwie/user/service/UserService.java
create mode 100644 bwie-user/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java
create mode 100644 bwie-user/src/main/resources/application.yml
create mode 100644 pom.xml
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..5ff6309
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,38 @@
+target/
+!.mvn/wrapper/maven-wrapper.jar
+!**/src/main/**/target/
+!**/src/test/**/target/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+build/
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$
new file mode 100644
index 0000000..58b7e3e
--- /dev/null
+++ b/.idea/$PROJECT_FILE$
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..13566b8
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
new file mode 100644
index 0000000..bb8df53
--- /dev/null
+++ b/.idea/encodings.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..8d66637
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..f25c597
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+ {
+ "isMigrated": true
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml
new file mode 100644
index 0000000..3dfd21f
--- /dev/null
+++ b/.idea/qaplug_profiles.xml
@@ -0,0 +1,465 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/bwie-common/pom.xml b/bwie-common/pom.xml
new file mode 100644
index 0000000..fa85c63
--- /dev/null
+++ b/bwie-common/pom.xml
@@ -0,0 +1,66 @@
+
+
+ 4.0.0
+
+ com.bwie
+ zhuangao6rk1313
+ 1.0-SNAPSHOT
+
+
+ bwie-common
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+
+ io.jsonwebtoken
+ jjwt
+ 0.9.1
+
+
+
+ com.alibaba
+ fastjson
+ 1.2.80
+
+
+
+ org.springframework.boot
+ spring-boot-starter-data-redis
+
+
+
+ org.springframework.boot
+ spring-boot-starter-validation
+
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ cn.hutool
+ hutool-all
+ 5.8.3
+
+
+
+ com.baomidou
+ mybatis-plus-boot-starter
+ 3.5.7
+
+
+
+
diff --git a/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java b/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java
new file mode 100644
index 0000000..b62e4b1
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/config/RedisConfig.java
@@ -0,0 +1,40 @@
+package com.bwie.common.config;
+
+import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.PropertyAccessor;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
+import org.springframework.data.redis.serializer.StringRedisSerializer;
+
+@Configuration
+public class RedisConfig {
+
+ @Bean
+ public RedisTemplate redisTemplate(RedisConnectionFactory factory) {
+ RedisTemplate template = new RedisTemplate<>();
+ template.setConnectionFactory(factory);
+ Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new
+ Jackson2JsonRedisSerializer(Object.class);
+ ObjectMapper om = new ObjectMapper();
+ om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
+ om.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL);
+ jackson2JsonRedisSerializer.setObjectMapper(om);
+
+ StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
+ // key采用String的序列化方式
+ template.setKeySerializer(stringRedisSerializer);
+ // hash的key也采用String的序列化方式
+ template.setHashKeySerializer(stringRedisSerializer);
+ // value序列化方式采用jackson
+ template.setValueSerializer(jackson2JsonRedisSerializer);
+ // hash的value序列化方式采用jackson
+ template.setHashValueSerializer(jackson2JsonRedisSerializer);
+ template.afterPropertiesSet();
+
+ return template;
+ }
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/constants/Constants.java b/bwie-common/src/main/java/com/bwie/common/constants/Constants.java
new file mode 100644
index 0000000..2fdc9fe
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/constants/Constants.java
@@ -0,0 +1,18 @@
+package com.bwie.common.constants;
+
+/**
+ * @description: 系统常量
+ * @author DongZl
+ */
+public class Constants {
+ /**
+ * 成功标记
+ */
+ public static final Integer SUCCESS = 200;
+ public static final String SUCCESS_MSG = "操作成功";
+ /**
+ * 失败标记
+ */
+ public static final Integer ERROR = 500;
+ public static final String ERROR_MSG = "操作异常";
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java
new file mode 100644
index 0000000..03692c1
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/constants/JwtConstants.java
@@ -0,0 +1,29 @@
+package com.bwie.common.constants;
+
+/**
+ * @author DongZl
+ * @description: Jwt常量
+ */
+public class JwtConstants {
+
+ /**
+ * 用户ID字段
+ */
+ public static final String DETAILS_USER_ID = "user_id";
+
+ /**
+ * 用户名字段
+ */
+ public static final String DETAILS_USERNAME = "username";
+
+ /**
+ * 用户标识
+ */
+ public static final String USER_KEY = "user_key";
+
+ /**
+ * 令牌秘钥
+ */
+ public final static String SECRET = "abcdefghijklmnopqrstuvwxyz";
+
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java
new file mode 100644
index 0000000..1f09187
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/constants/RabbitMQConstants.java
@@ -0,0 +1,5 @@
+package com.bwie.common.constants;
+
+public class RabbitMQConstants {
+ public static final String SEND_SMS_QUEUE = "send_sms_queue";
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java b/bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java
new file mode 100644
index 0000000..1871fb7
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/constants/TokenConstants.java
@@ -0,0 +1,24 @@
+package com.bwie.common.constants;
+
+/**
+ * @author DongZl
+ * @description: 令牌常量
+ */
+public class TokenConstants {
+ /**
+ * 缓存有效期,默认720(分钟)
+ */
+ public final static long EXPIRATION = 720;
+ /**
+ * 缓存刷新时间,默认120(分钟)
+ */
+ public final static long REFRESH_TIME = 120;
+ /**
+ * 权限缓存前缀
+ */
+ public final static String LOGIN_TOKEN_KEY = "login_tokens:";
+ /**
+ * token标识
+ */
+ public static final String TOKEN = "token";
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/User.java b/bwie-common/src/main/java/com/bwie/common/domain/User.java
new file mode 100644
index 0000000..98bc264
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/domain/User.java
@@ -0,0 +1,34 @@
+package com.bwie.common.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * @author Lenovo
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@TableName("user")
+public class User {
+ /**
+ * 用户编号
+ */
+ @TableId(type = IdType.AUTO)
+ private Integer id;
+ /**
+ * 用户名
+ */
+ @TableField("user_name")
+ private String userName;
+ /**
+ * 密码
+ */
+ @TableField("password")
+ private String password;
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java b/bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java
new file mode 100644
index 0000000..5d888b2
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/domain/response/JwtResponse.java
@@ -0,0 +1,9 @@
+package com.bwie.common.domain.response;
+
+import lombok.Data;
+
+@Data
+public class JwtResponse {
+ private String token;
+ private String existTime;
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/result/PageResult.java b/bwie-common/src/main/java/com/bwie/common/result/PageResult.java
new file mode 100644
index 0000000..85ecdda
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/result/PageResult.java
@@ -0,0 +1,34 @@
+package com.bwie.common.result;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author DongZl
+ * @description: 列表返回结果集
+ */
+@Data
+public class PageResult implements Serializable {
+ /**
+ * 总条数
+ */
+ private long total;
+ /**
+ * 结果集合
+ */
+ private List list;
+ public PageResult() {
+ }
+ public PageResult(long total, List list) {
+ this.total = total;
+ this.list = list;
+ }
+ public static PageResult toPageResult(long total, List list){
+ return new PageResult(total , list);
+ }
+ public static Result> toResult(long total, List list){
+ return Result.success(PageResult.toPageResult(total,list));
+ }
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/result/Result.java b/bwie-common/src/main/java/com/bwie/common/result/Result.java
new file mode 100644
index 0000000..30b1e73
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/result/Result.java
@@ -0,0 +1,76 @@
+package com.bwie.common.result;
+
+import com.bwie.common.constants.Constants;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author DongZl
+ * @description: 响应信息主体
+ */
+@Data
+public class Result implements Serializable {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * 成功
+ */
+ public static final int SUCCESS = Constants.SUCCESS;
+ /**
+ * 失败
+ */
+ public static final int FAIL = Constants.ERROR;
+ /**
+ * 返回状态码
+ */
+ private int code;
+ /**
+ * 响应信息
+ */
+ private String msg;
+ /**
+ * 响应数据
+ */
+ private T data;
+
+ public static Result success() {
+ return restResult(null, SUCCESS, Constants.SUCCESS_MSG);
+ }
+
+ public static Result success(T data) {
+ return restResult(data, SUCCESS, Constants.SUCCESS_MSG);
+ }
+
+ public static Result success(T data, String msg) {
+ return restResult(data, SUCCESS, msg);
+ }
+
+ public static Result error() {
+ return restResult(null, FAIL, Constants.ERROR_MSG);
+ }
+
+ public static Result error(String msg) {
+ return restResult(null, FAIL, msg);
+ }
+
+ public static Result error(T data) {
+ return restResult(data, FAIL, Constants.ERROR_MSG);
+ }
+
+ public static Result error(T data, String msg) {
+ return restResult(data, FAIL, msg);
+ }
+
+ public static Result error(int code, String msg) {
+ return restResult(null, code, msg);
+ }
+
+ private static Result restResult(T data, int code, String msg) {
+ Result apiResult = new Result<>();
+ apiResult.setCode(code);
+ apiResult.setData(data);
+ apiResult.setMsg(msg);
+ return apiResult;
+ }
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/utils/GenCodeUtils.java b/bwie-common/src/main/java/com/bwie/common/utils/GenCodeUtils.java
new file mode 100644
index 0000000..2ae9ff9
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/utils/GenCodeUtils.java
@@ -0,0 +1,86 @@
+package com.bwie.common.utils;
+
+import java.util.Random;
+
+/**
+ * @description: 生成验证码工具类
+ * @Date 2023-5-11 上午 10:09
+ */
+public class GenCodeUtils {
+
+ /**
+ * 数字类型
+ */
+ private static final String NUMBER_STR = "0123456789";
+ /**
+ * 字母类型
+ */
+ private static final String LETTERS_STR = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
+
+ /**
+ * 短信验证码长度
+ */
+ private static final Integer SMS_CODE_LENGTH = 4;
+
+ /**
+ * 生成短信四位验证码
+ * @return 验证码
+ */
+ public static String genLetterStrSms(){
+ return genCode(LETTERS_STR, SMS_CODE_LENGTH);
+ }
+
+ /**
+ * 生成短信四位验证码
+ * @return 验证码
+ */
+ public static String genNumberCodeSms(){
+ return genCode(NUMBER_STR, SMS_CODE_LENGTH);
+ }
+
+ /**
+ * 生成验证码
+ * @param codeLength 验证码长度
+ * @return 验证码
+ */
+ public static String genLetterStr(int codeLength){
+ return genCode(LETTERS_STR, codeLength);
+ }
+
+ /**
+ * 生成验证码
+ * @param codeLength 验证码长度
+ * @return 验证码
+ */
+ public static String genNumberCode( int codeLength){
+ return genCode(NUMBER_STR, codeLength);
+ }
+
+ /**
+ * 生成验证码
+ * @param str 验证码字符串
+ * @param codeLength 验证码长度
+ * @return 验证码
+ */
+ public static String genCode (String str, int codeLength){
+ //将字符串转换为一个新的字符数组。
+ char[] verificationCodeArray = str.toCharArray();
+ Random random = new Random();
+ //计数器
+ int count = 0;
+ StringBuilder stringBuilder = new StringBuilder();
+ do {
+ //随机生成一个随机数
+ int index = random.nextInt(verificationCodeArray.length);
+ char c = verificationCodeArray[index];
+ //限制四位不重复数字
+ if (stringBuilder.indexOf(String.valueOf(c)) == -1) {
+ stringBuilder.append(c);
+ //计数器加1
+ count++;
+ }
+ //当count等于4时结束,随机生成四位数的验证码
+ } while (count != codeLength);
+ return stringBuilder.toString();
+ }
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java b/bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java
new file mode 100644
index 0000000..75f3c7b
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/utils/JwtUtils.java
@@ -0,0 +1,115 @@
+package com.bwie.common.utils;
+
+import com.bwie.common.constants.JwtConstants;
+import io.jsonwebtoken.Claims;
+import io.jsonwebtoken.Jwts;
+import io.jsonwebtoken.SignatureAlgorithm;
+
+import java.util.Map;
+
+/**
+ * @description: Jwt工具类
+ */
+public class JwtUtils {
+
+ /**
+ * 秘钥
+ */
+ public static String secret = JwtConstants.SECRET;
+
+ /**
+ * 从数据声明生成令牌
+ *
+ * @param claims 数据声明
+ * @return 令牌
+ */
+ public static String createToken(Map claims) {
+ String token = Jwts.builder().setClaims(claims).signWith(SignatureAlgorithm.HS512, secret).compact();
+ return token;
+ }
+
+ /**
+ * 从令牌中获取数据声明
+ *
+ * @param token 令牌
+ * @return 数据声明
+ */
+ public static Claims parseToken(String token) {
+ return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
+ }
+
+ /**
+ * 根据令牌获取用户标识
+ *
+ * @param token 令牌
+ * @return 用户ID
+ */
+ public static String getUserKey(String token) {
+ Claims claims = parseToken(token);
+ return getValue(claims, JwtConstants.USER_KEY);
+ }
+
+ /**
+ * 根据令牌获取用户标识
+ *
+ * @param claims 身份信息
+ * @return 用户ID
+ */
+ public static String getUserKey(Claims claims) {
+ return getValue(claims, JwtConstants.USER_KEY);
+ }
+
+ /**
+ * 根据令牌获取用户ID
+ *
+ * @param token 令牌
+ * @return 用户ID
+ */
+ public static String getUserId(String token) {
+ Claims claims = parseToken(token);
+ return getValue(claims, JwtConstants.DETAILS_USER_ID);
+ }
+
+ /**
+ * 根据身份信息获取用户ID
+ *
+ * @param claims 身份信息
+ * @return 用户ID
+ */
+ public static String getUserId(Claims claims) {
+ return getValue(claims, JwtConstants.DETAILS_USER_ID);
+ }
+
+ /**
+ * 根据令牌获取用户名
+ *
+ * @param token 令牌
+ * @return 用户名
+ */
+ public static String getUserName(String token) {
+ Claims claims = parseToken(token);
+ return getValue(claims, JwtConstants.DETAILS_USERNAME);
+ }
+
+ /**
+ * 根据身份信息获取用户名
+ *
+ * @param claims 身份信息
+ * @return 用户名
+ */
+ public static String getUserName(Claims claims) {
+ return getValue(claims, JwtConstants.DETAILS_USERNAME);
+ }
+
+ /**
+ * 根据身份信息获取键值
+ *
+ * @param claims 身份信息
+ * @param key 键
+ * @return 值
+ */
+ public static String getValue(Claims claims, String key) {
+ Object obj = claims.get(key);
+ return obj == null ? "" : obj.toString();
+ }
+}
diff --git a/bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java b/bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java
new file mode 100644
index 0000000..7cf6a15
--- /dev/null
+++ b/bwie-common/src/main/java/com/bwie/common/utils/StringUtils.java
@@ -0,0 +1,67 @@
+package com.bwie.common.utils;
+
+import org.springframework.util.AntPathMatcher;
+
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * @description: 字符串处理工具类
+ */
+public class StringUtils extends org.apache.commons.lang3.StringUtils {
+
+ /**
+ * * 判断一个对象是否为空
+ *
+ * @param object Object
+ * @return true:为空 false:非空
+ */
+ public static boolean isNull(Object object) {
+ return object == null;
+ }
+
+ /**
+ * * 判断一个Collection是否为空, 包含List,Set,Queue
+ *
+ * @param coll 要判断的Collection
+ * @return true:为空 false:非空
+ */
+ public static boolean isEmpty(Collection> coll) {
+ return isNull(coll) || coll.isEmpty();
+ }
+
+ /**
+ * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
+ *
+ * @param str 指定字符串
+ * @param strs 需要检查的字符串数组
+ * @return 是否匹配
+ */
+ public static boolean matches(String str, List strs) {
+ if (isEmpty(str) || isEmpty(strs)) {
+ return false;
+ }
+ for (String pattern : strs) {
+ if (isMatch(pattern, str))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * 判断url是否与规则配置:
+ * ? 表示单个字符;
+ * * 表示一层路径内的任意字符串,不可跨层级;
+ * ** 表示任意层路径;
+ *
+ * @param pattern 匹配规则
+ * @param url 需要匹配的url
+ * @return
+ */
+ public static boolean isMatch(String pattern, String url) {
+ AntPathMatcher matcher = new AntPathMatcher();
+ return matcher.match(pattern, url);
+ }
+}
diff --git a/bwie-user/pom.xml b/bwie-user/pom.xml
new file mode 100644
index 0000000..3145470
--- /dev/null
+++ b/bwie-user/pom.xml
@@ -0,0 +1,39 @@
+
+
+ 4.0.0
+
+ com.bwie
+ zhuangao6rk1313
+ 1.0-SNAPSHOT
+
+
+ bwie-user
+
+
+ 17
+ 17
+ UTF-8
+
+
+
+
+
+ com.bwie
+ bwie-common
+ 1.0-SNAPSHOT
+
+
+
+ mysql
+ mysql-connector-java
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
diff --git a/bwie-user/src/main/java/com/bwie/user/UserApplication.java b/bwie-user/src/main/java/com/bwie/user/UserApplication.java
new file mode 100644
index 0000000..3f2e7e5
--- /dev/null
+++ b/bwie-user/src/main/java/com/bwie/user/UserApplication.java
@@ -0,0 +1,14 @@
+package com.bwie.user;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * @author Lenovo
+ */
+@SpringBootApplication
+public class UserApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(UserApplication.class);
+ }
+}
diff --git a/bwie-user/src/main/java/com/bwie/user/controller/UserController.java b/bwie-user/src/main/java/com/bwie/user/controller/UserController.java
new file mode 100644
index 0000000..049717a
--- /dev/null
+++ b/bwie-user/src/main/java/com/bwie/user/controller/UserController.java
@@ -0,0 +1,24 @@
+package com.bwie.user.controller;
+
+import com.bwie.common.domain.User;
+import com.bwie.common.domain.response.JwtResponse;
+import com.bwie.common.result.Result;
+import com.bwie.user.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author Lenovo
+ */
+@RestController
+public class UserController {
+ @Autowired
+ private UserService userService;
+
+ @PostMapping("/login")
+ public Result login(@RequestBody User user){
+ return userService.login(user);
+ }
+}
diff --git a/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java b/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java
new file mode 100644
index 0000000..75ccfdd
--- /dev/null
+++ b/bwie-user/src/main/java/com/bwie/user/mapper/UserMapper.java
@@ -0,0 +1,12 @@
+package com.bwie.user.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.bwie.common.domain.User;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * @author Lenovo
+ */
+@Mapper
+public interface UserMapper extends BaseMapper {
+}
diff --git a/bwie-user/src/main/java/com/bwie/user/service/UserService.java b/bwie-user/src/main/java/com/bwie/user/service/UserService.java
new file mode 100644
index 0000000..eed31d3
--- /dev/null
+++ b/bwie-user/src/main/java/com/bwie/user/service/UserService.java
@@ -0,0 +1,13 @@
+package com.bwie.user.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.bwie.common.domain.User;
+import com.bwie.common.domain.response.JwtResponse;
+import com.bwie.common.result.Result;
+
+/**
+ * @author Lenovo
+ */
+public interface UserService extends IService {
+ Result login(User user);
+}
diff --git a/bwie-user/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java b/bwie-user/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java
new file mode 100644
index 0000000..78f953b
--- /dev/null
+++ b/bwie-user/src/main/java/com/bwie/user/service/impl/UserServiceImpl.java
@@ -0,0 +1,41 @@
+package com.bwie.user.service.impl;
+
+import com.alibaba.fastjson.JSON;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.bwie.common.constants.JwtConstants;
+import com.bwie.common.constants.TokenConstants;
+import com.bwie.common.domain.User;
+import com.bwie.common.domain.response.JwtResponse;
+import com.bwie.common.result.Result;
+import com.bwie.common.utils.JwtUtils;
+import com.bwie.common.utils.StringUtils;
+import com.bwie.user.mapper.UserMapper;
+import com.bwie.user.service.UserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Service;
+import java.util.HashMap;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * @author Lenovo
+ */
+@Service
+public class UserServiceImpl extends ServiceImpl implements UserService {
+
+ @Override
+ public Result login(User user) {
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ if(StringUtils.isAnyBlank(user.getUserName(),user.getPassword())){
+ return Result.error("用户名或密码不能为空");
+ }
+ LambdaQueryWrapper select = lambdaQueryWrapper.select(User::getUserName, User::getPassword);
+ if(select!=null){
+ return Result.success("登录成功");
+ }
+ return Result.success("登录失败");
+ }
+}
diff --git a/bwie-user/src/main/resources/application.yml b/bwie-user/src/main/resources/application.yml
new file mode 100644
index 0000000..f4cc777
--- /dev/null
+++ b/bwie-user/src/main/resources/application.yml
@@ -0,0 +1,17 @@
+
+server:
+ port: 8080
+
+spring:
+ datasource:
+ driver-class-name: com.mysql.cj.jdbc.Driver
+ url: jdbc:mysql://129.211.0.187:3306/zhuangao6rk1313
+ username: root
+ password: wmw1234
+
+
+mybatis-plus:
+ mapper-locations: classpath*:mapper/*.xml
+ configuration:
+ # 设置Mybatis的日志实现类为控制台输出
+ log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..bde109e
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,60 @@
+
+
+ 4.0.0
+
+ com.bwie
+ zhuangao6rk1313
+ 1.0-SNAPSHOT
+ pom
+
+ bwie-user
+ bwie-common
+
+
+
+
+
+ spring-boot-starter-parent
+ org.springframework.boot
+ 2.6.2
+
+
+
+
+
+
+
+ org.springframework.cloud
+ spring-cloud-dependencies
+ 2021.0.0
+ pom
+ import
+
+
+
+ com.alibaba.cloud
+ spring-cloud-alibaba-dependencies
+ 2021.1
+ pom
+ import
+
+
+
+ com.alibaba.nacos
+ nacos-client
+ 2.0.4
+
+
+
+
+ com.bwie
+ bwie-common
+ 1.0-SNAPSHOT
+
+
+
+
+
+