diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java index 96fa96c..ec094d8 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuConsultController.java @@ -24,12 +24,10 @@ public class StuConsultController { @RequestMapping("/stu/consult") public String consult(HttpServletRequest request, @SessionAttribute Stu stu) { ArrayList orders = orderDao.findByStudent_id(stu.getUserid()); - if(orders!=null) { - System.out.println(orders); + if (orders != null) { request.setAttribute("Orders", orders); - }else{ - System.out.println("订单空"); - request.setAttribute("stuConsultMess","订单为空"); + } else { + request.setAttribute("stuConsultMess", "订单为空"); } return "/stu/consult"; diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java index e06f8d5..8191fba 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuCurrentController.java @@ -7,7 +7,8 @@ import cn.edu.cqwu.repair.entity.OrderStatus; import cn.edu.cqwu.repair.entity.Stu; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.SessionAttribute; import javax.servlet.http.HttpServletRequest; import java.util.ArrayList; @@ -21,30 +22,27 @@ public class StuCurrentController { public StuCurrentController(OrderDao orderDao) { this.orderDao = orderDao; } + @GetMapping("/stu/current") public String current(HttpServletRequest request, @SessionAttribute Stu stu) { ArrayList orders = orderDao.findByStudent_id(stu.getUserid()); ArrayList orders1 = new ArrayList<>(); for (Order order : orders) { - if(order.getOrderStatus()== OrderStatus.UNASSIGNED.value|| order.getOrderStatus()==OrderStatus.PROGRESS.value){ + if (order.getOrderStatus() == OrderStatus.UNASSIGNED.value || order.getOrderStatus() == OrderStatus.PROGRESS.value) { orders1.add(order); } } - if(orders1!=null) { - System.out.println(orders1); + if (orders1 != null) { request.setAttribute("Orders", orders1); - }else{ - System.out.println("订单空"); - request.setAttribute("stuCurrentMess","订单为空"); + } else { + request.setAttribute("stuCurrentMess", "订单为空"); } return "/stu/current"; - } - } diff --git a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java index 21a3c5d..f017922 100644 --- a/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java +++ b/src/main/java/cn/edu/cqwu/repair/controller/stu/StuDataController.java @@ -2,54 +2,54 @@ package cn.edu.cqwu.repair.controller.stu; import cn.edu.cqwu.repair.dao.StuDao; import cn.edu.cqwu.repair.entity.Stu; -import cn.edu.cqwu.repair.entity.mapper.StuMapper; -import com.mybatisflex.core.activerecord.Model; -import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpRequest; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.Mapping; -import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.SessionAttribute; +import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; +import java.io.File; +/** + * @author xtaod + */ @Controller - public class StuDataController { -StuDao stuDao; + StuDao stuDao; + @Autowired public StuDataController(StuDao stuDao) { this.stuDao = stuDao; } -// @RequestMapping(value = "/stu/data") -// public String stuData( ) { -// return "stu/data"; -// } - - @PostMapping("stu/data") - public String stuData(@Param("username")String username, @Param("gender")String gender, HttpServletRequest req){ - Stu stu = new Stu(); - Stu stu1 = (Stu)req.getSession().getAttribute("stu"); - - stu.setUsername(username); - stu.setGender(gender); - stu.setPassword(stu1.getPassword()); - stu.setUserid(stu1.getUserid()); - stu.setRegip(stu1.getRegip()); - stu.setStatus(stu1.getStatus()); - stu.setRegtime(stu1.getRegtime()); - stu.setUpdateTime(stu1.getUpdateTime()); - stu.setUserNo(stu1.getUserNo()); - int update = stuDao.update(stu); - if(update>0){ - req.setAttribute("stuMess", "修改成功"); - - }else{ - req.setAttribute("stuMess", "修改失败"); + @RequestMapping("/stu/edit.do") + public String stuData(@SessionAttribute Stu stu, MultipartFile myfile, String gender, HttpServletRequest req) { + String path = req.getServletContext().getRealPath("/upload/" + stu.getUserNo() + "/"); + File file = new File(path); + if (!file.exists()) { + file.mkdirs(); + } + String filename = myfile.getOriginalFilename(); + if (filename != null && (filename.endsWith(".jpg") || filename.endsWith(".JPG"))) { + try { + myfile.transferTo(new File(path + "/photo.jpg")); + } catch (Exception e) { + e.printStackTrace(); + } + stu.setPhoto("/upload/" + stu.getUserNo() + "/photo.jpg"); + } else { + req.setAttribute("stuEditMess", "图片格式不正确"); + return "/stu/data"; } - return "stu/data"; + stu.setGender(gender); + int update = stuDao.update(stu); + if (update > 0) { + req.setAttribute("stuEditMess", "修改成功"); + } else { + req.setAttribute("stuEditMess", "修改失败"); + } + return "/stu/data"; } } diff --git a/src/main/java/cn/edu/cqwu/repair/entity/Material.java b/src/main/java/cn/edu/cqwu/repair/entity/Material.java deleted file mode 100644 index e652d8a..0000000 --- a/src/main/java/cn/edu/cqwu/repair/entity/Material.java +++ /dev/null @@ -1,80 +0,0 @@ -package cn.edu.cqwu.repair.entity; - -import com.mybatisflex.annotation.Column; -import com.mybatisflex.annotation.Id; -import com.mybatisflex.annotation.KeyType; -import com.mybatisflex.annotation.Table; - -import java.sql.Timestamp; - -/** - * @author xtaod - */ -@Table(value = "material", dataSource = "repair") -public class Material { - // 材料 id - @Id(keyType = KeyType.Auto) - private int materialId; - // 材料名称 - private String materialName; - // 材料数量 - private int materialNum; - - // 创建时间 - @Column(onInsertValue = "now()") - private Timestamp createTime; - // 更新时间 - @Column(onInsertValue = "now()", onUpdateValue = "now()") - private Timestamp updateTime; - - public int getMaterialId() { - return materialId; - } - - public void setMaterialId(int materialId) { - this.materialId = materialId; - } - - public String getMaterialName() { - return materialName; - } - - public void setMaterialName(String materialName) { - this.materialName = materialName; - } - - public int getMaterialNum() { - return materialNum; - } - - public void setMaterialNum(int materialNum) { - this.materialNum = materialNum; - } - - public Timestamp getCreateTime() { - return createTime; - } - - public void setCreateTime(Timestamp createTime) { - this.createTime = createTime; - } - - public Timestamp getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(Timestamp updateTime) { - this.updateTime = updateTime; - } - - @Override - public String toString() { - return "Material{" + - "materialId=" + materialId + - ", materialName='" + materialName + '\'' + - ", materialNum=" + materialNum + - ", createTime=" + createTime + - ", updateTime=" + updateTime + - '}'; - } -} diff --git a/src/main/java/cn/edu/cqwu/repair/entity/Order.java b/src/main/java/cn/edu/cqwu/repair/entity/Order.java index 4e50db6..4751346 100644 --- a/src/main/java/cn/edu/cqwu/repair/entity/Order.java +++ b/src/main/java/cn/edu/cqwu/repair/entity/Order.java @@ -33,7 +33,9 @@ public class Order { // 故障图片 private String faultImg; - // 订单状态 0 表示未分配 1 表示分配、进行中 2 表示已完成 + // 评分 + private int score; + // 订单状态 0 表示未分配 1 表示分配、进行中 2 表示已完成,未评价 3 表示已评价,已完成 private int orderStatus; // 订单创建时间 @Column(onInsertValue = "now()") @@ -113,6 +115,14 @@ public class Order { this.faultImg = faultImg; } + public int getScore() { + return score; + } + + public void setScore(int score) { + this.score = score; + } + public int getOrderStatus() { return orderStatus; } @@ -149,6 +159,7 @@ public class Order { ", address='" + address + '\'' + ", faultDesc='" + faultDesc + '\'' + ", faultImg='" + faultImg + '\'' + + ", score=" + score + ", orderStatus=" + orderStatus + ", createTime=" + createTime + ", finishTime=" + finishTime + diff --git a/src/main/java/cn/edu/cqwu/repair/entity/OrderStatus.java b/src/main/java/cn/edu/cqwu/repair/entity/OrderStatus.java index 7696706..cb13786 100644 --- a/src/main/java/cn/edu/cqwu/repair/entity/OrderStatus.java +++ b/src/main/java/cn/edu/cqwu/repair/entity/OrderStatus.java @@ -1,11 +1,16 @@ package cn.edu.cqwu.repair.entity; +/** + * @author wobeitaoleshigexuruo + */ + public enum OrderStatus { UNASSIGNED(0), PROGRESS(1), - FINISHED(2); + FINISHED(2), + SCORED(3); - public int value; + public final int value; OrderStatus(int value) { this.value = value; diff --git a/src/main/java/cn/edu/cqwu/repair/entity/Stu.java b/src/main/java/cn/edu/cqwu/repair/entity/Stu.java index 08308fb..1647ad3 100644 --- a/src/main/java/cn/edu/cqwu/repair/entity/Stu.java +++ b/src/main/java/cn/edu/cqwu/repair/entity/Stu.java @@ -19,6 +19,8 @@ public class Stu { private String userNo; //学工号 private String username; //用户名 private String password; //密码 + // 头像 + private String photo; // 性别 private String gender; private String regip; //注册IP @@ -61,6 +63,14 @@ public class Stu { this.password = password; } + public String getPhoto() { + return photo; + } + + public void setPhoto(String photo) { + this.photo = photo; + } + public String getGender() { return gender; } @@ -108,6 +118,7 @@ public class Stu { ", userNo='" + userNo + '\'' + ", username='" + username + '\'' + ", password='" + password + '\'' + + ", photo='" + photo + '\'' + ", gender='" + gender + '\'' + ", regip='" + regip + '\'' + ", status=" + status + diff --git a/src/main/java/cn/edu/cqwu/repair/entity/mapper/MaterialMapper.java b/src/main/java/cn/edu/cqwu/repair/entity/mapper/MaterialMapper.java deleted file mode 100644 index 5f3a810..0000000 --- a/src/main/java/cn/edu/cqwu/repair/entity/mapper/MaterialMapper.java +++ /dev/null @@ -1,7 +0,0 @@ -package cn.edu.cqwu.repair.entity.mapper; - -import cn.edu.cqwu.repair.entity.Material; -import com.mybatisflex.core.BaseMapper; - -public interface MaterialMapper extends BaseMapper { -} diff --git a/src/main/webapp/includes/dropdown.jsp b/src/main/webapp/includes/dropdown.jsp index 86782b2..669cd82 100644 --- a/src/main/webapp/includes/dropdown.jsp +++ b/src/main/webapp/includes/dropdown.jsp @@ -17,8 +17,14 @@
-

请先登录

+

维修人员登录