2023.6.23
1. 完结撒花~~
This commit is contained in:
parent
e9c9e284fe
commit
c28867e3e4
@ -1,7 +1,7 @@
|
||||
package com.sdut.labex.Factory;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sdut.labex.entity.SubmitRecords;
|
||||
import com.sdut.labex.entity.SubmitRecord;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@ -12,13 +12,13 @@ import lombok.extern.slf4j.Slf4j;
|
||||
*/
|
||||
@Slf4j
|
||||
public class SubmitRecordsFactory {
|
||||
public static SubmitRecords create(JSONObject jsonObject) {
|
||||
SubmitRecords submitRecords = new SubmitRecords();
|
||||
submitRecords.setExperimentId(jsonObject.getInteger("experimentId"));
|
||||
submitRecords.setStudentId(jsonObject.getInteger("studentId"));
|
||||
submitRecords.setFilePath(jsonObject.getString("filePath"));
|
||||
submitRecords.setScore(jsonObject.getInteger("score"));
|
||||
log.info("SubMitRecords: " + submitRecords.toString());
|
||||
return submitRecords;
|
||||
public static SubmitRecord create(JSONObject jsonObject) {
|
||||
SubmitRecord submitRecord = new SubmitRecord();
|
||||
submitRecord.setId(jsonObject.getInteger("id"));
|
||||
submitRecord.setExperimentId(jsonObject.getInteger("experimentId"));
|
||||
submitRecord.setStudentId(jsonObject.getString("studentId"));
|
||||
submitRecord.setFilePath(jsonObject.getString("filePath"));
|
||||
submitRecord.setScore(jsonObject.getInteger("score"));
|
||||
return submitRecord;
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import com.sdut.labex.Factory.ExperimentFactory;
|
||||
import com.sdut.labex.entity.Experiment;
|
||||
import com.sdut.labex.service.ExperimentsService;
|
||||
import com.sdut.labex.utils.ResVo;
|
||||
import com.sdut.labex.utils.UserHolder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -31,9 +32,7 @@ public class ExperimentsController {
|
||||
public ResVo applyExperiment(@RequestBody JSONObject jsonObject) {
|
||||
Experiment experiment = ExperimentFactory.createExperiment(jsonObject);
|
||||
//设置申请人
|
||||
//experiment.setApplyUser(UserHolder.getUser().getId());
|
||||
//todo:上线删除
|
||||
experiment.setApplyUser("测试");
|
||||
experiment.setApplyUser(UserHolder.getUser().getUsername());
|
||||
//获取当前时间
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
@ -78,8 +77,10 @@ public class ExperimentsController {
|
||||
//获取实验列表
|
||||
@PostMapping("/experiments/{pageNum}/{pageSize}")
|
||||
public ResVo getExperiments(@RequestBody JSONObject jsonObject, @PathVariable int pageNum, @PathVariable int pageSize) {
|
||||
//todo: 如果用户为老师则只能看到自己的实验
|
||||
Experiment experiment = ExperimentFactory.createExperiment(jsonObject);
|
||||
if (UserHolder.getUser().getRole().equals("teacher")) {
|
||||
experiment.setApplyUser(UserHolder.getUser().getUsername());
|
||||
}
|
||||
return experimentsService.getExperiments(experiment, pageNum, pageSize);
|
||||
}
|
||||
|
||||
@ -88,4 +89,7 @@ public class ExperimentsController {
|
||||
public ResVo getExperiment(@PathVariable String id) {
|
||||
return experimentsService.getExperiment(id);
|
||||
}
|
||||
|
||||
//删除
|
||||
|
||||
}
|
||||
|
@ -15,29 +15,43 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class FileController {
|
||||
private final Path fileStorageLocation = Paths.get("/Users/springforest/");
|
||||
private final Path fileStorageLocation = Paths.get("/Users/springforest/Downloads/软件实训/");
|
||||
|
||||
@PostMapping("/upload")
|
||||
public ResVo uploadFile(@RequestParam("file") MultipartFile file) {
|
||||
try {
|
||||
// Copy file to the target location (Replacing existing file with the same name)
|
||||
if (file.isEmpty()) {
|
||||
return ResVo.error("您传了个寂寞");
|
||||
return ResVo.error("上传文件为空");
|
||||
}
|
||||
Path filePath = this.fileStorageLocation.resolve(file.getOriginalFilename());
|
||||
log.info(filePath.toString());
|
||||
|
||||
// 获取原始文件名的后缀
|
||||
String originalFileName = file.getOriginalFilename();
|
||||
String extension = originalFileName.substring(originalFileName.lastIndexOf("."));
|
||||
|
||||
// 生成新的文件名
|
||||
String newFileName = UUID.randomUUID().toString() + extension;
|
||||
|
||||
// 将文件保存到指定的路径
|
||||
Path filePath = this.fileStorageLocation.resolve(newFileName);
|
||||
Files.copy(file.getInputStream(), filePath, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
return ResVo.ok();
|
||||
// 返回新的文件名
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("fileName", newFileName);
|
||||
return ResVo.ok(map);
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
return ResVo.error("文件上传失败");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@GetMapping("/download/{fileName}")
|
||||
@ -45,6 +59,7 @@ public class FileController {
|
||||
log.info(fileName);
|
||||
try {
|
||||
Path filePath = this.fileStorageLocation.resolve(fileName).normalize();
|
||||
System.out.println(filePath.toUri());
|
||||
Resource resource = new UrlResource(filePath.toUri());
|
||||
|
||||
if (resource.exists()) {
|
||||
@ -52,7 +67,8 @@ public class FileController {
|
||||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
|
||||
.body(resource);
|
||||
} else {
|
||||
throw new RuntimeException("File not found " + fileName);
|
||||
log.error("File not found " + fileName);
|
||||
return ResponseEntity.notFound().build();
|
||||
}
|
||||
|
||||
} catch (MalformedURLException ex) {
|
||||
|
@ -2,10 +2,11 @@ package com.sdut.labex.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.sdut.labex.Factory.SubmitRecordsFactory;
|
||||
import com.sdut.labex.entity.SubmitRecords;
|
||||
import com.sdut.labex.entity.SubmitRecord;
|
||||
import com.sdut.labex.service.SubmitRecordsService;
|
||||
import com.sdut.labex.utils.ResVo;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import com.sdut.labex.utils.UserHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -17,21 +18,31 @@ import javax.annotation.Resource;
|
||||
* Description:
|
||||
*/
|
||||
@RestController
|
||||
@Configuration
|
||||
@CrossOrigin
|
||||
@Slf4j
|
||||
public class SubmitRecordsController {
|
||||
@Resource
|
||||
private SubmitRecordsService submitRecordsService;
|
||||
|
||||
@PostMapping("/records")
|
||||
public ResVo record(@RequestBody JSONObject jsonObject) {
|
||||
SubmitRecords submitRecords = SubmitRecordsFactory.create(jsonObject);
|
||||
return submitRecordsService.addRecords(submitRecords);
|
||||
public ResVo addRecord(@RequestBody JSONObject jsonObject) {
|
||||
SubmitRecord submitRecord = SubmitRecordsFactory.create(jsonObject);
|
||||
return submitRecordsService.addRecords(submitRecord);
|
||||
}
|
||||
|
||||
@PostMapping("/getRecord/{pageNum}/{pageSize}")
|
||||
public ResVo getRecord(@PathVariable int pageNum, @PathVariable int pageSize, @RequestBody JSONObject jsonObject) {
|
||||
SubmitRecords submitRecords = SubmitRecordsFactory.create(jsonObject);
|
||||
return submitRecordsService.selectRecords(pageNum, pageSize, submitRecords);
|
||||
@PostMapping("/getRecordST/{pageNum}/{pageSize}")
|
||||
public ResVo getRecordST(@PathVariable int pageNum, @PathVariable int pageSize, @RequestBody JSONObject jsonObject) {
|
||||
String className = jsonObject.getString("className");
|
||||
String stId = jsonObject.getString("studentId");
|
||||
String applyUser = jsonObject.getString("applyUser");
|
||||
if (UserHolder.getUser().getRole().equals("student")) {
|
||||
className = UserHolder.getUser().getClassName();
|
||||
stId = UserHolder.getUser().getId();
|
||||
} else if (UserHolder.getUser().getRole().equals("teacher")) {
|
||||
applyUser = UserHolder.getUser().getUsername();
|
||||
}
|
||||
|
||||
return submitRecordsService.selectRecords(pageNum, pageSize, className, stId, applyUser);
|
||||
}
|
||||
|
||||
@DeleteMapping("/records/{id}")
|
||||
@ -41,8 +52,9 @@ public class SubmitRecordsController {
|
||||
|
||||
@PutMapping("/records")
|
||||
public ResVo updateRecord(@RequestBody JSONObject jsonObject) {
|
||||
SubmitRecords submitRecords = SubmitRecordsFactory.create(jsonObject);
|
||||
return submitRecordsService.updateRecords(submitRecords);
|
||||
log.info("updateRecords:{}", jsonObject);
|
||||
SubmitRecord submitRecord = SubmitRecordsFactory.create(jsonObject);
|
||||
return submitRecordsService.updateRecords(submitRecord);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,4 +36,14 @@ public class TableController {
|
||||
public ResVo uploadTable(MultipartFile file, @RequestPart("date") String date, @RequestPart("room") String room) {
|
||||
return tableService.uploadTable(file, date, room);
|
||||
}
|
||||
|
||||
@PostMapping("/getUsedTable")
|
||||
public ResVo getUsedTable(@RequestBody JSONObject jsonObject) {
|
||||
String roomName = jsonObject.getString("roomName");
|
||||
String date = jsonObject.getString("date");
|
||||
if (roomName.equals("")) {
|
||||
roomName = "9教207";
|
||||
}
|
||||
return tableService.getUsedTable(roomName, date);
|
||||
}
|
||||
}
|
||||
|
31
src/main/java/com/sdut/labex/dto/ExperimentDTO.java
Normal file
31
src/main/java/com/sdut/labex/dto/ExperimentDTO.java
Normal file
@ -0,0 +1,31 @@
|
||||
package com.sdut.labex.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* File: ExperimentDTO
|
||||
* Created: 2023/6/22
|
||||
* Author: springforest
|
||||
* Description:
|
||||
*/
|
||||
@Data
|
||||
public class ExperimentDTO {
|
||||
private Integer recordId;
|
||||
private Integer experimentId;
|
||||
private String studentId;
|
||||
private String filePath;
|
||||
private Integer score;
|
||||
private String username;
|
||||
private String className;
|
||||
private String department;
|
||||
private String role;
|
||||
private String experimentName;
|
||||
private Integer status;
|
||||
private String experimentClass;
|
||||
private Date applyTime;
|
||||
private String applyUser;
|
||||
private String annex;
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class TimeTable {
|
||||
this.time = new String[2];
|
||||
this.reason = temp[0];
|
||||
|
||||
String tt = new String(temp[1].substring(1, 5));
|
||||
String tt = temp[1].substring(1, 5);
|
||||
switch (tt) {
|
||||
case "1-2节":
|
||||
this.time[0] = "第一节";
|
||||
|
@ -15,7 +15,7 @@ import java.io.Serializable;
|
||||
*/
|
||||
@TableName(value = "submit_records")
|
||||
@Data
|
||||
public class SubmitRecords implements Serializable {
|
||||
public class SubmitRecord implements Serializable {
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@ -30,7 +30,7 @@ public class SubmitRecords implements Serializable {
|
||||
/**
|
||||
* 学生ID
|
||||
*/
|
||||
private Integer studentId;
|
||||
private String studentId;
|
||||
|
||||
/**
|
||||
* 文件路径
|
@ -2,9 +2,12 @@ package com.sdut.labex.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.sdut.labex.entity.SubmitRecords;
|
||||
import com.sdut.labex.dto.ExperimentDTO;
|
||||
import com.sdut.labex.entity.SubmitRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author springforest
|
||||
* @description 针对表【submit_records(实验提交记录)】的数据库操作Mapper
|
||||
@ -12,8 +15,12 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
* @Entity com.sdut.labex.entity.SubmitRecords
|
||||
*/
|
||||
@Mapper
|
||||
public interface SubmitRecordsMapper extends BaseMapper<SubmitRecords> {
|
||||
Page<SubmitRecords> selectPage(Page<SubmitRecords> page, SubmitRecords submitRecords);
|
||||
public interface SubmitRecordsMapper extends BaseMapper<SubmitRecord> {
|
||||
Page<SubmitRecord> selectPageForCheck(Page<SubmitRecord> page, SubmitRecord submitRecord);
|
||||
|
||||
Page<ExperimentDTO> selectPageST(Page<ExperimentDTO> page, String className, String studentId, String applyUser);
|
||||
|
||||
void insertBatch(List<SubmitRecord> submitRecordList);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.sdut.labex.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.sdut.labex.entity.SubmitRecords;
|
||||
import com.sdut.labex.entity.SubmitRecord;
|
||||
import com.sdut.labex.utils.ResVo;
|
||||
|
||||
/**
|
||||
@ -9,13 +9,16 @@ import com.sdut.labex.utils.ResVo;
|
||||
* @description 针对表【submit_records(实验提交记录)】的数据库操作Service
|
||||
* @createDate 2023-06-21 11:01:21
|
||||
*/
|
||||
public interface SubmitRecordsService extends IService<SubmitRecords> {
|
||||
public ResVo addRecords(SubmitRecords submitRecords);
|
||||
public interface SubmitRecordsService extends IService<SubmitRecord> {
|
||||
public ResVo addRecords(SubmitRecord submitRecord);
|
||||
|
||||
public ResVo deleteRecord(Integer id);
|
||||
|
||||
public ResVo updateRecords(SubmitRecords submitRecords);
|
||||
public ResVo updateRecords(SubmitRecord submitRecord);
|
||||
|
||||
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecords submitRecords);
|
||||
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecord submitRecord);
|
||||
|
||||
//正式
|
||||
public ResVo selectRecords(int pageNum, int pageSize, String className, String studentId, String applyUser);
|
||||
|
||||
}
|
||||
|
@ -15,4 +15,6 @@ public interface TableService {
|
||||
public ResVo getUnUsedTable(String room, String date);
|
||||
|
||||
public ResVo uploadTable(MultipartFile file, String startDate, String roomName);
|
||||
|
||||
public ResVo getUsedTable(String room, String date);
|
||||
}
|
||||
|
@ -4,14 +4,20 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.sdut.labex.entity.Experiment;
|
||||
import com.sdut.labex.entity.SubmitRecord;
|
||||
import com.sdut.labex.entity.User;
|
||||
import com.sdut.labex.mapper.ExperimentsMapper;
|
||||
import com.sdut.labex.mapper.SubmitRecordsMapper;
|
||||
import com.sdut.labex.mapper.UserMapper;
|
||||
import com.sdut.labex.service.ExperimentsService;
|
||||
import com.sdut.labex.utils.FormatDate;
|
||||
import com.sdut.labex.utils.ResVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -27,6 +33,11 @@ public class ExperimentsServiceImpl extends ServiceImpl<ExperimentsMapper, Exper
|
||||
implements ExperimentsService {
|
||||
@Resource
|
||||
private ExperimentsMapper experimentsMapper;
|
||||
@Resource
|
||||
private UserMapper usersMapper;
|
||||
|
||||
@Resource
|
||||
private SubmitRecordsMapper submitRecordsMapper;
|
||||
|
||||
@Override
|
||||
public ResVo applyExperiment(Experiment experiment) {
|
||||
@ -110,17 +121,46 @@ public class ExperimentsServiceImpl extends ServiceImpl<ExperimentsMapper, Exper
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public ResVo isAdmitted(int id, int status) {
|
||||
Experiment experiment = experimentsMapper.selectById(id);
|
||||
if (experiment == null)
|
||||
return ResVo.error("该实验不存在");
|
||||
experiment.setStatus(status);
|
||||
|
||||
if (status == 1) {
|
||||
//为实验中包含的班级添加实验记录
|
||||
String[] classList = experiment.getClassName().split(";");
|
||||
List<User> users;
|
||||
List<SubmitRecord> submitRecordList = new ArrayList<>();
|
||||
for (String className : classList) {
|
||||
QueryWrapper<User> queryWrapper = new QueryWrapper<>();
|
||||
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);
|
||||
try {
|
||||
submitRecordsMapper.insertBatch(submitRecordList);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResVo.error("添加实验记录失败");
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
experimentsMapper.updateById(experiment);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResVo.error();
|
||||
}
|
||||
|
||||
return ResVo.ok();
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,12 @@ 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.SubmitRecords;
|
||||
import com.sdut.labex.dto.ExperimentDTO;
|
||||
import com.sdut.labex.entity.SubmitRecord;
|
||||
import com.sdut.labex.mapper.SubmitRecordsMapper;
|
||||
import com.sdut.labex.service.SubmitRecordsService;
|
||||
import com.sdut.labex.utils.ResVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -18,15 +20,16 @@ import java.util.Map;
|
||||
* @createDate 2023-06-21 11:01:21
|
||||
*/
|
||||
@Service
|
||||
public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, SubmitRecords>
|
||||
@Slf4j
|
||||
public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, SubmitRecord>
|
||||
implements SubmitRecordsService {
|
||||
@Resource
|
||||
private SubmitRecordsMapper submitRecordsMapper;
|
||||
|
||||
@Override
|
||||
public ResVo addRecords(SubmitRecords submitRecords) {
|
||||
public ResVo addRecords(SubmitRecord submitRecord) {
|
||||
try {
|
||||
submitRecordsMapper.insert(submitRecords);
|
||||
submitRecordsMapper.insert(submitRecord);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResVo.error("保存失败");
|
||||
@ -46,9 +49,10 @@ public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo updateRecords(SubmitRecords submitRecords) {
|
||||
public ResVo updateRecords(SubmitRecord submitRecord) {
|
||||
log.info("updateRecords:{}", submitRecord);
|
||||
try {
|
||||
submitRecordsMapper.updateById(submitRecords);
|
||||
submitRecordsMapper.updateById(submitRecord);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResVo.error("更新失败");
|
||||
@ -57,9 +61,10 @@ public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecords submitRecords) {
|
||||
Page<SubmitRecords> page = new Page<>(pageNum, pageSize);
|
||||
submitRecordsMapper.selectPage(page, submitRecords);
|
||||
public ResVo selectRecords(int pageNum, int pageSize, SubmitRecord submitRecord) {
|
||||
log.info("selectRecords:{}", submitRecord);
|
||||
Page<SubmitRecord> page = new Page<>(pageNum, pageSize);
|
||||
submitRecordsMapper.selectPageForCheck(page, submitRecord);
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("current", page.getCurrent());
|
||||
@ -67,6 +72,17 @@ public class SubmitRecordsServiceImpl extends ServiceImpl<SubmitRecordsMapper, S
|
||||
map.put("list", page.getRecords());
|
||||
return ResVo.ok(map);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo selectRecords(int pageNum, int pageSize, String className, String studentId, String applyUser) {
|
||||
Page<ExperimentDTO> page = new Page<>(pageNum, pageSize);
|
||||
submitRecordsMapper.selectPageST(page, className, studentId, applyUser);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("current", page.getCurrent());
|
||||
map.put("total", page.getTotal());
|
||||
map.put("list", page.getRecords());
|
||||
return ResVo.ok(map);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,4 +164,49 @@ public class TableServiceImpl implements TableService {
|
||||
return ResVo.error("文件读取失败");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo getUsedTable(String room, String date) {
|
||||
QueryWrapper<BorrowInfo> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("date", date)
|
||||
.eq("room_name", room);
|
||||
List<BorrowInfo> borrowedList = borrowInfoMapper.selectList(queryWrapper);
|
||||
Map<String, List<String>> tempMap = new HashMap<>();
|
||||
// 获取所有教室
|
||||
List<Room> roomList = roomMapper.selectList(null);
|
||||
// 获取所有时间(按顺序)
|
||||
List<TimeOption> timeOptionList = timeOptionMapper.selectList(null);
|
||||
|
||||
for (TimeOption time : timeOptionList) {
|
||||
List<String> rooms = new ArrayList<>();
|
||||
tempMap.put(time.getName(), rooms);
|
||||
}
|
||||
|
||||
for (BorrowInfo item : borrowedList) {
|
||||
tempMap.get(item.getTime()).add(item.getRoomName());
|
||||
}
|
||||
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
List<List<String>> res = new ArrayList<>();
|
||||
|
||||
// 获取不在borrowedList中的教室
|
||||
for (TimeOption key : timeOptionList) {
|
||||
List<String> rooms = new ArrayList<>();
|
||||
for (Room item : roomList) {
|
||||
if (tempMap.get(key.getName()).contains(item.getName())) {
|
||||
rooms.add(item.getName());
|
||||
}
|
||||
}
|
||||
res.add(rooms);
|
||||
}
|
||||
|
||||
if (room != null && !room.isEmpty()) {
|
||||
for (List<String> rooms : res) {
|
||||
rooms.removeIf(r -> !r.equals(room));
|
||||
}
|
||||
}
|
||||
|
||||
map.put("list", res);
|
||||
return ResVo.ok(map);
|
||||
}
|
||||
}
|
||||
|
@ -152,8 +152,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
}
|
||||
//默认密码为123456
|
||||
user.setPassword(DigestUtils.md5DigestAsHex("123456".getBytes()));
|
||||
//身份
|
||||
user.setRole("student");
|
||||
//班级
|
||||
try {
|
||||
if (excel.readCell(i, 2) == null) {
|
||||
@ -174,7 +172,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
e.printStackTrace();
|
||||
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第4列");
|
||||
}
|
||||
|
||||
//身份
|
||||
try {
|
||||
if (excel.readCell(i, 4) == null) {
|
||||
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第5列");
|
||||
}
|
||||
user.setRole(excel.readCell(i, 3));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResVo.error("Excel格式错误:第" + (i + 1) + "行第5列");
|
||||
}
|
||||
list.add(user);
|
||||
}
|
||||
|
||||
|
@ -27,5 +27,8 @@ logging:
|
||||
level:
|
||||
root: info
|
||||
|
||||
file:
|
||||
filePath:"/uploadPath/"
|
||||
# 启用MyBatis Plus的SQL语句打印功能
|
||||
#mybatis-plus:
|
||||
# configuration:
|
||||
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
|
||||
|
@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sdut.labex.mapper.FileMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.sdut.labex.entity.FileEntity">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="path" column="path" jdbcType="VARCHAR"/>
|
||||
<result property="experimentId" column="experiment_id" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
id,name,path,
|
||||
experiment_id
|
||||
</sql>
|
||||
</mapper>
|
@ -4,10 +4,10 @@
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sdut.labex.mapper.SubmitRecordsMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.sdut.labex.entity.SubmitRecords">
|
||||
<resultMap id="BaseResultMap" type="com.sdut.labex.entity.SubmitRecord">
|
||||
<id property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="experimentId" column="experiment_id" jdbcType="INTEGER"/>
|
||||
<result property="studentId" column="student_id" jdbcType="INTEGER"/>
|
||||
<result property="studentId" column="student_id" jdbcType="VARCHAR"/>
|
||||
<result property="filePath" column="file_path" jdbcType="VARCHAR"/>
|
||||
<result property="score" column="score" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
@ -16,18 +16,47 @@
|
||||
id,experiment_id,student_id,
|
||||
file_path,score
|
||||
</sql>
|
||||
<select id="selectPage" resultType="com.sdut.labex.entity.SubmitRecords">
|
||||
|
||||
<select id="selectPageForCheck" resultType="com.sdut.labex.entity.SubmitRecord">
|
||||
select
|
||||
<include refid="Base_Column_List"/>
|
||||
from submit_records
|
||||
<where>
|
||||
<if test="submitRecords.experimentId != null">
|
||||
experiment_id = #{submitRecords.experimentId}
|
||||
<if test="submitRecord.experimentId != null and submitRecord.experimentId != ''">
|
||||
and experiment_id = #{submitRecord.experimentId}
|
||||
</if>
|
||||
<if test="submitRecords.studentId != null">
|
||||
and student_id = #{submitRecords.studentId}
|
||||
<if test="submitRecord.studentId != null and submitRecord.studentId != ''">
|
||||
and student_id = #{submitRecord.studentId}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
<select id="selectPageST" resultType="com.sdut.labex.dto.ExperimentDTO">
|
||||
SELECT s.id AS record_id, s.experiment_id, s.student_id, s.file_path, s.score,
|
||||
u.username, u.class_name, u.department, u.role,
|
||||
e.name AS experiment_name, e.status, e.class_name AS experiment_class, e.apply_time, e.apply_user, e.annex
|
||||
FROM submit_records s
|
||||
INNER JOIN user u ON s.student_id = u.id
|
||||
INNER JOIN experiments e ON s.experiment_id = e.id
|
||||
<where>
|
||||
<if test="studentId != null and studentId != ''">
|
||||
AND u.id = #{studentId}
|
||||
</if>
|
||||
<if test="className != null and className != ''">
|
||||
AND u.class_name = #{className}
|
||||
</if>
|
||||
<if test="applyUser != null and applyUser != ''">
|
||||
AND e.apply_user = #{applyUser}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
insert into submit_records (experiment_id, student_id, file_path, score)
|
||||
values
|
||||
<foreach collection="list" item="submitRecord" separator="," index="index">
|
||||
(#{submitRecord.experimentId}, #{submitRecord.studentId}, #{submitRecord.filePath}, #{submitRecord.score})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
|
@ -1,6 +1,7 @@
|
||||
<template>
|
||||
<!--教室使用情况表-->
|
||||
<h4>可用教室</h4>
|
||||
<h4 v-if="userInfo.role==='teacher'">可用教室</h4>
|
||||
<h4 v-if="userInfo.role==='student'">课表查看</h4>
|
||||
<el-table :data="tableData" border>
|
||||
<el-table-column prop="date"/>
|
||||
<el-table-column v-for="(val,index) in timeSet" :key="index" :label="val" align="center">
|
||||
@ -14,7 +15,7 @@
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-form label-width="120px" :inline="true" style="margin-top: 20px;margin-bottom: -20px">
|
||||
<el-form-item label="教室筛选">
|
||||
<el-form-item label="教室选择">
|
||||
<div v-for="(item,i) in rooms">
|
||||
<el-tag type="warning" @click="subForm.roomName = item.name" style="cursor: pointer;margin-right: 20px;">
|
||||
{{ item.name }}
|
||||
@ -37,6 +38,15 @@ export default {
|
||||
},
|
||||
timeSet: ['第一节', '第二节', '第三节', '第四节', '第五节', '第六节', '第七节', '第八节', '第九节', '第十节'],
|
||||
tableData: [],
|
||||
|
||||
userInfo: {
|
||||
userId: '',
|
||||
role: '',
|
||||
username: '',
|
||||
userDepart: '',
|
||||
newPwd: '',
|
||||
oldPwd: ''
|
||||
},
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@ -51,6 +61,9 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted() {
|
||||
this.userInfo.role = window.sessionStorage.getItem('role');
|
||||
this.userInfo.username = window.sessionStorage.getItem("username");
|
||||
this.userInfo.userId = window.sessionStorage.getItem("userId");
|
||||
//此处传递的是引用
|
||||
this.subForm.date = this.$props.msg.date;
|
||||
this.subForm.roomName = this.$props.msg.roomName;
|
||||
@ -83,9 +96,17 @@ export default {
|
||||
})
|
||||
},
|
||||
getTableData(offset, subForm) {
|
||||
console.log(subForm); // 打印新的 subForm 对象
|
||||
|
||||
let url = '';
|
||||
if (this.userInfo.role !== 'student') {
|
||||
url = '/getUnusedTable';
|
||||
} else {
|
||||
url = '/getUsedTable';
|
||||
}
|
||||
url = '/getUsedTable';
|
||||
|
||||
this.$http({
|
||||
url: '/getUnusedTable',
|
||||
url: url,
|
||||
method: 'post',
|
||||
data: subForm
|
||||
}).then(res => {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { createApp } from 'vue'
|
||||
import {createApp} from 'vue'
|
||||
import App from './App.vue'
|
||||
import router from './router'
|
||||
import store from './store'
|
||||
@ -12,7 +12,7 @@ app.use(store).use(router).mount('#app')
|
||||
|
||||
app.config.globalProperties.$http = axios;
|
||||
//接口请求的基准路径
|
||||
axios.defaults.baseURL = 'http://localhost:8080/';
|
||||
axios.defaults.baseURL = 'http://10.0.0.157:8080/';
|
||||
// axios.defaults.baseURL = 'http://211.64.28.110:8080/';
|
||||
|
||||
// 添加请求拦截器
|
||||
|
@ -53,12 +53,10 @@ const routes = [
|
||||
name: 'ExperimentCheck',
|
||||
component: () => import('../views/ApplyExperiment/ExperimentCheck.vue')
|
||||
},
|
||||
|
||||
|
||||
{
|
||||
path: '/Upload',
|
||||
name: 'Upload',
|
||||
component: () => import('../views/Admin/Upload.vue')
|
||||
path: '/Sub',
|
||||
name: 'Sub',
|
||||
component: () => import('../views/Student/Sub.vue')
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,70 +0,0 @@
|
||||
<template>
|
||||
<el-space>
|
||||
|
||||
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
||||
<el-button type="warning">上传</el-button>
|
||||
</el-upload>
|
||||
|
||||
<el-button type="warning" @click="download()">下载</el-button>
|
||||
</el-space>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
let formData = new FormData;
|
||||
export default {
|
||||
name: 'Upload',
|
||||
methods: {
|
||||
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'
|
||||
});
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '文件解析失败',
|
||||
message: res.data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
formData = null;
|
||||
formData = new FormData();
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
download() {
|
||||
// const fileName = this.selectedFile.name;
|
||||
const fileName = '22级新生信息.xlsx';
|
||||
|
||||
this.$http({
|
||||
url: '/download/' + fileName,
|
||||
method: 'GET',
|
||||
responseType: 'blob', // important
|
||||
}).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();
|
||||
});
|
||||
}
|
||||
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@ -8,13 +8,15 @@
|
||||
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
||||
<el-button type="warning" :loading="loading">上传</el-button>
|
||||
</el-upload>
|
||||
</el-space>>
|
||||
<el-button type="success" :loading="loading" @click="download">下载模版</el-button>
|
||||
</el-space>
|
||||
>
|
||||
</div>
|
||||
<!--表格展示-->
|
||||
<div style="margin-top: 20px">
|
||||
<el-table :data="userList" border stripe v-loading="loading">
|
||||
<el-table-column align="center" prop="id" label="ID"/>
|
||||
<el-table-column align="center" prop="username" label="姓名" />
|
||||
<el-table-column align="center" prop="username" label="姓名"/>
|
||||
<el-table-column align="center" prop="className" label="班级"/>
|
||||
<el-table-column align="center" prop="department" label="学院"/>
|
||||
<el-table-column align="center" prop="role" label="身份"/>
|
||||
@ -73,27 +75,28 @@
|
||||
|
||||
<script>
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
|
||||
let formData = new FormData;
|
||||
export default {
|
||||
name: "UserManage",
|
||||
data() {
|
||||
return {
|
||||
loading:true,
|
||||
isEdit:false,
|
||||
loading: true,
|
||||
isEdit: false,
|
||||
|
||||
pageSize:30,
|
||||
pageNum:1,
|
||||
total:0,
|
||||
pageSize: 30,
|
||||
pageNum: 1,
|
||||
total: 0,
|
||||
|
||||
addForm:{
|
||||
id:'',
|
||||
username:'',
|
||||
role:'teacher',
|
||||
password:'123456',
|
||||
className:'',
|
||||
department:''
|
||||
addForm: {
|
||||
id: '',
|
||||
username: '',
|
||||
role: 'teacher',
|
||||
password: '123456',
|
||||
className: '',
|
||||
department: ''
|
||||
},
|
||||
userList:[],
|
||||
userList: [],
|
||||
dialogVisibleForAdd: false,
|
||||
}
|
||||
},
|
||||
@ -107,9 +110,9 @@ export default {
|
||||
this.$http({
|
||||
method: 'post',
|
||||
url: '/user/' + this.pageNum + '/' + this.pageSize,
|
||||
data:{
|
||||
id:'',
|
||||
username:''
|
||||
data: {
|
||||
id: '',
|
||||
username: ''
|
||||
}
|
||||
}).then(({data}) => {
|
||||
this.userList = data.list;
|
||||
@ -119,14 +122,14 @@ export default {
|
||||
},
|
||||
addUser() {
|
||||
let method = '';
|
||||
if(this.isEdit){
|
||||
if (this.isEdit) {
|
||||
method = 'put';
|
||||
}else {
|
||||
} else {
|
||||
method = 'post';
|
||||
}
|
||||
this.$http({
|
||||
method: method,
|
||||
url: '/user' ,
|
||||
url: '/user',
|
||||
data: this.addForm
|
||||
}).then(({data}) => {
|
||||
if (data.code === 200) {
|
||||
@ -140,7 +143,7 @@ export default {
|
||||
this.addForm.id = '';
|
||||
this.addForm.password = '123456';
|
||||
this.getUser();
|
||||
}else {
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.msg,
|
||||
type: 'error'
|
||||
@ -148,7 +151,7 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
update(row){
|
||||
update(row) {
|
||||
this.addForm = JSON.parse(JSON.stringify(row));
|
||||
this.isEdit = true;
|
||||
|
||||
@ -213,6 +216,28 @@ export default {
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
download() {
|
||||
let fileName = 'userTemplate.xlsx';
|
||||
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>
|
||||
|
@ -25,8 +25,8 @@
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template #default>
|
||||
<el-button link type="primary" size="small">删除</el-button>
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" size="small" @click="remove(scope.row.id)">删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -111,6 +111,25 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
remove(id) {
|
||||
this.$http({
|
||||
url: '/experiment/' + id,
|
||||
method: 'delete',
|
||||
}).then(({data}) => {
|
||||
if (data.code !== 200) {
|
||||
ElMessage({
|
||||
message: data.msg,
|
||||
type: 'error',
|
||||
})
|
||||
} else {
|
||||
ElMessage({
|
||||
message: "删除成功",
|
||||
type: 'success',
|
||||
})
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -2,38 +2,29 @@
|
||||
|
||||
<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="display: flex;justify-content: space-between;align-items: center">
|
||||
<el-space>
|
||||
<el-button type="primary" style="margin-right: 10px;" @click="dialogVisibleForAdd = true">添加成员</el-button>
|
||||
<el-upload :on-change="fileChange" :show-file-list="false" :auto-upload="false">
|
||||
<el-button type="warning" :loading="loading">上传</el-button>
|
||||
</el-upload>
|
||||
</el-space>
|
||||
>
|
||||
</div>
|
||||
<!--表格展示-->
|
||||
<div style="margin-top: 20px">
|
||||
<el-table :data="userList" border stripe v-loading="loading">
|
||||
<el-table-column align="center" prop="id" label="ID"/>
|
||||
<el-table-column align="center" prop="username" label="姓名"/>
|
||||
<el-table :data="list" border stripe v-loading="loading">
|
||||
<el-table-column align="center" prop="experimentName" label="实验名称"/>
|
||||
<el-table-column align="center" prop="studentId" label="学号"/>
|
||||
<el-table-column align="center" prop="className" label="班级"/>
|
||||
<el-table-column align="center" prop="department" label="学院"/>
|
||||
<el-table-column align="center" prop="role" label="身份"/>
|
||||
<el-table-column align="center" label="操作">
|
||||
<el-table-column align="center" prop="username" label="学生姓名"/>
|
||||
<el-table-column align="center" prop="score" label="得分"/>
|
||||
<el-table-column align="center" label="操作" width="250px">
|
||||
<template #default="scope">
|
||||
<el-button type="primary" @click="update(scope.row)">
|
||||
<span style="margin-left: 3px">更新</span>
|
||||
<el-button type="primary" @click="openDialog(scope.row)">
|
||||
<span style="margin-left: 3px">评分</span>
|
||||
</el-button>
|
||||
<el-button type="danger" @click="remove(scope.row.id)">
|
||||
<span style="margin-left: 3px">删除</span>
|
||||
<el-button type="info" v-if="scope.row.filePath===null" disabled>未上传</el-button>
|
||||
<el-button type="success" v-if="scope.row.filePath!==null" @click="download(scope.row.filePath)">下载文件
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
<el-pagination
|
||||
@size-change="getUser"
|
||||
@current-change="getUser"
|
||||
@size-change="getList"
|
||||
@current-change="getList"
|
||||
v-model:current-page="pageNum"
|
||||
|
||||
v-model:page-size="pageSize"
|
||||
@ -41,31 +32,31 @@
|
||||
:total="total">
|
||||
</el-pagination>
|
||||
<!--添加用户的对话框-->
|
||||
<el-dialog title="添加用户" v-model="dialogVisibleForAdd" width="30%" style="padding-top: 30px">
|
||||
<el-form ref="addForm" :model="addForm" label-width="100px">
|
||||
<el-form-item label="工号">
|
||||
<el-input :disabled="isEdit" v-model="addForm.id" placeholder="请输入工号..."></el-input>
|
||||
<el-dialog title="添加用户" v-model="dialogVisible" width="30%" style="padding-top: 30px">
|
||||
<el-form ref="addForm" :model="form" label-width="100px">
|
||||
<el-form-item label="ID">
|
||||
<el-input disabled v-model="form.id"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="addForm.username" placeholder="请输入姓名..."></el-input>
|
||||
<el-form-item label="实验ID">
|
||||
<el-input disabled v-model="form.experimentId"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="班级">
|
||||
<el-input v-model="addForm.className" placeholder="请输入班级..."></el-input>
|
||||
<el-form-item label="实验名称">
|
||||
<el-input disabled v-model="form.experimentName"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="学院">
|
||||
<el-input v-model="addForm.department" placeholder="请输入班级..."></el-input>
|
||||
<el-form-item label="学生ID">
|
||||
<el-input disabled v-model="form.studentId"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="密码">
|
||||
<el-input v-model="addForm.password" placeholder="请输入密码..."></el-input>
|
||||
<el-form-item label="文件">
|
||||
<el-button v-if="form.filePath === null" disabled>未上传文件</el-button>
|
||||
<el-button v-if="form.filePath !== null" @click="download(form.filePath)">下载</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="身份">
|
||||
<el-input v-model="addForm.role" placeholder="请输入密码..."></el-input>
|
||||
<el-form-item label="得分">
|
||||
<el-input v-model="form.score" placeholder="请输入得分..."></el-input>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="addUser">确 定</el-button>
|
||||
<el-button @click="dialogVisibleForAdd = false">取 消</el-button>
|
||||
<el-button type="primary" @click="update">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
@ -73,146 +64,85 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {ElMessage, ElMessageBox} from "element-plus";
|
||||
|
||||
let formData = new FormData;
|
||||
export default {
|
||||
name: "UserManage",
|
||||
naname: "ExperimentReview",
|
||||
data() {
|
||||
return {
|
||||
loading: true,
|
||||
isEdit: false,
|
||||
|
||||
pageSize: 30,
|
||||
pageNum: 1,
|
||||
total: 0,
|
||||
|
||||
addForm: {
|
||||
list: [],
|
||||
loading: false,
|
||||
form: {
|
||||
id: '',
|
||||
username: '',
|
||||
role: 'teacher',
|
||||
password: '123456',
|
||||
className: '',
|
||||
department: ''
|
||||
experimentId: '',
|
||||
studentId: '',
|
||||
filePath: '',
|
||||
score: ''
|
||||
},
|
||||
userList: [],
|
||||
dialogVisibleForAdd: false,
|
||||
dialogVisible: false,
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.getUser();
|
||||
this.getList()
|
||||
},
|
||||
methods: {
|
||||
getUser() {
|
||||
this.loading = true;
|
||||
this.userList = [];
|
||||
this.$http({
|
||||
method: 'post',
|
||||
url: '/user/' + this.pageNum + '/' + this.pageSize,
|
||||
data: {
|
||||
id: '',
|
||||
username: ''
|
||||
}
|
||||
}).then(({data}) => {
|
||||
this.userList = data.list;
|
||||
this.total = data.total;
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
addUser() {
|
||||
let method = '';
|
||||
if (this.isEdit) {
|
||||
method = 'put';
|
||||
} else {
|
||||
method = 'post';
|
||||
}
|
||||
this.$http({
|
||||
method: method,
|
||||
url: '/user',
|
||||
data: this.addForm
|
||||
}).then(({data}) => {
|
||||
if (data.code === 200) {
|
||||
ElMessage({
|
||||
message: '操作成功',
|
||||
type: 'success'
|
||||
})
|
||||
this.isEdit = false;
|
||||
this.dialogVisibleForAdd = false;
|
||||
this.addForm.username = '';
|
||||
this.addForm.id = '';
|
||||
this.addForm.password = '123456';
|
||||
this.getUser();
|
||||
} else {
|
||||
ElMessage({
|
||||
message: data.msg,
|
||||
type: 'error'
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
update(row) {
|
||||
this.addForm = JSON.parse(JSON.stringify(row));
|
||||
this.isEdit = true;
|
||||
|
||||
this.dialogVisibleForAdd = true;
|
||||
},
|
||||
remove(id) {
|
||||
ElMessageBox.confirm(
|
||||
'该操作不可撤销',
|
||||
'警告',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
this.$http({
|
||||
method: 'delete',
|
||||
url: '/user/' + id,
|
||||
}).then(res => {
|
||||
this.getUser();
|
||||
ElMessage({
|
||||
type: 'success',
|
||||
message: '删除成功',
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
ElMessage({
|
||||
type: 'info',
|
||||
message: '删除已取消',
|
||||
})
|
||||
})
|
||||
},
|
||||
fileChange(files, fileList) {
|
||||
formData.append('file', files.raw)
|
||||
files = null;
|
||||
getList() {
|
||||
this.loading = true;
|
||||
this.$http({
|
||||
method: 'post',
|
||||
url: '/addUserBatch',
|
||||
data: formData,
|
||||
headers: {
|
||||
'Content-Type': 'multipart/form-data'
|
||||
}
|
||||
url: '/getRecordST/' + this.pageNum + '/' + this.pageSize,
|
||||
method: 'POST',
|
||||
data: this.form
|
||||
}).then(res => {
|
||||
if (res.data.code === 200) {
|
||||
this.$notify({
|
||||
title: '上传成功',
|
||||
message: res.data.msg,
|
||||
type: 'success'
|
||||
});
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '文件解析失败',
|
||||
message: res.data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
formData = null;
|
||||
formData = new FormData();
|
||||
|
||||
this.list = res.data.list;
|
||||
this.total = res.data.total;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
download(fileName) {
|
||||
this.$http({
|
||||
url: '/download/' + fileName,
|
||||
method: 'GET',
|
||||
responseType: 'blob', // important
|
||||
}).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();
|
||||
});
|
||||
},
|
||||
openDialog(row) {
|
||||
//给form赋值
|
||||
this.form.id = row.recordId;
|
||||
this.form.experimentId = row.experimentId;
|
||||
this.form.studentId = row.studentId;
|
||||
this.form.filePath = row.filePath;
|
||||
this.form.score = row.score;
|
||||
this.form.experimentName = row.experimentName;
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
update() {
|
||||
this.$http({
|
||||
url: '/records',
|
||||
method: 'put',
|
||||
data: this.form
|
||||
}).then(res => {
|
||||
this.dialogVisible = false;
|
||||
this.form = {
|
||||
id: '',
|
||||
experimentId: '',
|
||||
studentId: '',
|
||||
filePath: '',
|
||||
score: ''
|
||||
};
|
||||
this.getList();
|
||||
}).catch(res => {
|
||||
this.$message.error("请注意评分为数字");
|
||||
})
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
<template>
|
||||
<el-page-header content="教室申请" style="margin-bottom: 30px" @back="this.$router.push('/Login')"/>
|
||||
<el-page-header v-if="userInfo.role==='teacher'" content="教室申请" style="margin-bottom: 30px"
|
||||
@back="this.$router.push('/Login')"/>
|
||||
<el-page-header v-if="userInfo.role==='student'" content="课表查看" style="margin-bottom: 30px"
|
||||
@back="this.$router.push('/Login')"/>
|
||||
<el-card>
|
||||
<Table :msg="borrowForm"/>
|
||||
<el-divider/>
|
||||
@ -16,7 +19,7 @@
|
||||
style="width: 200px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="时间">
|
||||
<el-form-item label="时间" v-if="userInfo.role!=='student'">
|
||||
<el-select
|
||||
v-model="borrowForm.time"
|
||||
placeholder="请选择借用时间"
|
||||
@ -37,11 +40,11 @@
|
||||
</el-form>
|
||||
</div>
|
||||
<el-divider/>
|
||||
<div style="margin-left:20px;margin-right:20px;padding-left: 70px;padding-top: 40px;padding-bottom: 30px">
|
||||
<div v-if="this.userInfo.role!=='student'"
|
||||
style="margin-left:20px;margin-right:20px;padding-left: 70px;padding-top: 40px;padding-bottom: 30px">
|
||||
<el-space :size="45" wrap>
|
||||
<div v-for="(item,i) in Rooms">
|
||||
<el-card :body-style="{ padding: '0px' }" style="width: 200px;">
|
||||
|
||||
<div style="padding: 14px">
|
||||
<div style="margin-bottom: 10px">{{ item.name }}</div>
|
||||
<div style="width: 100%;padding-left: 10px;padding-right: 10px">
|
||||
|
@ -14,26 +14,19 @@
|
||||
<img src="../assets/img/logoW.png" style="height: 60%;width: 80%; margin-left: 20px;margin-top: 5px"
|
||||
alt="">
|
||||
</div>
|
||||
<el-sub-menu index="1">
|
||||
<template #title>
|
||||
<span>实验管理</span>
|
||||
</template>
|
||||
<el-menu-item index="/ApplyExperiment">实验项目申请</el-menu-item>
|
||||
<el-menu-item index="/ExperimentCheck">实验项目批阅</el-menu-item>
|
||||
<el-menu-item index="/Admit">实验项目审核</el-menu-item>
|
||||
<el-menu-item index="/BorrowRoom">教室申请</el-menu-item>
|
||||
<el-menu-item index="/RecordList">教室申请记录查询</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-sub-menu index="2">
|
||||
<template #title>
|
||||
<i class="el-icon-user-solid"></i>
|
||||
<span>用户管理</span>
|
||||
</template>
|
||||
<el-menu-item index="/UserManage">用户管理</el-menu-item>
|
||||
<el-menu-item index="/Personal">个人信息</el-menu-item>
|
||||
</el-sub-menu>
|
||||
<el-menu-item index="/RoomTimeAndReasonManage">系统管理</el-menu-item>
|
||||
<el-menu-item index="/Upload">上传</el-menu-item>
|
||||
<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="/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="/UserManage" v-if="userInfo.role!=='student'">用户管理</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>
|
||||
</div>
|
||||
</el-aside>
|
||||
|
@ -9,12 +9,22 @@
|
||||
</el-card>
|
||||
<el-card style="margin-top: 10px">
|
||||
<el-table :data="itemList" style="width: 100%">
|
||||
<el-table-column fixed prop="name" label="项目名称"/>
|
||||
<el-table-column fixed prop="experimentName" label="项目名称"/>
|
||||
<el-table-column prop="className" label="上课班级"/>
|
||||
<el-table-column prop="time" label="上课时间"/>
|
||||
<el-table-column label="附件">
|
||||
<template #default="scope">
|
||||
<el-button link type="primary" size="small" @click="download(scope.row.annex)">下载</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column fixed="right" label="操作">
|
||||
<template #default>
|
||||
<el-button link type="primary" size="small" @click="upLoad">上传</el-button>
|
||||
<template #default="scope">
|
||||
<el-upload :on-change="fileChange" v-if="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 !== ''"
|
||||
@click="download(scope.row.filePath)">下载
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@ -32,6 +42,7 @@
|
||||
import {computed, ref} from 'vue'
|
||||
import {ElMessage} from "element-plus";
|
||||
|
||||
let formData = new FormData;
|
||||
const size = ref('')
|
||||
computed(() => {
|
||||
const marginMap = {
|
||||
@ -48,6 +59,7 @@ export default {
|
||||
data() {
|
||||
return {
|
||||
itemList: [],
|
||||
upID: "",
|
||||
form: {
|
||||
name: '',
|
||||
className: '',
|
||||
@ -56,6 +68,13 @@ export default {
|
||||
pageSize: 10,
|
||||
total: 0
|
||||
},
|
||||
exFrom: {
|
||||
id: '',
|
||||
experimentId: '',
|
||||
studentId: '',
|
||||
filePath: '',
|
||||
score: ''
|
||||
},
|
||||
size: '',
|
||||
userInfo: {
|
||||
userId: '',
|
||||
@ -75,15 +94,38 @@ export default {
|
||||
this.userInfo.userId = window.sessionStorage.getItem("userId");
|
||||
},
|
||||
methods: {
|
||||
upLoad() {
|
||||
change(row) {
|
||||
this.exFrom.experimentId = row.experimentId;
|
||||
this.exFrom.studentId = row.studentId;
|
||||
this.exFrom.filePath = row.filePath;
|
||||
this.exFrom.score = row.score;
|
||||
this.exFrom.id = row.recordId;
|
||||
},
|
||||
update() {
|
||||
this.$http({
|
||||
url: "/records",
|
||||
method: 'put',
|
||||
data: this.exFrom
|
||||
}).then(({data}) => {
|
||||
if (data.code !== 200) {
|
||||
ElMessage({
|
||||
message: '更新成功',
|
||||
type: 'success',
|
||||
})
|
||||
} else {
|
||||
this.getList()
|
||||
}
|
||||
})
|
||||
|
||||
this.getList()
|
||||
},
|
||||
getList() {
|
||||
this.$http({
|
||||
url: "/experiments/" + this.form.pageNum + "/" + this.form.pageSize,
|
||||
url: "/getRecordST/" + this.form.pageNum + "/" + this.form.pageSize,
|
||||
method: 'post',
|
||||
data: {}
|
||||
data: {
|
||||
studentId: this.userInfo.userId,
|
||||
className: '',
|
||||
}
|
||||
}).then(({data}) => {
|
||||
if (data.code !== 200) {
|
||||
ElMessage({
|
||||
@ -92,9 +134,63 @@ export default {
|
||||
})
|
||||
} else {
|
||||
this.itemList = data.list;
|
||||
this.form.total = data.total;
|
||||
}
|
||||
})
|
||||
},
|
||||
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('下载文件时发生错误!');
|
||||
}
|
||||
});
|
||||
},
|
||||
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.exFrom.filePath = res.data.fileName;
|
||||
this.update();
|
||||
} else {
|
||||
this.$notify({
|
||||
title: '文件解析失败',
|
||||
message: res.data.msg,
|
||||
type: 'error'
|
||||
});
|
||||
}
|
||||
formData = null;
|
||||
formData = new FormData();
|
||||
this.loading = false;
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Loading…
Reference in New Issue
Block a user