diff --git a/.gitignore b/.gitignore index 2af7cef..8c02b8f 100644 --- a/.gitignore +++ b/.gitignore @@ -19,6 +19,5 @@ target/ nbproject/private/ build/ nbbuild/ -dist/ nbdist/ .nb-gradle/ \ No newline at end of file diff --git a/API文档.xlsx b/API文档.xlsx new file mode 100644 index 0000000..1c95d9d Binary files /dev/null and b/API文档.xlsx differ diff --git a/ER图.vsdx b/ER图.vsdx new file mode 100644 index 0000000..e98803d Binary files /dev/null and b/ER图.vsdx differ diff --git a/README.md b/README.md new file mode 100644 index 0000000..b6c9abd --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +# 班级作业提交系统 +[系统介绍和详细截图](https://www.fjy8018.xin/index.php/archives/100/) + +## 起因 ## +在2017年下半学年收集作业的过程中,遇到经常需要统一命名格式的情况,十分繁琐,也有出现许多深夜、凌晨提交作业的情况,同时也有不少要求找回以往提交的作业的情况,故考虑开发作业提交系统,满足作业收集需求 + +## 系统成品 ## +[作业提交系统正式版(点击访问正式版网站本体)][1] + +[作业提交系统测试服务器版本(点击访问测试服务器网站本体)][2] + +[系统使用说明(点击访问)][3] + +## 系统优点 ## +系统主要解决以下几大核心问题 + + 1. 全天候接受作业提交并及时作出响应 + 2. 作业自动按学号+姓名命名,也可自定义文件前缀和后缀 + 3. 作业按列表进行展示 + 4. 用户可下载以往提交的作业和模板 + 5. 后台自动获取所有未提交人员名单 + 6. ... + +## 系统不足 ## + 1. 360浏览器不和手动切换极速模式则样式崩溃 + 2. 后端功能未完善 + 3. 数据库设计不合理,索引效率不高 + 4. 文件单节点存储,可靠性差 + 6. ... + + [1]: https://cms.fjy8018.xin/cms/index + [2]: http://s2.fjy8018.top:8085/cms/index + [3]: http://home.fjy8018.top:8090/blog/index.php/archives/99/ \ No newline at end of file diff --git a/cms.nginx - 副本.conf b/cms.nginx - 副本.conf new file mode 100644 index 0000000..964b8bd --- /dev/null +++ b/cms.nginx - 副本.conf @@ -0,0 +1,45 @@ +upstream cms-host{ +server cms.fjy8018.xin:8085; +} + + server { + listen 80; + listen 443 ssl; + server_name cms.fjy8018.xin; #域名 + index index.html; #指定的server的root的访问页面 + root /index; #指定的server的root目录 + + #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 + #error_page 404/404.html; + #HTTP_TO_HTTPS_START + if ($server_port !~ 443){ + rewrite ^(/.*)$ https://$host$1 permanent; + } + #HTTP_TO_HTTPS_END + ssl_certificate /www/wwwroot/cms/full_chain.pem; + ssl_certificate_key /www/wwwroot/cms/private.key; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + ssl_session_timeout 10m; + error_page 497 https://$host$request_uri; + + + #SSL-END + + #charset koi8-r; + + #access_log logs/host.access.log main; + + #我工程的context-path=mytest + location /cms { + proxy_pass http://cms.fjy8018.xin:8085; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + # root html; + # index index.html index.htm; + } + } \ No newline at end of file diff --git a/cms.nginx.conf b/cms.nginx.conf new file mode 100644 index 0000000..9238fc2 --- /dev/null +++ b/cms.nginx.conf @@ -0,0 +1,44 @@ +upstream cms-host{ +server cms.fjy8018.xin:8085; +} + + server { + listen 80; + listen 443 ssl; + server_name cms.fjy8018.xin; #域名 + index index.html; #指定的server的root的访问页面 + root /index; #指定的server的root目录 + + #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 + #error_page 404/404.html; + #HTTP_TO_HTTPS_START + if ($server_port !~ 443){ + rewrite ^(/.*)$ https://$host$1 permanent; + } + #HTTP_TO_HTTPS_END + ssl_certificate /www/wwwroot/cms/full_chain.pem; + ssl_certificate_key /www/wwwroot/cms/private.key; + ssl_protocols TLSv1 TLSv1.1 TLSv1.2; + ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE; + ssl_prefer_server_ciphers on; + ssl_session_cache shared:SSL:10m; + ssl_session_timeout 10m; + error_page 497 https://$host$request_uri; + + + #SSL-END + + #charset koi8-r; + + #access_log logs/host.access.log main; + + #我工程的context-path=mytest + location /cms { + proxy_pass http://cms.fjy8018.xin:8085; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header X-Forwarded-Port $server_port; + # root html; + # index index.html index.htm; + } + } \ No newline at end of file diff --git a/com/fjy/spring/Application.html b/com/fjy/spring/Application.html new file mode 100644 index 0000000..8d0d4bf --- /dev/null +++ b/com/fjy/spring/Application.html @@ -0,0 +1,271 @@ + + + + + + +Application + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring
+

类 Application

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/ApplicationTests.html b/com/fjy/spring/ApplicationTests.html new file mode 100644 index 0000000..a03a54b --- /dev/null +++ b/com/fjy/spring/ApplicationTests.html @@ -0,0 +1,271 @@ + + + + + + +ApplicationTests + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring
+

类 ApplicationTests

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/constant/GlobalConstant.html b/com/fjy/spring/constant/GlobalConstant.html new file mode 100644 index 0000000..4194cef --- /dev/null +++ b/com/fjy/spring/constant/GlobalConstant.html @@ -0,0 +1,277 @@ + + + + + + +GlobalConstant + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.constant
+

类 GlobalConstant

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/enums/RegisteredEnum.html b/com/fjy/spring/enums/RegisteredEnum.html new file mode 100644 index 0000000..b221451 --- /dev/null +++ b/com/fjy/spring/enums/RegisteredEnum.html @@ -0,0 +1,352 @@ + + + + + + +RegisteredEnum + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.enums
+

枚举 RegisteredEnum

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/enums/ResultEnum.html b/com/fjy/spring/enums/ResultEnum.html new file mode 100644 index 0000000..97edb2a --- /dev/null +++ b/com/fjy/spring/enums/ResultEnum.html @@ -0,0 +1,524 @@ + + + + + + +ResultEnum + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.enums
+

枚举 ResultEnum

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/handle/ExceptionHandle.html b/com/fjy/spring/handle/ExceptionHandle.html new file mode 100644 index 0000000..2e7f1ac --- /dev/null +++ b/com/fjy/spring/handle/ExceptionHandle.html @@ -0,0 +1,273 @@ + + + + + + +ExceptionHandle + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.handle
+

类 ExceptionHandle

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/properties/ServerProperties.html b/com/fjy/spring/properties/ServerProperties.html new file mode 100644 index 0000000..a454d38 --- /dev/null +++ b/com/fjy/spring/properties/ServerProperties.html @@ -0,0 +1,311 @@ + + + + + + +ServerProperties + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.properties
+

类 ServerProperties

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/HomeworkRepository.html b/com/fjy/spring/repository/HomeworkRepository.html new file mode 100644 index 0000000..65e3ea9 --- /dev/null +++ b/com/fjy/spring/repository/HomeworkRepository.html @@ -0,0 +1,213 @@ + + + + + + +HomeworkRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 HomeworkRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbAdminRepository.html b/com/fjy/spring/repository/TbAdminRepository.html new file mode 100644 index 0000000..a881e19 --- /dev/null +++ b/com/fjy/spring/repository/TbAdminRepository.html @@ -0,0 +1,253 @@ + + + + + + +TbAdminRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbAdminRepository

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbCourseRepository.html b/com/fjy/spring/repository/TbCourseRepository.html new file mode 100644 index 0000000..b3d100d --- /dev/null +++ b/com/fjy/spring/repository/TbCourseRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbCourseRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbCourseRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbFeedBackRepository.html b/com/fjy/spring/repository/TbFeedBackRepository.html new file mode 100644 index 0000000..216f241 --- /dev/null +++ b/com/fjy/spring/repository/TbFeedBackRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbFeedBackRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbFeedBackRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbFileRepository.html b/com/fjy/spring/repository/TbFileRepository.html new file mode 100644 index 0000000..4c05763 --- /dev/null +++ b/com/fjy/spring/repository/TbFileRepository.html @@ -0,0 +1,294 @@ + + + + + + +TbFileRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbFileRepository

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbLogRepository.html b/com/fjy/spring/repository/TbLogRepository.html new file mode 100644 index 0000000..a738d32 --- /dev/null +++ b/com/fjy/spring/repository/TbLogRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbLogRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbLogRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbNoticeRepository.html b/com/fjy/spring/repository/TbNoticeRepository.html new file mode 100644 index 0000000..eb017b9 --- /dev/null +++ b/com/fjy/spring/repository/TbNoticeRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbNoticeRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbNoticeRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbStudentListRepository.html b/com/fjy/spring/repository/TbStudentListRepository.html new file mode 100644 index 0000000..9b1c904 --- /dev/null +++ b/com/fjy/spring/repository/TbStudentListRepository.html @@ -0,0 +1,268 @@ + + + + + + +TbStudentListRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbStudentListRepository

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbStudentRepository.html b/com/fjy/spring/repository/TbStudentRepository.html new file mode 100644 index 0000000..82e8f0f --- /dev/null +++ b/com/fjy/spring/repository/TbStudentRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbStudentRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbStudentRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbTeacherRepository.html b/com/fjy/spring/repository/TbTeacherRepository.html new file mode 100644 index 0000000..79b3ca1 --- /dev/null +++ b/com/fjy/spring/repository/TbTeacherRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbTeacherRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbTeacherRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbUserRepository.html b/com/fjy/spring/repository/TbUserRepository.html new file mode 100644 index 0000000..11c58bb --- /dev/null +++ b/com/fjy/spring/repository/TbUserRepository.html @@ -0,0 +1,270 @@ + + + + + + +TbUserRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbUserRepository

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbUserqueRepository.html b/com/fjy/spring/repository/TbUserqueRepository.html new file mode 100644 index 0000000..d4e1537 --- /dev/null +++ b/com/fjy/spring/repository/TbUserqueRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbUserqueRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbUserqueRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/TbVersionRepository.html b/com/fjy/spring/repository/TbVersionRepository.html new file mode 100644 index 0000000..3c044e7 --- /dev/null +++ b/com/fjy/spring/repository/TbVersionRepository.html @@ -0,0 +1,213 @@ + + + + + + +TbVersionRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 TbVersionRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VAdminRepository.html b/com/fjy/spring/repository/VAdminRepository.html new file mode 100644 index 0000000..f33467a --- /dev/null +++ b/com/fjy/spring/repository/VAdminRepository.html @@ -0,0 +1,213 @@ + + + + + + +VAdminRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VAdminRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VCourseRepository.html b/com/fjy/spring/repository/VCourseRepository.html new file mode 100644 index 0000000..2186491 --- /dev/null +++ b/com/fjy/spring/repository/VCourseRepository.html @@ -0,0 +1,213 @@ + + + + + + +VCourseRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VCourseRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VFeedBackRepository.html b/com/fjy/spring/repository/VFeedBackRepository.html new file mode 100644 index 0000000..d8bb3bc --- /dev/null +++ b/com/fjy/spring/repository/VFeedBackRepository.html @@ -0,0 +1,213 @@ + + + + + + +VFeedBackRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VFeedBackRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VHomeworkRepository.html b/com/fjy/spring/repository/VHomeworkRepository.html new file mode 100644 index 0000000..5687417 --- /dev/null +++ b/com/fjy/spring/repository/VHomeworkRepository.html @@ -0,0 +1,213 @@ + + + + + + +VHomeworkRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VHomeworkRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VLogRepository.html b/com/fjy/spring/repository/VLogRepository.html new file mode 100644 index 0000000..3479b03 --- /dev/null +++ b/com/fjy/spring/repository/VLogRepository.html @@ -0,0 +1,213 @@ + + + + + + +VLogRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VLogRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VUserfileRepository.html b/com/fjy/spring/repository/VUserfileRepository.html new file mode 100644 index 0000000..b5a8ef6 --- /dev/null +++ b/com/fjy/spring/repository/VUserfileRepository.html @@ -0,0 +1,271 @@ + + + + + + +VUserfileRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VUserfileRepository

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VUserinfoRepository.html b/com/fjy/spring/repository/VUserinfoRepository.html new file mode 100644 index 0000000..8027c9f --- /dev/null +++ b/com/fjy/spring/repository/VUserinfoRepository.html @@ -0,0 +1,213 @@ + + + + + + +VUserinfoRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VUserinfoRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/VUserqueRepository.html b/com/fjy/spring/repository/VUserqueRepository.html new file mode 100644 index 0000000..f11458e --- /dev/null +++ b/com/fjy/spring/repository/VUserqueRepository.html @@ -0,0 +1,253 @@ + + + + + + +VUserqueRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 VUserqueRepository

+
+
+
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/WorkDetailRepository.html b/com/fjy/spring/repository/WorkDetailRepository.html new file mode 100644 index 0000000..f0e5b71 --- /dev/null +++ b/com/fjy/spring/repository/WorkDetailRepository.html @@ -0,0 +1,213 @@ + + + + + + +WorkDetailRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 WorkDetailRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/repository/WorkstatusRepository.html b/com/fjy/spring/repository/WorkstatusRepository.html new file mode 100644 index 0000000..a66c744 --- /dev/null +++ b/com/fjy/spring/repository/WorkstatusRepository.html @@ -0,0 +1,213 @@ + + + + + + +WorkstatusRepository + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.repository
+

接口 WorkstatusRepository

+
+
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/AdminService.html b/com/fjy/spring/service/AdminService.html new file mode 100644 index 0000000..92eb159 --- /dev/null +++ b/com/fjy/spring/service/AdminService.html @@ -0,0 +1,284 @@ + + + + + + +AdminService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 AdminService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/CourseService.html b/com/fjy/spring/service/CourseService.html new file mode 100644 index 0000000..d4e6c59 --- /dev/null +++ b/com/fjy/spring/service/CourseService.html @@ -0,0 +1,271 @@ + + + + + + +CourseService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 CourseService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/FeedBackService.html b/com/fjy/spring/service/FeedBackService.html new file mode 100644 index 0000000..b2f8020 --- /dev/null +++ b/com/fjy/spring/service/FeedBackService.html @@ -0,0 +1,284 @@ + + + + + + +FeedBackService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 FeedBackService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/FileService.html b/com/fjy/spring/service/FileService.html new file mode 100644 index 0000000..d810755 --- /dev/null +++ b/com/fjy/spring/service/FileService.html @@ -0,0 +1,377 @@ + + + + + + +FileService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 FileService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/HomeworkService.html b/com/fjy/spring/service/HomeworkService.html new file mode 100644 index 0000000..e4f4705 --- /dev/null +++ b/com/fjy/spring/service/HomeworkService.html @@ -0,0 +1,284 @@ + + + + + + +HomeworkService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 HomeworkService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/LogService.html b/com/fjy/spring/service/LogService.html new file mode 100644 index 0000000..49674a3 --- /dev/null +++ b/com/fjy/spring/service/LogService.html @@ -0,0 +1,284 @@ + + + + + + +LogService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 LogService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/NoticeService.html b/com/fjy/spring/service/NoticeService.html new file mode 100644 index 0000000..4c3d497 --- /dev/null +++ b/com/fjy/spring/service/NoticeService.html @@ -0,0 +1,284 @@ + + + + + + +NoticeService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 NoticeService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/com/fjy/spring/service/StudentService.html b/com/fjy/spring/service/StudentService.html new file mode 100644 index 0000000..bc2c8ef --- /dev/null +++ b/com/fjy/spring/service/StudentService.html @@ -0,0 +1,303 @@ + + + + + + +StudentService + + + + + + + + +
+ + +
跳过导航链接
+ + + + +
+ + + +
+
com.fjy.spring.service
+

类 StudentService

+
+
+ +
+ +
+
+ +
+
+ +
+
+ + +
+ + +
跳过导航链接
+ + + + +
+ + + + diff --git a/pom.xml b/pom.xml index ca95f9c..df365ce 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.fjy spring - 0.0.1-SNAPSHOT + V2.9.2 jar spring @@ -60,6 +60,7 @@ org.apache.ant ant + 1.10.2 diff --git a/sql.sql b/sql.sql new file mode 100644 index 0000000..d6d15ff --- /dev/null +++ b/sql.sql @@ -0,0 +1,249 @@ +CREATE DATABASE db_imis2 + +CREATE TABLE tb_user +( + coluserid INT(10) PRIMARY KEY NOT NULL AUTO_INCREMENT, + colname VARCHAR(30) NOT NULL, + colpassword VARCHAR(255) NOT NULL, + colemail VARCHAR(30) NOT NULL, + colstudentno VARCHAR(50) NOT NULL, + colrealname VARCHAR(20) NOT NULL +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +CREATE UNIQUE INDEX tb_user_colname_uindex ON tb_user (colname); +INSERT INTO tb_user (colname, colpassword, colemail, colstudentno, colrealname) VALUES ('root','-4e4hc3pvvu8n0rj1uena76948n37q23r','root@gmail.com','00001','FJY'); +SELECT * FROM tb_user; + + +CREATE TABLE tb_file +( + colfileid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + coltime VARCHAR(128) NOT NULL, + colip VARCHAR(128), + colrealname VARCHAR(255), + colfilename VARCHAR(255), + colfilesize VARCHAR(32), + colfilepath VARCHAR(128) +)ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_general_ci; +ALTER TABLE tb_file COMMENT = '文件表'; +ALTER TABLE tb_file ADD CONSTRAINT FK_fileuser FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid); + +CREATE TABLE tb_admin +( + adminid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + coltime VARCHAR(128) NOT NULL, + CONSTRAINT FK_adminuser FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_admin COMMENT = '管理员表'; + +CREATE TABLE tb_student +( + studentid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + coltime VARCHAR(128) NOT NULL, + CONSTRAINT FK_sutdentuser FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid) +)ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_general_ci; +ALTER TABLE tb_student COMMENT = '学生表'; + +CREATE TABLE tb_teacher +( + teacherid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + coltime VARCHAR(128) NOT NULL, + CONSTRAINT FK_teacheruser FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid) +)ENGINE = InnoDB CHARSET=utf8 COLLATE utf8_general_ci; +ALTER TABLE tb_teacher COMMENT = '老师表'; + +CREATE TABLE tb_log +( + logid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + coltime VARCHAR(128) NOT NULL, + colip VARCHAR(128), + colheader VARCHAR(255), + CONSTRAINT FK_loguser FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_log + COMMENT = '日志表'; + +CREATE TABLE tb_course +( + courseNo INT(10) PRIMARY KEY AUTO_INCREMENT, + courseName VARCHAR(128) NOT NULL, + courseTime VARCHAR(128) NOT NULL, + teacherid INT(10), + CONSTRAINT FK_teacherid FOREIGN KEY (teacherid) REFERENCES tb_teacher (teacherid) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_course COMMENT = '课程表'; + +CREATE TABLE tb_homework +( + workId INT(10) PRIMARY KEY AUTO_INCREMENT, + workName VARCHAR(128) NOT NULL, + workTime VARCHAR(128) NOT NULL , + colfileid INT(10), + workFolder VARCHAR(255) NOT NULL, + courseNo INT(10), + workRemark VARCHAR(255), + CONSTRAINT FK_colfileid FOREIGN KEY (colfileid) REFERENCES tb_file (colfileid), + CONSTRAINT FK_courseNo FOREIGN KEY (courseNo) REFERENCES tb_course (courseNo) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_homework COMMENT = '作业表'; + +CREATE TABLE tb_workstatus +( + statusid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + workId INT(10), + colstatus INT(10), + CONSTRAINT FK_statususer FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid), + CONSTRAINT FK_workId FOREIGN KEY (workId) REFERENCES tb_homework (workId) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_workstatus COMMENT = '作业提交状态表'; + +CREATE TABLE tb_feedback +( + feedbackid INT(10) PRIMARY KEY AUTO_INCREMENT, + coluserid INT(10), + feedbackContent VARCHAR(255), + issueTime VARCHAR(128), + CONSTRAINT FK_feedbackuser FOREIGN KEY (coluserid) REFERENCES tb_user (coluserid) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_workstatus COMMENT = '反馈信息表'; + +CREATE TABLE tb_notice +( + noticeid INT(10) PRIMARY KEY AUTO_INCREMENT, + adminid INT(10), + noticeContent VARCHAR(255), + issueTime VARCHAR(128), + CONSTRAINT FK_noticeuser FOREIGN KEY (adminid) REFERENCES tb_admin (adminid) +) + ENGINE = InnoDB + CHARSET = utf8 + COLLATE utf8_general_ci; +ALTER TABLE tb_workstatus COMMENT = '公告表'; + + +CREATE VIEW v_workdetail + AS + SELECT + workId, + workName, + workTime, + f.colfileid, + colfilename, + c.courseName, + workRemark, + h.workFolder + FROM tb_homework h, tb_course c, tb_file f + WHERE h.colfileid = f.colfileid AND h.courseNo = c.courseNo; + +CREATE VIEW v_log + AS + SELECT + logid, + colname, + coltime , + colip , + colheader + FROM tb_log,tb_user + WHERE tb_user.coluserid = tb_log.coluserid; + +CREATE VIEW v_feedback + AS + SELECT + feedbackid, + colname, + feedbackContent, + issueTime + FROM tb_feedback, tb_user + WHERE tb_user.coluserid = tb_feedback.coluserid; + + +CREATE VIEW v_course + AS + SELECT + courseNo, + courseName, + courseTime, + colrealname, + colname + FROM tb_course, tb_teacher,tb_user + WHERE tb_user.coluserid = tb_teacher.coluserid AND tb_teacher.teacherid=tb_course.teacherid; + +CREATE VIEW v_homework + AS + SELECT + workId, + workName, + workTime, + colfileid, + workFolder, + courseName, + workRemark + FROM tb_homework, tb_course + WHERE tb_homework.courseNo = tb_course.courseNo; + + +CREATE VIEW v_userfile + AS + SELECT + colfileid, + coltime, + colip, + colfilename, + colfilesize, + colfilepath, + courseName, + workFolder, + tb_user.colrealname, + colstudentno + FROM tb_file, tb_user + WHERE tb_user.coluserid = tb_file.coluserid; + + +CREATE VIEW v_userinfo + AS + SELECT + coluserid, + colname, + colemail, + colstudentno, + colrealname + FROM tb_user; + + +CREATE VIEW v_userque + AS + SELECT + tb_user.coluserid, + colname, + colquestion, + colanswer, + colrealname + FROM tb_userque,tb_user + WHERE tb_user.coluserid=tb_userque.coluserid; + diff --git a/src/main/java/com/fjy/spring/controller/DataController.java b/src/main/java/com/fjy/spring/controller/DataController.java index 6282973..d5615e5 100644 --- a/src/main/java/com/fjy/spring/controller/DataController.java +++ b/src/main/java/com/fjy/spring/controller/DataController.java @@ -5,23 +5,18 @@ import com.fjy.spring.enums.ResultEnum; import com.fjy.spring.exception.UserException; import com.fjy.spring.service.*; import com.fjy.spring.untils.CodingUtil; -import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigInteger; -import java.util.List; -import java.util.Optional; +import java.text.SimpleDateFormat; +import java.util.*; import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; @RestController -@Slf4j public class DataController { @Autowired @@ -42,96 +37,99 @@ public class DataController { @Autowired private HomeworkService homeworkService; - @Autowired - private FileService fileService; - @Autowired private VUserfileService vUserfileService; @Autowired private NoticeService noticeService; + @Autowired + private VersionService versionService; + + @Autowired + private AdminService adminService; + @Resource private HttpServletRequest httpServletRequest; @GetMapping("/home/findAllHomework") - public List findAllHomework(){ + public List findAllHomework() { List homeworks = workDetailService.findAll(); - if (homeworks!=null){ + if (homeworks != null) { return homeworks; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/findvlog") - public List findlog(){ + public List findlog() { List vlogs = logService.findvlog(); - if (vlogs!=null){ + if (vlogs != null) { return vlogs; } throw new UserException(ResultEnum.EMPTY_DATA); } - @GetMapping("/home/findvfeedback") - public List findAllVFeedback(){ + @GetMapping("/home/admin/findvfeedback") + public List findAllVFeedback() { List feedBacks = feedBackService.findAllVFeedback(); - if (feedBacks!=null){ + if (feedBacks != null) { return feedBacks; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/findvcourse") - public List findVCourse(){ + public List findVCourse() { List vCourses = courseService.findAllVCourse(); - if (vCourses!=null){ + if (vCourses != null) { return vCourses; } throw new UserException(ResultEnum.EMPTY_DATA); } - @GetMapping("/home/findalluser") - public List findAllUser(){ + @GetMapping("/home/admin/findalluser") + public List findAllUser() { List users = userService.findAllUser(); - if (users!=null){ + if (users != null) { return users; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/findallvhomework") - public List findAllVHomework(){ + public List findAllVHomework() { List vHomeworks = homeworkService.findAllVHomework(); - if (vHomeworks!=null){ + if (vHomeworks != null) { return vHomeworks; } throw new UserException(ResultEnum.EMPTY_DATA); } - @GetMapping("/home/findStudentInCourseFile") - public List findStudentInCourseFile( - @RequestParam(value = "Folder") String Folder,@RequestParam(value = "CourseName") String CourseName){ - List files = vUserfileService.findStudentNoByWorkFolderAndCourseName(Folder,CourseName); - if (files!=null){ + @GetMapping("/home/admin/findStudentInCourseFile") + public List findStudentInCourseFile( + @RequestParam(value = "Folder") String Folder, @RequestParam(value = "CourseName") String CourseName) { + List files = vUserfileService.findStudentNoByWorkFolderAndCourseName(Folder, CourseName); + if (files != null) { return files; } throw new UserException(ResultEnum.EMPTY_DATA); } @GetMapping("/home/userinfo") - public VUserinfo findUserInfo(){ - TbUser user= (TbUser)httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); + public VUserinfo findUserInfo() { + TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); return userService.findUserInfo(user.getColuserid()); } /** * 存储密保问题 + * * @param userque * @return */ @PostMapping("/home/adduserque") - public boolean adduserque(TbUserque userque)throws Exception{ - log.info(userque.toString()); + public boolean adduserque(TbUserque userque) throws Exception { //对密保问题加密存储 userque.setAnswer(new BigInteger(CodingUtil.encryptSHA(userque.getAnswer().getBytes())).toString(32)); return userService.addUserQue(userque); @@ -139,6 +137,7 @@ public class DataController { /** * 判断密保问题是否正确,正确返回true,错误返回false,其余反馈异常对象 + * * @param name * @param question * @param answer @@ -146,18 +145,19 @@ public class DataController { * @throws Exception */ @GetMapping("/finduserque") - public boolean findUserQue(@RequestParam(value = "name")String name - ,@RequestParam(value = "question")String question - ,@RequestParam(value = "answer")String answer)throws Exception{ + public boolean findUserQue(@RequestParam(value = "name") String name + , @RequestParam(value = "question") String question + , @RequestParam(value = "answer") String answer) throws Exception { Optional userque = userService.findUserQueByName(name); - if (!userque.isPresent()){ + if (!userque.isPresent()) { throw new UserException(ResultEnum.EMPTY_QUESTION); - }else if(question.equals(userque.get().getQuestion())){ - if(new BigInteger(CodingUtil.encryptSHA(answer.getBytes())).toString(32).equals(userque.get().getAnswer())) + } else if (question.equals(userque.get().getQuestion())) { + if (new BigInteger(CodingUtil.encryptSHA(answer.getBytes())).toString(32).equals(userque.get().getAnswer())) { return true; - else + } else { return false; - }else{ + } + } else { throw new UserException(ResultEnum.QUESTION_ERROR); } } @@ -165,19 +165,53 @@ public class DataController { @PostMapping("/resetPass") public boolean resetPass(@RequestParam(value = "name") String name , @RequestParam(value = "password") String password, - @RequestParam(value = "question") String question + @RequestParam(value = "question") String question , @RequestParam(value = "answer") String answer) throws Exception { - log.info("name:{}, password:{}, question:{}, answer:{}",name,password,question,answer); - if (findUserQue(name,question,answer)){ + //log.info("name:{}, password:{}, question:{}, answer:{}",name,password,question,answer); + if (findUserQue(name, question, answer)) { //service方法内含有对密码加密的操作 - return userService.updateColpasswordByColname(password,name); - }else { + return userService.updateColpasswordByColname(password, name); + } else { throw new UserException(ResultEnum.ILLEGAL_ACCESS); } } @GetMapping("/home/findAllNotice") - public List findAllNotice(){ + public List findAllNotice() { return noticeService.findAll(); } + + @PostMapping("/home/admin/addNotice") + public boolean addNotice(String content) { + TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); + TbNotice notice = new TbNotice(); + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dateNowStr = sdf.format(date); + Optional vAdmin = adminService.findAdminByUserId(user.getColuserid()); + if (vAdmin.isPresent()) { + VAdmin admin = vAdmin.get(); + notice.setAdminid(admin.getAdminid()); + notice.setIssueTime(dateNowStr); + notice.setNoticeContent(content); + return noticeService.addOne(notice) != null; + } else { + return false; + } + } + + @PostMapping("/home/admin/addoneversion") + public boolean addOneVersion(TbVersion version) { + return versionService.addOneVersion(version) != null; + } + + @PostMapping("/home/admin/addversion") + public boolean addVersion(@RequestBody List versions) { + return versionService.addAllVersion(versions) != null; + } + + @GetMapping("/home/findallversion") + public List findAllVersion() { + return versionService.findAll(); + } } diff --git a/src/main/java/com/fjy/spring/controller/DeleteController.java b/src/main/java/com/fjy/spring/controller/DeleteController.java index 5bc5930..bd77173 100644 --- a/src/main/java/com/fjy/spring/controller/DeleteController.java +++ b/src/main/java/com/fjy/spring/controller/DeleteController.java @@ -1,9 +1,13 @@ package com.fjy.spring.controller; import com.fjy.spring.domain.TbFile; +import com.fjy.spring.domain.TbLog; +import com.fjy.spring.domain.TbUser; import com.fjy.spring.enums.ResultEnum; import com.fjy.spring.exception.UserException; import com.fjy.spring.service.FileService; +import com.fjy.spring.service.LogService; +import com.fjy.spring.untils.GetIPAddrUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -12,13 +16,28 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; import java.io.File; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; @Controller @Slf4j public class DeleteController { + /** + * 文件相关数据库操作 + */ @Autowired - private FileService fileService;//文件相关数据库操作 + private FileService fileService; + + @Autowired + private LogService logService; + + @Resource + HttpServletRequest request; @GetMapping("/home/findfile") @ResponseBody @@ -33,20 +52,25 @@ public class DeleteController { */ @RequestMapping("/home/filedelete") @ResponseBody - public void delete(@RequestParam(value = "fileid") Integer fileid)throws Exception { + public boolean delete(@RequestParam(value = "fileid") Integer fileid)throws Exception { TbFile tbFile = new TbFile(); tbFile.setColfileid(fileid); TbFile resfile = fileService.findFileById(tbFile); File filepath = new File(resfile.getColfilepath()); if (!filepath.exists()) { log.error("删除文件失败:" + resfile.getColfilename() + "不存在!"); + return false; } else { if (filepath.isFile()){ deleteFile(resfile.getColfilepath(),resfile.getColfileid()); - new UserException(ResultEnum.SUCCESS); + return true; } - else + else{ deleteDirectory(resfile.getColfilepath()); + return true; + } + + } } @@ -63,6 +87,22 @@ public class DeleteController { if (file.delete()) { fileService.deleteFileById(tbFile); log.info("删除单个文件" + fileName + "成功!"); + + TbUser user =(TbUser)request.getSession().getAttribute(USER_SESSION_KEY); + //写入日志信息 + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dateNowStr = sdf.format(date); + TbLog log = new TbLog(); + log.setUserid(user.getColuserid()); + log.setColtime(dateNowStr); + log.setColheader("删除单个文件" + fileName + "成功!"); + log.setRequestURL(request.getRequestURL().toString()); + + //解决nginx代理后IP地址获取问题 + log.setColip(GetIPAddrUtil.getIpAddr(request)); + logService.addLogRec(log); + return true; } else { log.info("删除单个文件" + fileName + "失败!"); diff --git a/src/main/java/com/fjy/spring/controller/DownLoadController.java b/src/main/java/com/fjy/spring/controller/DownLoadController.java index ed47bfe..7a4d760 100644 --- a/src/main/java/com/fjy/spring/controller/DownLoadController.java +++ b/src/main/java/com/fjy/spring/controller/DownLoadController.java @@ -1,11 +1,14 @@ package com.fjy.spring.controller; import com.fjy.spring.domain.TbFile; +import com.fjy.spring.domain.TbLog; import com.fjy.spring.domain.TbUser; import com.fjy.spring.enums.ResultEnum; import com.fjy.spring.exception.UserException; import com.fjy.spring.properties.ServerProperties; import com.fjy.spring.service.FileService; +import com.fjy.spring.service.LogService; +import com.fjy.spring.untils.LogUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -28,12 +31,18 @@ import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; @Controller public class DownLoadController { + /** + * 服务器配置信息 + */ @Autowired - private ServerProperties serverProperties;//服务器配置信息 + private ServerProperties serverProperties; @Autowired private FileService fileService; + @Autowired + private LogService logService; + @Resource HttpServletRequest request; @@ -42,31 +51,32 @@ public class DownLoadController { return "download/dodownload"; }*/ - @GetMapping("/download/findall") + @GetMapping("/home/admin/download/findall") @ResponseBody - public List toDownloadAll(){ - List files = fileService.findAllFile();//此处做空指针判断并抛出错误 - if (files!=null) + public List toDownloadAll() { + //此处做空指针判断并抛出错误 + List files = fileService.findAllFile(); + if (files != null) { return files; - new UserException(ResultEnum.EMPTY_DATA); - return null; + } + throw new UserException(ResultEnum.EMPTY_DATA); } - @GetMapping("/download/findone") + @GetMapping("/home/download/findone") @ResponseBody - public List toDownloadOne(){ - TbUser user = (TbUser)request.getSession().getAttribute(USER_SESSION_KEY); + public List toDownloadOne() { + TbUser user = (TbUser) request.getSession().getAttribute(USER_SESSION_KEY); //log.info(user.toString()); List files = fileService.findByColuserid(user.getColuserid()); //此处做空指针判断并抛出错误 - if (files!=null) + if (files != null) { return files; - new UserException(ResultEnum.EMPTY_DATA); - return null; + } + throw new UserException(ResultEnum.EMPTY_DATA); } - @RequestMapping("/download/dodownload") - public String download(@RequestParam Integer fileId , HttpServletRequest request, HttpServletResponse response){ + @RequestMapping("/home/download/dodownload") + public String download(@RequestParam Integer fileId, HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html;charset=utf-8"); try { @@ -100,23 +110,29 @@ public class DownLoadController { while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) { bos.write(buff, 0, bytesRead); } + //记录下载日志 + addVisitLog("下载文件"+tbFile.getColrealname()+" "+tbFile.getColfilename()); + + } catch (Exception e) { e.printStackTrace(); } finally { - if (bis != null) + if (bis != null) { try { bis.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } - if (bos != null) + } + if (bos != null) { try { bos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } + } } return null; @@ -124,16 +140,17 @@ public class DownLoadController { /** * 传入课程名和文件夹名称,打包下载目录下所有文件 + * * @param courseName * @param folder * @param response */ - @GetMapping("/download/downloadzip") + @GetMapping("/home/admin/download/downloadzip") public void batDownload(@RequestParam(value = "courseName") String courseName, - @RequestParam(value = "Folder")String folder, HttpServletResponse response){ + @RequestParam(value = "Folder") String folder, HttpServletResponse response) { //获取文件夹名称 - String paths = serverProperties.getFilePath()+ "upload/"+courseName+"/"+folder; - String zipPath = serverProperties.getFilePath()+"zip/"; + String paths = serverProperties.getFilePath() + "upload/" + courseName + "/" + folder; + String zipPath = serverProperties.getFilePath() + "zip/"; File dir = new File(zipPath); if (!dir.exists()) { @@ -141,12 +158,12 @@ public class DownLoadController { } List pathList = new ArrayList(); - pathList=getFileString(paths); + pathList = getFileString(paths); //需要压缩的文件--包括文件地址和文件名 - String []path =(String[])pathList.toArray(new String[0]); + String[] path = (String[]) pathList.toArray(new String[0]); // 要生成的压缩文件地址和文件名称 - String zipFileName=courseName+folder+".zip"; - String desPath = zipPath+"\\"+zipFileName; + String zipFileName = courseName + folder + ".zip"; + String desPath = zipPath + "\\" + zipFileName; //System.out.println("打包文件存储地址:"+desPath); File zipFile = new File(desPath); @@ -156,35 +173,45 @@ public class DownLoadController { try { //构造最终压缩包的输出流 zipStream = new ZipOutputStream(new FileOutputStream(zipFile)); - for(int i =0;i getFileString(String fileDir) { List fileList = new ArrayList(); File file = new File(fileDir); - File[] files = file.listFiles();// 获取目录下的所有文件或文件夹 + // 获取目录下的所有文件或文件夹 + File[] files = file.listFiles(); List path = new ArrayList(); List name = new ArrayList(); - int i = 0,j=0; - if (files == null) {// 如果目录为空,直接退出 + int i = 0, j = 0; + // 如果目录为空,直接退出 + if (files == null) { path.add("空目录"); return path; } @@ -266,4 +298,15 @@ public class DownLoadController { System.out.println(it1.next()); } }*/ + + /** + * 登陆后的访问日志记录 + * + * @param content + */ + private void addVisitLog(String content) { + TbUser user = (TbUser) request.getSession().getAttribute(USER_SESSION_KEY); + TbLog log = LogUtil.addLog(user, content, request); + logService.addLogRec(log); + } } diff --git a/src/main/java/com/fjy/spring/controller/FeedBackController.java b/src/main/java/com/fjy/spring/controller/FeedBackController.java index 7852056..1944674 100644 --- a/src/main/java/com/fjy/spring/controller/FeedBackController.java +++ b/src/main/java/com/fjy/spring/controller/FeedBackController.java @@ -33,7 +33,7 @@ public class FeedBackController { HttpServletRequest request; @PostMapping("/home/dofeedback") - public void doFeedBack(@RequestParam(value = "content") String content){ + public boolean doFeedBack(@RequestParam(value = "content") String content){ Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateNowStr = sdf.format(date); @@ -45,7 +45,9 @@ public class FeedBackController { RedirectUtil red = new RedirectUtil(); if (feedBackService.addContent(feedBack)){ log.info("反馈信息写入数据库成功"); + return true; } + return false; } } diff --git a/src/main/java/com/fjy/spring/controller/LoginController.java b/src/main/java/com/fjy/spring/controller/LoginController.java index 56e8ec3..7bcbc61 100644 --- a/src/main/java/com/fjy/spring/controller/LoginController.java +++ b/src/main/java/com/fjy/spring/controller/LoginController.java @@ -1,15 +1,19 @@ package com.fjy.spring.controller; +import com.fjy.spring.domain.TbAdmin; import com.fjy.spring.domain.TbLog; import com.fjy.spring.domain.TbUser; import com.fjy.spring.properties.ServerProperties; +import com.fjy.spring.service.AdminService; import com.fjy.spring.service.LogService; import com.fjy.spring.service.UserService; import com.fjy.spring.untils.CodingUtil; +import com.fjy.spring.untils.GetIPAddrUtil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; @@ -19,6 +23,7 @@ import java.math.BigInteger; import java.sql.Timestamp; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Optional; import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; @@ -48,12 +53,17 @@ public class LoginController { Date date = new Date(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); String dateNowStr = sdf.format(date); + //System.out.println("当前时间:"+dateNowStr); TbLog log = new TbLog(); log.setUserid(user.getColuserid()); log.setColtime(dateNowStr); log.setColheader(request.getHeader("user-agent")); - log.setColip(request.getRemoteAddr()); + log.setRequestURL(request.getRequestURL().toString()); + + //解决nginx代理后IP地址获取问题 + //log.setColip(request.getRemoteAddr()); + log.setColip(GetIPAddrUtil.getIpAddr(request)); logService.addLogRec(log); return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":" @@ -65,10 +75,21 @@ public class LoginController { @PostMapping("/beforeLogin") @ResponseBody public boolean beforeLogin(TbUser tbUser)throws Exception{ - System.out.println(tbUser.toString()); - //加密用户密码 tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32)); TbUser user = userService.doLoginService(tbUser.getColname(),tbUser.getColpassword()); return user!=null; } + + /** + * 登录时判断用户名是否存在,若不存在,则返回false + * @param name + * @return + * @throws Exception + */ + @GetMapping("/beforeLoginCheckNameExist") + @ResponseBody + public boolean beforeLoginCheckNameExist(@RequestParam(value = "name") String name)throws Exception{ + Optional user = userService.findByColname(name); + return user.isPresent(); + } } diff --git a/src/main/java/com/fjy/spring/controller/NavController.java b/src/main/java/com/fjy/spring/controller/NavController.java index 3dec5cc..49daa9d 100644 --- a/src/main/java/com/fjy/spring/controller/NavController.java +++ b/src/main/java/com/fjy/spring/controller/NavController.java @@ -1,81 +1,132 @@ package com.fjy.spring.controller; +import com.fjy.spring.domain.TbLog; +import com.fjy.spring.domain.TbUser; +import com.fjy.spring.service.LogService; +import com.fjy.spring.untils.GetIPAddrUtil; +import com.fjy.spring.untils.LogUtil; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.SessionAttributes; import org.springframework.web.bind.support.SessionStatus; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; + @Controller +@SessionAttributes(USER_SESSION_KEY) public class NavController { @Resource HttpServletRequest request; + @Autowired + private LogService logService; + @GetMapping(value = {"index",""}) public String toLoginPage(){ + //获取访问头信息 + addIndexLog(request.getHeader("user-agent")); return "login"; } @GetMapping(value = {"testthymeleaf"}) public String toTestPage(){ + addVisitLog(); return "/dist/thymeleafTest"; } @GetMapping(value = {"axiosTest"}) public String toTestAxiosPage(){ + addVisitLog(); return "/dist/axiosTest"; } @GetMapping(value = {"/home"}) public String toHomePage(){ - return "/home/home"; + addVisitLog(); + return "home/home"; } @GetMapping(value = {"/logout"}) public String toLogOut(SessionStatus status){ //request.getSession().getAttribute(USER_SESSION_KEY).invalidate(); + addVisitLog(); status.setComplete(); return "login"; } @GetMapping(value = {"/home/feedback"}) public String toFeedbackPage(){ - return "/home/feedback"; + addVisitLog(); + return "home/feedback"; } @GetMapping(value = {"/home/about"}) public String toAboutPage(){ - return "/home/about"; + addVisitLog(); + return "home/about"; } @GetMapping(value = {"/home/admin"}) public String toAdminPage(){ - return "/home/admin"; + addVisitLog(); + return "home/admin"; } - @GetMapping(value = {"/home/managecourse"}) + @GetMapping(value = {"/home/admin/managecourse"}) public String toManageCoursePage(){ - return "/home/managecourse"; + addVisitLog(); + return "home/managecourse"; } - @GetMapping(value = {"/home/manageuser"}) + @GetMapping(value = {"/home/admin/manageuser"}) public String toManageUserPage(){ - return "/home/manageuser"; + addVisitLog(); + return "home/manageuser"; } - @GetMapping(value = {"/home/homework"}) + @GetMapping(value = {"/home/admin/homework"}) public String toHomeworkPage(){ - return "/home/homework"; + addVisitLog(); + return "home/homework"; } @GetMapping(value = {"/home/user"}) public String toUserPage(){ - return "/home/user"; + addVisitLog(); + return "home/user"; } @GetMapping(value = {"/error"}) public String toErrorPage(){ - return "/error"; + addVisitLog(); + return "error"; + } + + /** + * 首页的访问日志记录 + * @param content + */ + private void addIndexLog(String content){ + TbUser user = new TbUser(); + user.setColname("访客"); + TbLog log = LogUtil.addLog(user,content,request); + logService.addLogRec(log); + } + + /** + * 登陆后的访问日志记录 + */ + private void addVisitLog(){ + TbUser user =(TbUser)request.getSession().getAttribute(USER_SESSION_KEY); + TbLog log = LogUtil.addLog(user,request.getHeader("user-agent"),request); + logService.addLogRec(log); } } diff --git a/src/main/java/com/fjy/spring/controller/RegisterController.java b/src/main/java/com/fjy/spring/controller/RegisterController.java index cbda46e..0115358 100644 --- a/src/main/java/com/fjy/spring/controller/RegisterController.java +++ b/src/main/java/com/fjy/spring/controller/RegisterController.java @@ -2,6 +2,7 @@ package com.fjy.spring.controller; import com.fjy.spring.domain.TbStudentlist; import com.fjy.spring.domain.TbUser; +import com.fjy.spring.enums.RegisteredEnum; import com.fjy.spring.enums.ResultEnum; import com.fjy.spring.exception.UserException; import com.fjy.spring.properties.ServerProperties; @@ -48,6 +49,8 @@ public class RegisterController { //加密用户密码 tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32)); if (userService.doRegisterService(tbUser)){ + //更新用户列表是否注册的标记 + studentService.UpdateStudentListRegistered(tbUser.getColrealname(),tbUser.getColstudentno(),RegisteredEnum.REGISTERED.getCode()); return true; /*return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":" + serverProperties.getPortNum() + request.getContextPath() + "/index";*/ @@ -60,8 +63,9 @@ public class RegisterController { @ResponseBody public boolean doCheckStudentNo(@RequestParam(value = "studentno") String studentno){ TbStudentlist studentlist = studentService.findStudentByNo(studentno); - if (studentlist!=null) + if (studentlist!=null) { return true; + } return false; } @@ -70,8 +74,9 @@ public class RegisterController { public boolean doCheckStudent(@RequestParam(value = "studentno") String studentno, @RequestParam(value = "realname") String realname){ TbStudentlist studentlist = studentService.findByColstudentnoAndColrealname(studentno,realname); - if (studentlist!=null) + if (studentlist!=null&&studentlist.getRegistered().equals(RegisteredEnum.REGISTERED.getCode()) ) { return true; + } return false; } @@ -84,8 +89,9 @@ public class RegisterController { @ResponseBody public boolean doUserName(@RequestParam(value = "name") String name){ Optional user = userService.findByColname(name); - if (user.isPresent()) + if (user.isPresent()) { return false; + } return true; } diff --git a/src/main/java/com/fjy/spring/controller/UpLoadController.java b/src/main/java/com/fjy/spring/controller/UpLoadController.java index c05801e..3809589 100644 --- a/src/main/java/com/fjy/spring/controller/UpLoadController.java +++ b/src/main/java/com/fjy/spring/controller/UpLoadController.java @@ -1,13 +1,17 @@ package com.fjy.spring.controller; import com.fjy.spring.constant.GlobalConstant; +import com.fjy.spring.domain.Homework; import com.fjy.spring.domain.TbFile; import com.fjy.spring.domain.TbLog; import com.fjy.spring.domain.TbUser; import com.fjy.spring.properties.ServerProperties; import com.fjy.spring.service.FileService; +import com.fjy.spring.service.HomeworkService; import com.fjy.spring.service.LogService; import com.fjy.spring.untils.FormatFileSizeUtil; +import com.fjy.spring.untils.GetIPAddrUtil; +import com.fjy.spring.untils.LogUtil; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,15 +30,26 @@ import java.util.Date; import java.util.List; import java.util.Map; +import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; + @Controller @Slf4j public class UpLoadController { + /** + * 服务器配置信息 + */ @Autowired - private ServerProperties serverProperties;//服务器配置信息 + private ServerProperties serverProperties; + + /** + * 文件相关数据库操作 + */ + @Autowired + private FileService fileService; @Autowired - private FileService fileService;//文件相关数据库操作 + private HomeworkService homeworkService; @Autowired private LogService logService; @@ -42,16 +57,6 @@ public class UpLoadController { @Resource HttpServletRequest httpServletRequest; - @GetMapping("/toOneUpload") - public String toOneUpload() { - return "oneUpload"; - } - - @GetMapping("/toMoreUpload") - public String toMoreUpload() { - return "moreUpload"; - } - /** * 测试文件上传路径地址 * @@ -81,27 +86,34 @@ public class UpLoadController { String uploadUrl = serverProperties.getFilePath() + "upload/"; String filename = imageFile.getOriginalFilename(); File dir = new File(uploadUrl); - if (!dir.exists()) {//判断目录是否存在,否则自动创建 + //判断目录是否存在,否则自动创建 + if (!dir.exists()) { dir.mkdirs(); } /** * 存储文件信息 */ TbFile file = new TbFile(); - file.setColfilesize(new FormatFileSizeUtil().GetFileSize(imageFile.getSize())); + file.setColfilesize(FormatFileSizeUtil.GetFileSize(imageFile.getSize())); file.setColfilename(filename); file.setColfilepath(uploadUrl + filename); file.setColip(request.getRemoteAddr()); file.setColuserid(user.getColuserid()); - if (fileService.addFile(file)) + if (fileService.addFile(file)) { log.info("记录写入数据库成功"); - //System.out.println("记录写入数据库成功"); - else + + // 记录上传日志 + addVisitLog("上传文件" + file.getColrealname() + " " + file.getColfilename()); + + } + //System.out.println("记录写入数据库成功"); + else { log.error("记录写入数据库失败"); + } //System.out.println("记录写入数据库失败"); log.info("文件上传到: " + uploadUrl + filename); - log.info("文件大小: " + new FormatFileSizeUtil().GetFileSize(imageFile.getSize())); + log.info("文件大小: " + FormatFileSizeUtil.GetFileSize(imageFile.getSize())); log.info("文件名: " + filename); File targetFile = new File(uploadUrl + filename); @@ -135,10 +147,11 @@ public class UpLoadController { * @param request * @return */ - @RequestMapping("/moreUpload") + @RequestMapping("/home/moreUpload") public void moreUpload(HttpServletRequest request, @RequestParam(value = "courseName", required = false) String courseName, @RequestParam(value = "folder", required = false) String folder, + @RequestParam(value = "workid", required = false) Integer workId, @RequestParam(value = "rename", required = true) boolean rename) { MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest) request; @@ -167,13 +180,25 @@ public class UpLoadController { List fileList = new ArrayList(); for (MultipartFile file : files.values()) { + Homework homework = new Homework(); + //管理员上传不需要传workId + if (workId != null) { + homework = homeworkService.findById(workId); + } + String filePrefix = homework.getFilePrefix(); + String fileSuffix = homework.getFileSuffix(); String filename = file.getOriginalFilename(); - String suffix = "." + filename.substring(filename.lastIndexOf(".") + 1);//获取文件后缀 + + //获取文件后缀 + String suffix = "." + filename.substring(filename.lastIndexOf(".") + 1); TbFile tbFile = new TbFile(); String pathname; - if (rename) { - pathname = uploadUrl + user.getColstudentno() + user.getColrealname() + suffix; - tbFile.setColfilename(user.getColstudentno() + user.getColrealname() + suffix); + + + //文件重命名 + if (rename && workId != null) { + pathname = uploadUrl + filePrefix + user.getColstudentno() + user.getColrealname() + fileSuffix + suffix; + tbFile.setColfilename(filePrefix + user.getColstudentno() + user.getColrealname() + fileSuffix + suffix); } else { pathname = uploadUrl + filename; tbFile.setColfilename(filename); @@ -181,55 +206,54 @@ public class UpLoadController { File targetFile = new File(pathname); //若文件已存在则自动重命名 - if (targetFile.exists()){ + if (targetFile.exists()) { String bakpathname; if (rename) { - bakpathname = uploadUrl + "bak/" +user.getColstudentno() + user.getColrealname() + suffix; + bakpathname = uploadUrl + "bak/" + user.getColstudentno() + user.getColrealname() + suffix; } else { - bakpathname = uploadUrl +"bak/"+ filename; + bakpathname = uploadUrl + "bak/" + filename; } - log.info("源文件路径:"+pathname); + log.info("源文件路径:" + pathname); TbFile file1 = fileService.findByFilepath(pathname); - file1.setColfilepath(bakpathname+"."+dateNowStr2+".bak"); - file1.setColfilename(file1.getColfilename()+"."+dateNowStr2+".bak"); - if (fileService.addFile(file1)) + file1.setColfilepath(bakpathname + "." + dateNowStr2 + ".bak"); + file1.setColfilename(file1.getColfilename() + "." + dateNowStr2 + ".bak"); + if (fileService.addFile(file1)) { log.info("重命名文件数据库更新成功"); - else + } else { log.error("重命名文件数据库更新失败"); - File mvfile = new File(bakpathname+"."+dateNowStr2+".bak"); + } + File mvfile = new File(bakpathname + "." + dateNowStr2 + ".bak"); try { FileUtils.moveFile(targetFile, mvfile); - log.info("源文件:"+targetFile.getName()+"已重命名为:"+ mvfile.getName()); + log.info("源文件:" + targetFile.getName() + "已重命名为:" + mvfile.getName()); } catch (IOException e) { e.printStackTrace(); } } log.info("文件上传到: " + uploadUrl + filename); - log.info("文件大小: " + new FormatFileSizeUtil().GetFileSize(file.getSize())); + log.info("文件大小: " + FormatFileSizeUtil.GetFileSize(file.getSize())); log.info("文件名: " + filename); - tbFile.setColfilesize(new FormatFileSizeUtil().GetFileSize(file.getSize())); + tbFile.setColfilesize(FormatFileSizeUtil.GetFileSize(file.getSize())); tbFile.setColtime(dateNowStr); tbFile.setColrealname(filename); - tbFile.setColfilepath(pathname);//文件自动学号+姓名命名 + //文件自动学号+姓名命名 + tbFile.setColfilepath(pathname); tbFile.setColip(request.getRemoteAddr()); tbFile.setColuserid(user.getColuserid()); tbFile.setCourseName(courseName); tbFile.setWorkFolder(folder); - TbLog logs = new TbLog(); - logs.setUserid(user.getColuserid()); - logs.setColtime(dateNowStr); - logs.setColip(httpServletRequest.getRemoteAddr()); - logs.setColheader(user.getColname() + "上传了'" + filename + "'文件"); - logService.addLogRec(logs); - - if (fileService.addFile(tbFile)) + if (fileService.addFile(tbFile)) { log.info("记录写入数据库成功"); - else + + // 记录上传日志 + addVisitLog("上传了" + tbFile.getColrealname() + "->" + tbFile.getColfilename()); + } else { log.error("记录写入数据库失败"); + } if (!targetFile.exists()) { try { @@ -244,13 +268,20 @@ public class UpLoadController { request.getScheme() + "://" + request.getServerName() + ":" + serverProperties.getPortNum() + request.getContextPath() + "/upload/" + file.getOriginalFilename()); - } catch (IllegalStateException e) { - e.printStackTrace(); - } catch (IOException e) { + } catch (Exception e) { e.printStackTrace(); } - } } } + + /** + * 登陆后的访问日志记录 + * @param content + */ + private void addVisitLog(String content) { + TbUser user = (TbUser) httpServletRequest.getSession().getAttribute(USER_SESSION_KEY); + TbLog log = LogUtil.addLog(user, content, httpServletRequest); + logService.addLogRec(log); + } } diff --git a/src/main/java/com/fjy/spring/controller/UpdateController.java b/src/main/java/com/fjy/spring/controller/UpdateController.java index 1641ba5..1126ac1 100644 --- a/src/main/java/com/fjy/spring/controller/UpdateController.java +++ b/src/main/java/com/fjy/spring/controller/UpdateController.java @@ -1,21 +1,30 @@ package com.fjy.spring.controller; +import com.fjy.spring.domain.TbLog; import com.fjy.spring.domain.TbUser; +import com.fjy.spring.domain.VUserinfo; +import com.fjy.spring.enums.RegisteredEnum; import com.fjy.spring.enums.ResultEnum; import com.fjy.spring.exception.UserException; import com.fjy.spring.properties.ServerProperties; +import com.fjy.spring.service.LogService; +import com.fjy.spring.service.StudentService; import com.fjy.spring.service.UserService; import com.fjy.spring.untils.CodingUtil; +import com.fjy.spring.untils.LogUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.ResponseBody; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.math.BigInteger; +import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; + @Controller @Slf4j public class UpdateController { @@ -23,26 +32,46 @@ public class UpdateController { private UserService userService; @Autowired - private ServerProperties serverProperties; + private StudentService studentService; + + @Autowired + private LogService logService; @Resource HttpServletRequest request; @PostMapping(value = "/home/userUpdate") - public String doUserUpdate(TbUser tbUser)throws Exception{ + @ResponseBody + public boolean doUserUpdate(TbUser tbUser)throws Exception{ if (tbUser.getColuserid()==null){ throw new UserException(ResultEnum.ID_NULLPOINT); } - if (tbUser.getColpassword()!=null&&tbUser.getColpassword()!=""){ - //加密用户密码 - tbUser.setColpassword(new BigInteger(CodingUtil.encryptSHA(tbUser.getColpassword().getBytes())).toString(32)); + if (tbUser.getColpassword()!=null){ + userService.updateColpasswordByColname(tbUser.getColpassword(),tbUser.getColname()); } + //注销原本的注册标记 + VUserinfo tempUser = userService.findUserInfo(tbUser.getColuserid()); + studentService.UpdateStudentListRegistered(tempUser.getColrealname(),tempUser.getColstudentno(), + RegisteredEnum.UNREGISTERED.getCode()); if (userService.doRegisterService(tbUser)){ + studentService.UpdateStudentListRegistered(tbUser.getColrealname(),tbUser.getColstudentno(), + RegisteredEnum.REGISTERED.getCode()); log.info(tbUser.getColname()+" 信息更新成功"); - return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":" - + serverProperties.getPortNum() + request.getContextPath() + "/home/user"; + //写入数据库日志 + TbUser user =(TbUser)request.getSession().getAttribute(USER_SESSION_KEY); + TbLog tbLog = LogUtil.addLog(user,tbUser.getColname()+" 信息更新成功",request); + logService.addLogRec(tbLog); + + return true; + /*return "redirect:" + request.getScheme() + "://" + request.getServerName() + ":" + + serverProperties.getPortNum() + request.getContextPath() + "/home/user";*/ // return "login"; } - throw new UserException(ResultEnum.UNKOWN_ERROR); + //写入数据库日志 + TbUser user =(TbUser)request.getSession().getAttribute(USER_SESSION_KEY); + TbLog tbLog = LogUtil.addLog(user,tbUser.getColname()+" 信息更新失败",request); + logService.addLogRec(tbLog); + log.error(tbUser.getColname()+" 信息更新失败"); + return false; } } diff --git a/src/main/java/com/fjy/spring/domain/Homework.java b/src/main/java/com/fjy/spring/domain/Homework.java index 74aa8bc..1b17d61 100644 --- a/src/main/java/com/fjy/spring/domain/Homework.java +++ b/src/main/java/com/fjy/spring/domain/Homework.java @@ -30,4 +30,10 @@ public class Homework { @Column(name = "workremark") private String Remark; + + @Column(name = "pre") + private String filePrefix; + + @Column(name = "suf") + private String fileSuffix; } diff --git a/src/main/java/com/fjy/spring/domain/TbLog.java b/src/main/java/com/fjy/spring/domain/TbLog.java index da6e50d..5f7598f 100644 --- a/src/main/java/com/fjy/spring/domain/TbLog.java +++ b/src/main/java/com/fjy/spring/domain/TbLog.java @@ -20,4 +20,7 @@ public class TbLog { private String colheader; + @Column(name = "requesturl") + private String requestURL; + } diff --git a/src/main/java/com/fjy/spring/domain/TbStudentlist.java b/src/main/java/com/fjy/spring/domain/TbStudentlist.java index 07c53b5..77161d3 100644 --- a/src/main/java/com/fjy/spring/domain/TbStudentlist.java +++ b/src/main/java/com/fjy/spring/domain/TbStudentlist.java @@ -17,4 +17,6 @@ public class TbStudentlist { private String sex; + private Integer registered; + } diff --git a/src/main/java/com/fjy/spring/domain/TbVersion.java b/src/main/java/com/fjy/spring/domain/TbVersion.java new file mode 100644 index 0000000..d90d3b3 --- /dev/null +++ b/src/main/java/com/fjy/spring/domain/TbVersion.java @@ -0,0 +1,27 @@ +package com.fjy.spring.domain; + +import lombok.Data; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +@Data +public class TbVersion { + @Id + @GeneratedValue + private Integer versionid; + + private String date; + + private String content; + + private String version; + + private String user; + + public TbVersion() { + super(); + } +} diff --git a/src/main/java/com/fjy/spring/domain/VAdmin.java b/src/main/java/com/fjy/spring/domain/VAdmin.java new file mode 100644 index 0000000..586558b --- /dev/null +++ b/src/main/java/com/fjy/spring/domain/VAdmin.java @@ -0,0 +1,25 @@ +package com.fjy.spring.domain; + +import lombok.Data; +import org.hibernate.annotations.Immutable; +import org.hibernate.annotations.Subselect; + +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; + +@Entity +@Immutable +@Subselect("SELECT * FROM v_admin") +@Data +public class VAdmin { + @Id + @Column(name = "coluserid") + private Integer userid; + + private Integer adminid; + + private String coltime; + + private String colname; +} diff --git a/src/main/java/com/fjy/spring/enums/RegisteredEnum.java b/src/main/java/com/fjy/spring/enums/RegisteredEnum.java new file mode 100644 index 0000000..665fd4a --- /dev/null +++ b/src/main/java/com/fjy/spring/enums/RegisteredEnum.java @@ -0,0 +1,18 @@ +package com.fjy.spring.enums; + +import lombok.Getter; + +@Getter +public enum RegisteredEnum { + REGISTERED(1,"该用户已注册"), + UNREGISTERED(0,"该用户未注册"), + FORBIDDEN(2,"该用户已被列入黑名单") + ; + private Integer code; + private String msg; + + RegisteredEnum(Integer code, String msg) { + this.code = code; + this.msg = msg; + } +} diff --git a/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java b/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java index 91a9c44..ac5b24b 100644 --- a/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java +++ b/src/main/java/com/fjy/spring/interceptor/AdminInterceptor.java @@ -1,21 +1,42 @@ package com.fjy.spring.interceptor; import com.fjy.spring.constant.GlobalConstant; +import com.fjy.spring.domain.TbAdmin; import com.fjy.spring.domain.TbUser; +import com.fjy.spring.service.AdminService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.BeanFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.web.context.support.WebApplicationContextUtils; import org.springframework.web.servlet.HandlerInterceptor; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.Optional; +@Slf4j public class AdminInterceptor implements HandlerInterceptor { + @Autowired + private AdminService adminService; + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { TbUser user = (TbUser)request.getSession().getAttribute(GlobalConstant.USER_SESSION_KEY); - if (!user.getColname().equals("root")){ - response.sendRedirect("/cms/home"); - return false; + //log.info(user.getColuserid()+""); + //解决service为null无法注入问题 + if (adminService == null) { + BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext()); + adminService = (AdminService) factory.getBean("adminService"); + } + Optional admin = adminService.findAdminById(user.getColuserid()); + + if (!admin.isPresent()){ + response.sendRedirect("/cms/home"); + return false; + }else { + return true; } - return true; } } diff --git a/src/main/java/com/fjy/spring/interceptor/LoginInterceptor.java b/src/main/java/com/fjy/spring/interceptor/LoginInterceptor.java index 80aa6c3..2f9f0fb 100644 --- a/src/main/java/com/fjy/spring/interceptor/LoginInterceptor.java +++ b/src/main/java/com/fjy/spring/interceptor/LoginInterceptor.java @@ -2,7 +2,6 @@ package com.fjy.spring.interceptor; import com.fjy.spring.constant.GlobalConstant; import org.springframework.web.servlet.HandlerInterceptor; -import org.springframework.web.servlet.ModelAndView; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; diff --git a/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java b/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java index 5c000e8..722f8eb 100644 --- a/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java +++ b/src/main/java/com/fjy/spring/interceptor/WebAppConfig.java @@ -2,11 +2,10 @@ package com.fjy.spring.interceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.PathMatchConfigurer; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -/*@Configuration*/ +@Configuration public class WebAppConfig implements WebMvcConfigurer { /** diff --git a/src/main/java/com/fjy/spring/repository/TbAdminRepository.java b/src/main/java/com/fjy/spring/repository/TbAdminRepository.java index fca1ad0..bba61b7 100644 --- a/src/main/java/com/fjy/spring/repository/TbAdminRepository.java +++ b/src/main/java/com/fjy/spring/repository/TbAdminRepository.java @@ -3,6 +3,8 @@ package com.fjy.spring.repository; import com.fjy.spring.domain.TbAdmin; import org.springframework.data.jpa.repository.JpaRepository; -public interface TbAdminRepository extends JpaRepository { +import java.util.Optional; +public interface TbAdminRepository extends JpaRepository { + Optional findByUserid(Integer userid); } diff --git a/src/main/java/com/fjy/spring/repository/TbVersionRepository.java b/src/main/java/com/fjy/spring/repository/TbVersionRepository.java new file mode 100644 index 0000000..e475f25 --- /dev/null +++ b/src/main/java/com/fjy/spring/repository/TbVersionRepository.java @@ -0,0 +1,8 @@ +package com.fjy.spring.repository; + +import com.fjy.spring.domain.TbVersion; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface TbVersionRepository extends JpaRepository { + +} diff --git a/src/main/java/com/fjy/spring/repository/VAdminRepository.java b/src/main/java/com/fjy/spring/repository/VAdminRepository.java new file mode 100644 index 0000000..02976ce --- /dev/null +++ b/src/main/java/com/fjy/spring/repository/VAdminRepository.java @@ -0,0 +1,7 @@ +package com.fjy.spring.repository; + +import com.fjy.spring.domain.VAdmin; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface VAdminRepository extends JpaRepository { +} diff --git a/src/main/java/com/fjy/spring/service/AdminService.java b/src/main/java/com/fjy/spring/service/AdminService.java new file mode 100644 index 0000000..5dc27fc --- /dev/null +++ b/src/main/java/com/fjy/spring/service/AdminService.java @@ -0,0 +1,27 @@ +package com.fjy.spring.service; + +import com.fjy.spring.domain.TbAdmin; +import com.fjy.spring.domain.VAdmin; +import com.fjy.spring.repository.TbAdminRepository; +import com.fjy.spring.repository.VAdminRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.Optional; + +@Service +public class AdminService { + @Autowired + private TbAdminRepository adminRepository; + + @Autowired + private VAdminRepository vAdminRepository; + + public Optional findAdminById(Integer id){ + return adminRepository.findByUserid(id); + } + + public Optional findAdminByUserId(Integer id){ + return vAdminRepository.findById(id); + } +} diff --git a/src/main/java/com/fjy/spring/service/FileService.java b/src/main/java/com/fjy/spring/service/FileService.java index fa7e489..fe30f59 100644 --- a/src/main/java/com/fjy/spring/service/FileService.java +++ b/src/main/java/com/fjy/spring/service/FileService.java @@ -15,15 +15,17 @@ public class FileService { public boolean addFile(TbFile tbFile) { TbFile file = tbFileRepository.save(tbFile); - if (file != null) + if (file != null) { return true; + } return false; } public List findFile(TbFile tbFile){ List files = tbFileRepository.findByColfilename(tbFile.getColfilename()); - if (files!=null) + if (files!=null) { return files; + } return null; } diff --git a/src/main/java/com/fjy/spring/service/HomeworkService.java b/src/main/java/com/fjy/spring/service/HomeworkService.java index 5ac3f42..af4a678 100644 --- a/src/main/java/com/fjy/spring/service/HomeworkService.java +++ b/src/main/java/com/fjy/spring/service/HomeworkService.java @@ -2,13 +2,13 @@ package com.fjy.spring.service; import com.fjy.spring.domain.Homework; import com.fjy.spring.domain.VHomework; -import com.fjy.spring.domain.VWorkDetail; import com.fjy.spring.repository.HomeworkRepository; import com.fjy.spring.repository.VHomeworkRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Optional; @Service public class HomeworkService { @@ -25,4 +25,12 @@ public class HomeworkService { public List findAllVHomework(){ return vHomeworkRepository.findAll(); } + + public Homework findById(Integer id){ + Optional homework = homeworkRepository.findById(id); + if (homework.isPresent()){ + return (Homework)homework.get(); + } + return null; + } } diff --git a/src/main/java/com/fjy/spring/service/NoticeService.java b/src/main/java/com/fjy/spring/service/NoticeService.java index 0b1ac51..79bd719 100644 --- a/src/main/java/com/fjy/spring/service/NoticeService.java +++ b/src/main/java/com/fjy/spring/service/NoticeService.java @@ -17,4 +17,7 @@ public class NoticeService { return noticeRepository.findAll(); } + public TbNotice addOne(TbNotice notice){ + return noticeRepository.save(notice); + } } diff --git a/src/main/java/com/fjy/spring/service/StudentService.java b/src/main/java/com/fjy/spring/service/StudentService.java index 701e342..c4ef454 100644 --- a/src/main/java/com/fjy/spring/service/StudentService.java +++ b/src/main/java/com/fjy/spring/service/StudentService.java @@ -3,6 +3,7 @@ package com.fjy.spring.service; import com.fjy.spring.domain.TbStudent; import com.fjy.spring.domain.TbStudentlist; import com.fjy.spring.domain.TbUser; +import com.fjy.spring.enums.RegisteredEnum; import com.fjy.spring.repository.TbStudentListRepository; import com.fjy.spring.repository.TbStudentRepository; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +27,12 @@ public class StudentService { return tbStudentListRepository.findByColstudentnoAndColrealname(studentno,realname); } + public TbStudentlist UpdateStudentListRegistered(String realname,String studentno,Integer code){ + TbStudentlist studentlist = new TbStudentlist(); + studentlist = findByColstudentnoAndColrealname(studentno,realname); + studentlist.setRegistered(code); + return tbStudentListRepository.save(studentlist); + } } diff --git a/src/main/java/com/fjy/spring/service/UserService.java b/src/main/java/com/fjy/spring/service/UserService.java index 7114ab8..b4960b2 100644 --- a/src/main/java/com/fjy/spring/service/UserService.java +++ b/src/main/java/com/fjy/spring/service/UserService.java @@ -81,8 +81,9 @@ public class UserService { public boolean addUserQue(TbUserque userque) { TbUserque tbUserque = userqueRepository.save(userque); - if (tbUserque != null) + if (tbUserque != null) { return true; + } return false; } diff --git a/src/main/java/com/fjy/spring/service/VersionService.java b/src/main/java/com/fjy/spring/service/VersionService.java new file mode 100644 index 0000000..0289882 --- /dev/null +++ b/src/main/java/com/fjy/spring/service/VersionService.java @@ -0,0 +1,27 @@ +package com.fjy.spring.service; + +import com.fjy.spring.domain.TbVersion; +import com.fjy.spring.repository.TbVersionRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +public class VersionService { + + @Autowired + private TbVersionRepository versionRepository; + + public TbVersion addOneVersion(TbVersion tbVersion){ + return versionRepository.save(tbVersion); + } + + public List addAllVersion(List versions){ + return versionRepository.saveAll(versions); + } + + public List findAll(){ + return versionRepository.findAll(); + } +} diff --git a/src/main/java/com/fjy/spring/untils/GetIPAddrUtil.java b/src/main/java/com/fjy/spring/untils/GetIPAddrUtil.java new file mode 100644 index 0000000..14429fd --- /dev/null +++ b/src/main/java/com/fjy/spring/untils/GetIPAddrUtil.java @@ -0,0 +1,22 @@ +package com.fjy.spring.untils; + +import javax.servlet.http.HttpServletRequest; + +public class GetIPAddrUtil { + public static String getIpAddr(HttpServletRequest request) { + String ip = request.getHeader("X-Real-IP"); + if (ip == null || ip.length() == 0 || " unknown ".equalsIgnoreCase(ip)) { + ip = request.getHeader(" Proxy-Client-IP "); + //System.out.println("【Proxy-Client-IP】"); + } + if (ip == null || ip.length() == 0 || " unknown ".equalsIgnoreCase(ip)) { + ip = request.getHeader(" WL-Proxy-Client-IP "); + //System.out.println("【WL-Proxy-Client-IP】"); + } + if (ip == null || ip.length() == 0 || " unknown ".equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + //System.out.println("【unknown】"); + } + return ip; + } +} diff --git a/src/main/java/com/fjy/spring/untils/LogUtil.java b/src/main/java/com/fjy/spring/untils/LogUtil.java new file mode 100644 index 0000000..d7543d1 --- /dev/null +++ b/src/main/java/com/fjy/spring/untils/LogUtil.java @@ -0,0 +1,47 @@ +package com.fjy.spring.untils; + +import com.fjy.spring.domain.TbLog; +import com.fjy.spring.domain.TbUser; +import com.fjy.spring.service.LogService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; + +import javax.servlet.http.HttpServletRequest; +import java.text.SimpleDateFormat; +import java.util.Date; + +import static com.fjy.spring.constant.GlobalConstant.USER_SESSION_KEY; + +/** + * @author F嘉阳 + * @date 2018-04-26 12:45 + * 日志信息填充工具类 + */ +@Slf4j +public class LogUtil { + + /** + * 写入日志记录 + * @param user + * @param content + */ + public static TbLog addLog(TbUser user,String content,HttpServletRequest request){ + //写入日志信息 + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + String dateNowStr = sdf.format(date); + TbLog tbLog = new TbLog(); + tbLog.setUserid(user.getColuserid()); + tbLog.setColtime(dateNowStr); + tbLog.setColheader(user.getColname()+" "+content); + tbLog.setRequestURL(request.getRequestURL().toString()); + + //解决nginx代理后IP地址获取问题 + tbLog.setColip(GetIPAddrUtil.getIpAddr(request)); + + log.info(tbLog.toString()); + + + return tbLog; + } +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 5f4f096..e702b4a 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -2,6 +2,8 @@ server: servlet: context-path: /cms + session: + timeout: 1440s port: 8080 serverproperties: port_num: 8080 @@ -22,7 +24,12 @@ spring: hibernate: ddl-auto: update show-sql: true + servlet: + multipart: + max-file-size: 100Mb + max-request-size: 100Mb + + #resources: # static-locations: classpath:/templates/ debug: true - diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index e69de29..6fc34e7 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -0,0 +1,39 @@ +#运行环境配置文件 +server: + servlet: + context-path: /cms + session: + timeout: 1440s + port: 8085 + tomcat: + remote-ip-header: x-forwarded-for + protocol-header: x-forwarded-proto + port-header: X-Forwarded-Port + use-forward-headers: true +serverproperties: + port_num: 8085 + filePath: /www/cmsfile/ +spring: + thymeleaf: + prefix: classpath:/templates/ + cache: true + check-template: true + + datasource: + driver-class-name: com.mysql.jdbc.Driver + url: jdbc:mysql://127.0.0.1:3306/db_imis2?useUnicode=true&characterEncoding=utf-8&useSSL=true + username: imis2 + password: 2015imis2 + + servlet: + multipart: + max-file-size: 100Mb + max-request-size: 100Mb + + jpa: + hibernate: + ddl-auto: update + show-sql: false + #resources: + # static-locations: classpath:/templates/ +debug: false \ No newline at end of file diff --git a/src/main/resources/logback-spring.xml b/src/main/resources/logback-spring.xml index 81d90ce..9530fc7 100644 --- a/src/main/resources/logback-spring.xml +++ b/src/main/resources/logback-spring.xml @@ -25,7 +25,8 @@ - F:\JAVA Workspace\Temp\log\info.%d.log + F:\JAVA Workspace\Temp\log\%d\info.%d.log + @@ -43,7 +44,8 @@ - F:\JAVA Workspace\Temp\log\error.%d.log + F:\JAVA Workspace\Temp\log\error.%d.log + diff --git a/src/main/resources/static/css/style.css b/src/main/resources/static/css/style.css index bc079a1..47b3e2c 100644 --- a/src/main/resources/static/css/style.css +++ b/src/main/resources/static/css/style.css @@ -7,6 +7,8 @@ src: url('../fonts/element-icons.ttf'), url('../fonts/element-icons.woff'); /* IE9 */ } +html{height:100%;} +body{min-height:100%;} .loginTitle{ text-align: center; } @@ -55,6 +57,10 @@ a{ width: 50%; } .footer{ + width:100%; + font-size:14px; + bottom:20px; + left:0; text-align: center; } diff --git a/src/main/resources/static/js/admin.js b/src/main/resources/static/js/admin.js index 3819f37..f351bc1 100644 --- a/src/main/resources/static/js/admin.js +++ b/src/main/resources/static/js/admin.js @@ -1,6 +1,9 @@ var Main = { data() { return { + NoticeForm: { + content: '' + }, activeIndex: '1', form: { content: '', @@ -49,7 +52,7 @@ var Main = { .catch(function (error) { console.log(error); }); - axios.get(getRootPath_web()+'/home/findvfeedback') + axios.get(getRootPath_web()+'/home/admin/findvfeedback') .then(function (response) { console.log(response.data); that.feedbackData = response.data; @@ -61,8 +64,27 @@ var Main = { }) }, methods: { + openNotiSuccess(title, content) { + this.$notify({ + title: title, + message: content, + type: 'success' + }); + }, + openNotiError(title, content) { + this.$notify.error({ + title: title, + message: content + }); + }, + openSuccess(content) { + this.$message({ + message: content, + type: 'success' + }); + }, uploadURL(row) { - return getRootPath_web()+"/moreUpload?rename=false"; + return getRootPath_web()+"/home/moreUpload?rename=false"; }, submitUpload() { this.$refs.upload.submit(); @@ -81,6 +103,50 @@ var Main = { }, onSubmit() { console.log('submit!'); + },submitForm(formName) { + this.$refs[formName].validate((valid) => { + let that = this; + if (valid) { + axios({ + url: getRootPath_web()+'/home/admin/addNotice', + method: 'post', + data: { + content: this.$refs.content.value + }, + transformRequest: [function (data) { + // Do whatever you want to transform the data + let ret = '' + for (let it in data) { + ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&' + } + return ret + }], + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }).then(function (response) { + console.log(response.data); + if (response.data===true){ + //that.$refs[formName].submit; + //return true; + that.openNotiSuccess("成功", "发布成功!") + }else if (response.data===false){ + that.openNotiError("失败", "发布失败!"); + }else { + that.openNotiError("错误", response.data.message); + } + }).catch(function (error) { + console.log(error); + that.openNotiError("错误", "服务器错误!"); + }); + //console.log(this.$refs.content.value) + //this.$options.methods.openNotiSuccess.bind(this)(); + //alert('submit!'); + } else { + console.log('error submit!!'); + return false; + } + }); } } } diff --git a/src/main/resources/static/js/common.js b/src/main/resources/static/js/common.js index 440d04a..d966012 100644 --- a/src/main/resources/static/js/common.js +++ b/src/main/resources/static/js/common.js @@ -10,3 +10,23 @@ function getRootPath_web() { var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1); return (localhostPaht + projectName); } +function compareTime(startTime,endTime) { + var startTimes = startTime.substring(0, 10).split('-'); + var endTimes = endTime.substring(0, 10).split('-'); + startTime = startTimes[1] + '-' + startTimes[2] + '-' + startTimes[0] + ' ' + startTime.substring(10, 19); + endTime = endTimes[1] + '-' + endTimes[2] + '-' + endTimes[0] + ' ' + endTime.substring(10, 19); + var thisResult = (Date.parse(endTime) - Date.parse(startTime)) / 3600 / 1000; + if (thisResult < 0) { + console.log("endTime小于tartTime!"); + return false; + } else if (thisResult > 0) { + console.log("endTime大于tartTime!"); + return true; + } else if (thisResult == 0) { + console.log("endTime等于tartTime!"); + return false; + } else { + return '异常'; + } + +} diff --git a/src/main/resources/static/js/home.js b/src/main/resources/static/js/home.js index 6888970..c713ba0 100644 --- a/src/main/resources/static/js/home.js +++ b/src/main/resources/static/js/home.js @@ -328,8 +328,14 @@ var Main = { }); }, uploadURL(row) { - return "http://localhost:8080/cms/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder; - }, + console.log(row.worktime); + if (compareTime(cur,row.worktime)){ + document.getElementById("btn-group").style.display=""; + return "http://localhost:8080/cms/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder; + }else{ + document.getElementById("btn-show").style.display=""; + } + }, limitTime(row) { return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur); }, diff --git a/src/main/resources/static/js/homePage.js b/src/main/resources/static/js/homepage.js similarity index 52% rename from src/main/resources/static/js/homePage.js rename to src/main/resources/static/js/homepage.js index a988c7f..d490a1f 100644 --- a/src/main/resources/static/js/homePage.js +++ b/src/main/resources/static/js/homepage.js @@ -5,13 +5,22 @@ var year = dt.getFullYear(); var cur = year + '-' + month + '-' + day; function DateDiff(sDate1, sDate2) { //sDate1和sDate2是2002-12-18格式 - var aDate, oDate1, oDate2, iDays - aDate = sDate1.split("-") - oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式 - aDate = sDate2.split("-") - oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) - iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数 - return iDays + let aDate, oDate1, oDate2, iDays; + if (compareTime(sDate1, sDate2)) { + return "已截止"; + } + else { + aDate = sDate1.split("-"); + oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]); //转换为12-18-2002格式 + aDate = sDate2.split("-"); + oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]); + iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24); //把相差的毫秒数转换为天数 + return iDays + } +} + +function displayStyle(id, type) { + document.getElementById(id).style.display = type; } var Main = { @@ -65,6 +74,7 @@ var Main = { colrealname: '', colemail: '' }, + iShow: true, rules2: { colpassword: [ {required: true, validator: validatePass, trigger: 'blur'} @@ -93,7 +103,7 @@ var Main = { activeName: 'login', fileList: [], DownloadList: [], - NoticeList:[ + NoticeList: [ { noticeid: 1, adminid: 1, @@ -107,216 +117,12 @@ var Main = { issueTime: "2018-2-26 11:13" } ], - VersionList:[ + VersionList: [ { - date:'2018-02-24', - content:'实现对重复文件自动重命名', - version:'V1.11', - user:'F嘉阳' - }, - { - date:'2018-02-24', - content:'实现对文件是否重命名的控制,目前设定为管理员上传的文件不会重命名,完善日志输出存储', - version:'V1.10', - user:'F嘉阳' - }, - { - date:'2018-02-24', - content:'添加运行日志处理,频率为每天对error和info级别的日志进行文件保存,实现判断注册用户名是否已存在', - version:'V1.9.1', - user:'F嘉阳' - }, - { - date:'2018-02-24', - content:'实现前端对学号和用户名的异步判断,核心技术为axios', - version:'V1.9', - user:'F嘉阳' - }, - { - date:'2018-02-24', - content:'修复注册表单输入正确不会显示反馈图标的问题', - version:'V1.8.2', - user:'F嘉阳' - }, - { - date:'2018-02-24', - content:'修复文件批量下载的错误,为压缩文件进行统一管理,批量下载不支持多线程', - version:'V1.8.1', - user:'F嘉阳' - }, - { - date:'2018-02-24', - content:'实现文件批量下载', - version:'V1.8', - user:'F嘉阳' - }, - { - date:'2018-02-23', - content:'实现对未交作业人员的查询和展示', - version:'V1.7', - user:'F嘉阳' - }, - { - date:'2018-02-23', - content:'去除js对绝对地址的依赖,为日志添加排序选项', - version:'V1.6.1', - user:'F嘉阳' - }, - { - date:'2018-02-23', - content:'实现用户仅能查看自己提交的文件', - version:'V1.6', - user:'F嘉阳' - }, - { - date:'2018-02-23', - content:'修复用户信息修改页面数据绑定方式,改为使用axios进行数据获取和绑定', - version:'V1.5', - user:'F嘉阳' - }, - { - date:'2018-02-22', - content:'实现后台对未交作业人员的查询', - version:'V1.4', - user:'F嘉阳' - }, - { - date:'2018-02-22', - content:'实现用户信息修改', - version:'V1.3.1', - user:'F嘉阳' - }, - { - date:'2018-02-21', - content:'实现用户信息修改页面session传值', - version:'V1.3', - user:'F嘉阳' - }, - { - date:'2018-02-09', - content:'实现用户管理和作业管理数据读取', - version:'V1.2.1', - user:'F嘉阳' - }, - { - date:'2018-02-09', - content:'实现单文件删除', - version:'V1.2', - user:'F嘉阳' - }, - { - date:'2018-02-08', - content:'完成课程管理数据读取,修复页面加载css,js错误', - version:'V1.1.2', - user:'F嘉阳' - }, - { - date:'2018-02-08', - content:'完成管理员主页的数据读取', - version:'V1.1.1', - user:'F嘉阳' - }, - { - date:'2018-02-08', - content:'完成前端界面设计', - version:'V1.0', - user:'F嘉阳' - }, - { - date:'2018-02-08', - content:'实现表单异步提交并显示消息', - version:'V0.15', - user:'F嘉阳' - }, - { - date:'2018-02-07', - content:'实现作业上传自动创建文件夹', - version:'V0.14', - user:'F嘉阳' - }, - { - date:'2018-02-07', - content:'实现作业获取和展示', - version:'V0.13', - user:'F嘉阳' - }, - { - date:'2018-02-06', - content:'完成前端上传页面设计', - version:'V0.12', - user:'F嘉阳' - }, - { - date:'2018-02-06', - content:'实现登录日志记录', - version:'V0.11', - user:'F嘉阳' - }, - { - date:'2018-02-05', - content:'提高加密安全性', - version:'V0.10.1', - user:'F嘉阳' - }, - { - date:'2018-02-05', - content:'实现用户密码SHA加密', - version:'V0.10', - user:'F嘉阳' - }, - { - date:'2018-02-05', - content:'实现登录拦截器', - version:'V0.9', - user:'F嘉阳' - }, - { - date:'2018-02-05', - content:'实现注册功能', - version:'V0.8', - user:'F嘉阳' - }, - { - date:'2018-02-05', - content:'实现json数据绑定', - version:'V0.7', - user:'F嘉阳' - }, - { - date:'2018-02-04', - content:'实现多文件上传,按钮vue传值(vue2.1特性)', - version:'V0.6', - user:'F嘉阳' - }, - { - date:'2018-02-04', - content:'实现Element组件+单文件上传', - version:'V0.5', - user:'F嘉阳' - }, - { - date:'2018-02-04', - content:'使用thymeleaf模板引擎,引入frame框架和公用css和js文件', - version:'V0.4', - user:'F嘉阳' - }, - { - date:'2018-02-03', - content:'实现文件上传和数据库记录、Element+vue登录注册UI', - version:'V0.3', - user:'F嘉阳' - }, - { - date:'2018-01-30', - content:'实现登录,编写错误码,实现错误码返回json', - version:'V0.2', - user:'F嘉阳' - }, - { - date:'2018-01-30', - content:'实现数据库查询用户,获取密码,编写了单元测试类', - version:'V0.1', - user:'F嘉阳' + date: '2018-01-30', + content: '实现数据库查询用户,获取密码,编写了单元测试类', + version: 'V0.1', + user: 'F嘉阳' } ], tableHomeworkData: [ @@ -367,16 +173,12 @@ var Main = { }, mounted() { this.$nextTick(() => { - var that = this; - axios.get(getRootPath_web()+'/download/findone') - .then(function (response) { - console.log(response.data); - that.DownloadList = response.data; - }) - .catch(function (error) { - console.log(error); - }); - axios.get(getRootPath_web()+'/home/findAllHomework') + let that = this; + /*setInterval(function(){ + that.getFileList(); + },1000);*/ + this.getFileList(); + axios.get(getRootPath_web() + '/home/findAllHomework') .then(function (response) { console.log(response.data); that.tableHomeworkData = response.data; @@ -385,7 +187,7 @@ var Main = { .catch(function (error) { console.log(error); }); - axios.get(getRootPath_web()+'/home/findAllNotice') + axios.get(getRootPath_web() + '/home/findAllNotice') .then(function (response) { console.log(response.data); that.NoticeList = response.data; @@ -394,9 +196,30 @@ var Main = { .catch(function (error) { console.log(error); }); + axios.get(getRootPath_web() + '/home/findallversion') + .then(function (response) { + console.log(response.data); + that.VersionList = response.data; + //that.limitTime = response.data; + }) + .catch(function (error) { + console.log(error); + }); }) }, methods: { + getFileList() { + let that = this; + axios.get(getRootPath_web() + '/home/download/findone') + .then(function (response) { + //console.log(response.data); + that.DownloadList = response.data; + }) + .catch(function (error) { + console.log(error); + that.openNotiError("失败", "获取文件列表失败!"); + }); + }, openNotiSuccess(title, content) { this.$notify({ title: title, @@ -404,6 +227,12 @@ var Main = { type: 'success' }); }, + openNotiError(title, content) { + this.$notify.error({ + title: title, + message: content + }); + }, openSuccess(content) { this.$message({ message: content, @@ -411,16 +240,18 @@ var Main = { }); }, uploadURL(row) { - return getRootPath_web()+"/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder+"&rename=true"; + return getRootPath_web() + "/home/moreUpload?courseName=" + row.coursename + "&folder=" + row.workfolder + "&workid=" + row.workid + "&rename=true"; + }, limitTime(row) { return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur); }, submitForm(formName, url) { this.$refs[formName].validate((valid) => { + let that = this; if (valid) { axios({ - url: getRootPath_web()+'/' + url, + url: getRootPath_web() + '/' + url, method: 'post', data: { content: this.$refs.content.value @@ -436,9 +267,22 @@ var Main = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } - }) - console.log(this.$refs.content.value) - this.openNotiSuccess("成功", "反馈成功!") + }).then(function (response) { + console.log(response.data); + if (response.data === true) { + //that.$refs[formName].submit; + //return true; + that.openNotiSuccess("成功", "反馈成功!") + } else if (response.data === false) { + that.openNotiError("失败", "反馈失败!"); + } else { + that.openNotiError("错误", response.data.message); + } + }).catch(function (error) { + console.log(error); + that.openNotiError("错误", "服务器错误!"); + }); + //console.log(this.$refs.content.value) //this.$options.methods.openNotiSuccess.bind(this)(); //alert('submit!'); } else { @@ -454,21 +298,27 @@ var Main = { console.log(row.colfileid); }, submitUpload() { + let that = this; this.$refs.upload.submit(); + this.openNotiSuccess("成功", "文件上传成功!"); + setTimeout(function () { + that.getFileList(); + }, 1000); }, handleRemove(file, fileList) { console.log(file, fileList); }, ClickToJump(targe) { - window.location.href = getRootPath_web()+"/" + targe; + window.location.href = getRootPath_web() + "/" + targe; }, handleDownload(row) { /*var url = window.location.protocol+"://"+window.location.host+":"+window.location.port+"/"*/ - window.open(getRootPath_web()+"/download/dodownload?fileId=" + row.colfileid); + window.open(getRootPath_web() + "/home/download/dodownload?fileId=" + row.colfileid); }, handleDelete(row) { + let that = this; axios({ - url: getRootPath_web()+'/home/filedelete', + url: getRootPath_web() + '/home/filedelete', method: 'post', data: { fileid: row.colfileid @@ -484,11 +334,64 @@ var Main = { headers: { 'Content-Type': 'application/x-www-form-urlencoded' } + }).then(function (response) { + console.log(response.data); + if (response.data === true) { + //that.$refs[formName].submit; + //return true; + that.openNotiSuccess("成功", "删除成功!"); + that.getFileList(); + } else if (response.data === false) { + that.openNotiError("失败", "删除失败!"); + } else { + that.openNotiError("错误", response.data.message); + } + }).catch(function (error) { + console.log(error); + that.openNotiError("错误", "服务器错误!"); }); - this.openNotiSuccess("成功", "删除成功!"); }, - handlePreview(file) { - console.log(file); + isShow(row) { + let that = this; + // console.log(row.worktime + "||" + row.workid); + if (compareTime(cur, row.worktime)) { + console.log("true"); + return true; + //提交时间合法 + //document.getElementById("btn-group").style.display=""; + //displayStyle("btn-show"+row.workid,"none"); + //displayStyle("btn-group"+row.workid,""); + } else { + console.log("false"); + return false; + //提交时间不合法 + //displayStyle("btn-show"+row.workid,""); + //displayStyle("btn-group"+row.workid,"none"); + //displayStyle("btn-show"); + //document.getElementById("btn-show").style.display=""; + } + }, + handlePreview(row) { + console.log(row); + /* let that = this; + console.log(row.worktime+"||"+row.workid); + if (compareTime(cur,row.worktime)){ + that.isShow = true; + console.log("Show"+that.isShow); + //提交时间合法 + //document.getElementById("btn-group").style.display=""; + //displayStyle("btn-show"+row.workid,"none"); + //displayStyle("btn-group"+row.workid,""); + } + if (!compareTime(cur,row.worktime)){ + that.isShow = false; + console.log("EShow"+that.isShow); + //提交时间不合法 + //displayStyle("btn-show"+row.workid,""); + //displayStyle("btn-group"+row.workid,"none"); + //displayStyle("btn-show"); + //document.getElementById("btn-show").style.display=""; + }*/ }, handleExceed(files, fileList) { this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`); diff --git a/src/main/resources/static/js/homework.js b/src/main/resources/static/js/homework.js index 97c60d1..4d3ce4b 100644 --- a/src/main/resources/static/js/homework.js +++ b/src/main/resources/static/js/homework.js @@ -51,21 +51,13 @@ var Main = { .catch(function (error) { console.log(error); }); - axios.get(getRootPath_web()+'/home/findallvhomework') - .then(function (response) { - console.log(response.data); - that.homeworkData = response.data; - }) - .catch(function (error) { - console.log(error); - }); }) }, methods: { findUncommitStudent(row){ var that = this; this.dialogTableVisible = true; - axios.get(getRootPath_web()+'/home/findStudentInCourseFile', + axios.get(getRootPath_web()+'/home/admin/findStudentInCourseFile', { params: { Folder: row.folder, @@ -111,7 +103,7 @@ var Main = { }, handleDownload(row) { /*var url = window.location.protocol+"://"+window.location.host+":"+window.location.port+"/"*/ - window.open(getRootPath_web()+"/download/downloadzip?courseName=" + window.open(getRootPath_web()+"/home/admin/download/downloadzip?courseName=" + row.courseName+"&Folder="+row.folder); }, handleSelect(key, keyPath) { diff --git a/src/main/resources/static/js/LoginStyle.js b/src/main/resources/static/js/loginstyle.js similarity index 95% rename from src/main/resources/static/js/LoginStyle.js rename to src/main/resources/static/js/loginstyle.js index 704a8aa..e53dde3 100644 --- a/src/main/resources/static/js/LoginStyle.js +++ b/src/main/resources/static/js/loginstyle.js @@ -64,8 +64,25 @@ var Main = { var checkName1 = (rule, value, callback) => { if (!value) { return callback(new Error('用户名不能为空')); - } else { - callback() + }else { + //判断用户名是否已存在 + axios.get(getRootPath_web() + '/beforeLoginCheckNameExist', { + params: { + name: value + } + }) + .then(function (response) { + console.log(response.data); + if (response.data === true) { + callback() + } else { + return callback(new Error('用户名未注册')); + } + }) + .catch(function (error) { + console.log(error); + that.errorNotify(error.message); + }); } }; var checkNo = (rule, value, callback) => { @@ -106,7 +123,7 @@ var Main = { .then(function (response) { console.log(response.data); if (response.data === false) { - return callback(new Error('姓名与学号不匹配')); + return callback(new Error('姓名与学号不匹配或该用户已注册')); } else { callback() } diff --git a/src/main/resources/static/js/managecourse.js b/src/main/resources/static/js/managecourse.js index be07062..e2d6eb3 100644 --- a/src/main/resources/static/js/managecourse.js +++ b/src/main/resources/static/js/managecourse.js @@ -18,7 +18,12 @@ var Main = { teacherrealname: "root" } ], - multipleSelection: [] + multipleSelection: [], + courseList:[ + {courseName:"root"}, + {courseName:"root2"}, + ], + teacherList:[], } }, mounted() { diff --git a/src/main/resources/static/js/manageuser.js b/src/main/resources/static/js/manageuser.js index 4217f44..73b93d5 100644 --- a/src/main/resources/static/js/manageuser.js +++ b/src/main/resources/static/js/manageuser.js @@ -18,7 +18,7 @@ var Main = { mounted() { this.$nextTick(() => { var that = this; - axios.get(getRootPath_web()+'/home/findalluser') + axios.get(getRootPath_web()+'/home/admin/findalluser') .then(function (response) { console.log(response.data); that.userData = response.data; diff --git a/src/main/resources/static/js/user.js b/src/main/resources/static/js/user.js index ad8dc7c..385d20f 100644 --- a/src/main/resources/static/js/user.js +++ b/src/main/resources/static/js/user.js @@ -1,53 +1,112 @@ var dt = new Date(); let th = this; -var month = dt.getMonth()+1; +/*let username = this.ruleForm2.colname.value;*/ +var month = dt.getMonth() + 1; var day = dt.getDate(); var year = dt.getFullYear(); var cur = year + '-' + month + '-' + day; -function DateDiff(sDate1, sDate2){ //sDate1和sDate2是2002-12-18格式 - var aDate, oDate1, oDate2, iDays - aDate = sDate1.split("-") - oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式 - aDate = sDate2.split("-") - oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) - iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24) //把相差的毫秒数转换为天数 - return iDays + +function DateDiff(sDate1, sDate2) { //sDate1和sDate2是2002-12-18格式 + var aDate, oDate1, oDate2, iDays + aDate = sDate1.split("-") + oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) //转换为12-18-2002格式 + aDate = sDate2.split("-") + oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0]) + iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 / 24) //把相差的毫秒数转换为天数 + return iDays } + var Main = { data() { var checkQuestion = (rule, value, callback) => { if (!value) { return callback(new Error('问题不能为空')); - }else { + } else { callback() } }; var checkAnswer = (rule, value, callback) => { if (!value) { return callback(new Error('答案不能为空')); - }else { + } else { callback() } }; var checkName = (rule, value, callback) => { + let that = this; if (!value) { return callback(new Error('用户名不能为空')); - }else { - callback() + } else { + //判断用户名是否已存在 + axios.get(getRootPath_web() + '/CheckUserName', { + params: { + name: value + } + }) + .then(function (response) { + console.log(response.data); + if (response.data === true) { + callback(); + } else if (value !== that.ruleForm2.colname) { + return callback(new Error('用户名已存在')); + } else { + callback(); + } + }) + .catch(function (error) { + console.log(error); + that.errorNotify(error.message); + }); } }; var checkNo = (rule, value, callback) => { if (!value) { return callback(new Error('学号不能为空')); - }else { - callback() + } else { + //判断是否为指定班级的合法用户 + axios.get(getRootPath_web() + '/CheckStudentNo', { + params: { + studentno: value + } + }) + .then(function (response) { + console.log(response.data); + if (response.data === true) { + callback() + } else { + return callback(new Error('学号非法')); + } + }) + .catch(function (error) { + console.log(error); + this.errorNotify(error.message); + }); } }; var checkRealName = (rule, value, callback) => { + let that = this; if (!value) { return callback(new Error('真实姓名不能为空')); - }else { - callback() + } else { + //判断用户名与学号是否匹配 + axios.get(getRootPath_web() + '/CheckStudent', { + params: { + realname: value, + studentno: this.ruleForm2.colstudentno + } + }) + .then(function (response) { + console.log(response.data); + if (response.data === false && value !== that.ruleForm2.colrealname) { + return callback(new Error('姓名与学号不匹配或该用户已注册')); + } else { + callback() + } + }) + .catch(function (error) { + console.log(error); + this.errorNotify(error.message); + }); } }; var validatePass = (rule, value, callback) => { @@ -72,7 +131,7 @@ var Main = { return { activeIndex: '2', ruleForm2: { - coluserid:'', + coluserid: '', colname: '', colstudentno: '', colrealname: '', @@ -81,24 +140,24 @@ var Main = { checkPass: '', }, ruleForm3: { - coluserid:'', + coluserid: '', question: '', answer: '' }, rules3: { question: [ - {required: true,validator: checkQuestion, trigger: 'blur'} + {required: true, validator: checkQuestion, trigger: 'blur'} ], answer: [ - {required: true,validator: checkAnswer, trigger: 'blur'} + {required: true, validator: checkAnswer, trigger: 'blur'} ] }, rules2: { colpassword: [ - {required: true,validator: validatePass, trigger: 'blur'} + {required: true, validator: validatePass, trigger: 'blur'} ], checkPass: [ - {required: true,validator: validatePass2, trigger: 'blur'} + {required: true, validator: validatePass2, trigger: 'blur'} ], colstudentno: [ { @@ -115,7 +174,7 @@ var Main = { } ], colname: [ - {required: true,validator: checkName, trigger: 'blur'} + {required: true, validator: checkName, trigger: 'blur'} ], }, tableHomeworkData: [ @@ -140,9 +199,29 @@ var Main = { workfolder: "第一次作业" } ], + NoticeList: [ + { + noticeid: 1, + adminid: 1, + noticeContent: "系统正式上线,Alpha测试版", + issueTime: "2018-2-26 11:00" + }, + { + noticeid: 2, + adminid: 1, + noticeContent: "系统,测试", + issueTime: "2018-2-26 11:13" + } + ] } }, methods: { + errorNotify(content) { + this.$notify.error({ + title: '错误', + message: content + }) + }, openNotiSuccess(title, content) { this.$notify({ title: title, @@ -156,25 +235,18 @@ var Main = { message: content }); }, - limitTime(row){ - return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur); + limitTime(row) { + return DateDiff(row.worktime.replace(/([^\s]+)\s.*/, "$1"), cur); }, submitForm(formName, url) { this.$refs[formName].validate((valid) => { var that = this; - var params = new URLSearchParams(); - params.append('userid', '55'); //你要传给后台的参数值 key/value - params.append('question', th.ruleForm3.question.value); - params.append('answer', th.ruleForm3.answer.value); - if (valid) {//此处暂时去除校验 + if (valid) { axios({ - url: getRootPath_web()+'/' + url, + url: getRootPath_web() + '/home/userUpdate', method: 'post', - data: { - userid:th.ruleForm3.userid.value, - question:th.ruleForm3.question.value, - answer:th.ruleForm3.answer.value - }, + data: that.ruleForm2 + , transformRequest: [function (data) { // Do whatever you want to transform the data let ret = '' @@ -188,11 +260,59 @@ var Main = { } }).then(function (response) { console.log(response.data); - if (response.data===true){ - that.openNotiSuccess("成功", "修改成功!"); - }else if (response.data===false){ + if (response.data === true) { + that.openNotiSuccess("成功", "修改成功,刷新页面即可查看新信息!"); + } else if (response.data === false) { that.openNotiError("失败", "修改失败!"); - }else { + } else { + that.openNotiError("错误", response.data.message); + } + }).catch(function (error) { + console.log(error); + that.openNotiError("错误", "服务器错误!"); + }); + //console.log(this.$refs.content.value) + //this.openNotiSuccess("成功", "修改成功!") + //this.$options.methods.openNotiSuccess.bind(this)(); + //alert('submit!'); + } else { + console.log('error submit!!'); + that.openNotiError("错误", "表单填写错误!"); + return false; + } + }); + }, + clickToSubmit(formName) { + this.$refs[formName].validate((valid) => { + var that = this; + if (valid) { + axios({ + url: getRootPath_web() + '/beforeLogin', + method: 'post', + data: { + colname: outSideThis.ruleForm1.colname.value, + colpassword: outSideThis.ruleForm1.colpassword.value + }, + transformRequest: [function (data) { + // Do whatever you want to transform the data + let ret = ''; + for (let it in data) { + ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&' + } + return ret + }], + headers: { + 'Content-Type': 'application/x-www-form-urlencoded' + } + }).then(function (response) { + console.log(response.data); + if (response.data === true) { + //that.$refs[formName].submit; + //return true; + document.getElementById('ruleForm1').submit(); + } else if (response.data === false) { + that.openNotiError("失败", response.data.message); + } else { that.openNotiError("错误", response.data.message); } }).catch(function (error) { @@ -217,7 +337,7 @@ var Main = { console.log(tab, event); }, ClickToJump(targe) { - window.location.href = getRootPath_web()+"/" + targe; + window.location.href = getRootPath_web() + "/" + targe; }, handleSelect(key, keyPath) { console.log(key, keyPath); @@ -229,13 +349,34 @@ var Main = { mounted() { this.$nextTick(() => { var that = this; - axios.get(getRootPath_web()+'/home/userinfo') + axios.get(getRootPath_web() + '/home/userinfo') .then(function (response) { - console.log(response.data); + //console.log(response.data); that.ruleForm2 = response.data; }) .catch(function (error) { - console.log(error); + //console.log(error); + that.openNotiError("错误", response.data.message); + }); + axios.get(getRootPath_web() + '/home/findAllHomework') + .then(function (response) { + console.log(response.data); + that.tableHomeworkData = response.data; + //that.limitTime = response.data; + }) + .catch(function (error) { + //console.log(error); + that.openNotiError("错误", response.data.message); + }); + axios.get(getRootPath_web() + '/home/findAllNotice') + .then(function (response) { + console.log(response.data); + that.NoticeList = response.data; + //that.limitTime = response.data; + }) + .catch(function (error) { + //console.log(error); + that.openNotiError("错误", response.data.message); }); }) } diff --git a/src/main/resources/templates/dist/axiosTest.html b/src/main/resources/templates/dist/axiosTest.html new file mode 100644 index 0000000..baad7fd --- /dev/null +++ b/src/main/resources/templates/dist/axiosTest.html @@ -0,0 +1,23 @@ + + + + + axios + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/dist/thymeleaf/common_foot.html b/src/main/resources/templates/dist/thymeleaf/common_foot.html new file mode 100644 index 0000000..77cbbc9 --- /dev/null +++ b/src/main/resources/templates/dist/thymeleaf/common_foot.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/dist/thymeleaf/common_head.html b/src/main/resources/templates/dist/thymeleaf/common_head.html new file mode 100644 index 0000000..9bfa9a2 --- /dev/null +++ b/src/main/resources/templates/dist/thymeleaf/common_head.html @@ -0,0 +1,21 @@ + + + + + + + + + + + +
+ + + + + + +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/dist/thymeleaf/footer.html b/src/main/resources/templates/dist/thymeleaf/footer.html new file mode 100644 index 0000000..a62d5f1 --- /dev/null +++ b/src/main/resources/templates/dist/thymeleaf/footer.html @@ -0,0 +1,9 @@ + + + +
+ © 2016 xxx +
+ + \ No newline at end of file diff --git a/src/main/resources/templates/dist/thymeleaf/layout.html b/src/main/resources/templates/dist/thymeleaf/layout.html new file mode 100644 index 0000000..b49d581 --- /dev/null +++ b/src/main/resources/templates/dist/thymeleaf/layout.html @@ -0,0 +1,117 @@ + + + + + + 首页 + 个人中心 + 关于 + 意见反馈 + 登出 + + + + + + +
默认颜色
+ + + + + + 选项1 + 选项2 + + + 选项3 + + + + 选项1 + + + + + 导航二 + + + + 导航三 + + +
+
+
+ + +
+ + 用户名
+ +
+
+ 首页
+ 个人中心
+ 关于
+ 意见反馈 +
+
+ + +
+ 管理员
+ 管理员号 +
+
+ 后台主页 +
+ 课程管理 +
+ 作业管理 +
+ 用户管理 +
+
+ + +
+ 作业提交倒计时 + + +
+
+ + + + + + + +
+
+ + +
+ 公告 +
+
+ {{notice.noticeContent + notice.issueTime}} +
+
+ + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/dist/thymeleafTest.html b/src/main/resources/templates/dist/thymeleafTest.html new file mode 100644 index 0000000..5f36c72 --- /dev/null +++ b/src/main/resources/templates/dist/thymeleafTest.html @@ -0,0 +1,18 @@ + + + + + +
+
+ +
+
+
+
+ + + + + \ No newline at end of file diff --git a/src/main/resources/templates/home/about.html b/src/main/resources/templates/home/about.html index 2ccf26b..107e4d2 100644 --- a/src/main/resources/templates/home/about.html +++ b/src/main/resources/templates/home/about.html @@ -32,6 +32,7 @@
  • 具备完整开发和维护文档,提供错误码、数据字典
  • URL为RESTful API风格,便于开发和维护
  • 异常统一管理
  • +
  • 更多