2023.6.25

1. 答辩完成
This commit is contained in:
KaiyuanOSG 2023-06-26 12:35:35 +08:00
parent c28867e3e4
commit 60040d341c
28 changed files with 229 additions and 58 deletions

View File

@ -57,6 +57,13 @@ public class ExperimentFactory {
e.printStackTrace();
log.error("解析实验申请用户失败");
}
try {
experiment.setAnnex(jsonObject.getString("annex"));
} catch (Exception e) {
e.printStackTrace();
log.error("解析实验申请附件失败");
}
return experiment;
}
}

View File

@ -23,7 +23,7 @@ import java.util.UUID;
@RestController
@CrossOrigin
public class FileController {
private final Path fileStorageLocation = Paths.get("/Users/springforest/Downloads/软件实训/");
private final Path fileStorageLocation = Paths.get("/Users/springforest/Downloads/软件实训/uploads/");
@PostMapping("/upload")
public ResVo uploadFile(@RequestParam("file") MultipartFile file) {
@ -51,7 +51,6 @@ public class FileController {
ex.printStackTrace();
return ResVo.error("文件上传失败");
}
}
@GetMapping("/download/{fileName}")

View File

@ -3,6 +3,7 @@ package com.sdut.labex.controller;
import com.alibaba.fastjson.JSONObject;
import com.sdut.labex.Factory.UserFactory;
import com.sdut.labex.entity.User;
import com.sdut.labex.service.LogService;
import com.sdut.labex.service.UserService;
import com.sdut.labex.utils.ResVo;
import com.sdut.labex.utils.UserHolder;
@ -22,6 +23,8 @@ import javax.annotation.Resource;
public class UserController {
@Resource
private UserService userService;
@Resource
private LogService logService;
@PostMapping("/login")
public ResVo login(@RequestBody JSONObject jsonObject) {
@ -63,4 +66,9 @@ public class UserController {
User user = UserFactory.createUser(jsonObject);
return userService.add(user);
}
@GetMapping("/log/{pageNum}/{pageSize}")
public ResVo getLog(@PathVariable("pageNum") int pageNum, @PathVariable("pageSize") int pageSize) {
return logService.getLog(pageNum, pageSize);
}
}

View File

@ -19,7 +19,7 @@ public class TimeTable {
public int startWeek;
public int endWeek;
public String name;
public String applyUser;
public String[] time;
public String reason;
@ -61,6 +61,6 @@ public class TimeTable {
this.startWeek = Integer.parseInt(startWeekTemp);
this.endWeek = Integer.parseInt(endWeekTemp);
this.name = temp[2];
this.applyUser = temp[2];
}
}

View File

@ -48,6 +48,10 @@ public class Experiment implements Serializable {
* 申请人
*/
private String applyUser;
/*
* 附件
* */
private String annex;
@TableField(exist = false)
private static final long serialVersionUID = 1L;

View File

@ -20,7 +20,7 @@ import java.util.Map;
public interface BorrowInfoMapper extends BaseMapper<BorrowInfo> {
public Page<BorrowInfo> queryBorrowInfoByOptions(Page<BorrowInfo> page, BorrowInfo borrowInfo);
public void addTimeTable(Map<String, String> map);
public void addTimeTable(Map<String, Object> map);
public List<Room> notBorrowedYet(@Param("timeList") List<String> timeList, @Param("date") String date);
}

View File

@ -12,7 +12,6 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface LogMapper extends BaseMapper<LogEntity> {
}

View File

@ -2,6 +2,7 @@ package com.sdut.labex.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.sdut.labex.entity.LogEntity;
import com.sdut.labex.utils.ResVo;
/**
* @author springforest
@ -10,6 +11,6 @@ import com.sdut.labex.entity.LogEntity;
*/
public interface LogService extends IService<LogEntity> {
public void insertLog(LogEntity log);
public ResVo getLog(int pageNum, int pageSize);
}

View File

@ -138,14 +138,15 @@ public class ExperimentsServiceImpl extends ServiceImpl<ExperimentsMapper, Exper
queryWrapper.eq("class_name", className);
users = usersMapper.selectList(queryWrapper);
for (User user : users) {
SubmitRecord submitRecord = new SubmitRecord();
submitRecord.setExperimentId(experiment.getId());
submitRecord.setStudentId(user.getId());
submitRecordList.add(submitRecord);
}
}
System.out.println(submitRecordList);
if (submitRecordList.size() == 0) {
return ResVo.error("该实验没有班级");
}
try {
submitRecordsMapper.insertBatch(submitRecordList);
} catch (Exception e) {

View File

@ -1,12 +1,16 @@
package com.sdut.labex.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdut.labex.entity.LogEntity;
import com.sdut.labex.mapper.LogMapper;
import com.sdut.labex.service.LogService;
import com.sdut.labex.utils.ResVo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;
/**
* @author springforest
@ -21,12 +25,14 @@ public class LogServiceImpl extends ServiceImpl<LogMapper, LogEntity>
@Override
public void insertLog(LogEntity log) {
try {
logMapper.insert(log);
} catch (Exception e) {
e.printStackTrace();
}
public ResVo getLog(int pageNum, int pageSize) {
Page<LogEntity> page = new Page<>(pageNum, pageSize);
logMapper.selectPage(page, null);
Map<String, Object> map = new HashMap<>();
map.put("total", page.getTotal());
map.put("list", page.getRecords());
return ResVo.ok(map);
}
}

View File

@ -99,7 +99,7 @@ public class TableServiceImpl implements TableService {
// 解析文件将单元格内容解析为List
// 处理list
Map<String, String> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
// 获取当前日期
Date today = new Date();
@ -131,11 +131,11 @@ public class TableServiceImpl implements TableService {
String[] ttmp = temp.split("/");
if (ttmp.length <= 10) {
TimeTable timeTable = new TimeTable(temp);
map.put("name", timeTable.getName());
map.put("reason", timeTable.getReason());
map.put("applyUser", timeTable.getApplyUser());
map.put("roomName", roomName);
map.put("applyDate", dateFormat.format(today));
map.put("date", dateFormat.format(today));
map.put("isAdmit", "1");
map.put("applyDate", new Date());
calendar.add(Calendar.DATE, 7 * (timeTable.getStartWeek() - 1)); // 设置开始周
try {

View File

@ -39,8 +39,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
if (user == null) {
return ResVo.error("用户不存在");
}
//仅测试用
//todo上线后删除||判断
if (password.equals(user.getPassword()) || DigestUtils.md5DigestAsHex(password.getBytes()).equals(user.getPassword())) {
Map<String, String> map = new HashMap<>();
map.put("id", user.getId());
@ -177,7 +176,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
if (excel.readCell(i, 4) == null) {
return ResVo.error("Excel格式错误" + (i + 1) + "行第5列");
}
user.setRole(excel.readCell(i, 3));
user.setRole(excel.readCell(i, 4));
} catch (Exception e) {
e.printStackTrace();
return ResVo.error("Excel格式错误" + (i + 1) + "行第5列");
@ -204,4 +203,5 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
map.put("list", page.getRecords());
return ResVo.ok(map);
}
}

View File

@ -1,7 +1,11 @@
server:
port: 8080
port: 8085
spring:
servlet:
multipart:
max-file-size: 10MB # 设置上传文件的最大大小为10MB
max-request-size: 100MB # 设置上传数据的最大总大小为100MB
# Redis
redis:
host: 8.219.96.16

View File

@ -33,6 +33,7 @@
and room_name = #{borrowInfo.roomName}
</if>
</where>
order by apply_date desc
</select>

View File

@ -11,6 +11,7 @@
<result property="className" column="class_name" jdbcType="VARCHAR"/>
<result property="applyTime" column="apply_time" jdbcType="VARCHAR"/>
<result property="applyUser" column="apply_user" jdbcType="VARCHAR"/>
<result property="annex" column="annex" jdbcType="VARCHAR"/>
</resultMap>

View File

@ -103,8 +103,6 @@ export default {
} else {
url = '/getUsedTable';
}
url = '/getUsedTable';
this.$http({
url: url,
method: 'post',

View File

@ -12,7 +12,7 @@ app.use(store).use(router).mount('#app')
app.config.globalProperties.$http = axios;
//接口请求的基准路径
axios.defaults.baseURL = 'http://10.0.0.157:8080/';
axios.defaults.baseURL = 'http://localhost:8085/';
// axios.defaults.baseURL = 'http://211.64.28.110:8080/';
// 添加请求拦截器

View File

@ -34,9 +34,9 @@ const routes = [
component: () => import('../views/Admin/UserManage.vue')
},
{
path: '/RoomTimeAndReasonManage',
name: 'RoomTimeAndReasonManage',
component: () => import('../views/Admin/RoomAndTimeManage.vue')
path: '/System',
name: 'System',
component: () => import('../views/Admin/System.vue')
},
{
path: '/Personal',
@ -57,6 +57,10 @@ const routes = [
path: '/Sub',
name: 'Sub',
component: () => import('../views/Student/Sub.vue')
}, {
path: '/Log',
name: 'Log',
component: () => import('../views/Admin/Log.vue')
}
]
},

View File

@ -39,7 +39,7 @@ export default {
getAllAdmit() {
this.loading = true;
this.$http({
url: '/experiments/1/10',
url: '/experiments/1/30',
method: 'post',
data: {
status: 0
@ -65,7 +65,7 @@ export default {
}).then(({data}) => {
if (data.code !== 200) {
ElMessage({
message: '操作失败',
message: data.msg,
type: 'error',
})
} else {
@ -82,7 +82,7 @@ export default {
}).then(({data}) => {
if (data.code !== 200) {
ElMessage({
message: '操作失败',
message: data.msg,
type: 'error',
})
} else {

View File

@ -0,0 +1,67 @@
<template>
<el-page-header content="系统日志" style="margin-bottom: 30px" @back="this.$router.push('/Login')"/>
<el-card style="max-width: 1200px;margin:0 auto;background-color: #f9fafb">
<!--表格展示-->
<div style="margin-top: 20px">
<el-table :data="list" border stripe v-loading="loading">
<el-table-column align="center" prop="id" label="ID"/>
<el-table-column align="center" prop="content" label="请求方法"/>
<el-table-column align="center" prop="date" label="时间"/>
<el-table-column align="center" prop="cost" label="耗时"/>
</el-table>
</div>
<el-pagination
@size-change="getLog"
@current-change="getLog"
v-model:current-page="pageNum"
v-model:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</el-card>
</template>
<script>
let formData = new FormData;
export default {
name: "Log",
data() {
return {
loading: true,
isEdit: false,
pageSize: 30,
pageNum: 1,
total: 0,
list: [],
dialogVisibleForAdd: false,
}
},
mounted() {
this.getLog();
},
methods: {
getLog() {
this.loading = true;
this.list = [];
this.$http({
method: 'get',
url: '/log/' + this.pageNum + '/' + this.pageSize,
}).then(({data}) => {
this.list = data.list;
this.total = data.total;
this.loading = false;
})
},
}
}
</script>
<style scoped>
</style>

View File

@ -204,6 +204,7 @@ export default {
message: res.data.msg,
type: 'success'
});
this.getUser()
} else {
this.$notify({
title: '文件解析失败',

View File

@ -9,6 +9,15 @@
<el-input v-model="form.className" type="text" id="name" required/>
</el-form-item>
<el-form-item class="btn-Ex">
<el-upload :on-change="fileChange"
:show-file-list="false"
:auto-upload="false"
v-if="form.annex === null">
<el-button type="primary">上传附件</el-button>
</el-upload>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submit">确认</el-button>
</el-form-item>
</form>
@ -45,6 +54,7 @@
import {computed, ref} from 'vue'
import {ElMessage} from "element-plus";
let formData = new FormData;
const size = ref('')
computed(() => {
const marginMap = {
@ -66,7 +76,8 @@ export default {
className: '',
pageNum: 1,
pageSize: 10,
total: 0
total: 0,
annex: null
},
size: '',
}
@ -130,6 +141,37 @@ export default {
}
})
},
fileChange(files, fileList) {
formData.append('file', files.raw)
files = null;
this.loading = true;
this.$http({
method: 'post',
url: '/upload',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
}
}).then(res => {
if (res.data.code === 200) {
this.$notify({
title: '上传成功',
message: res.data.msg,
type: 'success'
});
this.form.annex = res.data.fileName;
} else {
this.$notify({
title: '文件解析失败',
message: res.data.msg,
type: 'error'
});
}
formData = null;
formData = new FormData();
this.loading = false;
})
},
}
}
</script>

View File

@ -2,6 +2,10 @@
<el-page-header content="实验批阅" style="margin-bottom: 30px" @back="this.$router.push('/Login')"/>
<el-card style="max-width: 1200px;margin:0 auto;background-color: #f9fafb">
<el-space style="margin-bottom: 10px">
<el-input placeholder="请输入学生ID" v-model="form.studentId"/>
<el-button @click="getList">搜索</el-button>
</el-space>
<!--表格展示-->
<div style="margin-top: 20px">
<el-table :data="list" border stripe v-loading="loading">
@ -67,7 +71,7 @@
let formData = new FormData;
export default {
naname: "ExperimentReview",
name: "ExperimentReview",
data() {
return {
list: [],
@ -81,7 +85,7 @@ export default {
},
dialogVisible: false,
pageNum: 1,
pageSize: 10,
pageSize: 20,
total: 0
}
},

View File

@ -53,7 +53,6 @@
</el-space>
</div>
</div>
<el-button type="primary" @click="preBorrow(item.name)" v-if="item.status === 1" style="width: 100%">
借用该教室
</el-button>

View File

@ -43,9 +43,8 @@
</el-select>
</el-form-item>
<el-form-item label="导入课表" v-show="userInfo.role === 'admin'">
<a href="/static/template.xls" download="课表模板.xlsx">
<el-button type="primary" style="margin-right: 10px;" :loading="loading">下载模板</el-button>
</a>
<el-button type="primary" @click="download('tableTemplate.xls')">下载模版
</el-button>
<el-breadcrumb :separator-icon="ArrowRight" style="margin-right: 20px;">
<el-date-picker v-model="this.startDate" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD"
placeholder="学期开始日期"/>
@ -64,17 +63,17 @@
<el-table-column align="center" prop="roomName" label="教室名称"/>
<el-table-column align="center" prop="applyUser" label="借用人"/>
<el-table-column align="center" prop="applyDate" label="申请时间"/>
<el-table-column align="center" width="100" label="状态">
<template #default="scope">
<el-tag v-show="scope.row.isAdmit === 0" type="warning">待审核</el-tag>
<el-tag v-show="scope.row.isAdmit === 2" type="danger">拒绝</el-tag>
<el-tag v-show="scope.row.isAdmit === 1" type="success">通过</el-tag>
</template>
</el-table-column>
<!-- <el-table-column align="center" width="100" label="状态">-->
<!-- <template #default="scope">-->
<!-- <el-tag v-show="scope.row.isAdmit === 0" type="warning">待审核</el-tag>-->
<!-- <el-tag v-show="scope.row.isAdmit === 2" type="danger">拒绝</el-tag>-->
<!-- <el-tag v-show="scope.row.isAdmit === 1" type="success">通过</el-tag>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column align="center" label="操作">
<template #default="scope">
<el-button type="danger" @click="cancel(scope.row.id)"
v-show="userInfo.role === 'admin' || userInfo.username === scope.row.name">撤销
v-if="userInfo.role === 'admin' || userInfo.username === scope.row.applyUser">撤销
</el-button>
</template>
</el-table-column>
@ -132,10 +131,13 @@ export default {
startDate: null,
}
},
mounted() {
created() {
this.userInfo.role = window.sessionStorage.getItem("role");
this.userInfo.userId = window.sessionStorage.getItem("userId");
this.userInfo.username = window.sessionStorage.getItem("username");
},
mounted() {
this.getBorrowInfo();
this.getAllRooms();
this.getAllTimeOptions();
@ -221,12 +223,12 @@ export default {
return;
}
formData.append("startDate", this.startDate);
formData.append("roomName", this.subForm.roomName);
formData.append("date", this.startDate);
formData.append("room", this.subForm.roomName);
this.$http({
method: 'post',
url: '/file/importTimeTable',
url: '/uploadTable',
data: formData,
headers: {
'Content-Type': 'multipart/form-data'
@ -251,6 +253,27 @@ export default {
this.loading = false;
})
},
download(fileName) {
this.$http({
url: '/download/' + fileName,
method: 'GET',
responseType: 'blob',
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', fileName);
document.body.appendChild(link);
link.click();
}).catch((error) => {
if (error.response && error.response.status === 404) {
this.$message.error('文件不存在!');
} else {
//
this.$message.error('下载文件时发生错误!');
}
});
},
}
}
</script>

View File

@ -15,18 +15,19 @@
alt="">
</div>
<el-menu-item index="/ApplyExperiment" v-if="userInfo.role!=='student'">实验项目申请</el-menu-item>
<el-menu-item index="/Admit" v-if="userInfo.role!=='student'">实验项目审核</el-menu-item>
<el-menu-item index="/Admit" v-if="userInfo.role==='admin'">实验项目审核</el-menu-item>
<el-menu-item index="/ExperimentCheck" v-if="userInfo.role!=='student'">实验项目批阅</el-menu-item>
<el-menu-item index="/BorrowRoom" v-if="userInfo.role!=='student'">教室申请</el-menu-item>
<el-menu-item index="/BorrowRoom" v-if="userInfo.role==='student'">课表查看</el-menu-item>
<el-menu-item index="/RecordList" v-if="userInfo.role!=='student'">教室申请记录查询</el-menu-item>
<el-menu-item index="/Sub">我的实验</el-menu-item>
<el-menu-item index="/RecordList" v-if="userInfo.role!=='student'">教室申请记录</el-menu-item>
<el-menu-item index="/Sub" v-if="userInfo.role==='student'">我的实验</el-menu-item>
<el-menu-item index="/UserManage" v-if="userInfo.role!=='student'">用户管理</el-menu-item>
<el-menu-item index="/UserManage" v-if="userInfo.role==='admin'">用户管理</el-menu-item>
<el-menu-item index="/Personal">个人信息</el-menu-item>
<el-menu-item index="/RoomTimeAndReasonManage" v-if="userInfo.role!=='student'">系统管理</el-menu-item>
<el-menu-item index="/System" v-if="userInfo.role!=='student'">系统管理</el-menu-item>
<el-menu-item index="/Log" v-if="userInfo.role==='admin'">系统日志</el-menu-item>
</el-menu>
</div>
</el-aside>

View File

@ -18,11 +18,12 @@
</el-table-column>
<el-table-column fixed="right" label="操作">
<template #default="scope">
<el-upload :on-change="fileChange" v-if="scope.row.filePath === ''" :show-file-list="false"
<el-upload :on-change="fileChange" v-if="scope.row.filePath === null ||scope.row.filePath === '' "
:show-file-list="false"
:auto-upload="false">
<el-button link type="primary" size="small" @click="change(scope.row)">上传</el-button>
</el-upload>
<el-button link type="primary" size="small" v-if="scope.row.filePath !== ''"
<el-button link type="primary" size="small" v-if="scope.row.filePath !== null && scope.row.filePath !== ''"
@click="download(scope.row.filePath)">下载
</el-button>
</template>