package com.ilovecl.demo.web;
import com.ilovecl.demo._const.RepairEnumCN;
import com.ilovecl.demo._const.StudentConst;
import com.ilovecl.demo._const.UrgentRepairEnum;
import com.ilovecl.demo.dto.LoginResult;
import com.ilovecl.demo.dto.ModifyRepairResult;
import com.ilovecl.demo.dto.StudentResult;
import com.ilovecl.demo.dto.StudentUrgentResult;
import com.ilovecl.demo.entity.Repair;
import com.ilovecl.demo.entity.RepairInfoVo;
import com.ilovecl.demo.entity.Student;
import com.ilovecl.demo.entity.UrgentRepair;
import com.ilovecl.demo.service.RepairService;
import com.ilovecl.demo.service.StudentService;
import com.ilovecl.demo.service.UrgentRepairService;
import com.ilovecl.demo.util.MD5;
import com.ilovecl.demo.util.Spider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
/**
* 用户的web层
*
*/
@Controller
@CrossOrigin(origins = {"http://localhost:8080", "null"})
@RequestMapping("/student")
public class StudentController {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
@Resource
private StudentService studentService;
@Resource
private RepairService repairService;
@Resource
private UrgentRepairService urgentRepairService;
@RequestMapping(value = "/introduce", method = RequestMethod.GET)
public String index() {
return "student/introduce";
}
/**
* 登录的GET方法
*
* @return
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login() {
return "student/login";
}
/**
* 登录的POST方法
*
* @param id
* @param password
* @param httpSession
* @return
*/
@RequestMapping(value = "/login", method = RequestMethod.POST)
public
@ResponseBody
LoginResult login(String id, String password, HttpSession httpSession, HttpServletResponse httpServletResponse) {
LoginResult loginResult=null;
String stuName = null;
Student student = studentService.getStudentById(id);
Spider spider = new Spider();
try {
//调用service将数据存入数据库中
if(student==null){
stuName = spider.getStudentName(id, password);
student = new Student(id, stuName, password);
System.out.println(stuName);
studentService.addStudent(id, stuName, password, 0, "", "");
loginResult = new LoginResult(true);
}else{
stuName = student.getName();
// 密码正确
if (student.getPassword().equals(password)) {
loginResult = new LoginResult(true);
} else {
loginResult = new LoginResult(false);
loginResult.setReason("invalid user");
}
}
} catch (IOException e) {
e.printStackTrace();
}
if(loginResult.isSuccess()){
// 登录成功后,为该学生生成session
httpSession.setAttribute(StudentConst.STUDENT_ID, id);
httpServletResponse.addCookie(new Cookie(StudentConst.STUDENT_ID, id));
System.out.println("StudentName:"+StudentConst.STUDENT_NAME);
httpServletResponse.addCookie(new Cookie(StudentConst.STUDENT_NAME, stuName));
}
logger.info("***************************************************************************");
logger.info("登录: " + String.valueOf(loginResult.isSuccess()) + " id : " + id + " password : " + password);
logger.info("***************************************************************************");
return loginResult;
}
/**
* 退出的控制
*
* @param httpSession
* @return
*/
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout(HttpSession httpSession) {
httpSession.removeAttribute(StudentConst.STUDENT_EMAIL);
return "redirect:/student/login";
}
/**
* 提交报修单的POST方法
*
* @param model
* @return
*/
@RequestMapping(value = "/commit", method = RequestMethod.GET)
public String commit(Model model) {
return "/student/commit";
}
@RequestMapping(value = "/commit", method = RequestMethod.POST)
public String commit(@RequestParam("detail") String detail, @RequestParam("place") String place,
@RequestParam("file") MultipartFile file, HttpServletRequest httpServletRequest) {
String id = httpServletRequest.getSession().getAttribute(StudentConst.STUDENT_ID).toString();
Student student = studentService.getStudentById(id);
String picMD5 = "";
logger.info(detail);
logger.info(place);
logger.info(picMD5);
try {
logger.info(file.getInputStream().toString());
} catch (IOException e) {
e.printStackTrace();
}
if (file != null) {
try {
picMD5 = MD5.getMD5(id + String.valueOf(System.currentTimeMillis()) + file.getOriginalFilename());
} catch (Exception e) {
e.printStackTrace();
}
// 往数据库中插入维修单记录
repairService.submitRepair(detail, place, picMD5, student.getId());
// 保存现场照片
String path = httpServletRequest.getSession().getServletContext().getRealPath("/");
System.out.println("图片路径:" + path);
String fileName = picMD5;
File targetFile = new File(path, fileName);
try {
InputStream inputStream = file.getInputStream();
OutputStream outputStream = new FileOutputStream(targetFile);
byte[] buffer = new byte[2048];
int len = 0;
while ((len = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, len);
}
inputStream.close();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
} else {
// 往数据库中插入维修单记录
repairService.submitRepair(detail, place, picMD5, student.getId());
}
return "redirect:/student/dashboard";
}
/**
* 获取显示的主页面
*
* @param model
* @return
*/
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
public String board(Model model, HttpServletRequest httpServletRequest) {
String id = httpServletRequest.getSession().getAttribute(StudentConst.STUDENT_ID).toString();
List<Repair> repairs = repairService.getRepqirByStudentId(id);
List<RepairInfoVo> repairInfoVos = new ArrayList<>();
for(Repair repair: repairs){
repair.setPicMD5("/"+repair.getPicMD5());
RepairInfoVo repairInfoVo = new RepairInfoVo(repair);
repairInfoVo.setStatesInfo(RepairEnumCN.stateOf(repair.getStatus()).getStateInfo());
repairInfoVos.add(repairInfoVo);
}
model.addAttribute("repairInfoVos", repairInfoVos);
return "/student/dashboard";
}
/**
* 报修单详情
*
* @param repairId
* @param model
* @return
*/
@RequestMapping(value = "/repair/{repairId}/detail", method = RequestMethod.GET)
public String detail(@PathVariable("repairId
没有合适的资源?快使用搜索试试~ 我知道了~
基于SSM框架+Mysql构建的校园报修系统项目.zip
共384个文件
gif:75个
java:49个
js:49个
0 下载量 198 浏览量
2023-09-04
14:57:46
上传
评论
收藏 9.05MB ZIP 举报
温馨提示
项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。项目真实可靠,源码都经测试过,能跑通,可用作本科毕业设计经测试过,请放心下载使用。
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM框架+Mysql构建的校园报修系统项目.zip (384个子文件)
2d35e0b5ee49634c0d9fa483ba2010da 528KB
34981b9d8fe9a43af5c78bd924398d02 0B
34a19f5ef84c7f02eeabe1754a4f9b6b 0B
389de63cf22d625a23fa38f31466230e 0B
4729731cc23c521b5285c374d2c402f8 0B
4a8bf9fe989578891e887affef3af719 0B
4be291791881f75b31f2a22c3fd70e02 0B
592a9cf91fbf4effe3ed4cd6699f6893 528KB
65f439ae2cae3985445933cd629f64cf 528KB
7884e23b1d7465214e507aa908b6d432 528KB
80349df4993652a94ef18ccde6c8bb65 57KB
83e00e4e1f68abdd21d4150f2bdd912a 57KB
84df5cf96a80016e074dda01e05bd2f5 0B
85df2afa6e8920d7bf37c277796cab90 57KB
872f42fad3648bd537ef34e7a85697d8 227KB
88adb4847a4bb1a06be4fc898b107f28 0B
88cc13cd183f83baa999aa0a6c8df6c1 0B
90f8ca577376b47cc8ba2fb3f8add0d 57KB
92834ef30242b840b4ca5f2a4ba16a4 0B
9a8657cd57eec778d962a2802ca8c7c3 1KB
a13e3e478141f4f06fb6629ee5846122 0B
a6490d312669d6f057d118ebbe65ae02 0B
afa71d8a0b810029f4852723021b093f 0B
b714dc5976a769000c35507e0c327e98 424KB
c890f6c515173e467eb9a043aca466d4 57KB
mvnw.cmd 5KB
bootstrap.css 138KB
bootstrap.css 138KB
bootstrap.min.css 115KB
bootstrap.min.css 115KB
layui.css 68KB
layui.css 68KB
font-awesome.css 28KB
font-awesome.css 28KB
font-awesome.min.css 23KB
font-awesome.min.css 23KB
bootstrap-theme.css 22KB
bootstrap-theme.css 22KB
bootstrap-theme.min.css 19KB
bootstrap-theme.min.css 19KB
layer.css 14KB
layui.mobile.css 10KB
laydate.css 7KB
signup-varab.0c7cffb4.css 6KB
login-varab.30c2bb34.css 6KB
login-varab.30c2bb34.css 6KB
style.css 3KB
style.css 3KB
form-elements.css 2KB
form-elements.css 2KB
dashboard.css 2KB
code.css 1KB
signin.css 832B
ie10-viewport-bug-workaround.css 523B
jumbotron.css 131B
adminDecoration.css 61B
d2bfb14f2d089a9e652990e129e813b 57KB
d602f541df4030cc0cff0551530edfb7 0B
fontawesome-webfont.eot 59KB
fontawesome-webfont.eot 59KB
iconfont.eot 40KB
glyphicons-halflings-regular.eot 20KB
glyphicons-halflings-regular.eot 20KB
f11727968a2ce6cca46878488c31c30 0B
fb46a902c5045885114581350f994934 424KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
共 384 条
- 1
- 2
- 3
- 4
资源评论
c++服务器开发
- 粉丝: 3045
- 资源: 4463
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功