commit 3a9a3ad59d393b54af5ebcf8eac405489657413a
Author: Your Username <3342440179@qq.com>
Date: Thu Apr 24 13:16:44 2025 +0800
添加注释
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..89be8cf
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 数据源本地存储已忽略文件
+/../../../../../../../:\Users\33424\Desktop\gym\jianshenfanggl\.idea/dataSources/
+/dataSources.local.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
new file mode 100644
index 0000000..03d9549
--- /dev/null
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jianshenfanggl.iml b/.idea/jianshenfanggl.iml
new file mode 100644
index 0000000..d6ebd48
--- /dev/null
+++ b/.idea/jianshenfanggl.iml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..51e0d1c
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..c2152f6
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,187 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.2.2.RELEASE
+
+
+ com.jlwl
+
+ jianshenfanggl
+ 0.0.1-SNAPSHOT
+ jianshenfanggl
+ 健身房管理系统
+
+
+ 1.8
+ 1.2.8
+ 3.1.1
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+ 2.1.1
+
+
+ org.springframework.boot
+ spring-boot-starter-jdbc
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-thymeleaf
+
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+
+ mysql
+ mysql-connector-java
+
+
+ org.apache.shiro
+ shiro-spring
+ 1.3.2
+
+
+
+ com.baomidou
+ mybatis-plus
+ 2.3
+
+
+ com.baomidou
+ mybatisplus-spring-boot-starter
+ 1.0.5
+
+
+ com.google.protobuf
+ protobuf-java
+ 3.10.0
+
+
+
+ org.apache.commons
+ commons-lang3
+ 3.0
+
+
+
+ javax.validation
+ validation-api
+ 2.0.1.Final
+
+
+
+ commons-io
+ commons-io
+ 2.5
+
+
+
+
+ cn.hutool
+ hutool-all
+ 4.0.12
+
+
+
+
+ com.alibaba
+ fastjson
+ ${fastjson.version}
+
+
+
+
+
+ com.baidu.aip
+ java-sdk
+ 4.4.1
+
+
+
+
+ commons-io
+ commons-io
+ 2.2
+
+
+ org.apache.poi
+ poi-examples
+ 3.9
+
+
+ org.apache.poi
+ poi-excelant
+ 3.9
+
+
+ org.apache.poi
+ poi-ooxml
+ 3.9
+
+
+ org.apache.poi
+ poi-ooxml-schemas
+ 3.9
+
+
+ org.apache.poi
+ poi-scratchpad
+ 3.9
+
+
+ com.alipay.sdk
+ alipay-sdk-java
+ 4.10.170.ALL
+
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+
+
+
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/src/main/java/com/ServletContextListener/DictionaryServletContextListener.java b/src/main/java/com/ServletContextListener/DictionaryServletContextListener.java
new file mode 100644
index 0000000..a74d177
--- /dev/null
+++ b/src/main/java/com/ServletContextListener/DictionaryServletContextListener.java
@@ -0,0 +1,61 @@
+package com.ServletContextListener;
+
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.entity.DictionaryEntity;
+import com.service.DictionaryService;
+import com.thread.MyThreadMethod;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.context.ApplicationContext;
+import org.springframework.web.context.support.WebApplicationContextUtils;
+
+import javax.servlet.ServletContextListener;
+import javax.servlet.ServletContextEvent;
+import javax.servlet.annotation.WebListener;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 字典初始化监视器 用的是服务器监听,每次项目启动,都会调用这个类
+ */
+@WebListener
+public class DictionaryServletContextListener implements ServletContextListener {
+
+ private static final Logger logger = LoggerFactory.getLogger(DictionaryServletContextListener.class);
+ private MyThreadMethod myThreadMethod;
+ @Override
+ public void contextDestroyed(ServletContextEvent sce) {
+ logger.info("----------服务器停止----------");
+ }
+
+ @Override
+ public void contextInitialized(ServletContextEvent sce) {
+ ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(sce.getServletContext());
+
+ logger.info("----------字典表初始化开始----------");
+ DictionaryService dictionaryService = (DictionaryService)appContext.getBean("dictionaryService");
+ List dictionaryEntities = dictionaryService.selectList(new EntityWrapper());
+ Map> map = new HashMap<>();
+ for(DictionaryEntity d :dictionaryEntities){
+ Map m = map.get(d.getDicCode());
+ if(m ==null || m.isEmpty()){
+ m = new HashMap<>();
+ }
+ m.put(d.getCodeIndex(),d.getIndexName());
+ map.put(d.getDicCode(),m);
+ }
+ sce.getServletContext().setAttribute("dictionaryMap", map);
+ logger.info("----------字典表初始化完成----------");
+
+
+
+ logger.info("----------线程执行开始----------");
+ if (myThreadMethod == null) {
+ myThreadMethod = new MyThreadMethod();
+ myThreadMethod.start(); // servlet 上下文初始化时启动线程myThreadMethod
+ }
+ logger.info("----------线程执行结束----------");
+ }
+
+}
diff --git a/src/main/java/com/annotation/APPLoginUser.java b/src/main/java/com/annotation/APPLoginUser.java
new file mode 100644
index 0000000..b57ee2f
--- /dev/null
+++ b/src/main/java/com/annotation/APPLoginUser.java
@@ -0,0 +1,24 @@
+// 定义该文件所在的包路径,在 Java 里,包是组织类和接口的一种方式,此包路径为 com.annotation,能防止命名冲突,也便于代码的管理与维护
+package com.annotation;
+
+// 导入 java.lang.annotation.ElementType 类,它是一个枚举类型,包含了多种不同的元素类型,像类、方法、字段等,在定义注解时可借助它来指定注解的作用目标
+import java.lang.annotation.ElementType;
+
+// 导入 java.lang.annotation.Retention 注解,它用于指定注解的保留策略,也就是注解在不同阶段的存活时间和可见性
+import java.lang.annotation.Retention;
+
+// 导入 java.lang.annotation.RetentionPolicy 枚举类,它定义了三种保留策略,分别是 SOURCE(仅在源码中保留)、CLASS(在编译后的字节码文件中保留,但运行时不可用)、RUNTIME(在运行时也保留,可通过反射机制获取)
+import java.lang.annotation.RetentionPolicy;
+
+// 导入 java.lang.annotation.Target 注解,它用于指定自定义注解可以应用的目标元素类型,与 ElementType 结合使用,能精确控制注解的使用范围
+import java.lang.annotation.Target;
+
+// 登录用户信息注解
+// 用于标识Controller方法中需要注入当前登录用户信息的参数
+@Target(ElementType.PARAMETER)
+// 指定该注解只能用于方法参数上
+@Retention(RetentionPolicy.RUNTIME)
+public @interface APPLoginUser {// 指定该注解在运行时保留,可以通过反射读取
+ // 这是一个标记注解,不包含任何属性
+ // 用于标识需要自动注入当前登录用户信息的参数
+}
\ No newline at end of file
diff --git a/src/main/java/com/annotation/ColumnInfo.java b/src/main/java/com/annotation/ColumnInfo.java
new file mode 100644
index 0000000..d041578
--- /dev/null
+++ b/src/main/java/com/annotation/ColumnInfo.java
@@ -0,0 +1,13 @@
+package com.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface ColumnInfo {
+ String comment();
+ String type();
+}
diff --git a/src/main/java/com/annotation/IgnoreAuth.java b/src/main/java/com/annotation/IgnoreAuth.java
new file mode 100644
index 0000000..7c3cc55
--- /dev/null
+++ b/src/main/java/com/annotation/IgnoreAuth.java
@@ -0,0 +1,13 @@
+package com.annotation;
+
+import java.lang.annotation.*;
+
+/**
+ * 忽略Token验证
+ */
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+@Documented
+public @interface IgnoreAuth {
+
+}
diff --git a/src/main/java/com/annotation/LoginUser.java b/src/main/java/com/annotation/LoginUser.java
new file mode 100644
index 0000000..3d808d3
--- /dev/null
+++ b/src/main/java/com/annotation/LoginUser.java
@@ -0,0 +1,15 @@
+package com.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * 登录用户信息
+ */
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface LoginUser {
+
+}
diff --git a/src/main/java/com/config/InterceptorConfig.java b/src/main/java/com/config/InterceptorConfig.java
new file mode 100644
index 0000000..586ccc5
--- /dev/null
+++ b/src/main/java/com/config/InterceptorConfig.java
@@ -0,0 +1,39 @@
+package com.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+
+import com.interceptor.AuthorizationInterceptor;
+
+@Configuration
+public class InterceptorConfig extends WebMvcConfigurationSupport{
+
+ @Bean
+ public AuthorizationInterceptor getAuthorizationInterceptor() {
+ return new AuthorizationInterceptor();
+ }
+
+ @Override
+ public void addInterceptors(InterceptorRegistry registry) {
+ registry.addInterceptor(getAuthorizationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**");
+ super.addInterceptors(registry);
+ }
+
+ /**
+ * springboot 2.0配置WebMvcConfigurationSupport之后,会导致默认配置被覆盖,要访问静态资源需要重写addResourceHandlers方法
+ */
+ @Override
+ public void addResourceHandlers(ResourceHandlerRegistry registry) {
+ registry.addResourceHandler("/**")
+ .addResourceLocations("classpath:/resources/")
+ .addResourceLocations("classpath:/static/")
+ .addResourceLocations("classpath:/admin/")
+ .addResourceLocations("classpath:/img/")
+ .addResourceLocations("classpath:/front/")
+ .addResourceLocations("classpath:/public/");
+ super.addResourceHandlers(registry);
+ }
+}
diff --git a/src/main/java/com/config/MyMetaObjectHandler.java b/src/main/java/com/config/MyMetaObjectHandler.java
new file mode 100644
index 0000000..2f9e793
--- /dev/null
+++ b/src/main/java/com/config/MyMetaObjectHandler.java
@@ -0,0 +1,28 @@
+package com.config;
+
+import java.util.Date;
+
+import org.apache.ibatis.reflection.MetaObject;
+
+import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
+
+/**
+ * 自定义填充处理器
+ */
+public class MyMetaObjectHandler extends MetaObjectHandler {
+
+ @Override
+ public void insertFill(MetaObject metaObject) {
+ this.setFieldValByName("ctime", new Date(), metaObject);
+ }
+
+ @Override
+ public boolean openUpdateFill() {
+ return false;
+ }
+
+ @Override
+ public void updateFill(MetaObject metaObject) {
+ // 关闭更新填充、这里不执行
+ }
+}
diff --git a/src/main/java/com/config/MybatisPlusConfig.java b/src/main/java/com/config/MybatisPlusConfig.java
new file mode 100644
index 0000000..ec2e84b
--- /dev/null
+++ b/src/main/java/com/config/MybatisPlusConfig.java
@@ -0,0 +1,24 @@
+
+package com.config;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
+import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
+
+/**
+ * mybatis-plus配置
+ */
+@Configuration
+public class MybatisPlusConfig {
+
+ /**
+ * 分页插件
+ */
+ @Bean
+ public PaginationInterceptor paginationInterceptor() {
+ return new PaginationInterceptor();
+ }
+
+}
diff --git a/src/main/java/com/controller/CommonController.java b/src/main/java/com/controller/CommonController.java
new file mode 100644
index 0000000..1b4c98f
--- /dev/null
+++ b/src/main/java/com/controller/CommonController.java
@@ -0,0 +1,685 @@
+package com.controller;
+
+import java.io.*;
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+import javax.servlet.http.HttpServletRequest;
+
+import com.alibaba.fastjson.JSON;
+import com.utils.StringUtil;
+import org.apache.commons.lang3.StringUtils;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.annotation.IgnoreAuth;
+import com.baidu.aip.face.AipFace;
+import com.baidu.aip.face.MatchRequest;
+import com.baidu.aip.util.Base64Util;
+import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.baomidou.mybatisplus.mapper.Wrapper;
+import com.entity.ConfigEntity;
+import com.service.CommonService;
+import com.service.ConfigService;
+import com.utils.BaiduUtil;
+import com.utils.FileUtil;
+import com.utils.R;
+
+/**
+ * 通用接口
+ */
+@RestController
+public class CommonController {
+ private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
+ @Autowired
+ private CommonService commonService;
+
+
+ /**
+ * Java代码实现MySQL数据库导出
+ *
+ * @param mysqlUrl MySQL安装路径
+ * @param hostIP MySQL数据库所在服务器地址IP
+ * @param userName 进入数据库所需要的用户名
+ * @param hostPort 数据库端口
+ * @param password 进入数据库所需要的密码
+ * @param savePath 数据库文件保存路径
+ * @param fileName 数据库导出文件文件名
+ * @param databaseName 要导出的数据库名
+ * @return 返回true表示导出成功,否则返回false。
+ */
+ @IgnoreAuth
+ @RequestMapping("/beifen")
+ public R beifen(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {
+ File saveFile = new File(savePath);
+ if (!saveFile.exists()) {// 如果目录不存在
+ saveFile.mkdirs();// 创建文件夹
+ }
+ if (!savePath.endsWith(File.separator)) {
+ savePath = savePath + File.separator;
+ }
+ PrintWriter printWriter = null;
+ BufferedReader bufferedReader = null;
+ try {
+ Runtime runtime = Runtime.getRuntime();
+ String cmd = mysqlUrl + "mysqldump -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName;
+ runtime.exec(cmd);
+ Process process = runtime.exec(cmd);
+ InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream(), "utf8");
+ bufferedReader = new BufferedReader(inputStreamReader);
+ printWriter = new PrintWriter(new OutputStreamWriter(new FileOutputStream(savePath + fileName), "utf8"));
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ printWriter.println(line);
+ }
+ printWriter.flush();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return R.error("备份数据出错");
+ } finally {
+ try {
+ if (bufferedReader != null) {
+ bufferedReader.close();
+ }
+ if (printWriter != null) {
+ printWriter.close();
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ return R.ok();
+ }
+
+ /**
+ * Java实现MySQL数据库导入
+ *
+ * @param mysqlUrl MySQL安装路径
+ * @param hostIP MySQL数据库所在服务器地址IP
+ * @param userName 进入数据库所需要的用户名
+ * @param hostPort 数据库端口
+ * @param password 进入数据库所需要的密码
+ * @param savePath 数据库文件保存路径
+ * @param fileName 数据库导出文件文件名
+ * @param databaseName 要导出的数据库名
+ */
+ @IgnoreAuth
+ @RequestMapping("/huanyuan")
+ public R huanyuan(String mysqlUrl, String hostIP, String userName, String hostPort, String password, String savePath, String fileName, String databaseName) {
+ try {
+ Runtime rt = Runtime.getRuntime();
+ Process child1 = rt.exec(mysqlUrl+"mysql.exe -h" + hostIP + " -u" + userName + " -P" + hostPort + " -p" + password + " " + databaseName);
+ OutputStream out = child1.getOutputStream();//控制台的输入信息作为输出流
+ String inStr;
+ StringBuffer sb = new StringBuffer("");
+ String outStr;
+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(savePath+"/"+fileName), "utf-8"));
+ while ((inStr = br.readLine()) != null) {
+ sb.append(inStr + "\r\n");
+ }
+ outStr = sb.toString();
+ OutputStreamWriter writer = new OutputStreamWriter(out, "utf8");
+ writer.write(outStr);
+// 注:这里如果用缓冲方式写入文件的话,会导致中文乱码,用flush()方法则可以避免
+ writer.flush();
+ out.close();
+ br.close();
+ writer.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return R.error("数据导入出错");
+ }
+ return R.ok();
+ }
+
+
+ /**
+ * 饼状图求和
+ * @return
+ */
+ @RequestMapping("/pieSum")
+ public R pieSum(@RequestParam Map params) {
+ logger.debug("饼状图求和:,,Controller:{},,params:{}",this.getClass().getName(),params);
+ List