Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
御承扬
Campus
提交
95c31177
C
Campus
项目概览
御承扬
/
Campus
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Campus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
95c31177
编写于
1月 18, 2021
作者:
7
7wc98#14
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
commit
上级
45b2e501
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
77 addition
and
117 deletion
+77
-117
src/main/java/com/pyc/campus/controller/WebController.java
src/main/java/com/pyc/campus/controller/WebController.java
+41
-0
src/main/java/com/pyc/campus/dao/GradeRepository.java
src/main/java/com/pyc/campus/dao/GradeRepository.java
+19
-0
src/main/resources/templates/page/BrowserQuestion.html
src/main/resources/templates/page/BrowserQuestion.html
+1
-39
src/main/resources/templates/page/QueryGrade.html
src/main/resources/templates/page/QueryGrade.html
+15
-39
src/main/resources/templates/page/UpQuestion.html
src/main/resources/templates/page/UpQuestion.html
+1
-39
未找到文件。
src/main/java/com/pyc/campus/controller/WebController.java
浏览文件 @
95c31177
...
...
@@ -17,6 +17,7 @@ import org.springframework.security.core.context.SecurityContextImpl;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.ui.ModelMap
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
...
@@ -44,6 +45,38 @@ public class WebController {
this
.
friendListRepository
=
friendListRepository
;
}
@RequestMapping
(
"/desc"
)
public
String
desc
(
Model
model
,
HttpSession
session
){
SecurityContextImpl
securityContext
=
(
SecurityContextImpl
)
session
.
getAttribute
(
"SPRING_SECURITY_CONTEXT"
);
String
currentStudentId
=
((
UserDetails
)
securityContext
.
getAuthentication
().
getPrincipal
()).
getUsername
();
List
<
Grade
>
gradeListDesc
=
gradeRepository
.
findAllByStudentIDOrderByGradeDesc
(
currentStudentId
);
int
minGrade
=
gradeRepository
.
findMinGrade
(
currentStudentId
);
int
maxGrade
=
gradeRepository
.
findMaxGrade
(
currentStudentId
);
int
sumCredit
=
gradeRepository
.
findSumCredit
(
currentStudentId
);
float
avgGPA
=
gradeRepository
.
findAvgGPA
(
currentStudentId
);
model
.
addAttribute
(
"minGrade"
,
minGrade
);
model
.
addAttribute
(
"maxGrade"
,
maxGrade
);
model
.
addAttribute
(
"sumCredit"
,
sumCredit
);
model
.
addAttribute
(
"avgGPA"
,
avgGPA
);
model
.
addAttribute
(
"gradeItems"
,
gradeListDesc
);
return
"page/QueryGrade"
;
}
@RequestMapping
(
"/asc"
)
public
String
asc
(
Model
model
,
HttpSession
session
){
SecurityContextImpl
securityContext
=
(
SecurityContextImpl
)
session
.
getAttribute
(
"SPRING_SECURITY_CONTEXT"
);
String
currentStudentId
=
((
UserDetails
)
securityContext
.
getAuthentication
().
getPrincipal
()).
getUsername
();
List
<
Grade
>
gradeListAsc
=
gradeRepository
.
findAllByStudentIDOrderByGradeAsc
(
currentStudentId
);
int
minGrade
=
gradeRepository
.
findMinGrade
(
currentStudentId
);
int
maxGrade
=
gradeRepository
.
findMaxGrade
(
currentStudentId
);
int
sumCredit
=
gradeRepository
.
findSumCredit
(
currentStudentId
);
float
avgGPA
=
gradeRepository
.
findAvgGPA
(
currentStudentId
);
model
.
addAttribute
(
"minGrade"
,
minGrade
);
model
.
addAttribute
(
"maxGrade"
,
maxGrade
);
model
.
addAttribute
(
"sumCredit"
,
sumCredit
);
model
.
addAttribute
(
"avgGPA"
,
avgGPA
);
model
.
addAttribute
(
"gradeItems"
,
gradeListAsc
);
return
"page/QueryGrade"
;
}
@RequestMapping
(
"/home"
)
public
String
home
(
Model
model
,
HttpSession
session
){
SecurityContextImpl
securityContext
=
(
SecurityContextImpl
)
session
.
getAttribute
(
"SPRING_SECURITY_CONTEXT"
);
...
...
@@ -463,6 +496,14 @@ public class WebController {
SecurityContextImpl
securityContext
=
(
SecurityContextImpl
)
session
.
getAttribute
(
"SPRING_SECURITY_CONTEXT"
);
String
currentStudentId
=
((
UserDetails
)
securityContext
.
getAuthentication
().
getPrincipal
()).
getUsername
();
List
<
Grade
>
gradeList
=
gradeRepository
.
findAllByStudentID
(
currentStudentId
);
int
minGrade
=
gradeRepository
.
findMinGrade
(
currentStudentId
);
int
maxGrade
=
gradeRepository
.
findMaxGrade
(
currentStudentId
);
int
sumCredit
=
gradeRepository
.
findSumCredit
(
currentStudentId
);
float
avgGPA
=
gradeRepository
.
findAvgGPA
(
currentStudentId
);
model
.
addAttribute
(
"minGrade"
,
minGrade
);
model
.
addAttribute
(
"maxGrade"
,
maxGrade
);
model
.
addAttribute
(
"sumCredit"
,
sumCredit
);
model
.
addAttribute
(
"avgGPA"
,
avgGPA
);
model
.
addAttribute
(
"gradeItems"
,
gradeList
);
return
"page/QueryGrade"
;
}
...
...
src/main/java/com/pyc/campus/dao/GradeRepository.java
浏览文件 @
95c31177
...
...
@@ -10,6 +10,7 @@ package com.pyc.campus.dao;
import
com.pyc.campus.domain.Grade
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.data.rest.core.annotation.RestResource
;
...
...
@@ -20,4 +21,22 @@ public interface GradeRepository extends JpaRepository<Grade, Long> {
List
<
Grade
>
findAllByStudentID
(
String
studentId
);
@RestResource
(
path
=
"findAllByName"
,
rel
=
"findAllByName"
)
List
<
Grade
>
findAllByName
(
@Param
(
"name"
)
String
name
);
// 按成绩降序排列
//@Query("select Grade from Grade g where g.studentID=?1 order by g.grade desc ")
List
<
Grade
>
findAllByStudentIDOrderByGradeDesc
(
String
stuID
);
//按成绩升序排列
List
<
Grade
>
findAllByStudentIDOrderByGradeAsc
(
String
stuID
);
// 查找最低成绩
@Query
(
"select min(g.grade) from Grade g where g.studentID=?1"
)
int
findMinGrade
(
String
stuID
);
// 查找最高成绩
@Query
(
"select max(g.grade) from Grade g where g.studentID=?1"
)
int
findMaxGrade
(
String
stuID
);
// 查找总学分
@Query
(
"select sum(g.credit) from Grade g where g.studentID=?1"
)
int
findSumCredit
(
String
stuID
);
// 查找总平均绩点
@Query
(
"select avg(g.gpa) from Grade g where g.studentID=?1"
)
float
findAvgGPA
(
String
stuID
);
}
src/main/resources/templates/page/BrowserQuestion.html
浏览文件 @
95c31177
...
...
@@ -67,45 +67,7 @@
</div>
<!-- 页面的头部 -->
<!-- 页面的导航 -->
<nav
class=
"navbar navbar-inverse"
>
<div
class=
"container-fluid"
>
<div
class=
"navbar-header"
>
<button
type=
"button"
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
"#myNavbar"
>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"/home"
>
Campus
</a>
</div>
<div
class=
"collapse navbar-collapse"
id=
"myNavbar"
>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"/home"
>
Home
</a></li>
<li
class=
"dropdown"
>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"/aboutLearn"
>
学习中心
<span
class=
"caret"
></span>
</a>
<ul
class=
"dropdown-menu"
>
<li><a
href=
"/learn"
>
编程学习
</a></li>
<li><a
href=
"/toEnglish"
>
英语
</a></li>
<li><a
href=
"/toMath"
>
数学
</a></li>
<li
class=
"divider"
></li>
<li><a
href=
"/toPhilosophy"
>
哲学
</a></li>
</ul>
</li>
<li><a
href=
"/news"
>
校内新闻
</a></li>
<li
class=
"active"
sec:authorize=
"hasRole('ROLE_USER')"
><a
href=
"/userCenter"
style=
"color: green"
>
用户中心
</a></li>
<li
sec:authorize=
"hasRole('ROLE_ADMIN')"
><a
href=
"/admin"
>
网站管理
</a></li>
<li
class=
"active"
sec:authorize=
"hasRole('ROLE_ADMIN')"
><a
href=
"/userCenter"
style=
"color: red"
>
用户中心
</a></li>
<li><a
href=
"/toHelp"
>
帮助中心
</a>
</li>
</ul>
</div>
</div>
</nav>
<!--页面主体-->
<div
class=
"container"
style=
"margin-bottom: 10%;margin-top: 5%"
>
<div
class=
"row"
>
<div
class=
"col-sm-4"
>
...
...
src/main/resources/templates/page/QueryGrade.html
浏览文件 @
95c31177
...
...
@@ -71,45 +71,7 @@
</div>
<!-- 页面的头部 -->
<!-- 页面的导航 -->
<nav
class=
"navbar navbar-inverse"
>
<div
class=
"container-fluid"
>
<div
class=
"navbar-header"
>
<button
type=
"button"
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
"#myNavbar"
>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"/home"
>
Campus
</a>
</div>
<div
class=
"collapse navbar-collapse"
id=
"myNavbar"
>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"/home"
>
Home
</a></li>
<li
class=
"dropdown"
>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"/aboutLearn"
>
学习中心
<span
class=
"caret"
></span>
</a>
<ul
class=
"dropdown-menu"
>
<li><a
href=
"/learn"
>
编程学习
</a></li>
<li><a
href=
"/toEnglish"
>
英语
</a></li>
<li><a
href=
"/toMath"
>
数学
</a></li>
<li
class=
"divider"
></li>
<li><a
href=
"/toPhilosophy"
>
哲学
</a></li>
</ul>
</li>
<li><a
href=
"/news"
>
校内新闻
</a></li>
<li
class=
"active"
sec:authorize=
"hasRole('ROLE_USER')"
><a
href=
"/userCenter"
style=
"color: green"
>
用户中心
</a></li>
<li
sec:authorize=
"hasRole('ROLE_ADMIN')"
><a
href=
"/admin"
>
网站管理
</a></li>
<li
class=
"active"
sec:authorize=
"hasRole('ROLE_ADMIN')"
><a
href=
"/userCenter"
style=
"color: red"
>
用户中心
</a></li>
<li><a
href=
"/toHelp"
>
帮助中心
</a>
</li>
</ul>
</div>
</div>
</nav>
<!--页面主体-->
<div
class=
"container"
style=
"margin-bottom: 10%;margin-top: 5%"
>
<div
class=
"row"
>
<div
class=
"col-sm-4"
>
...
...
@@ -160,6 +122,20 @@
</tbody>
</table>
</div>
<br>
<h3>
当前最低课程成绩:
<b
th:text=
"${minGrade}"
></b>
,最高成绩:
<b
th:text=
"${maxGrade}"
></b>
,
已获得学分:
<b
th:text=
"${sumCredit}"
></b>
,总平均绩点:
<b
th:text=
"${avgGPA}"
></b>
</h3>
<br>
<div
class=
"form-inline"
>
<div
class=
"form-group"
>
<button
class=
"btn btn-primary"
onclick=
"window.location.href='/desc'"
>
按成绩降序排列
</button>
</div>
<div
class=
"form-group"
>
<button
class=
"btn btn-primary"
onclick=
"window.location.href='/asc'"
>
按成绩升序排列
</button>
</div>
</div>
</div>
</div>
</div>
...
...
src/main/resources/templates/page/UpQuestion.html
浏览文件 @
95c31177
...
...
@@ -75,45 +75,7 @@
</div>
<!-- 页面的头部 -->
<!-- 页面的导航 -->
<nav
class=
"navbar navbar-inverse"
>
<div
class=
"container-fluid"
>
<div
class=
"navbar-header"
>
<button
type=
"button"
class=
"navbar-toggle"
data-toggle=
"collapse"
data-target=
"#myNavbar"
>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
<span
class=
"icon-bar"
></span>
</button>
<a
class=
"navbar-brand"
href=
"/home"
>
Campus
</a>
</div>
<div
class=
"collapse navbar-collapse"
id=
"myNavbar"
>
<ul
class=
"nav navbar-nav"
>
<li><a
href=
"/home"
>
Home
</a></li>
<li
class=
"dropdown"
>
<a
class=
"dropdown-toggle"
data-toggle=
"dropdown"
href=
"/aboutLearn"
>
学习中心
<span
class=
"caret"
></span>
</a>
<ul
class=
"dropdown-menu"
>
<li><a
href=
"/learn"
>
编程学习
</a></li>
<li><a
href=
"/toEnglish"
>
英语
</a></li>
<li><a
href=
"/toMath"
>
数学
</a></li>
<li
class=
"divider"
></li>
<li><a
href=
"/toPhilosophy"
>
哲学
</a></li>
</ul>
</li>
<li><a
href=
"/news"
>
校内新闻
</a></li>
<li
class=
"active"
sec:authorize=
"hasRole('ROLE_USER')"
><a
href=
"/userCenter"
style=
"color: green"
>
用户中心
</a></li>
<li
sec:authorize=
"hasRole('ROLE_ADMIN')"
><a
href=
"/admin"
>
网站管理
</a></li>
<li
class=
"active"
sec:authorize=
"hasRole('ROLE_ADMIN')"
><a
href=
"/userCenter"
style=
"color: red"
>
用户中心
</a></li>
<li><a
href=
"/toHelp"
>
帮助中心
</a>
</li>
</ul>
</div>
</div>
</nav>
<!--页面主体-->
<div
class=
"container"
style=
"margin-bottom: 10%;margin-top: 5%"
>
<div
class=
"row"
>
<div
class=
"col-sm-4"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录