java+SpringBoot設(shè)計(jì)實(shí)現(xiàn)評(píng)教系統(tǒng)
主要功能
共有三個(gè)角色:管理員、教師、學(xué)生。
管理員功能有:學(xué)生管理、教師管理、評(píng)教管理、指標(biāo)管理、課程管理等。
教師功能有:學(xué)生管理、指標(biāo)管理、課程管理。
學(xué)生功能有:評(píng)教管理。
運(yùn)行環(huán)境
jdk1.8、mysql5.X、maven3.5\3.6、idea
效果圖展示






主要代碼
教師管理控制層
@Authority(roles = {Role.TEACHER})
@Controller
@RequestMapping("/teacher")
public class TeacherController {
@Autowired
TeacherService teacherService;
@Autowired
SubjectService subjectService;
@RequestMapping(value = {"", "/loginPage"})
public String loginPage() {
return "teacher/login";
}
@GetMapping("/index")
public String homePage() {
return "teacher/public-teacher-index";
}
@GetMapping("/updatePwd")
public String updatePwd() {
return "teacher/teacherInfo/updatePwd";
}
@GetMapping("/teacherInfo")
public String teacherInfo() {
return "teacher/teacherInfo/teacherinfo";
}
@GetMapping("/modifyinfo")
public String modifyInfo() {
return "teacher/teacherInfo/updateinfo";
}
@GetMapping("/workapprovalinfo")
public String workInfo() {
return "teacher/workapproval/winfo";
}
@GetMapping("/workapprovaldata")
public String workData() {
return "teacher/workapproval/wdata";
}
@GetMapping("/seeworkdata")
public String seeWorkData() {
return "teacher/workapproval/seewdata";
}
//填寫(xiě)表格頁(yè)面
@GetMapping("/term_debriefing")
public String termDebriefing() {
return "teacher/fillouttable/termdebriefing";
}
@GetMapping("/year_debriefing")
public String yearDebriefing() {
return "teacher/fillouttable/yeardebriefing";
}
@GetMapping("/annual_assessment")
public String annualAssessment() {
return "teacher/fillouttable/annualassessment";
}
@GetMapping("/work_load")
public String workLoad() {
return "teacher/fillouttable/workload";
}
@GetMapping("/technical_personnel")
public String technicalPersonnel() {
return "teacher/fillouttable/technicalpersonnel";
}
@GetMapping("/term_business")
public String termBusiness() {
return "teacher/fillouttable/termbusiness";
}
//查看表格頁(yè)面
@GetMapping("/show_year_debriefing")
public String showYearDebriefing() {
return "teacher/showtable/yeardebriefing";
}
@GetMapping("/show_term_debriefing")
public String showTermDebriefing() {
return "teacher/showtable/termdebriefing";
}
@GetMapping("/show_annual_assessment")
public String showAnnualAssessment() {
return "teacher/showtable/annualassessment";
}
@GetMapping("/show_technical_personnel")
public String showTechnicalPersonnel() {
return "teacher/showtable/technicalpersonnel";
}
@GetMapping("/show_workload")
public String showWorkLoad() {
return "teacher/showtable/workload";
}
@GetMapping("/exit")
public String exit(HttpServletResponse response) {
//將Cookie 中的token 置空
Cookie cookie = new Cookie("token", null);
cookie.setPath("/");
response.addCookie(cookie);
return "redirect:/";
}
//打印頁(yè)面
@GetMapping("/print_term_debriefing")
public String printYearDebriefing(Long year, String term, Model model) {
model.addAttribute("year", year);
model.addAttribute("term", term);
return "teacher/showtable/print/termdebriefing";
}
@GetMapping("/print_year_debriefing")
public String printTermDebriefing(Long year, Model model) {
model.addAttribute("year", year);
return "teacher/showtable/print/yeardebriefing";
}
@GetMapping("/login")
@ResponseBody
public Msg login(String name, String pwd, HttpSession httpSession, HttpServletResponse response) throws ParseException {
name = name.trim();
int flag = teacherService.teacherDL(name, pwd);
if (flag == 200) {
User user = new User();
//-1表示為超管
user.setId(0L);
user.setRole("teacher");
user.setUserName(name);
//生成Token 存到 Cookie
Cookie cookie = new Cookie("token", TokenUtil.createToken(
user
));
//該Cookie無(wú)法被js讀取
cookie.setHttpOnly(true);
cookie.setPath("/");
response.addCookie(cookie);
Teacher teacher = teacherService.selectTeacher(name);
httpSession.setAttribute("teacherInfo", teacher);
httpSession.setMaxInactiveInterval(3600);
}
return Msg.success().add("info", flag);
}
//教師信息修改
//修改教師密碼
@PostMapping("/teacherupdetpwd")
@ResponseBody
public Msg fun6(String oldpwd, String newpwd, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
int flag = teacherService.teacherUpdetpwd(teacher.getUsername(), oldpwd, newpwd);
return Msg.success().add("flag", flag);
}
//修改教師信息
@PostMapping("/teacherupdeteinfo")
@ResponseBody
public Msg updateinfo(String name, String gender, HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
teacher.setName(name);
teacher.setGender(gender);
teacherService.teacherupdateInfo(teacher);
return Msg.success();
}
//教師出差模塊
//查詢所有教師出差申請(qǐng)信息
@GetMapping("/select_work_all")
@ResponseBody
public Msg fun1(HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<WorkapprovalWithBLOBs> list = teacherService.selectTeacherWorkAll(teacher.getId());
return Msg.success().add("workinfo", list);
}
//查詢申請(qǐng)成功教師出差申請(qǐng)
@GetMapping("/select_work_success")
@ResponseBody
public Msg fun2(HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<WorkapprovalWithBLOBs> list = teacherService.selectWorkSuccess(teacher.getId());
return Msg.success().add("workinfo", list);
}
//查詢申請(qǐng)失敗教師出差申請(qǐng)
@GetMapping("/select_work_failed")
@ResponseBody
public Msg fun3(HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<WorkapprovalWithBLOBs> list = teacherService.selectWorkFailed(teacher.getId());
return Msg.success().add("workinfo", list);
}
//查詢已提交教師出差申請(qǐng)
@GetMapping("/select_work_submitted")
@ResponseBody
public Msg fun4(HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<WorkapprovalWithBLOBs> list = teacherService.selectWorkSubmitted(teacher.getId());
return Msg.success().add("workinfo", list);
}
//刪除申請(qǐng)失敗的教師出差
@PostMapping("/delete_work")
@ResponseBody
public Msg deleteWork(Long id) {
teacherService.deleteWorkById(id);
return Msg.success();
}
//加載報(bào)告填寫(xiě)頁(yè)面
@GetMapping("/fillworkapproval")
public String fun5(Long id, Model model) throws ParseException {
WorkapprovalWithBLOBs workapproval = teacherService.selectWorkById(id);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd");
String start = sdf.format(workapproval.getBeginDate());
String end = sdf.format(workapproval.getEndDate());
String time = start + " - " + end;
model.addAttribute("workapproval", workapproval);
model.addAttribute("time", time);
return "teacher/workapproval/fillwdata";
}
//上傳出差報(bào)告
@PostMapping("/fill_in_w")
@ResponseBody
public Msg fun7(@RequestParam("id_work") Long idWork, @RequestParam("news") String news, @RequestParam("flag") Integer flag,
@RequestParam("file") MultipartFile file) throws IOException {
//判斷file的值是否為空
if (file.isEmpty()) {
return Msg.error();
}
String fileName = file.getOriginalFilename();// 獲取上傳文件的原名
int size = (int) file.getSize();
System.out.println(fileName + "-->" + size);
File path = new File(ResourceUtils.getURL("target").getPath());
String savePath = path.getAbsolutePath() + "\\classes\\static\\model";
String saveFileName = savePath + "\\" + fileName;
// String path = "D:/test";//文件保存路徑
File targetFile = new File(savePath);
if (!targetFile.getParentFile().exists()) { //判斷文件父目錄是否存在
targetFile.getParentFile().mkdir();
}
file.transferTo(new File(targetFile, fileName)); // 開(kāi)始接受文件
Workapprovaldata workapprovaldata = new Workapprovaldata();
workapprovaldata.setIdWorkapproval(idWork);
workapprovaldata.setNews(news);
workapprovaldata.setDatarar(saveFileName);
//flag == 0 公有 flag == 1私有
workapprovaldata.setFlag(flag);
teacherService.insertWordData(workapprovaldata);
return Msg.success();
}
//查看出差報(bào)告
@GetMapping("/select_work_data")
@ResponseBody
public Msg fun8(Integer pn, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
PageHelper.startPage(pn, 9);
List<Workapprovaldata> list = teacherService.selectWorkData(teacher.getIdSection());
PageInfo page = new PageInfo(list, 5);
return Msg.success().add("dataInfo", page);
}
//出差附件下載
@RequestMapping(value = "/file_download")
public ResponseEntity<byte[]> downloadFile(String dataId, HttpServletRequest req, HttpServletResponse response) throws IOException {
Workapprovaldata workapprovaldata = null;
if (dataId != null) {
Long id = Long.valueOf(dataId);
workapprovaldata = teacherService.selectWorkDataById(id);
}
if (workapprovaldata != null) {
String filePath = workapprovaldata.getDatarar();
//設(shè)置文件路徑
File file = new File(filePath);
if (!file.exists()) {
file.mkdirs();
}
String fileName = file.getName();
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
String encodeFilename = URLEncoder.encode(fileName, StandardCharsets.UTF_8.toString());
headers.setContentDispositionFormData("attachment", encodeFilename);
return new ResponseEntity<byte[]>(FileUtils.readFileToByteArray(file),
headers, HttpStatus.CREATED);
}
return null;
}
//學(xué)期述職
@PostMapping("/upload_term_debriefing")
@ResponseBody
public Msg fun9(String year, String term, String teachingTask, String scientificResearch,
String otherWork, String winAward, String summary, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
DebriefingWithBLOBs debriefingWithBLOBs = new DebriefingWithBLOBs();
debriefingWithBLOBs.setIdTeacher(teacher.getId());
debriefingWithBLOBs.setYear(Long.parseLong(year));
debriefingWithBLOBs.setTerm(term);
debriefingWithBLOBs.setTeachingtask(teachingTask);
debriefingWithBLOBs.setAchievementsinscientificresearch(scientificResearch);
debriefingWithBLOBs.setOtherwork(otherWork);
debriefingWithBLOBs.setWinaward(winAward);
debriefingWithBLOBs.setSummary(summary);
int flag = teacherService.selectTermDebriefingFlag(teacher.getId(), Long.parseLong(year), term);
if (flag == 1) {
teacherService.updateTermDebriefing(debriefingWithBLOBs);
} else {
int i = teacherService.insertTermDebriefing(debriefingWithBLOBs);
}
return Msg.success();
}
// 工作量表相關(guān)
@GetMapping("/wordload")
public String wordloadPage() {
return "teacher/table/workload";
}
@GetMapping("/wordloadData")
@ResponseBody
public Msg wordloadData(
@RequestParam("year") String year,
@RequestParam("trem") String trem
) {
Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
return Msg.success()
.add("teacher", teacher)
.add("workloadDTO", teacherService.getWorkload(teacher.getId(), year, trem));
}
private static final Logger LOGGER = LoggerFactory.getLogger(TeacherController.class);
@Autowired
HttpServletRequest request;
@PostMapping("/wordload")
@ResponseBody
public Msg wordloadSave(
@RequestBody WorkloadDTO workloadDTO
) {
Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
// LOGGER.info("{}",workloadDTO);
teacherService.saveWorkload(workloadDTO, teacher);
return Msg.success();
}
// 教師業(yè)務(wù)表
@GetMapping("/business")
public String businessPage() {
return "teacher/table/business";
}
@GetMapping("/businessData")
@ResponseBody
public Msg businessData(
@RequestParam("year") String year,
@RequestParam("trem") String trem
) {
Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
return teacherService.getBusiness(teacher.getId(), year, trem)
.add("teacher", teacher);
}
@PostMapping("/business")
@ResponseBody
public Msg saveBusiness(
@RequestBody BusinessDTO businessDTO
) {
Teacher teacher = (Teacher) request.getSession().getAttribute("teacherInfo");
return Msg.sqlChange((int) teacherService.saveBusiness(businessDTO, teacher));
}
//年度述職
@PostMapping("/upload_year_debriefing")
@ResponseBody
public Msg fun10(String year, String teachingTask, String scientificResearch,
String otherWork, String winAward, String summary, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
DebriefingYearWithBLOBs debriefingYear = new DebriefingYearWithBLOBs();
debriefingYear.setIdTeacher(teacher.getId());
debriefingYear.setYear(Long.parseLong(year));
debriefingYear.setTeachingtask(teachingTask);
debriefingYear.setAchievementsinscientificresearch(scientificResearch);
debriefingYear.setOtherwork(otherWork);
debriefingYear.setWinaward(winAward);
debriefingYear.setSummary(summary);
Long flag = teacherService.selectYearDebriefingFlag(teacher.getId(), Long.parseLong(year));
if (flag == 1) {
teacherService.updateYearDebriefing(debriefingYear);
} else {
int i = teacherService.insertYearDebriefing(debriefingYear);
}
return Msg.success();
}
//查詢年度述職中年份
@GetMapping("/select_debriefing_year")
@ResponseBody
public Msg fun11() {
List<DebriefingYear> list = teacherService.selectDebriefingByYear();
// 把年份排序
Collections.sort(list, new Comparator<DebriefingYear>() {
@Override
public int compare(DebriefingYear o1, DebriefingYear o2) {
return (int) (o2.getYear() - o1.getYear());
}
});
return Msg.success().add("year", list);
}
//查詢指定年份的年度述職信息
@GetMapping("/select_debriefing_year_info")
@ResponseBody
public Msg fun12(Long year, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
DebriefingYearWithBLOBs debriefingYear = teacherService.selectYearDebriefingInfo(teacher.getId(), year);
return Msg.success().add("debriefingInfo", debriefingYear);
}
//查詢學(xué)期述職中年份
@GetMapping("select_debriefing_term")
@ResponseBody
public Msg fun13() {
List<Debriefing> list = teacherService.selectDebriefingTermByYear();
List<Long> temp = new ArrayList<>();
//去除重復(fù)的年份
for (Debriefing s : list) {
if (!temp.contains(s.getYear())) {
temp.add(s.getYear());
}
}
return Msg.success().add("year", temp);
}
//查詢指定年份的學(xué)期述職信息
@GetMapping("/select_debriefing_term_info")
@ResponseBody
public Msg fun14(Long year, String term, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
DebriefingWithBLOBs debriefing = teacherService.selectTermDebriefingInfo(teacher.getId(), year, term);
return Msg.success().add("debriefingInfo", debriefing);
}
//年度考核
@PostMapping("/upload_annual_assessment")
@ResponseBody
public Msg fun15(String personalSummary, String year, String remark, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
AnnualAssessmentWithBLOBs assessment = new AnnualAssessmentWithBLOBs();
assessment.setIdTeacher(teacher.getId());
assessment.setPersonalsummary(personalSummary);
assessment.setYear(year);
assessment.setRemark(remark);
Long flag = teacherService.selectAnnualAssessmentFlag(teacher.getId(), year);
if (flag == 1) {
int i = teacherService.updateAnnualAssessment(assessment);
} else {
int i = teacherService.insertAnnualAssessment(assessment);
}
return Msg.success();
}
//年度專業(yè)技術(shù)人員考核表
@PostMapping("/upload_technical_personnel")
@ResponseBody
public Msg fun16(String year, String mainAchievements, String attendance, String rewardsAndPunishments, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
TechnicalPersonnelWithBLOBs technicalPersonnelWithBLOBs = new TechnicalPersonnelWithBLOBs();
technicalPersonnelWithBLOBs.setIdTeacher(teacher.getId());
technicalPersonnelWithBLOBs.setYear(year);
technicalPersonnelWithBLOBs.setMainachievements(mainAchievements);
technicalPersonnelWithBLOBs.setAttendance(attendance);
technicalPersonnelWithBLOBs.setRewardsandpunishments(rewardsAndPunishments);
Long flag = teacherService.selectTechnicalPersonnelFlag(teacher.getId(), Long.parseLong(year));
if (flag == 1) {
int i = teacherService.updateTechnicalPersonnel(technicalPersonnelWithBLOBs);
} else {
int i = teacherService.insertTechnicalPersonnel(technicalPersonnelWithBLOBs);
}
return Msg.success();
}
//查詢年度考核年份
@GetMapping("/select_annual_assessment")
@ResponseBody
public Msg fun17(HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
List<AnnualAssessment> list = teacherService.selectAnnualAssessmentByYear(teacher.getId());
if (list.isEmpty()) {
return Msg.fail();
} else {
return Msg.success().add("year", list);
}
}
//查詢指定年度考核信息
@GetMapping("/select_annualassessment_year_info")
@ResponseBody
public Msg fun18(Long year, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
AnnualAssessmentWithBLOBs assessment = teacherService.selectAnnualAssessmentInfo(teacher.getId(), year);
return Msg.success().add("assessmentInfo", assessment);
}
//查詢度專業(yè)技術(shù)人員考核表年份
@GetMapping("/select_technical_personnel_year")
@ResponseBody
public Msg fun18(HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
List<TechnicalPersonnel> list = teacherService.selectTechnicalPersonnelByYear(teacher.getId());
if (list.isEmpty()) {
return Msg.fail();
} else {
return Msg.success().add("year", list);
}
}
//查詢度專業(yè)技術(shù)人員考核表信息
@GetMapping("/select_technicalpersonnel_year_info")
@ResponseBody
public Msg fun19(Long year, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
TechnicalPersonnelWithBLOBs technicalPersonnelWithBLOBs = teacherService.selectTechnicalPersonnelInfo(teacher.getId(), year);
return Msg.success().add("technicalPersonnel", technicalPersonnelWithBLOBs);
}
// 畢業(yè)設(shè)計(jì)內(nèi)容
// 加載上傳課題頁(yè)面
@GetMapping("/upload_topic_page")
public String uploadTopic(ModelMap modelMap, HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<Projecttype> projecttypes = teacherService.select_allProjecttype();
List<Projectsource> projectsources = teacherService.select_allProjectsource();
List<Specialty> specialties = teacherService.select_allSpecialty(teacher.getIdSection());
modelMap.addAttribute("projecttypes", projecttypes);
modelMap.addAttribute("projectsources", projectsources);
modelMap.addAttribute("specialties", specialties);
return "teacher/graduation/upload";
}
// 上傳課題
@PostMapping("/up_project")
@ResponseBody
public Msg fun20(String projectName, Long idProjecttype, Long idProjectsource, String marchspecialty, String teachernames, @RequestParam("file") MultipartFile file, HttpServletRequest request, HttpSession httpSession) throws IOException {
if (file == null) {
return Msg.fail().add("msg","文件上傳失敗");
}
if(teacherService.selectProjectByName(projectName).size()>0){
System.out.println("上傳失敗");
return Msg.fail().add("msg","課題名已存在");
}
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
ServletContext servletContext = request.getSession().getServletContext();
String uploadFileName = file.getOriginalFilename(); // 獲取上傳文件的原名
System.out.println(uploadFileName);
uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);
System.out.println(uploadFileName);
File path = new File(ResourceUtils.getURL("target").getPath());
String savePath =
path.getAbsolutePath() + File.separator+"classes+"+File.separator+"static"
+File.separator+"model"+File.separator + teacher.getId();
String saveFileName = savePath +File.separator + uploadFileName;
File dirs = new File(savePath);
//判斷路徑是否存在,如果不存在就創(chuàng)建一個(gè)
if (!dirs.exists()) {
dirs.mkdirs();
}
file.transferTo(new File(dirs, uploadFileName)); // 開(kāi)始接受文件
System.out.println(teachernames);
ProjectWithBLOBs project = new ProjectWithBLOBs();
project.setProjectname(projectName);
project.setIdProjecttype(idProjecttype);
project.setIdProjectsource(idProjectsource);
project.setIdTeacher(teacher.getId());
project.setFilepath(saveFileName);
project.setMarchspecialty(marchspecialty.trim());
project.setTeachernames(teachernames);
project.setSelectcount(0);
project.setSelectFlag(0);
project.setVerifyprojectFlag(0);
project.setReleaseFlag(0);
int i = teacherService.insert_project(project);
return Msg.success();
}
//查看自己的課題發(fā)布記錄
@GetMapping("/cxmyProject")
public String fun21(ModelMap modelMap, HttpSession httpSession) {
TeacherWithBLOBs teacher = (TeacherWithBLOBs) httpSession.getAttribute("teacherInfo");
List<Projecttype> projecttypes = teacherService.select_allProjecttype();
List<Projectsource> projectsources = teacherService.select_allProjectsource();
List<Specialty> specialties = teacherService.select_allSpecialty(teacher.getIdSection());
modelMap.addAttribute("projecttypes", projecttypes);
modelMap.addAttribute("projectsources", projectsources);
modelMap.addAttribute("specialties", specialties);
List<Project> projects = teacherService.selectTeacherProject(teacher.getName());
for (int i = 0; i < projects.size(); i++) {
if (projects.get(i).getVerifyprojectFlag() == 0) projects.get(i).setProjectZT("未審核");
else if (projects.get(i).getVerifyprojectFlag() == 1) projects.get(i).setProjectZT("審核未通過(guò)");
else projects.get(i).setProjectZT("審核通過(guò)");
}
modelMap.addAttribute("Myproject", projects);
return "teacher/graduation/section_xq/index";
}
// 發(fā)布或取消發(fā)布已審核通過(guò)的課題
@PostMapping("/fb_project")
@ResponseBody
public String fun8(Long project_id, String pd,HttpSession httpSession) {
int s = Integer.parseInt(pd);
teacherService.updateProjectFB(project_id, s);
if (s == 0) {
teacherService.deleteSelectedAll(project_id);
teacherService.updateProjectCount(project_id);
}
Map<String, String> map = new HashMap<String, String>();
map.put("pd", "" + 1);
return JSONObject.toJSONString(map);
}
@PostMapping("del_project")
@ResponseBody
public Msg deleteProject(Long id) {
teacherService.deleteProject(id);
return Msg.success();
}
@PostMapping("/updateSubject")
@ResponseBody
public Msg updateProject(Long id, String projectName, Long idProjecttype, Long idProjectsource, String marchspecialty, String teachernames, @RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, HttpSession httpSession) throws IOException {
//拼接 teacherNames 字段
TeacherWithBLOBs teacher = (TeacherWithBLOBs) request.getSession().getAttribute("teacherInfo");
String teacherName = teacher.getName();
if (teachernames == null || teachernames.trim().length() == 0) {
teachernames = teacherName;
} else {
teachernames = teacherName + "&" + teachernames;
}
SubjectWithBLOBs subject = null;
//文件大小 為 0 則表示 文件沒(méi)上傳
long size = file.getSize();
//不更新課題文件情況
if (file == null || size == 0) {
subject = new SubjectWithBLOBs();
subject.setId(id);
subject.setProjectname(projectName);
subject.setIdProjecttype(idProjecttype);
subject.setIdProjectsource(idProjectsource);
subject.setMarchspecialty(marchspecialty);
subject.setTeachernames(teachernames);
//修改后狀態(tài)置 0
subject.setSelectFlag(0);
subject.setVerifyprojectFlag(0);
subject.setReleaseFlag(0);
subjectService.updateSubjectByid(subject);
return Msg.success();
} else {
//獲取課題
SubjectWithBLOBs subject1 = subjectService.getSubjectByID(id);
//獲取課題路徑
String oldPath = subject1.getFilepath();
File oldFile = new File(oldPath);
//如果文件存在則刪除
if (oldFile.exists()) {
//刪除成功
if (oldFile.delete()) {
} else {
return Msg.fail();
}
}
ServletContext servletContext = request.getSession().getServletContext();
String uploadFileName = file.getOriginalFilename(); // 獲取上傳文件的原名
uploadFileName = uploadFileName.substring(uploadFileName.lastIndexOf(File.separator) + 1);
File path = new File(ResourceUtils.getURL("target").getPath());
// String savePath = path.getAbsolutePath() + "\\classes\\static\\model\\" + teacher.getId();
// String saveFileName = savePath + "\\" + uploadFileName;
String savePath =
path.getAbsolutePath() + File.separator+"classes+"+File.separator+"static"
+File.separator+"model"+File.separator + teacher.getId();
String saveFileName = savePath +File.separator + uploadFileName;
File dirs = new File(savePath);
//判斷路徑是否存在,如果不存在就創(chuàng)建一個(gè)
if (!dirs.exists()) {
dirs.mkdirs();
}
file.transferTo(new File(dirs, uploadFileName)); // 開(kāi)始接受文件
SubjectWithBLOBs project = subject1;
project.setProjectname(projectName);
project.setIdProjecttype(idProjecttype);
project.setIdProjectsource(idProjectsource);
project.setFilepath(saveFileName);
project.setMarchspecialty(marchspecialty.trim());
project.setTeachernames(teachernames);
//修改后狀態(tài)置 0
project.setSelectFlag(0);
project.setVerifyprojectFlag(0);
project.setReleaseFlag(0);
int i = subjectService.updateSubjectByid(project);
return Msg.success();
}
}
@GetMapping("/getSubjectById")
@ResponseBody
public Msg getss(Long id) {
SubjectWithBLOBs subject = subjectService.getSubjectByID(id);
System.out.println(subject);
subject.setFilepath(subject.getFilepath().substring(subject.getFilepath().lastIndexOf("\\") + 1));
String[] teachers = subject.getTeachernames().split("&");
String teacher2 = "";
if (teachers.length >= 2) {
teacher2 = teachers[teachers.length - 1];
}
subject.setTeachernames(teacher2);
return Msg.success()
.add("subject", subject)
;
}
//查看自己所在教研室的課題發(fā)布記錄
@GetMapping("/cxallProject")
public String fun7(ModelMap modelMap, HttpSession httpSession) {
Teacher teacher = (Teacher) httpSession.getAttribute("teacherInfo");
List<Project> projects = teacherService.selecSectionProject(teacher.getSectionName());
for (int i = 0; i < projects.size(); i++) {
if (projects.get(i).getVerifyprojectFlag() == 0) projects.get(i).setProjectZT("未審核");
else if (projects.get(i).getVerifyprojectFlag() == 1) projects.get(i).setProjectZT("審核未通過(guò)");
else projects.get(i).setProjectZT("審核通過(guò)");
}
modelMap.addAttribute("allproject", projects);
return "teacher/graduation/section_xq/subjectinfoto";
}
}
登錄控制層
@Controller
public class LoginController {
private static final Logger LOGGER = LoggerFactory.getLogger(LoginController.class);
@Autowired
AdminService adminService;
@GetMapping("/cs")
public String cs() {
return "cs";
}
@GetMapping("/login")
public String login() {
return "login";
}
@PostMapping("/login")
@ResponseBody
public Msg login(String name, String pwd, HttpSession httpSession) {
name = name.trim();
// LOGGER.info("{}--{}",name,pwd);
return adminService.login(name, pwd, httpSession);
}
}
管理員控制層
@Authority(roles = {Role.ADMIN, Role.SADMIN})
@Controller
@RequestMapping("/admin")
public class AdminController {
private static final Logger LOGGER = LoggerFactory.getLogger(AdminController.class);
@Autowired
AdminService adminService;
@Autowired
AdminMapper adminMapper;
@Autowired
CollegeService collegeService;
@Autowired
SectionService sectionService;
@Autowired
SpecialtyService specialtyService;
@Autowired
ClassService classService;
@Autowired
TeacherService teacherService;
@Autowired
StudentService studentService;
@Autowired
SubjectService subjectService;
@Autowired
ExcelService excelService;
@Autowired
SubjectRelationStudentMapper subjectRelationStudentMapper;
@Autowired
HttpServletRequest request;
@Autowired
HttpServletResponse response;
@Autowired
HttpSession session;
@ModelAttribute("id_institute")
public long getRoleInfo() {
User user = (User) request.getAttribute("user");
// LOGGER.info("USER:{}",user);
if (user != null) {
if (user.getRole().equals("admin")) {
Institute institute = collegeService.selectCollege(adminMapper.selectByPrimaryKey(user.getId()).getIdInstitute());
return institute.getId();
}
if (user.getRole().equals("sadmin")) {
return -1;
}
return 0;
} else {
return 0;
}
}
// admin index page 子管首頁(yè)
@GetMapping(value = {"", "/index"})
public String index() {
User user = (User) request.getAttribute("user");
// LOGGER.info("index user:{}",user);
//這部分還是用了session存儲(chǔ)部分信息 后續(xù)可能修改
//根據(jù) user的id 判斷 渲染頁(yè)面
if (user.getId() == -1) {
LOGGER.info("超級(jí)管理員登錄");
session.setAttribute("instituteName", "超級(jí)管理員");
session.setAttribute("ROLE", "sadmin");
session.setAttribute("username", user.getUserName());
return "admin/public-admin-index";
}
Institute institute = collegeService.selectCollege(adminMapper.selectByPrimaryKey(user.getId()).getIdInstitute());
System.out.println(institute.getInstituteName());
session.setAttribute("instituteName", institute.getInstituteName());
session.setAttribute("ROLE", "admin");
session.setAttribute("username", user.getUserName());
return "admin/public-admin-index";
}
// exit 退出登錄
@GetMapping("/exit")
public String exit(HttpSession httpSession) {
//將Cookie 中的token 置空
Cookie cookie = new Cookie("token", null);
cookie.setPath("/");
response.addCookie(cookie);
return "login";
}
// login 在單獨(dú)Controller
// updatePwd 更新密碼
@GetMapping("/updatePwd")
public String updatePwd() {
return "admin/updatePwd";
}
@PostMapping("/updatePwd")
@ResponseBody
public Msg updatePwd(
@RequestBody Admin admin,
HttpSession httpSession) {
User user = (User) request.getAttribute("user");
adminService.updatePwdByUserName(
user.getUserName(),
admin.getPwd()
);
return Msg.success();
}
// 教研室
@GetMapping("/SectionManagement")
public String section() {
return "admin/Department/SectionManagement";
}
@GetMapping("/sections")
@ResponseBody
public Msg getSections(@ModelAttribute("id_institute") long id_institute) {
return Msg.success().add("sections", sectionService.getSections(id_institute));
}
@DeleteMapping("/section")
@ResponseBody
public Msg delSection(@RequestBody Section section) {
return Msg.sqlChange((int) sectionService.delSection(section));
}
@PutMapping("/section")
@ResponseBody
public Msg updateSection(@RequestBody @Validated Section section, @ModelAttribute("id_institute") long id_institute) throws MyException {
return Msg.sqlChange((int) sectionService.updateSection(section, section.getSectionName(), id_institute));
}
@PostMapping("/section")
@ResponseBody
public Msg addSection(@RequestBody @Validated Section section, @ModelAttribute("id_institute") long id_institute) {
return Msg.sqlChange((int) sectionService.addSection(section, id_institute));
}
// 專業(yè)方向
@GetMapping("/SpecialtyManagement")
public String specialty() {
return "admin/Department/SpecialtyManagement";
}
@GetMapping("/specialtys")
@ResponseBody
public Msg getSpecialtys(
@RequestParam Integer offset,
@RequestParam(required = false) Long sectionId,
@RequestParam(required = false) String keyWord,
@ModelAttribute("id_institute") long id_institute) {
long total = specialtyService.getSpecialtyCount(offset, keyWord, sectionId, id_institute);
return Msg.success()
.add("specialtys", specialtyService.getSpecialtys(offset, keyWord, sectionId, id_institute))
.add("total", total);
}
@ResponseBody
@DeleteMapping("/specialty")
public Msg delSpecialty(
@RequestBody Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.delSpecialty(specialty, id_institute));
}
@ResponseBody
@PutMapping("/specialty")
public Msg putSpecialty(
@RequestBody @Validated({Update.class}) Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.putSpecialty(specialty, id_institute));
}
@ResponseBody
@PostMapping("/specialty")
public Msg postSpecialty(
@RequestBody @Validated({Add.class}) Specialty specialty,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) specialtyService.postSpecialty(specialty, id_institute));
}
// 班級(jí)
@GetMapping("/ClassManagement")
public String Class() {
return "admin/Department/ClassManagement";
// //獲取管理員的 學(xué)院id
// public static Long getIdInstitute(ModelMap modelMap) {
// Subadmin subadmin = (Subadmin) modelMap.get("admin");
// return subadmin.getIdInstitute();
// }
}
@ResponseBody
@GetMapping("/classes")
public Msg getClasses(
@RequestParam("offset") Integer offset,
@RequestParam(required = false) Long specialtyId,
@RequestParam(required = false) String keyWord,
@ModelAttribute("id_institute") long id_institute) {
long total = classService.getClassesCount(offset, keyWord, specialtyId, id_institute);
return Msg.success()
.add("classes", classService.getClasses(offset, keyWord, specialtyId, id_institute))
.add("total", total);
}
@ResponseBody
@DeleteMapping("/class")
public Msg delClass(
@RequestBody MyClass myClass,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) classService.delClass(myClass, id_institute));
}
@ResponseBody
@PutMapping("/class")
public Msg putClass(
@RequestBody @Validated({One.class}) MyClass myClass,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) classService.putClass(myClass, id_institute));
}
@ResponseBody
@PostMapping("/class")
public Msg postClass(
@RequestBody @Validated({One.class}) MyClass myClass,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) classService.postClass(myClass, id_institute));
}
// 課題綜合管理
@GetMapping("/SourceManagement")
public String source() {
return "admin/Subject/SourceManagement";
}
@ResponseBody
@GetMapping("/sources")
public Msg getSources() {
return Msg.success().add("sources", subjectService.selectSubjectSources());
}
@ResponseBody
@PostMapping("/source")
public Msg addSource(@RequestBody @Validated SubjectSource source) throws MyException {
return Msg.sqlChange((int) subjectService.insertSubjectSource(source.getSourcename()));
}
@ResponseBody
@DeleteMapping("/source")
public Msg delSource(@RequestBody SubjectSource source) throws MyException {
return Msg.sqlChange(subjectService.delSubjectSource(source.getId()));
}
@ResponseBody
@PutMapping("/source")
public Msg updateSource(@RequestBody @Validated SubjectSource source) {
return Msg.sqlChange(subjectService.updateSubjectSource(source));
}
//課題類型
@GetMapping("/TypeManagement")
public String subjectType() {
return "admin/Subject/TypeManagement";
}
@ResponseBody
@GetMapping("/sujecttypes")
public Msg getType() {
return Msg.success().add("sujecttypes", subjectService.selectSubjectTypes());
}
@ResponseBody
@PostMapping("/sujecttype")
public Msg addType(@RequestBody @Validated SubjectType type) throws MyException {
return Msg.sqlChange((int) subjectService.insertSubjectType(type.getTypename()));
}
@ResponseBody
@DeleteMapping("/sujecttype")
public Msg delType(@RequestBody SubjectType type) throws MyException {
return Msg.sqlChange(subjectService.delSubjectType(type.getId()));
}
@ResponseBody
@PutMapping("/sujecttype")
public Msg updateType(@RequestBody @Validated SubjectType type) {
return Msg.sqlChange(subjectService.updateSubjectType(type));
}
//課題管理
@GetMapping("/SubjectManagement")
public String Subject() {
return "admin/Subject/SubjectManagement";
}
@ResponseBody
@GetMapping("/subjects")
public Msg getSubjects(
@RequestParam Integer offset,
@RequestParam(required = false) Long sectionId,
@RequestParam(required = false) String keyWord,
@ModelAttribute("id_institute") long id_institute) {
long total = subjectService.selectSubjectsCount(offset, keyWord, sectionId, id_institute);
return Msg.success()
.add("subjects", subjectService.selectSubjects(offset, keyWord, sectionId, id_institute))
.add("total", total);
}
@ResponseBody
@PostMapping("/subject")
public Msg addSubject(
@RequestBody @Validated(Add.class) SubjectWithBLOBs subject,
@ModelAttribute("id_institute") long id_institute) throws MyException {
return Msg.sqlChange((int) subjectService.insertSubject(subject, id_institute));
}
@ResponseBody
@DeleteMapping("/subject")
public Msg delSubject(
@RequestBody SubjectWithBLOBs subject,
@ModelAttribute("id_institute") long id_institute) throws MyException {
return Msg.sqlChange(subjectService.delSubject(subject, id_institute));
}
@ResponseBody
@PutMapping("/subject")
public Msg updateSubject(
@RequestBody @Validated(Update.class) SubjectWithBLOBs subject,
@ModelAttribute("id_institute") long id_institute) throws MyException {
return Msg.sqlChange(subjectService.updateSuject(subject, id_institute));
}
//get學(xué)生選題的狀態(tài)
@GetMapping("/SRS")
@ResponseBody
public Msg getSelectSubjected(
@ModelAttribute("id_institute") long id_institute
) {
System.out.println(subjectService.getSelectSubjected(null, id_institute));
return Msg.success().add("SRS", subjectService.getSelectSubjected(null, id_institute));
}
//get 選某個(gè)課題的所有學(xué)生
@GetMapping("/studentsBySubject")
@ResponseBody
public Msg getStuentBySubject(
@RequestParam("id") Long id,
@ModelAttribute("id_institute") long id_institute
) {
return subjectService.getStuentBySubject(id, id_institute);
}
// 教師管理 增刪改查
@GetMapping("/TeacherManagement")
public String teacher() {
return "admin/BasicInfo/TeacherManagement";
}
@ResponseBody
@GetMapping("/teachers")
public Msg getTeachers(
@RequestParam Integer offset,
@RequestParam(required = false) Long sectionId,
@RequestParam(required = false) String keyWord,
@ModelAttribute("id_institute") long id_institute) {
long total = teacherService.selectTeachersCount(offset, keyWord, sectionId, id_institute);
return Msg.success()
.add("teachers", teacherService.selectTeachers(offset, keyWord, sectionId, id_institute))
.add("total", total);
}
@ResponseBody
@DeleteMapping("/teacher")
public Msg delTeacher(
@RequestBody TeacherWithBLOBs teacher,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) teacherService.delTeacher(teacher, id_institute));
}
@ResponseBody
@PostMapping("/teacher")
public Msg addTeacher(
@RequestBody @Validated(Add.class) TeacherWithBLOBs teacher,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) teacherService.addTeacher(teacher, id_institute));
}
@ResponseBody
@PutMapping("/teacher")
public Msg updateTeacher(
@RequestBody @Validated({Update.class}) TeacherWithBLOBs teacher,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) teacherService.updateTeacher(teacher, id_institute));
}
//教師批量教師導(dǎo)入
@PostMapping("/TeacherExcel")
@ResponseBody
public Msg addTeacherExcel(
@RequestParam("excel") MultipartFile excelFile,
@ModelAttribute("id_institute") long id_institute
) throws MyException, IOException {
return excelService.teacherExcelImport(excelFile, id_institute);
}
//教師批量導(dǎo)入模板
@GetMapping("/TeacherExcelDemo")
public void getTeacherExcelDemo(HttpServletResponse response) throws IOException {
excelService.teacherExcelDownload(response);
}
// 學(xué)生管理
@GetMapping("/StudentManagement")
public String student() {
return "admin/BasicInfo/StudentManagement";
}
@ResponseBody
@GetMapping("/students")
public Msg getStudents(
@RequestParam Integer offset,
@RequestParam(required = false) Long classId,
@RequestParam(required = false) Long specialtyId,
@RequestParam(required = false) String keyWord,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
long total = studentService.selectStudentsCount(offset, keyWord, classId, specialtyId, id_institute);
return Msg.success()
.add("students", studentService.selectStudents(offset, keyWord, classId, specialtyId, id_institute))
.add("total", total);
}
@ResponseBody
@DeleteMapping("/student")
public Msg delStudent(
@RequestBody StudentWithBLOBs student,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) studentService.delStudent(student, id_institute));
}
@ResponseBody
@PostMapping("/student")
public Msg addStudent(
@RequestBody @Validated(Add.class) StudentWithBLOBs student,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) studentService.addStudent(student, id_institute));
}
@ResponseBody
@PutMapping("/student")
public Msg updateStudent(
@RequestBody @Validated({Update.class}) StudentWithBLOBs student,
@ModelAttribute("id_institute") long id_institute
) throws MyException {
return Msg.sqlChange((int) studentService.updateStudent(student, id_institute));
}
// 批量導(dǎo)入模板
@GetMapping("/StudentExcelDemo")
public void getStudentExcelDemo(HttpServletResponse response) throws IOException {
excelService.studentExcelDownload(response);
}
//批量學(xué)生導(dǎo)入
@PostMapping("/StudentExcel")
@ResponseBody
public Msg addStudentExcel(
@RequestParam("excel") MultipartFile excelFile,
@ModelAttribute("id_institute") long id_institute
) throws MyException, IOException {
return excelService.studentExcelImport(excelFile, id_institute);
}
// 生成一覽表
//課題一覽表
@GetMapping("/SubjectExcel")
public void getSubjectExcel(
HttpServletResponse response,
HttpServletRequest request,
@ModelAttribute("id_institute") long id_institute) throws IOException {
excelService.subjectExcelDownload(response, request, id_institute);
}
}
以上就是java+SpringBoot設(shè)計(jì)實(shí)現(xiàn)評(píng)教系統(tǒng)的詳細(xì)內(nèi)容,更多關(guān)于java SpringBoot評(píng)教系統(tǒng)的資料請(qǐng)關(guān)注腳本之家其它相關(guān)文章!
- java?Springboot實(shí)現(xiàn)教務(wù)管理系統(tǒng)
- Java+Springboot搭建一個(gè)在線網(wǎng)盤(pán)文件分享系統(tǒng)
- 基于Java?SpringBoot的前后端分離信息管理系統(tǒng)的設(shè)計(jì)和實(shí)現(xiàn)
- 基于java+springboot+mybatis+laiyu實(shí)現(xiàn)學(xué)科競(jìng)賽管理系統(tǒng)
- 基于java SSM springboot實(shí)現(xiàn)抗疫物質(zhì)信息管理系統(tǒng)
- 基于java SSM springboot實(shí)現(xiàn)景區(qū)行李寄存管理系統(tǒng)
- 基于java ssm springboot實(shí)現(xiàn)選課推薦交流平臺(tái)系統(tǒng)
相關(guān)文章
使用logstash同步mysql數(shù)據(jù)到elasticsearch實(shí)現(xiàn)
這篇文章主要為大家介紹了使用logstash同步mysql數(shù)據(jù)到elasticsearch實(shí)現(xiàn)詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-12-12
Javaweb項(xiàng)目session超時(shí)解決方案
這篇文章主要介紹了Javaweb項(xiàng)目session超時(shí)解決方案,關(guān)于解決方案分類比較明確,內(nèi)容詳細(xì),需要的朋友可以參考下。2017-09-09
簡(jiǎn)單聊一聊Java線程池ThreadPoolExecutor
在使用線程池之后,開(kāi)啟線程就變成了在線程池當(dāng)中找到一個(gè)空閑的線程,銷毀線程變成了歸還線程到線程池的過(guò)程,下面這篇文章主要給大家介紹了關(guān)于Java線程池ThreadPoolExecutor的相關(guān)資料,需要的朋友可以參考下2022-06-06
Java通過(guò)MyBatis框架對(duì)MySQL數(shù)據(jù)進(jìn)行增刪查改的基本方法
MyBatis框架由Java的JDBC API進(jìn)一步封裝而來(lái),在操作數(shù)據(jù)庫(kù)方面效果拔群,接下來(lái)我們就一起來(lái)看看Java通過(guò)MyBatis框架對(duì)MySQL數(shù)據(jù)進(jìn)行增刪查改的基本方法:2016-06-06
Spring SpringMVC在啟動(dòng)完成后執(zhí)行方法源碼解析
這篇文章主要介紹了SpringMVC在啟動(dòng)完成后執(zhí)行方法源碼解析,還是非常不錯(cuò)的,在這里分享給大家,需要的朋友可以參考下。2017-09-09
Mybatis參數(shù)(Parameters)傳遞方式
這篇文章主要介紹了Mybatis參數(shù)(Parameters)傳遞方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-12-12

