实现用户管理和作业管理数据读取

This commit is contained in:
F嘉阳
2018-02-09 16:23:43 +08:00
parent c66b0bd9ae
commit 4335a6764e
13 changed files with 254 additions and 264 deletions

View File

@@ -1,15 +1,9 @@
package com.fjy.spring.controller; package com.fjy.spring.controller;
import com.fjy.spring.domain.VCourse; import com.fjy.spring.domain.*;
import com.fjy.spring.domain.VFeedBack;
import com.fjy.spring.domain.VLog;
import com.fjy.spring.domain.VWorkDetail;
import com.fjy.spring.enums.ResultEnum; import com.fjy.spring.enums.ResultEnum;
import com.fjy.spring.exception.UserException; import com.fjy.spring.exception.UserException;
import com.fjy.spring.service.CourseService; import com.fjy.spring.service.*;
import com.fjy.spring.service.FeedBackService;
import com.fjy.spring.service.LogService;
import com.fjy.spring.service.WorkDetailService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@@ -31,6 +25,12 @@ public class DataController {
@Autowired @Autowired
private CourseService courseService; private CourseService courseService;
@Autowired
private UserService userService;
@Autowired
private HomeworkService homeworkService;
@GetMapping("/home/findAllHomework") @GetMapping("/home/findAllHomework")
public List<VWorkDetail> findAllHomework(){ public List<VWorkDetail> findAllHomework(){
List<VWorkDetail> homeworks = workDetailService.findAll(); List<VWorkDetail> homeworks = workDetailService.findAll();
@@ -70,4 +70,24 @@ public class DataController {
new UserException(ResultEnum.EMPTY_DATA); new UserException(ResultEnum.EMPTY_DATA);
return null; return null;
} }
@GetMapping("/home/findalluser")
public List<TbUser> findAllUser(){
List<TbUser> users = userService.findAllUser();
if (users!=null){
return users;
}
new UserException(ResultEnum.EMPTY_DATA);
return null;
}
@GetMapping("/home/findallvhomework")
public List<VHomework> findAllVHomework(){
List<VHomework> vHomeworks = homeworkService.findAllVHomework();
if (vHomeworks!=null){
return vHomeworks;
}
new UserException(ResultEnum.EMPTY_DATA);
return null;
}
} }

View File

@@ -0,0 +1,89 @@
package com.fjy.spring.domain;
import org.hibernate.annotations.Immutable;
import org.hibernate.annotations.Subselect;
import javax.persistence.*;
@Entity
@Immutable
@Subselect("SELECT * FROM v_homework")
public class VHomework {
@Id
@Column(name = "workid")
private Integer Id;
@Column(name = "workname")
private String Name;
@Column(name = "worktime")
private String Time;
@Column(name = "colfileid")
private Integer fileid;
@Column(name = "workfolder")
private String Folder;
@Column(name = "coursename")
private String courseName;
@Column(name = "workremark")
private String Remark;
public Integer getId() {
return Id;
}
public void setId(Integer id) {
Id = id;
}
public String getName() {
return Name;
}
public void setName(String name) {
Name = name;
}
public String getTime() {
return Time;
}
public void setTime(String time) {
Time = time;
}
public Integer getFileid() {
return fileid;
}
public void setFileid(Integer fileid) {
this.fileid = fileid;
}
public String getFolder() {
return Folder;
}
public void setFolder(String folder) {
Folder = folder;
}
public String getCourseName() {
return courseName;
}
public void setCourseName(String courseName) {
this.courseName = courseName;
}
public String getRemark() {
return Remark;
}
public void setRemark(String remark) {
Remark = remark;
}
}

View File

@@ -7,7 +7,7 @@ import javax.persistence.*;
@Entity @Entity
@Immutable @Immutable
@Subselect("SELECT *FROM v_log LIMIT 0, 20") @Subselect("SELECT * FROM v_log ORDER BY coltime LIMIT 0, 20")
public class VLog { public class VLog {
@Id @Id
private Integer logid; private Integer logid;

View File

@@ -0,0 +1,8 @@
package com.fjy.spring.repository;
import com.fjy.spring.domain.VHomework;
import org.springframework.data.jpa.repository.JpaRepository;
public interface VHomeworkRepository extends JpaRepository<VHomework,Integer> {
}

View File

@@ -1,8 +1,10 @@
package com.fjy.spring.service; package com.fjy.spring.service;
import com.fjy.spring.domain.Homework; import com.fjy.spring.domain.Homework;
import com.fjy.spring.domain.VHomework;
import com.fjy.spring.domain.VWorkDetail; import com.fjy.spring.domain.VWorkDetail;
import com.fjy.spring.repository.HomeworkRepository; import com.fjy.spring.repository.HomeworkRepository;
import com.fjy.spring.repository.VHomeworkRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@@ -13,7 +15,14 @@ public class HomeworkService {
@Autowired @Autowired
private HomeworkRepository homeworkRepository; private HomeworkRepository homeworkRepository;
@Autowired
private VHomeworkRepository vHomeworkRepository;
public List<Homework> findAll(){ public List<Homework> findAll(){
return homeworkRepository.findAll(); return homeworkRepository.findAll();
} }
public List<VHomework> findAllVHomework(){
return vHomeworkRepository.findAll();
}
} }

View File

@@ -7,6 +7,8 @@ import com.fjy.spring.repository.TbUserRepository;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
public class UserService { public class UserService {
@@ -37,4 +39,8 @@ public class UserService {
} }
return false; return false;
} }
public List<TbUser> findAllUser(){
return tbUserRepository.findAll();
}
} }

View File

@@ -1,30 +1,12 @@
/* function getRootPath_web() {
/!* //获取当前网址,如: http://localhost:8083/uimcardprj/share/meun.jsp
* the first time to call var curWwwPath = window.document.location.href;
*!/ //获取主机地址之后的目录,如: uimcardprj/share/meun.jsp
setTimeout(function () { var pathName = window.document.location.pathname;
Push(); var pos = curWwwPath.indexOf(pathName);
// alert("setTimeout called"); //获取主机地址,如: http://localhost:8083
}, 200); var localhostPaht = curWwwPath.substring(0, pos);
//获取带"/"的项目名,如:/uimcardprj
setInterval(function () { var projectName = pathName.substring(0, pathName.substr(1).indexOf('/') + 1);
Push(); return (localhostPaht + projectName);
//alert("setInterval called");
}, 3000);
//con.showMsg('登录成功');
function Push() {
$.ajax({
type: "POST",
url: "../CheckLoginServlet?dt=" + new Date().getTime(),//why getTime and wont use
data: {},
beforeSend: function () {
},
success: function (data) {
var obj = eval("(" + data + ")");//eval使用前要先加括号才能得到完整的json数据
if (obj.msg != 0) {
con.showMsg(obj.msg);
} }
}
})
};*/

View File

@@ -6,45 +6,33 @@ var Main = {
user: '', user: '',
region: '' region: ''
}, },
tableData3: [{ homeworkData: [
id:'1', {
date: '2016-05-03', fileid: 56,
name: '王小虎', courseName: "信息安全",
address: '上海市普陀区金沙江路 1518 弄' name: "实验报告",
}, { id: 1,
id:'2', time: "2018-02-06 20:44:08.0",
date: '2016-05-02', remark: "3000字以上",
name: '王小虎', folder: "第一次作业"
address: '上海市普陀区金沙江路 1518 弄' }
}, { ],
id:'3',
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'4',
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'5',
date: '2016-05-08',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'6',
date: '2016-05-06',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'7',
date: '2016-05-07',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
multipleSelection: [] multipleSelection: []
} }
}, },
mounted() {
this.$nextTick(() => {
var that = this;
axios.get('http://localhost:8080/cms/home/findallvhomework')
.then(function (response) {
console.log(response.data);
that.homeworkData = response.data;
})
.catch(function (error) {
console.log(error);
});
})
},
methods: { methods: {
togglePost(url){ togglePost(url){
axios({ axios({

View File

@@ -2,45 +2,41 @@ var Main = {
data() { data() {
return { return {
activeIndex: '1', activeIndex: '1',
tableData3: [{ userData: [
id:'1', {
date: '2016-05-03', coluserid: 53,
name: '王小虎', colname: "FFFF",
address: '上海市普陀区金沙江路 1518 弄' colpassword: "330399941720950163549766122324520082468573044291",
}, { colemail: "123@gmail.com",
id:'2', colstudentno: "123456",
date: '2016-05-02', colrealname: "ENMM"
name: '王小虎', }
address: '上海市普陀区金沙江路 1518 弄' ],
}, {
id:'3',
date: '2016-05-04',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'4',
date: '2016-05-01',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'5',
date: '2016-05-08',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'6',
date: '2016-05-06',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}, {
id:'7',
date: '2016-05-07',
name: '王小虎',
address: '上海市普陀区金沙江路 1518 弄'
}],
multipleSelection: [] multipleSelection: []
} }
}, },
mounted() {
this.$nextTick(() => {
var that = this;
axios.get('http://localhost:8080/cms/home/findalluser')
.then(function (response) {
console.log(response.data);
that.userData = response.data;
})
.catch(function (error) {
console.log(error);
});
/*axios.get('http://localhost:8080/cms/home/findvfeedback')
.then(function (response) {
console.log(response.data);
that.feedbackData = response.data;
//that.limitTime = response.data;
})
.catch(function (error) {
console.log(error);
});*/
})
},
methods: { methods: {
togglePost(url){ togglePost(url){
/*axios({ /*axios({

View File

@@ -16,21 +16,7 @@
<el-card th:include="dist/thymeleaf/layout :: userbox"></el-card> <el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
</el-row> </el-row>
<el-row> <el-row>
<el-card class="box-card"> <el-card th:include="dist/thymeleaf/layout :: adminbox"></el-card>
<div slot="header" class="clearfix">
<span>管理员</span><br>
<span>管理员号</span>
</div>
<div class="item">
<el-button type="text" @click="ClickToJump('admin')">后台主页</el-button>
<br>
<el-button type="text" @click="ClickToJump('managecourse')">课程管理</el-button>
<br>
<el-button type="text" @click="ClickToJump('homework')">作业管理</el-button>
<br>
<el-button type="text" @click="ClickToJump('manageuser')">用户管理</el-button>
</div>
</el-card>
</el-row> </el-row>
</el-col> </el-col>
<el-col :md="13" :lg="13" :xl="13" :sm="18" :xs="23" :offset="1"> <el-col :md="13" :lg="13" :xl="13" :sm="18" :xs="23" :offset="1">

View File

@@ -1,65 +1,23 @@
<!DOCTYPE html> <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html lang="en"> <html xmlns="http://www.w3.org/1999/xhtml"
<head> xmlns:th="http://www.thymeleaf.org">
<meta charset="UTF-8"> <head th:include="dist/thymeleaf/common_head :: header('课程管理')">
<title>作业管理</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!--<link rel="stylesheet" href="https://unpkg.com/element-ui@2.1.0/lib/theme-chalk/display.css">-->
<link rel="stylesheet" href="../../static/css/style.css">
</head> </head>
<body> <body>
<!-- 先引入 Vue --> <div th:insert="~{dist/thymeleaf/common_head :: #body_js}"></div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app"> <div id="app">
<el-container> <el-container>
<el-container> <el-container>
<el-header> <el-header th:include="dist/thymeleaf/layout :: header"></el-header>
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
<el-menu-item index="1">首页</el-menu-item>
<el-submenu index="2">
<template slot="title">个人中心</template>
<el-menu-item index="2-1">选项1</el-menu-item>
<el-menu-item index="2-2">选项2</el-menu-item>
<el-menu-item index="2-3">选项3</el-menu-item>
</el-submenu>
<el-menu-item index="3" @click="ClickToJump('about')">关于</el-menu-item>
<el-menu-item index="4" @click="ClickToJump('feedback')">意见反馈</el-menu-item>
<el-menu-item index="5"><a href="login.jsp">登出</a></el-menu-item>
</el-menu>
</el-header>
<el-main> <el-main>
<el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down"> <el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down">
<el-row><el-card class="box-card"> <el-row>
<div slot="header" class="clearfix"> <el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
<span>用户名</span><br>
<span>学号</span>
</div>
<div class="item">
<el-button type="text" @click="ClickToJump('home')">首页</el-button><br>
<el-button type="text" @click="ClickToJump('user')">个人中心</el-button><br>
<el-button type="text" @click="ClickToJump('about')">关于</el-button><br>
<el-button type="text" @click="ClickToJump('feedback')">意见反馈</el-button>
</div>
</el-card>
</el-row> </el-row>
<el-row> <el-row>
<el-card class="box-card"> <el-card th:include="dist/thymeleaf/layout :: adminbox"></el-card>
<div slot="header" class="clearfix"> </el-row>
<span>管理员</span><br>
<span>管理员号</span>
</div>
<div class="item">
<el-button type="text" @click="ClickToJump('home')">用户管理</el-button><br>
<el-button type="text" @click="ClickToJump('user')">课程/老师管理</el-button><br>
<el-button type="text" @click="ClickToJump('about')">作业管理</el-button><br>
<el-button type="text" @click="ClickToJump('feedback')">公告/日志</el-button>
</div>
</el-card></el-row>
</el-col> </el-col>
<el-col :md="12" :lg="12" :xl="12" :sm="16" :xs="23" :offset="1"> <el-col :md="12" :lg="12" :xl="12" :sm="16" :xs="23" :offset="1">
<el-row> <el-row>
@@ -69,16 +27,19 @@
<el-button @click="toggleSelection()">取消选择</el-button> <el-button @click="toggleSelection()">取消选择</el-button>
<el-button @click="togglePost()" type="danger" plain>删除作业</el-button> <el-button @click="togglePost()" type="danger" plain>删除作业</el-button>
</div> </div>
<el-table ref="multipleTable" :data="tableData3" <el-table ref="multipleTable" :data="homeworkData"
tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange"> tooltip-effect="dark" style="width: 100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" prop='id' width="55"> <el-table-column type="selection" prop='fileid'>
</el-table-column> </el-table-column>
<el-table-column label="日期" width="120"> <el-table-column prop="courseName" label="课程名">
<template slot-scope="scope">{{ scope.row.date }}</template>
</el-table-column> </el-table-column>
<el-table-column prop="name" label="姓名" width="120"> <el-table-column prop="name" label="作业名">
</el-table-column> </el-table-column>
<el-table-column prop="address" label="地址" show-overflow-tooltip> <el-table-column prop="time" label="日期">
</el-table-column>
<el-table-column prop="remark" label="要求">
</el-table-column>
<el-table-column prop="folder" label="子文件夹" show-overflow-tooltip>
</el-table-column> </el-table-column>
</el-table> </el-table>
</template></el-row> </template></el-row>
@@ -123,7 +84,7 @@
</el-container> </el-container>
</el-container> </el-container>
</div> </div>
<script src="../../static/js/homework.js"></script> <script th:src="@{/js/homework.js}"></script>
<script src="../../static/js/common.js"></script> <script th:src="@{/js/common.js}"></script>
</body> </body>
</html> </html>

View File

@@ -16,18 +16,8 @@
<el-card th:include="dist/thymeleaf/layout :: userbox"></el-card> <el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
</el-row> </el-row>
<el-row> <el-row>
<el-card class="box-card"> <el-card th:include="dist/thymeleaf/layout :: adminbox"></el-card>
<div slot="header" class="clearfix"> </el-row>
<span>管理员</span><br>
<span>管理员号</span>
</div>
<div class="item">
<el-button type="text" @click="ClickToJump('home')">用户管理</el-button><br>
<el-button type="text" @click="ClickToJump('user')">课程/老师管理</el-button><br>
<el-button type="text" @click="ClickToJump('about')">作业管理</el-button><br>
<el-button type="text" @click="ClickToJump('feedback')">公告/日志</el-button>
</div>
</el-card></el-row>
</el-col> </el-col>
<el-col :md="12" :lg="12" :xl="12" :sm="16" :xs="23" :offset="1"> <el-col :md="12" :lg="12" :xl="12" :sm="16" :xs="23" :offset="1">
<el-row> <el-row>

View File

@@ -1,85 +1,43 @@
<!DOCTYPE html> <!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-4.dtd">
<html lang="en"> <html xmlns="http://www.w3.org/1999/xhtml"
<head> xmlns:th="http://www.thymeleaf.org">
<meta charset="UTF-8"> <head th:include="dist/thymeleaf/common_head :: header('用户管理')">
<title>用户管理</title>
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!--<link rel="stylesheet" href="https://unpkg.com/element-ui@2.1.0/lib/theme-chalk/display.css">-->
<link rel="stylesheet" href="../../static/css/style.css">
</head> </head>
<body> <body>
<!-- 先引入 Vue --> <div th:insert="~{dist/thymeleaf/common_head :: #body_js}"></div>
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<div id="app"> <div id="app">
<el-container> <el-container>
<el-container> <el-container>
<el-header> <el-header th:include="dist/thymeleaf/layout :: header"></el-header>
<el-menu :default-active="activeIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
<el-menu-item index="1">首页</el-menu-item>
<el-submenu index="2">
<template slot="title">个人中心</template>
<el-menu-item index="2-1">选项1</el-menu-item>
<el-menu-item index="2-2">选项2</el-menu-item>
<el-menu-item index="2-3">选项3</el-menu-item>
</el-submenu>
<el-menu-item index="3" @click="ClickToJump('about')">关于</el-menu-item>
<el-menu-item index="4" @click="ClickToJump('feedback')">意见反馈</el-menu-item>
<el-menu-item index="5"><a href="login.jsp">登出</a></el-menu-item>
</el-menu>
</el-header>
<el-main> <el-main>
<el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down"> <el-col :md="4" :lg="4" :xl="4" class="hidden-sm-and-down">
<el-row><el-card class="box-card"> <el-row>
<div slot="header" class="clearfix"> <el-card th:include="dist/thymeleaf/layout :: userbox"></el-card>
<span>用户名</span><br>
<span>学号</span>
</div>
<div class="item">
<el-button type="text" @click="ClickToJump('home')">首页</el-button><br>
<el-button type="text" @click="ClickToJump('user')">个人中心</el-button><br>
<el-button type="text" @click="ClickToJump('about')">关于</el-button><br>
<el-button type="text" @click="ClickToJump('feedback')">意见反馈</el-button>
</div>
</el-card>
</el-row> </el-row>
<el-row> <el-row>
<el-card class="box-card"> <el-card th:include="dist/thymeleaf/layout :: adminbox"></el-card>
<div slot="header" class="clearfix"> </el-row>
<span>管理员</span><br>
<span>管理员号</span>
</div>
<div class="item">
<el-button type="text" @click="ClickToJump('home')">用户管理</el-button><br>
<el-button type="text" @click="ClickToJump('user')">课程/老师管理</el-button><br>
<el-button type="text" @click="ClickToJump('about')">作业管理</el-button><br>
<el-button type="text" @click="ClickToJump('feedback')">公告/日志</el-button>
</div>
</el-card></el-row>
</el-col> </el-col>
<el-col :md="12" :lg="12" :xl="12" :sm="16" :xs="23" :offset="1"> <el-col :md="12" :lg="12" :xl="12" :sm="16" :xs="23" :offset="1">
<template> <template>
<div style="margin-bottom: 20px"> <div style="margin-bottom: 20px">
<el-button @click="toggleSelection([tableData3[1], tableData3[2]])">切换第二、第三行的选中状态</el-button>
<el-button @click="toggleSelection()">取消选择</el-button> <el-button @click="toggleSelection()">取消选择</el-button>
<el-button @click="togglePost()" type="primary" plain>设为老师</el-button> <el-button @click="togglePost()" type="primary" plain>设为老师</el-button>
<el-button @click="togglePost()" type="warning" plain>设为管理员</el-button> <el-button @click="togglePost()" type="warning" plain>设为管理员</el-button>
<el-button @click="togglePost()" type="danger" plain>删除用户</el-button> <el-button @click="togglePost()" type="danger" plain>删除用户</el-button>
</div> </div>
<el-table ref="multipleTable" :data="tableData3" @selection-change="handleSelectionChange" <el-table ref="multipleTable" :data="userData" @selection-change="handleSelectionChange"
tooltip-effect="dark" style="width: 100%" > tooltip-effect="dark" style="width: 100%" >
<el-table-column type="selection" prop='id' width="55"> <el-table-column type="selection" prop='coluserid'>
</el-table-column> </el-table-column>
<el-table-column label="日期" width="120"> <el-table-column prop="colname" label="用户名">
<template slot-scope="scope">{{ scope.row.date }}</template>
</el-table-column> </el-table-column>
<el-table-column prop="name" label="姓名" width="120"> <el-table-column label="邮箱">
<template slot-scope="scope">{{ scope.row.colemail }}</template>
</el-table-column> </el-table-column>
<el-table-column prop="address" label="地址" show-overflow-tooltip> <el-table-column prop="colstudentno" label="学号" show-overflow-tooltip>
</el-table-column>
<el-table-column prop="colrealname" label="姓名">
</el-table-column> </el-table-column>
</el-table> </el-table>
</template> </template>
@@ -88,14 +46,11 @@
</el-col> </el-col>
</el-main> </el-main>
<el-footer> <el-footer th:include="dist/thymeleaf/layout :: footer"></el-footer>
<div class="footer">
© 2018 作业提交系统
</div></el-footer>
</el-container> </el-container>
</el-container> </el-container>
</div> </div>
<script src="../../static/js/manageuser.js"></script> <script th:src="@{/js/manageuser.js}"></script>
<script src="../../static/js/common.js"></script> <script th:src="@{/js/common.js}"></script>
</body> </body>
</html> </html>