From 32ac2b800066a9c3d5accd6e42a74c110bee342d Mon Sep 17 00:00:00 2001 From: kwey Date: Wed, 25 Jun 2025 15:51:01 +0800 Subject: [PATCH 1/6] 2025/6/25-16:00 --- vite/src/views/Admin.vue | 946 +++++++++++++++++++++---------------- vite/src/views/Home.vue | 96 ++-- vite/src/views/Student.vue | 754 ++++++++++++++++++----------- 3 files changed, 1056 insertions(+), 740 deletions(-) diff --git a/vite/src/views/Admin.vue b/vite/src/views/Admin.vue index 31c0154d3..fc9526442 100644 --- a/vite/src/views/Admin.vue +++ b/vite/src/views/Admin.vue @@ -133,9 +133,11 @@ 申请编号 - 申请类型 - 申请人 - 申请时间 + 用户Id + 课程id + 数据库Id + 描述 + 创建时间 状态 操作 @@ -143,12 +145,14 @@ {{ app.id }} - {{ app.type }} - {{ app.applicant }} - {{ app.time }} + {{ app.userId }} + {{ app.courseid }} + {{ app.dataBaseId }} + {{ app.description }} + {{ app.createTime }} - - {{ app.status }} + + {{ getStatusText(app.status) }} @@ -169,21 +173,23 @@
-
- - -
+
+
+ +
@@ -203,9 +209,11 @@ 申请编号 - 申请类型 - 申请人 - 申请时间 + 用户Id + 课程id + 数据库Id + 描述 + 创建时间 状态 @@ -215,12 +223,14 @@ {{ app.id }} - {{ app.type }} - {{ app.applicant }} - {{ app.time }} + {{ app.userId }} + {{ app.courseid }} + {{ app.dataBaseId }} + {{ app.description }} + {{ app.createTime }} - - {{ app.status }} + + {{ getStatusText(app.status) }} @@ -259,8 +269,8 @@ 授权ID - 授权类型 用户/组 + 数据库ID 授权时间 到期时间 状态 @@ -270,8 +280,8 @@ {{ item.id }} - {{ item.type }} {{ item.user }} + {{ item.dataBaseId }} {{ item.authTime }} {{ item.expiryTime }} @@ -375,8 +385,28 @@ 操作 - - + + + {{ server.id }} + {{ server.name }} + {{ server.ip }} + {{ server.dbCount }} + {{ server.userCount }} + +
+
+
+ {{ server.usage }}% + + + + + +
@@ -442,8 +472,26 @@ 操作 - - + + + {{ db.id }} + {{ db.name }} + {{ db.user }} + {{ db.createTime }} + {{ db.size }} + {{ db.course }} + + + + + +
@@ -512,9 +560,24 @@ + + +
+
+
+ +
+
+

操作成功

+
申请已成功授权
+
+ +
+
- - - \ No newline at end of file diff --git a/vite/src/views/Home.vue b/vite/src/views/Home.vue index bb47e0383..2110a97ff 100644 --- a/vite/src/views/Home.vue +++ b/vite/src/views/Home.vue @@ -1,63 +1,48 @@ - - - \ No newline at end of file diff --git a/vite/src/views/Student.vue b/vite/src/views/Student.vue index eb15b909f..f93beb120 100644 --- a/vite/src/views/Student.vue +++ b/vite/src/views/Student.vue @@ -1,3 +1,4 @@ + -- Gitee From a299e7b981f4d33e8d9294766dc4c46a6729e70b Mon Sep 17 00:00:00 2001 From: kwey Date: Wed, 25 Jun 2025 15:51:01 +0800 Subject: [PATCH 2/6] 2025/6/25-16:00 --- vite/src/views/Admin.vue | 946 +++++++++++++++++++++---------------- vite/src/views/Home.vue | 96 ++-- vite/src/views/Student.vue | 754 ++++++++++++++++++----------- 3 files changed, 1056 insertions(+), 740 deletions(-) diff --git a/vite/src/views/Admin.vue b/vite/src/views/Admin.vue index 31c0154d3..fc9526442 100644 --- a/vite/src/views/Admin.vue +++ b/vite/src/views/Admin.vue @@ -133,9 +133,11 @@ 申请编号 - 申请类型 - 申请人 - 申请时间 + 用户Id + 课程id + 数据库Id + 描述 + 创建时间 状态 操作 @@ -143,12 +145,14 @@ {{ app.id }} - {{ app.type }} - {{ app.applicant }} - {{ app.time }} + {{ app.userId }} + {{ app.courseid }} + {{ app.dataBaseId }} + {{ app.description }} + {{ app.createTime }} - - {{ app.status }} + + {{ getStatusText(app.status) }} @@ -169,21 +173,23 @@
-
- - -
+
+
+ +
@@ -203,9 +209,11 @@ 申请编号 - 申请类型 - 申请人 - 申请时间 + 用户Id + 课程id + 数据库Id + 描述 + 创建时间 状态 @@ -215,12 +223,14 @@ {{ app.id }} - {{ app.type }} - {{ app.applicant }} - {{ app.time }} + {{ app.userId }} + {{ app.courseid }} + {{ app.dataBaseId }} + {{ app.description }} + {{ app.createTime }} - - {{ app.status }} + + {{ getStatusText(app.status) }} @@ -259,8 +269,8 @@ 授权ID - 授权类型 用户/组 + 数据库ID 授权时间 到期时间 状态 @@ -270,8 +280,8 @@ {{ item.id }} - {{ item.type }} {{ item.user }} + {{ item.dataBaseId }} {{ item.authTime }} {{ item.expiryTime }} @@ -375,8 +385,28 @@ 操作 - - + + + {{ server.id }} + {{ server.name }} + {{ server.ip }} + {{ server.dbCount }} + {{ server.userCount }} + +
+
+
+ {{ server.usage }}% + + + + + +
@@ -442,8 +472,26 @@ 操作 - - + + + {{ db.id }} + {{ db.name }} + {{ db.user }} + {{ db.createTime }} + {{ db.size }} + {{ db.course }} + + + + + +
@@ -512,9 +560,24 @@ + + +
+
+
+ +
+
+

操作成功

+
申请已成功授权
+
+ +
+
- - - \ No newline at end of file diff --git a/vite/src/views/Home.vue b/vite/src/views/Home.vue index bb47e0383..2110a97ff 100644 --- a/vite/src/views/Home.vue +++ b/vite/src/views/Home.vue @@ -1,63 +1,48 @@ - - - \ No newline at end of file diff --git a/vite/src/views/Student.vue b/vite/src/views/Student.vue index eb15b909f..f93beb120 100644 --- a/vite/src/views/Student.vue +++ b/vite/src/views/Student.vue @@ -1,3 +1,4 @@ + -- Gitee From f25037b937521f8d263186a6a06e971975e9ca1d Mon Sep 17 00:00:00 2001 From: kwey Date: Thu, 26 Jun 2025 17:55:22 +0800 Subject: [PATCH 3/6] 2025/6/26-18:00 --- vite/src/router/index.ts | 75 +- vite/src/views/Teacher.vue | 1508 ++++++++++++++++++++++-------------- 2 files changed, 951 insertions(+), 632 deletions(-) diff --git a/vite/src/router/index.ts b/vite/src/router/index.ts index bc0c2aac7..95a194548 100644 --- a/vite/src/router/index.ts +++ b/vite/src/router/index.ts @@ -2,52 +2,43 @@ import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router' import Home from '../views/Home.vue' import Dish from '../views/Dish.vue' import Card from '../views/RouterCard.vue' -import Admin from '@/views/Admin.vue'; -import Teacher from '@/views/Teacher.vue'; -import Student from '@/views/Student.vue'; +import Admin from '@/views/Admin.vue' +import Teacher from '@/views/Teacher.vue' +import Student from '@/views/Student.vue' const routes: Array = [ - { - path: '/', - name: 'home', - redirect: '/dish', - component: Home, - - // 子路由 - children: [ - { - path: '/dish', - name: 'dish', - component: Dish - }, - { - path: '/card', - name: 'card', - component: Card - }, - { - path: '/Admin', - name: 'Admin', - component: Admin - }, - { - path: '/Teacher', - name: 'Teacher', - component: Teacher - }, - { - path: '/Student', - name: 'Student', - component: Student - } - ] - }, - + { + path: '/', + name: 'home', + component: Home, + children: [ + { + path: '', // 默认子路由,访问/时显示 + name: 'home-default', + component: Admin + }, + { + path: 'admin', + name: 'admin', + component: Admin + }, + { + path: 'teacher', + name: 'teacher', + component: Teacher + }, + { + path: 'student', + name: 'student', + component: Student + } + ] + } ] const router = createRouter({ - history: createWebHashHistory(), // 最好使用WebHashHistory方式;如果使用WebHistory会非常麻烦,不建议使用这种方式 - routes + history: createWebHashHistory(), + routes }) -export default router +export default router \ No newline at end of file diff --git a/vite/src/views/Teacher.vue b/vite/src/views/Teacher.vue index bdd59fbac..e9faab870 100644 --- a/vite/src/views/Teacher.vue +++ b/vite/src/views/Teacher.vue @@ -245,7 +245,7 @@ -- - @@ -261,7 +261,7 @@ 2025-06-19 10:20 - @@ -277,7 +277,7 @@ 2025-06-16 16:30 - @@ -314,28 +314,56 @@
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
- - - + + + + + - + - - - + + + + + - - - - - - - - - - - - - - - - @@ -578,153 +604,148 @@
-
+

我的申请记录

-

查看所有数据库相关的申请记录和状态

+

查看所有数据库相关的申请历史记录

-
-
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
- +
-
- -
-
- -
-
- -
+
-
-
申请编号学生姓名数据库名称申请时间用户Id课程id数据库Id描述创建时间 状态 操作
{{ app.id }}{{ app.student }}{{ app.dbName }}{{ app.time }}{{ app.userId }}{{ app.courseid }}{{ app.dataBaseId }}{{ app.description }}{{ app.createTime }} - - {{ app.status }} + + {{ getStatusText(app.status) }} @@ -351,17 +379,16 @@
- 显示 15 条,共 12 条记录 + 显示 {{ (currentPage - 1) * pageSize + 1 }}{{ Math.min(currentPage * pageSize, filteredStdAuthApplications.length) }} 条,共 {{ filteredStdAuthApplications.length }} 条记录
- - - - ... - - +
@@ -370,58 +397,89 @@
+ +
+
+ + +
+
+ + +
+
+ +
+ + +
+
+
+
- - + + + + + + - + - - - - - - - - - - - - - - + + + + + + + + + - - - - - - - -
授权编号学生姓名数据库名称用户Id课程id数据库Id描述授权人Id审批人Id 授权时间授权期限 状态操作
DBAuth20250620001张三 (S2023001)电商数据分析2025-06-20 15:452025-06-20 至 2025-12-20 - - 已授权 - -
DBAuth20250618002王五 (S2023032)数据库课程作业2025-06-18 11:302025-06-18 至 2025-09-18
{{ record.id }}{{ record.userId }}{{ record.courseid }}{{ record.dataBaseId }}{{ record.description }}{{ record.authorizedId }}{{ record.approverId }}{{ record.authTime }} - - 已授权 + + {{ getRecordStatusText(record.status) }}
DBAuth20250615003李四 (S2023015)机器学习实验2025-06-15 09:202025-06-15 至 2026-06-15 - - 已过期 - + +
+ + +
+
+ 显示 13 条,共 12 条记录 +
+
+ + + + ... + + +
+
@@ -530,39 +588,7 @@
-- - -
DBCreate20250615002教学案例库2025-06-15 14:30 - - 已通过 - - 2025-06-16 16:45 - -
DBCreate20250610003科研实验数据库2025-06-10 09:20 - - 已拒绝 - - 2025-06-12 11:30 -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
申请编号申请类型申请时间处理状态处理时间操作
DBView20250620001公共数据库表查看2025-06-20 09:30 - - 审核中 - - -- - -
DBCreate20250620001自建数据库申请2025-06-20 10:15 - - 审核中 - - -- - -
DBView20250618002公共数据库表查看2025-06-18 14:15 - - 已通过 - - 2025-06-19 10:20 - -
DBCreate20250615002自建数据库申请2025-06-15 14:30 - - 已通过 - - 2025-06-16 16:45 - -
DBView20250615003公共数据库表查看2025-06-15 11:45 - - 已拒绝 - - 2025-06-16 16:30 - -
-
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
申请编号申请类型申请内容申请时间处理状态处理时间操作
DBView20250620001公共数据库表查看教学数据库 - 学生信息表2025-06-20 09:30 + + 审核中 + + -- + +
DBView20250618002公共数据库表查看科研数据库 - 实验数据表2025-06-18 14:15 + + 已通过 + + 2025-06-19 10:20 + +
DBView20250615003公共数据库表查看经济类数据库 - 统计分析表2025-06-15 11:45 + + 已拒绝 + + 2025-06-16 16:30 + +
DBCreate20250620001自建数据库申请机器学习研究库2025-06-20 10:15 + + 审核中 + + -- + +
- 显示 15 条,共 12 条记录 + 显示 14 条,共 12 条记录
- + ... + ...
+
- -
-
-
-

选择数据库表

- -
-
- -
-
- - -
+ +
+ +
+ +
+

{{ modalTitle }}

+
-
- -
-
-
-

{{ stdAuthModalTitle }}

- -
-
- -
+ +
+ +
+
-

申请编号

-

{{ currentStdAuthApp?.id }}

+

申请编号

+

{{ currentApplyDetail.id }}

-

学生姓名

-

{{ currentStdAuthApp?.student }}

+

申请类型

+

{{ currentApplyDetail.type }}

-

数据库名称

-

{{ currentStdAuthApp?.dbName }}

+

申请时间

+

{{ currentApplyDetail.applyTime }}

-

申请时间

-

{{ currentStdAuthApp?.time }}

+

处理状态

+

{{ currentApplyDetail.status }}

-

申请理由

-
- 用于课程《数据库原理》的实验作业,需要访问数据库进行SQL查询练习和数据分析。 +

申请理由

+

{{ currentApplyDetail.reason }}

+
+
+

处理意见

+

{{ currentApplyDetail.processingOpinion || '无处理意见' }}

+
+
+ +

申请内容

+
+
+
+

数据库名称

+

{{ currentApplyDetail.dbName }}

+
+
+

数据库类型

+

{{ currentApplyDetail.dbType }}

+
+
+

关联课程

+

{{ currentApplyDetail.course || '无关联课程' }}

+
+
+

预期使用方式

+

{{ currentApplyDetail.useType || '未填写' }}

-
-

审核意见

- +
+
+ + +
+
+
+

申请编号

+

{{ currentStdAuth.id }}

-

授权期限

- +

用户Id

+

{{ currentStdAuth.userId }}

-

授权权限

-
-
- - -
-
- - -
-
- - -
-
- - -
+

课程Id

+

{{ currentStdAuth.courseid }}

+
+
+

数据库Id

+

{{ currentStdAuth.dataBaseId }}

+
+
+

创建时间

+

{{ currentStdAuth.createTime }}

+
+
+

当前状态

+

{{ getStatusText(currentStdAuth.status) }}

+
+
+

申请描述

+

{{ currentStdAuth.description }}

+
+
+ +

授权设置

+
+
+
+ + +
+
+ + +
+
+ +
-
- - -
-
-
- -
-
-
-
- © 2025 教师数据库管理系统. 保留所有权利. -
-
- - 帮助中心 - - - 联系我们 - - - 使用条款 - + +
+
+
+

授权编号

+

{{ currentAuthDetail.id }}

+
+
+

授权类型

+

{{ currentAuthDetail.type }}

+
+
+

被授权人

+

{{ currentAuthDetail.user }}

+
+
+

授权人

+

{{ currentAuthDetail.authorizer }}

+
+
+

授权时间

+

{{ currentAuthDetail.authTime }}

+
+
+

过期时间

+

{{ currentAuthDetail.expireTime }}

+
+
+

当前状态

+

{{ getRecordStatusText(currentAuthDetail.status) }}

+
+
+

授权权限

+

{{ currentAuthDetail.permission }}

+
+
+

授权描述

+

{{ currentAuthDetail.description }}

+
+
+

授权意见

+

{{ currentAuthDetail.opinion }}

+
-
+ + +
+ + + +
+
- \ No newline at end of file -- Gitee From c5418df2e50056631713b677e6f3507f4d09a014 Mon Sep 17 00:00:00 2001 From: kwey Date: Thu, 26 Jun 2025 17:59:49 +0800 Subject: [PATCH 4/6] 2025/6/26-18:00 --- Readme.md | 185 ++++++++---------------------------------------------- 1 file changed, 25 insertions(+), 160 deletions(-) diff --git a/Readme.md b/Readme.md index 11476be02..dc2e4f3f3 100644 --- a/Readme.md +++ b/Readme.md @@ -1,172 +1,37 @@ -todo 晚点Typora写好再复制上来 +# databaseTool -工具开发模板 SpringIOC容器版本 -主要是为了方便工具开发 -注意action并没有受Spring管理 +#### 介绍 +databaseTool -可以使用切面技术 +#### 软件架构 +软件架构说明 -```xml - - org.springframework - spring-aspects - 4.3.7.RELEASE - -``` -### :warning:前端项目版本说明 +#### 安装教程 -- NodeJS版本:`'^18.0.0 || >=20.0.0'` -- yarn版本:`>=1.22.19`【如果使用yarn】 -- npm版本:`>=8.0.0`【如果使用npm】 -- vite版本:`^5.0.0`,此版本必须要求NodeJS版本在18或20及以上。(来自:https://cn.vitejs.dev/guide/) +1. xxxx +2. xxxx +3. xxxx -### 前端项目启动前的配置 +#### 使用说明 -#### 前端修改工具名称 +1. xxxx +2. xxxx +3. xxxx -在项目目录下的`.env`文件里修改`VITE_APP_TITLE`属性的值,例如: +#### 参与贡献 -```properties -VITE_APP_TITLE=XXX工具 -``` +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request -#### 配置ESLint和Prettier实现代码规范化(可选) -项目中的ESLint和Prettier的依赖和配置都已搭好,为了使其生效,我们需要安装VS Code插件 `ESLint` 和 `Prettier`。 +#### 特技 -安装好两个插件后,在项目根目录添加`.vscode`文件夹并且新建一个`settings.json`文件 - -```bash -# Create directory -mkdir .vscode -# Create settings.json file -touch .vscode/settings.json -``` - -配置保存时使用`Prettier`对代码进行格式化, 在`settings.json`文件中增加如下内容: - -```json -// settings.json -{ - "editor.defaultFormatter": "esbenp.prettier-vscode", - "editor.formatOnSave": true, - "editor.codeActionsOnSave": { - "source.organizeImports": true, - "source.fixAll": true - } -} -``` - -这样可以通过键盘快捷键或在保存文件时自动从编辑器中运行 `Prettier`,从而充分利用它。当一行在编码时变得太长,以至于不适合你的屏幕时,只需按保存快捷键,就可以看到它神奇地被包裹成多行!或者,当你粘贴一些代码时,缩进会变得一团糟,让 `Prettier` 在不离开编辑器的情况下为你修复它。 - -最后要记得配置使用格式化,在`.vue`或`.ts`等文件右键,然后执行如下操作: - -![image-20231223175329639](./images/Readme.assets/image-20231223175329639.png) - -![image-20231223175425941](./images/Readme.assets/image-20231223175425941.png) - -### 后端项目启动前的配置 - -#### 修改项目名称 - -1. 第一步:修改项目名称 - - - 修改 ToolTemplate-Java ——–> 自定义项目名 - -2. 第二步:修改包名 - -3. 第三步:修改`com.wetoband.template.action`包下的类名 - - - ToolTemplateAction ——> 自定义类名 - - - 同时修改`src`下的`config.xml`的配置: - - ```diff - - - - 3.0 - - + action包下的类的全路径 - - {aid:"21419389378723787447"} - - http://127.0.0.1:8080 - - ``` - -4. 修改`pom.xml`的名称 - -#### 导入项目依赖的jar包 - -1. 导入项目路径下的`lib` -2. 导入项目路径下的`WebRoot/WEB-INF/lib` - -#### 设置WebRoot为项目的web - -1. 进入idea的Project Structure,找到Modules下的项目并展开 -2. 点击上面的加号,在菜单中选中`web` -3. 修改弹出的右侧设置 - 1. 修改`Deployment Descriptors`的Path为WebRoot下的web.xml - 2. 修改`Web Resource Directories`下的`Web Resource Director`的路径为WebRoot路径 - -#### 添加Tomcat服务器 - -点击idea界面右上角的`Add Configuration`,进去添加一个Tomcat服务器就可以运行了。 - -#### 修改AppConfig.java的ComponentScan注解 - -```java -@ComponentScan("Java项目的包路径") -``` - -如模板中的就是:`com.wetoband.template` - -### 启动项目 - -#### 启动前端 - -- 第一步:yarn install - -- 第二步:yarn run dev - -#### 启动后端 - -- 第一步:在idea中配置tomcat - -- 第二步:启动tomcat - -#### 运行成功效果 - -分别点击页面的`发送GET请求`和`发送POST请求`按钮,出现如下结果即为成功: - -![image-20231229194853913](./images/Readme.assets/image-20231229194853913.png) - - - -![image-20231229194927753](./images/Readme.assets/image-20231229194927753.png) - -切换About路由页面: - -![image-20231229195132053](./images/Readme.assets/image-20231229195132053.png) - -切换Background路由: - -![bg](./images/Readme.assets/bg.png) - -### 打包项目 - -#### 打包前端 - -- 第一步:执行 yarn run build 或 yarn build 命令,会在项目目录下生成一个dist目录 - -#### 打包后端 - -- 第一步:把前端生成的dist目录下的所有文件放到后端项目的WebRoot目录下的resource目录中 -- 第二步:执行Maven的 clean 和 package 指令,会在target目录下生成一个jar包文件。 - -### :warning:注意事项 - -1. 项目路径不可为中文路径; -2. 前端路由最好使用Hash; +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. Gitee 官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解 Gitee 上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目 +5. Gitee 官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) -- Gitee From 978953ed836b3c2507f022a5063c6679a0ebb13a Mon Sep 17 00:00:00 2001 From: kwey Date: Thu, 26 Jun 2025 10:03:44 +0000 Subject: [PATCH 5/6] Revert "Merge branch 'kwy' of gitee.com:pan-yongxi/database-tool into kwy" This reverts commit 77531fdeee7bd4633c495366e80f115155d46273. --- .../javatool/action/JavaToolDemoAction.java | 194 +----------------- .../src/com/wtb/javatool/dao/ApplyMapper.java | 16 -- .../com/wtb/javatool/entity/ApplyBuild.java | 52 ----- .../com/wtb/javatool/entity/ApplyView.java | 46 ----- java/src/com/wtb/javatool/entity/User.java | 2 +- .../wtb/javatool/service/IApplyService.java | 10 +- .../service/impl/ApplyServiceImpl.java | 98 ++++----- java/src/mappers/ApplyMapper.xml | 29 --- java/src/mappers/DishMapper.xml | 1 - 9 files changed, 40 insertions(+), 408 deletions(-) delete mode 100644 java/src/com/wtb/javatool/dao/ApplyMapper.java delete mode 100644 java/src/com/wtb/javatool/entity/ApplyBuild.java delete mode 100644 java/src/com/wtb/javatool/entity/ApplyView.java delete mode 100644 java/src/mappers/ApplyMapper.xml diff --git a/java/src/com/wtb/javatool/action/JavaToolDemoAction.java b/java/src/com/wtb/javatool/action/JavaToolDemoAction.java index 001f46051..a1edc6cde 100644 --- a/java/src/com/wtb/javatool/action/JavaToolDemoAction.java +++ b/java/src/com/wtb/javatool/action/JavaToolDemoAction.java @@ -3,10 +3,8 @@ package com.wtb.javatool.action; import com.fy.wetoband.tool.Tool; import com.fy.wetoband.utils.RequestUtil; import com.wtb.javatool.common.Result; -import com.wtb.javatool.entity.ApplyBuild; import com.wtb.javatool.entity.Dish; import com.wtb.javatool.entity.User; -import com.wtb.javatool.service.IApplyService; import com.wtb.javatool.service.IDishService; import com.wtb.javatool.service.IStudent; import com.wtb.javatool.vo.DishDto; @@ -19,9 +17,6 @@ import org.springframework.context.annotation.Scope; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Date; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -39,9 +34,6 @@ public class JavaToolDemoAction extends Tool { @Autowired private IStudent studentService; - @Autowired - private IApplyService iApplyService; - @Action @ApiOperation(value = "添加菜品", httpMethod = "POST", notes = "添加菜品信息") @ApiImplicitParams({ @@ -145,14 +137,14 @@ public class JavaToolDemoAction extends Tool { @Action - @ApiOperation(value = "测试", httpMethod = "POST", notes = "测试") + @ApiOperation(value = "学生申请自建数据库", httpMethod = "POST", notes = "学生申请自建数据库") @ApiImplicitParams({ @ApiImplicitParam(name = "studentId", dataType = "long", value = "学生ID", required = true), @ApiImplicitParam(name = "courseId", dataType = "long", value = "课程ID", required = true)}) @ApiResponses({ @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) }) - public Result> test(HttpServletRequest request,HttpServletResponse response){ + public Result> applyByCourseId(HttpServletRequest request,HttpServletResponse response){ // Long studentId = RequestUtil.getLongParameter(request, "studentId"); // Long courseId = RequestUtil.getLongParameter(request, "courseId"); @@ -164,188 +156,6 @@ public class JavaToolDemoAction extends Tool { } - @Action - @ApiOperation(value = "学生申请自建数据库", httpMethod = "POST", notes = "学生申请自建数据库") - @ApiImplicitParams({ - @ApiImplicitParam(name = "userId", dataType = "long", value = "学生ID", required = true), - @ApiImplicitParam(name = "classId", dataType = "long", value = "课程ID", required = true)}) - @ApiResponses({ - @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) - }) - public Result applyByCourseId(HttpServletRequest request,HttpServletResponse response){ - - Long userId = RequestUtil.getLongParameter(request, "userId"); - Long classId = RequestUtil.getLongParameter(request, "classId"); - Integer dataBaseId = RequestUtil.getIntegerParameter(request, "dataBaseId"); - String description = RequestUtil.getStringParameter(request, "description"); - - Long approverId = RequestUtil.getLongParameter(request, "approverId"); - - ApplyBuild applyBuild = new ApplyBuild(); - - applyBuild.setUserId(userId); - applyBuild.setClassId(classId); - applyBuild.setDataBaseId(dataBaseId); - applyBuild.setDescription(description); - applyBuild.setApproverId(approverId); - - //创建Calendar对象 - Calendar cal=Calendar.getInstance(); - - //用Calendar类提供的方法获取年、月、日、时、分、秒 - int year =cal.get(Calendar.YEAR); //年 - int month =cal.get(Calendar.MONTH)+1; //月 默认是从0开始 即1月获取到的是0 - int day =cal.get(Calendar.DAY_OF_MONTH); //日,即一个月中的第几天 - int hour =cal.get(Calendar.HOUR_OF_DAY); //小时 - int minute=cal.get(Calendar.MINUTE); //分 - int second=cal.get(Calendar.SECOND); //秒 - - //拼接成字符串输出 - String date=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; - - applyBuild.setCreateTime(date); - applyBuild.setStatus(0); - - final Integer integer = iApplyService.applyByCourseId(applyBuild); - - - if(integer <= 0){ - return Result.error("申请失败"); - } - - return Result.success("申请成功"); - - } - - - @Action - @ApiOperation(value = "教师审批自建数据库请求", httpMethod = "POST", notes = "教师审批自建数据库请求") - @ApiImplicitParams({ - @ApiImplicitParam(name = "applyId", dataType = "Integer", value = "请求id", required = true) - }) - @ApiResponses({ - @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) - }) - public Result approveApply(HttpServletRequest request,HttpServletResponse response){ - - Integer applyId = RequestUtil.getIntegerParameter(request, "applyId");//获取此次申请的编号 - Integer status = RequestUtil.getIntegerParameter(request, "status");//获取此次审批是否同意,教师同意应当将status设置为1 - - Long userId = RequestUtil.getLongParameter(request, "userId"); - Long classId = RequestUtil.getLongParameter(request, "classId"); - Integer dataBaseId = RequestUtil.getIntegerParameter(request, "dataBaseId"); - String description = RequestUtil.getStringParameter(request, "description"); - - Long approverId = RequestUtil.getLongParameter(request, "approverId"); - String createTime = RequestUtil.getStringParameter(request, "createTime"); - Long authorizedId = RequestUtil.getLongParameter(request, "authorizedId"); - - ApplyBuild applyBuild = new ApplyBuild(); - - applyBuild.setUserId(userId); - applyBuild.setClassId(classId); - applyBuild.setDataBaseId(dataBaseId); - applyBuild.setDescription(description); - applyBuild.setApproverId(approverId); - applyBuild.setCreateTime(createTime); - - //创建Calendar对象 - Calendar cal=Calendar.getInstance(); - - //用Calendar类提供的方法获取年、月、日、时、分、秒 - int year =cal.get(Calendar.YEAR); //年 - int month =cal.get(Calendar.MONTH)+1; //月 默认是从0开始 即1月获取到的是0 - int day =cal.get(Calendar.DAY_OF_MONTH); //日,即一个月中的第几天 - int hour =cal.get(Calendar.HOUR_OF_DAY); //小时 - int minute=cal.get(Calendar.MINUTE); //分 - int second=cal.get(Calendar.SECOND); //秒 - - //拼接成字符串输出 - String approveTime =year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; - - applyBuild.setId(applyId);//设置此次申请的编号 - applyBuild.setApproveTime(approveTime);//设置此次申请的审批时间 - applyBuild.setStatus(status);//设置是否通过审批 - applyBuild.setAuthorizedId(authorizedId);//设置交给哪个管理员进行下一步授权 - - - final Integer update = iApplyService.approveApply(applyBuild); - - - if (update<=0){ - return Result.error("审批失败"); - } - return Result.success("审批成功"); - - } - - - @Action - @ApiOperation(value = "管理员授权自建数据库请求", httpMethod = "POST", notes = "管理员授权自建数据库请求") - @ApiImplicitParams({ - @ApiImplicitParam(name = "applyId", dataType = "Integer", value = "请求id", required = true) - }) - @ApiResponses({ - @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) - }) - public Result authorizedApply(HttpServletRequest request,HttpServletResponse response){ - - Integer applyId = RequestUtil.getIntegerParameter(request, "applyId");//获取此次申请的编号 - Integer status = RequestUtil.getIntegerParameter(request, "status");//获取此次授权是否同意, - // 管理员同意应当将status设置为2,否则设置为1 - - Long userId = RequestUtil.getLongParameter(request, "userId"); - Long classId = RequestUtil.getLongParameter(request, "classId"); - Integer dataBaseId = RequestUtil.getIntegerParameter(request, "dataBaseId"); - String description = RequestUtil.getStringParameter(request, "description"); - - Long approverId = RequestUtil.getLongParameter(request, "approverId"); - String createTime = RequestUtil.getStringParameter(request, "createTime"); - Long authorizedId = RequestUtil.getLongParameter(request, "authorizedId"); - String approveTime = RequestUtil.getStringParameter(request, "approveTime");//要获取教师审核的时间 - - ApplyBuild applyBuild = new ApplyBuild(); - - applyBuild.setUserId(userId); - applyBuild.setClassId(classId); - applyBuild.setDataBaseId(dataBaseId); - applyBuild.setDescription(description); - applyBuild.setApproverId(approverId); - applyBuild.setCreateTime(createTime); - applyBuild.setApproveTime(approveTime); - applyBuild.setAuthorizedId(authorizedId); - - //创建Calendar对象 - Calendar cal=Calendar.getInstance(); - - //用Calendar类提供的方法获取年、月、日、时、分、秒 - int year =cal.get(Calendar.YEAR); //年 - int month =cal.get(Calendar.MONTH)+1; //月 默认是从0开始 即1月获取到的是0 - int day =cal.get(Calendar.DAY_OF_MONTH); //日,即一个月中的第几天 - int hour =cal.get(Calendar.HOUR_OF_DAY); //小时 - int minute=cal.get(Calendar.MINUTE); //分 - int second=cal.get(Calendar.SECOND); //秒 - - //拼接成字符串输出 - String authorizedTime =year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; - - applyBuild.setId(applyId);//设置此次申请的编号 - applyBuild.setAuthorizedTime(authorizedTime);//设置此次申请的授权时间 - applyBuild.setStatus(status);//设置是否通过审批 - - - - final Integer update = iApplyService.authorizedApply(applyBuild); - - - if (update<=0){ - return Result.error("授权失败"); - } - return Result.success("授权成功"); - - } - - diff --git a/java/src/com/wtb/javatool/dao/ApplyMapper.java b/java/src/com/wtb/javatool/dao/ApplyMapper.java deleted file mode 100644 index e5844c17c..000000000 --- a/java/src/com/wtb/javatool/dao/ApplyMapper.java +++ /dev/null @@ -1,16 +0,0 @@ -package com.wtb.javatool.dao; - - -import com.wtb.javatool.entity.ApplyBuild; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface ApplyMapper { - - Integer applyByCourseId(ApplyBuild applyBuild); - - - Integer approveApply(ApplyBuild applyBuild); - - Integer authorizedApply(ApplyBuild applyBuild); -} diff --git a/java/src/com/wtb/javatool/entity/ApplyBuild.java b/java/src/com/wtb/javatool/entity/ApplyBuild.java deleted file mode 100644 index adbb6d1ff..000000000 --- a/java/src/com/wtb/javatool/entity/ApplyBuild.java +++ /dev/null @@ -1,52 +0,0 @@ -package com.wtb.javatool.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.ToString; - -/** - * 创建申请表 - * @author yangzhuoheng - * - */ -@Data -@ToString -@ApiModel(value = "apply_build",description="创建申请") -public class ApplyBuild { - - @ApiModelProperty(value = "id") - private Integer id; - - @ApiModelProperty(value = "用户Id") - private Long userId; - - @ApiModelProperty(value = "班级id") - private Long classId; - - @ApiModelProperty(value = "数据库Id") - private Integer dataBaseId; - - @ApiModelProperty(value = "描述") - private String description; - - @ApiModelProperty(value = "授权人Id,管理员") - private Long authorizedId; - - @ApiModelProperty(value = "审批人Id,教师") - private Long approverId; - - @ApiModelProperty(value = "创建时间") - private String createTime; - - @ApiModelProperty(value = "状态,0表示已向老师发送申请但未同意,1表示老师同意并且已向管理员发送申请但未授权,2表示管理员审批成功整个流程完成") - private Integer status; - - @ApiModelProperty(value = "审批时间") - private String approveTime; - - @ApiModelProperty(value = "授权时间") - private String authorizedTime; - - -} diff --git a/java/src/com/wtb/javatool/entity/ApplyView.java b/java/src/com/wtb/javatool/entity/ApplyView.java deleted file mode 100644 index 01b3cf0fa..000000000 --- a/java/src/com/wtb/javatool/entity/ApplyView.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.wtb.javatool.entity; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Data; -import lombok.ToString; - -/** - * 查看申请表 - * @author yangzhuoheng - * - */ -@Data -@ToString -@ApiModel(value = "apply_view",description="查看申请") -public class ApplyView { - - @ApiModelProperty(value = "id") - private Integer id; - - @ApiModelProperty(value = "用户Id") - private Long userId; - - @ApiModelProperty(value = "数据库Id") - private Integer databaseId; - - @ApiModelProperty(value = "描述") - private String description; - - @ApiModelProperty(value = "审批人Id") - private Long approverId; - - @ApiModelProperty(value = "创建时间") - private String createTime; - - @ApiModelProperty(value = "状态,0表示已向老师发送申请但未同意,1表示老师同意并且已向管理员发送申请但未授权,2表示管理员审批成功整个流程完成") - private Integer status; - - - - - - - - -} diff --git a/java/src/com/wtb/javatool/entity/User.java b/java/src/com/wtb/javatool/entity/User.java index 8192bc731..484b40e85 100644 --- a/java/src/com/wtb/javatool/entity/User.java +++ b/java/src/com/wtb/javatool/entity/User.java @@ -23,7 +23,7 @@ public class User { @ApiModelProperty(value = "用户名") private String userName; - @ApiModelProperty(value = "角色id,0表示学生,1表示老师,2表示管理员") + @ApiModelProperty(value = "角色id") private Integer roleId; diff --git a/java/src/com/wtb/javatool/service/IApplyService.java b/java/src/com/wtb/javatool/service/IApplyService.java index ecb3b2ad5..7d1cc4549 100644 --- a/java/src/com/wtb/javatool/service/IApplyService.java +++ b/java/src/com/wtb/javatool/service/IApplyService.java @@ -1,7 +1,6 @@ package com.wtb.javatool.service; import com.wtb.javatool.common.Result; -import com.wtb.javatool.entity.ApplyBuild; public interface IApplyService { @@ -11,13 +10,6 @@ public interface IApplyService { * @param courseId 课程ID * @return 申请结果 */ + Result applyByCourseId(Long studentId, Long courseId); - Result apply(Long studentId, Long courseId);//测试用 - - Integer applyByCourseId(ApplyBuild applyBuild); - - - Integer approveApply(ApplyBuild applyBuild); - - Integer authorizedApply(ApplyBuild applyBuild); } diff --git a/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java b/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java index 716284efc..a9c9cc3f5 100644 --- a/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java +++ b/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java @@ -1,63 +1,37 @@ package com.wtb.javatool.service.impl; import com.wtb.javatool.common.Result; -import com.wtb.javatool.dao.ApplyMapper; -import com.wtb.javatool.entity.ApplyBuild; import com.wtb.javatool.service.IApplyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import javax.persistence.criteria.CriteriaBuilder; import java.util.Objects; -@Service -public class ApplyServiceImpl implements IApplyService { - - @Autowired - private ApplyMapper applyMapper; - - - @Override - public Integer applyByCourseId(ApplyBuild applyBuild) { - - Integer integer = applyMapper.applyByCourseId(applyBuild); - - return integer; - } - - @Override - public Integer approveApply(ApplyBuild applyBuild) { - - Integer integer = applyMapper.approveApply(applyBuild); - - return integer; - } - - @Override - public Integer authorizedApply(ApplyBuild applyBuild) { - - Integer integer = applyMapper.authorizedApply(applyBuild); - - System.out.println(applyBuild); - - return integer; - } - - - @Override - @Transactional(rollbackFor = Exception.class) - public Result apply(Long studentId, Long courseId) { - // 参数校验 - if (Objects.isNull(studentId)) { - throw new RuntimeException("学生ID不能为空且必须大于0"); - } - if (Objects.isNull(courseId)) { - throw new RuntimeException("课程ID不能为空且必须大于0"); - } - - +//@Service +//public class ApplyServiceImpl implements IApplyService { +// +//// @Autowired +//// private DatabaseApplicationMapper databaseApplicationMapper; +//// +//// @Autowired +//// private StudentCourseMapper studentCourseMapper; +//// +// +// +// @Override +// @Transactional(rollbackFor = Exception.class) +// public Result applyByCourseId(Long studentId, Long courseId) { +// // 参数校验 +// if (Objects.isNull(studentId)) { +// throw new RuntimeException("学生ID不能为空且必须大于0"); +// } +// if (Objects.isNull(courseId)) { +// throw new RuntimeException("课程ID不能为空且必须大于0"); +// } +// +// // // 创建数据库申请记录 // DatabaseApplication application = new DatabaseApplication(); // application.setStudentId(studentId); @@ -72,16 +46,16 @@ public class ApplyServiceImpl implements IApplyService { // if (rows <= 0) { // throw new BusinessException("数据库申请提交失败"); // } - - // 这里可以添加异步任务,通知管理员审核 - - return Result.success("数据库申请已提交,等待审核"); - } -} - - - - - - - +// +// // 这里可以添加异步任务,通知管理员审核 +// +// return Result.success("数据库申请已提交,等待审核"); +// } +//} +// +// +// +// +// +// +//} diff --git a/java/src/mappers/ApplyMapper.xml b/java/src/mappers/ApplyMapper.xml deleted file mode 100644 index 68d6a65fc..000000000 --- a/java/src/mappers/ApplyMapper.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - - - - INSERT INTO apply_build(user_id,class_id,database_id,description,approver_id,status,create_time) - VALUES(#{userId},#{classId},#{dataBaseId},#{description},#{approverId},#{status},#{createTime}) - - - - UPDATE apply_build - SET user_id=#{userId},class_id=#{classId},database_id=#{dataBaseId}, - description=#{description},approver_id=#{approverId},status=#{status}, - create_time=#{createTime},approve_time=#{approveTime},authorized_id=#{authorizedId} - WHERE id = #{id} - - - - UPDATE apply_build - SET user_id=#{userId},class_id=#{classId},database_id=#{dataBaseId}, - description=#{description},approver_id=#{approverId},status=#{status}, - create_time=#{createTime},approve_time=#{approveTime},authorized_id=#{authorizedId}, - authorized_time=#{authorizedTime} - WHERE id = #{id} - - - diff --git a/java/src/mappers/DishMapper.xml b/java/src/mappers/DishMapper.xml index 2fb6d3366..4dfb6ab09 100644 --- a/java/src/mappers/DishMapper.xml +++ b/java/src/mappers/DishMapper.xml @@ -3,7 +3,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - INSERT INTO dish (name, price, description, create_time, update_time) VALUES(#{name}, #{price,jdbcType=DECIMAL},#{description},#{createTime},#{updateTime}) -- Gitee From 8b90c9d39397c2b5c75ac767ece71c0b631a710b Mon Sep 17 00:00:00 2001 From: kwey Date: Thu, 26 Jun 2025 10:16:35 +0000 Subject: [PATCH 6/6] Revert "Revert "Merge branch 'kwy' of gitee.com:pan-yongxi/database-tool into kwy"" This reverts commit 978953ed836b3c2507f022a5063c6679a0ebb13a. --- .../javatool/action/JavaToolDemoAction.java | 194 +++++++++++++++++- .../src/com/wtb/javatool/dao/ApplyMapper.java | 16 ++ .../com/wtb/javatool/entity/ApplyBuild.java | 52 +++++ .../com/wtb/javatool/entity/ApplyView.java | 46 +++++ java/src/com/wtb/javatool/entity/User.java | 2 +- .../wtb/javatool/service/IApplyService.java | 10 +- .../service/impl/ApplyServiceImpl.java | 98 +++++---- java/src/mappers/ApplyMapper.xml | 29 +++ java/src/mappers/DishMapper.xml | 1 + 9 files changed, 408 insertions(+), 40 deletions(-) create mode 100644 java/src/com/wtb/javatool/dao/ApplyMapper.java create mode 100644 java/src/com/wtb/javatool/entity/ApplyBuild.java create mode 100644 java/src/com/wtb/javatool/entity/ApplyView.java create mode 100644 java/src/mappers/ApplyMapper.xml diff --git a/java/src/com/wtb/javatool/action/JavaToolDemoAction.java b/java/src/com/wtb/javatool/action/JavaToolDemoAction.java index a1edc6cde..001f46051 100644 --- a/java/src/com/wtb/javatool/action/JavaToolDemoAction.java +++ b/java/src/com/wtb/javatool/action/JavaToolDemoAction.java @@ -3,8 +3,10 @@ package com.wtb.javatool.action; import com.fy.wetoband.tool.Tool; import com.fy.wetoband.utils.RequestUtil; import com.wtb.javatool.common.Result; +import com.wtb.javatool.entity.ApplyBuild; import com.wtb.javatool.entity.Dish; import com.wtb.javatool.entity.User; +import com.wtb.javatool.service.IApplyService; import com.wtb.javatool.service.IDishService; import com.wtb.javatool.service.IStudent; import com.wtb.javatool.vo.DishDto; @@ -17,6 +19,9 @@ import org.springframework.context.annotation.Scope; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; import java.util.List; import java.util.function.Function; import java.util.stream.Collectors; @@ -34,6 +39,9 @@ public class JavaToolDemoAction extends Tool { @Autowired private IStudent studentService; + @Autowired + private IApplyService iApplyService; + @Action @ApiOperation(value = "添加菜品", httpMethod = "POST", notes = "添加菜品信息") @ApiImplicitParams({ @@ -137,14 +145,14 @@ public class JavaToolDemoAction extends Tool { @Action - @ApiOperation(value = "学生申请自建数据库", httpMethod = "POST", notes = "学生申请自建数据库") + @ApiOperation(value = "测试", httpMethod = "POST", notes = "测试") @ApiImplicitParams({ @ApiImplicitParam(name = "studentId", dataType = "long", value = "学生ID", required = true), @ApiImplicitParam(name = "courseId", dataType = "long", value = "课程ID", required = true)}) @ApiResponses({ @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) }) - public Result> applyByCourseId(HttpServletRequest request,HttpServletResponse response){ + public Result> test(HttpServletRequest request,HttpServletResponse response){ // Long studentId = RequestUtil.getLongParameter(request, "studentId"); // Long courseId = RequestUtil.getLongParameter(request, "courseId"); @@ -156,6 +164,188 @@ public class JavaToolDemoAction extends Tool { } + @Action + @ApiOperation(value = "学生申请自建数据库", httpMethod = "POST", notes = "学生申请自建数据库") + @ApiImplicitParams({ + @ApiImplicitParam(name = "userId", dataType = "long", value = "学生ID", required = true), + @ApiImplicitParam(name = "classId", dataType = "long", value = "课程ID", required = true)}) + @ApiResponses({ + @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) + }) + public Result applyByCourseId(HttpServletRequest request,HttpServletResponse response){ + + Long userId = RequestUtil.getLongParameter(request, "userId"); + Long classId = RequestUtil.getLongParameter(request, "classId"); + Integer dataBaseId = RequestUtil.getIntegerParameter(request, "dataBaseId"); + String description = RequestUtil.getStringParameter(request, "description"); + + Long approverId = RequestUtil.getLongParameter(request, "approverId"); + + ApplyBuild applyBuild = new ApplyBuild(); + + applyBuild.setUserId(userId); + applyBuild.setClassId(classId); + applyBuild.setDataBaseId(dataBaseId); + applyBuild.setDescription(description); + applyBuild.setApproverId(approverId); + + //创建Calendar对象 + Calendar cal=Calendar.getInstance(); + + //用Calendar类提供的方法获取年、月、日、时、分、秒 + int year =cal.get(Calendar.YEAR); //年 + int month =cal.get(Calendar.MONTH)+1; //月 默认是从0开始 即1月获取到的是0 + int day =cal.get(Calendar.DAY_OF_MONTH); //日,即一个月中的第几天 + int hour =cal.get(Calendar.HOUR_OF_DAY); //小时 + int minute=cal.get(Calendar.MINUTE); //分 + int second=cal.get(Calendar.SECOND); //秒 + + //拼接成字符串输出 + String date=year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; + + applyBuild.setCreateTime(date); + applyBuild.setStatus(0); + + final Integer integer = iApplyService.applyByCourseId(applyBuild); + + + if(integer <= 0){ + return Result.error("申请失败"); + } + + return Result.success("申请成功"); + + } + + + @Action + @ApiOperation(value = "教师审批自建数据库请求", httpMethod = "POST", notes = "教师审批自建数据库请求") + @ApiImplicitParams({ + @ApiImplicitParam(name = "applyId", dataType = "Integer", value = "请求id", required = true) + }) + @ApiResponses({ + @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) + }) + public Result approveApply(HttpServletRequest request,HttpServletResponse response){ + + Integer applyId = RequestUtil.getIntegerParameter(request, "applyId");//获取此次申请的编号 + Integer status = RequestUtil.getIntegerParameter(request, "status");//获取此次审批是否同意,教师同意应当将status设置为1 + + Long userId = RequestUtil.getLongParameter(request, "userId"); + Long classId = RequestUtil.getLongParameter(request, "classId"); + Integer dataBaseId = RequestUtil.getIntegerParameter(request, "dataBaseId"); + String description = RequestUtil.getStringParameter(request, "description"); + + Long approverId = RequestUtil.getLongParameter(request, "approverId"); + String createTime = RequestUtil.getStringParameter(request, "createTime"); + Long authorizedId = RequestUtil.getLongParameter(request, "authorizedId"); + + ApplyBuild applyBuild = new ApplyBuild(); + + applyBuild.setUserId(userId); + applyBuild.setClassId(classId); + applyBuild.setDataBaseId(dataBaseId); + applyBuild.setDescription(description); + applyBuild.setApproverId(approverId); + applyBuild.setCreateTime(createTime); + + //创建Calendar对象 + Calendar cal=Calendar.getInstance(); + + //用Calendar类提供的方法获取年、月、日、时、分、秒 + int year =cal.get(Calendar.YEAR); //年 + int month =cal.get(Calendar.MONTH)+1; //月 默认是从0开始 即1月获取到的是0 + int day =cal.get(Calendar.DAY_OF_MONTH); //日,即一个月中的第几天 + int hour =cal.get(Calendar.HOUR_OF_DAY); //小时 + int minute=cal.get(Calendar.MINUTE); //分 + int second=cal.get(Calendar.SECOND); //秒 + + //拼接成字符串输出 + String approveTime =year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; + + applyBuild.setId(applyId);//设置此次申请的编号 + applyBuild.setApproveTime(approveTime);//设置此次申请的审批时间 + applyBuild.setStatus(status);//设置是否通过审批 + applyBuild.setAuthorizedId(authorizedId);//设置交给哪个管理员进行下一步授权 + + + final Integer update = iApplyService.approveApply(applyBuild); + + + if (update<=0){ + return Result.error("审批失败"); + } + return Result.success("审批成功"); + + } + + + @Action + @ApiOperation(value = "管理员授权自建数据库请求", httpMethod = "POST", notes = "管理员授权自建数据库请求") + @ApiImplicitParams({ + @ApiImplicitParam(name = "applyId", dataType = "Integer", value = "请求id", required = true) + }) + @ApiResponses({ + @ApiResponse(code = 200, message = "成功发送申请", response = Result.class) + }) + public Result authorizedApply(HttpServletRequest request,HttpServletResponse response){ + + Integer applyId = RequestUtil.getIntegerParameter(request, "applyId");//获取此次申请的编号 + Integer status = RequestUtil.getIntegerParameter(request, "status");//获取此次授权是否同意, + // 管理员同意应当将status设置为2,否则设置为1 + + Long userId = RequestUtil.getLongParameter(request, "userId"); + Long classId = RequestUtil.getLongParameter(request, "classId"); + Integer dataBaseId = RequestUtil.getIntegerParameter(request, "dataBaseId"); + String description = RequestUtil.getStringParameter(request, "description"); + + Long approverId = RequestUtil.getLongParameter(request, "approverId"); + String createTime = RequestUtil.getStringParameter(request, "createTime"); + Long authorizedId = RequestUtil.getLongParameter(request, "authorizedId"); + String approveTime = RequestUtil.getStringParameter(request, "approveTime");//要获取教师审核的时间 + + ApplyBuild applyBuild = new ApplyBuild(); + + applyBuild.setUserId(userId); + applyBuild.setClassId(classId); + applyBuild.setDataBaseId(dataBaseId); + applyBuild.setDescription(description); + applyBuild.setApproverId(approverId); + applyBuild.setCreateTime(createTime); + applyBuild.setApproveTime(approveTime); + applyBuild.setAuthorizedId(authorizedId); + + //创建Calendar对象 + Calendar cal=Calendar.getInstance(); + + //用Calendar类提供的方法获取年、月、日、时、分、秒 + int year =cal.get(Calendar.YEAR); //年 + int month =cal.get(Calendar.MONTH)+1; //月 默认是从0开始 即1月获取到的是0 + int day =cal.get(Calendar.DAY_OF_MONTH); //日,即一个月中的第几天 + int hour =cal.get(Calendar.HOUR_OF_DAY); //小时 + int minute=cal.get(Calendar.MINUTE); //分 + int second=cal.get(Calendar.SECOND); //秒 + + //拼接成字符串输出 + String authorizedTime =year+"-"+month+"-"+day+" "+hour+":"+minute+":"+second; + + applyBuild.setId(applyId);//设置此次申请的编号 + applyBuild.setAuthorizedTime(authorizedTime);//设置此次申请的授权时间 + applyBuild.setStatus(status);//设置是否通过审批 + + + + final Integer update = iApplyService.authorizedApply(applyBuild); + + + if (update<=0){ + return Result.error("授权失败"); + } + return Result.success("授权成功"); + + } + + diff --git a/java/src/com/wtb/javatool/dao/ApplyMapper.java b/java/src/com/wtb/javatool/dao/ApplyMapper.java new file mode 100644 index 000000000..e5844c17c --- /dev/null +++ b/java/src/com/wtb/javatool/dao/ApplyMapper.java @@ -0,0 +1,16 @@ +package com.wtb.javatool.dao; + + +import com.wtb.javatool.entity.ApplyBuild; +import org.apache.ibatis.annotations.Mapper; + +@Mapper +public interface ApplyMapper { + + Integer applyByCourseId(ApplyBuild applyBuild); + + + Integer approveApply(ApplyBuild applyBuild); + + Integer authorizedApply(ApplyBuild applyBuild); +} diff --git a/java/src/com/wtb/javatool/entity/ApplyBuild.java b/java/src/com/wtb/javatool/entity/ApplyBuild.java new file mode 100644 index 000000000..adbb6d1ff --- /dev/null +++ b/java/src/com/wtb/javatool/entity/ApplyBuild.java @@ -0,0 +1,52 @@ +package com.wtb.javatool.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +/** + * 创建申请表 + * @author yangzhuoheng + * + */ +@Data +@ToString +@ApiModel(value = "apply_build",description="创建申请") +public class ApplyBuild { + + @ApiModelProperty(value = "id") + private Integer id; + + @ApiModelProperty(value = "用户Id") + private Long userId; + + @ApiModelProperty(value = "班级id") + private Long classId; + + @ApiModelProperty(value = "数据库Id") + private Integer dataBaseId; + + @ApiModelProperty(value = "描述") + private String description; + + @ApiModelProperty(value = "授权人Id,管理员") + private Long authorizedId; + + @ApiModelProperty(value = "审批人Id,教师") + private Long approverId; + + @ApiModelProperty(value = "创建时间") + private String createTime; + + @ApiModelProperty(value = "状态,0表示已向老师发送申请但未同意,1表示老师同意并且已向管理员发送申请但未授权,2表示管理员审批成功整个流程完成") + private Integer status; + + @ApiModelProperty(value = "审批时间") + private String approveTime; + + @ApiModelProperty(value = "授权时间") + private String authorizedTime; + + +} diff --git a/java/src/com/wtb/javatool/entity/ApplyView.java b/java/src/com/wtb/javatool/entity/ApplyView.java new file mode 100644 index 000000000..01b3cf0fa --- /dev/null +++ b/java/src/com/wtb/javatool/entity/ApplyView.java @@ -0,0 +1,46 @@ +package com.wtb.javatool.entity; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.ToString; + +/** + * 查看申请表 + * @author yangzhuoheng + * + */ +@Data +@ToString +@ApiModel(value = "apply_view",description="查看申请") +public class ApplyView { + + @ApiModelProperty(value = "id") + private Integer id; + + @ApiModelProperty(value = "用户Id") + private Long userId; + + @ApiModelProperty(value = "数据库Id") + private Integer databaseId; + + @ApiModelProperty(value = "描述") + private String description; + + @ApiModelProperty(value = "审批人Id") + private Long approverId; + + @ApiModelProperty(value = "创建时间") + private String createTime; + + @ApiModelProperty(value = "状态,0表示已向老师发送申请但未同意,1表示老师同意并且已向管理员发送申请但未授权,2表示管理员审批成功整个流程完成") + private Integer status; + + + + + + + + +} diff --git a/java/src/com/wtb/javatool/entity/User.java b/java/src/com/wtb/javatool/entity/User.java index 484b40e85..8192bc731 100644 --- a/java/src/com/wtb/javatool/entity/User.java +++ b/java/src/com/wtb/javatool/entity/User.java @@ -23,7 +23,7 @@ public class User { @ApiModelProperty(value = "用户名") private String userName; - @ApiModelProperty(value = "角色id") + @ApiModelProperty(value = "角色id,0表示学生,1表示老师,2表示管理员") private Integer roleId; diff --git a/java/src/com/wtb/javatool/service/IApplyService.java b/java/src/com/wtb/javatool/service/IApplyService.java index 7d1cc4549..ecb3b2ad5 100644 --- a/java/src/com/wtb/javatool/service/IApplyService.java +++ b/java/src/com/wtb/javatool/service/IApplyService.java @@ -1,6 +1,7 @@ package com.wtb.javatool.service; import com.wtb.javatool.common.Result; +import com.wtb.javatool.entity.ApplyBuild; public interface IApplyService { @@ -10,6 +11,13 @@ public interface IApplyService { * @param courseId 课程ID * @return 申请结果 */ - Result applyByCourseId(Long studentId, Long courseId); + Result apply(Long studentId, Long courseId);//测试用 + + Integer applyByCourseId(ApplyBuild applyBuild); + + + Integer approveApply(ApplyBuild applyBuild); + + Integer authorizedApply(ApplyBuild applyBuild); } diff --git a/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java b/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java index a9c9cc3f5..716284efc 100644 --- a/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java +++ b/java/src/com/wtb/javatool/service/impl/ApplyServiceImpl.java @@ -1,37 +1,63 @@ package com.wtb.javatool.service.impl; import com.wtb.javatool.common.Result; +import com.wtb.javatool.dao.ApplyMapper; +import com.wtb.javatool.entity.ApplyBuild; import com.wtb.javatool.service.IApplyService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.persistence.criteria.CriteriaBuilder; import java.util.Objects; -//@Service -//public class ApplyServiceImpl implements IApplyService { -// -//// @Autowired -//// private DatabaseApplicationMapper databaseApplicationMapper; -//// -//// @Autowired -//// private StudentCourseMapper studentCourseMapper; -//// -// -// -// @Override -// @Transactional(rollbackFor = Exception.class) -// public Result applyByCourseId(Long studentId, Long courseId) { -// // 参数校验 -// if (Objects.isNull(studentId)) { -// throw new RuntimeException("学生ID不能为空且必须大于0"); -// } -// if (Objects.isNull(courseId)) { -// throw new RuntimeException("课程ID不能为空且必须大于0"); -// } -// -// +@Service +public class ApplyServiceImpl implements IApplyService { + + @Autowired + private ApplyMapper applyMapper; + + + @Override + public Integer applyByCourseId(ApplyBuild applyBuild) { + + Integer integer = applyMapper.applyByCourseId(applyBuild); + + return integer; + } + + @Override + public Integer approveApply(ApplyBuild applyBuild) { + + Integer integer = applyMapper.approveApply(applyBuild); + + return integer; + } + + @Override + public Integer authorizedApply(ApplyBuild applyBuild) { + + Integer integer = applyMapper.authorizedApply(applyBuild); + + System.out.println(applyBuild); + + return integer; + } + + + @Override + @Transactional(rollbackFor = Exception.class) + public Result apply(Long studentId, Long courseId) { + // 参数校验 + if (Objects.isNull(studentId)) { + throw new RuntimeException("学生ID不能为空且必须大于0"); + } + if (Objects.isNull(courseId)) { + throw new RuntimeException("课程ID不能为空且必须大于0"); + } + + // // 创建数据库申请记录 // DatabaseApplication application = new DatabaseApplication(); // application.setStudentId(studentId); @@ -46,16 +72,16 @@ import java.util.Objects; // if (rows <= 0) { // throw new BusinessException("数据库申请提交失败"); // } -// -// // 这里可以添加异步任务,通知管理员审核 -// -// return Result.success("数据库申请已提交,等待审核"); -// } -//} -// -// -// -// -// -// -//} + + // 这里可以添加异步任务,通知管理员审核 + + return Result.success("数据库申请已提交,等待审核"); + } +} + + + + + + + diff --git a/java/src/mappers/ApplyMapper.xml b/java/src/mappers/ApplyMapper.xml new file mode 100644 index 000000000..68d6a65fc --- /dev/null +++ b/java/src/mappers/ApplyMapper.xml @@ -0,0 +1,29 @@ + + + + + + INSERT INTO apply_build(user_id,class_id,database_id,description,approver_id,status,create_time) + VALUES(#{userId},#{classId},#{dataBaseId},#{description},#{approverId},#{status},#{createTime}) + + + + UPDATE apply_build + SET user_id=#{userId},class_id=#{classId},database_id=#{dataBaseId}, + description=#{description},approver_id=#{approverId},status=#{status}, + create_time=#{createTime},approve_time=#{approveTime},authorized_id=#{authorizedId} + WHERE id = #{id} + + + + UPDATE apply_build + SET user_id=#{userId},class_id=#{classId},database_id=#{dataBaseId}, + description=#{description},approver_id=#{approverId},status=#{status}, + create_time=#{createTime},approve_time=#{approveTime},authorized_id=#{authorizedId}, + authorized_time=#{authorizedTime} + WHERE id = #{id} + + + diff --git a/java/src/mappers/DishMapper.xml b/java/src/mappers/DishMapper.xml index 4dfb6ab09..2fb6d3366 100644 --- a/java/src/mappers/DishMapper.xml +++ b/java/src/mappers/DishMapper.xml @@ -3,6 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + INSERT INTO dish (name, price, description, create_time, update_time) VALUES(#{name}, #{price,jdbcType=DECIMAL},#{description},#{createTime},#{updateTime}) -- Gitee