feat: stu edit photo and gender
This commit is contained in:
parent
9acc5b3d3c
commit
8954d66842
@ -25,10 +25,8 @@ public class StuConsultController {
|
||||
public String consult(HttpServletRequest request, @SessionAttribute Stu stu) {
|
||||
ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid());
|
||||
if (orders != null) {
|
||||
System.out.println(orders);
|
||||
request.setAttribute("Orders", orders);
|
||||
} else {
|
||||
System.out.println("订单空");
|
||||
request.setAttribute("stuConsultMess", "订单为空");
|
||||
}
|
||||
return "/stu/consult";
|
||||
|
@ -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,6 +22,7 @@ public class StuCurrentController {
|
||||
public StuCurrentController(OrderDao orderDao) {
|
||||
this.orderDao = orderDao;
|
||||
}
|
||||
|
||||
@GetMapping("/stu/current")
|
||||
public String current(HttpServletRequest request, @SessionAttribute Stu stu) {
|
||||
ArrayList<Order> orders = orderDao.findByStudent_id(stu.getUserid());
|
||||
@ -33,18 +35,14 @@ public class StuCurrentController {
|
||||
}
|
||||
}
|
||||
if (orders1 != null) {
|
||||
System.out.println(orders1);
|
||||
request.setAttribute("Orders", orders1);
|
||||
} else {
|
||||
System.out.println("订单空");
|
||||
request.setAttribute("stuCurrentMess", "订单为空");
|
||||
}
|
||||
return "/stu/current";
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
@Autowired
|
||||
public StuDataController(StuDao stuDao) {
|
||||
this.stuDao = stuDao;
|
||||
}
|
||||
|
||||
// @RequestMapping(value = "/stu/data")
|
||||
// public String stuData( ) {
|
||||
// return "stu/data";
|
||||
// }
|
||||
@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";
|
||||
}
|
||||
|
||||
@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", "修改成功");
|
||||
|
||||
req.setAttribute("stuEditMess", "修改成功");
|
||||
} else {
|
||||
req.setAttribute("stuMess", "修改失败");
|
||||
req.setAttribute("stuEditMess", "修改失败");
|
||||
}
|
||||
return "stu/data";
|
||||
|
||||
return "/stu/data";
|
||||
}
|
||||
}
|
||||
|
@ -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 +
|
||||
'}';
|
||||
}
|
||||
}
|
@ -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 +
|
||||
|
@ -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;
|
||||
|
@ -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 +
|
||||
|
@ -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<Material> {
|
||||
}
|
@ -17,8 +17,14 @@
|
||||
<div class="dropdown">
|
||||
<a href="#" class="d-flex align-items-center link-body-emphasis text-decoration-none dropdown-toggle"
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<c:if test="${not empty sessionScope.stu.photo}">
|
||||
<img src="${webroot}${sessionScope.stu.photo}" alt="" width="32" height="32"
|
||||
class="rounded-circle me-2">
|
||||
</c:if>
|
||||
<c:if test="${empty sessionScope.stu.photo}">
|
||||
<img src="${webroot}/images/logo.jpg" alt="" width="32" height="32"
|
||||
class="rounded-circle me-2">
|
||||
</c:if>
|
||||
<strong>${sessionScope.stu.username}</strong>
|
||||
</a>
|
||||
<ul class="dropdown-menu text-small shadow">
|
||||
|
@ -21,22 +21,22 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="${webroot}/stu/data.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 个人资料
|
||||
>> 个人资料修改
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="${webroot}/stu/upload.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 上传订单
|
||||
>> 创建维修单
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="${webroot}/stu/current" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 当前订单
|
||||
>> 未完成维修单
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="${webroot}/stu/consult" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 历史订单
|
||||
>> 历史维修单
|
||||
</a>
|
||||
</li>
|
||||
</c:when>
|
||||
@ -110,6 +110,12 @@
|
||||
<a href="${webroot}/" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 主页
|
||||
</a>
|
||||
<a href="${webroot}/worker_login.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 维修人员登录
|
||||
</a>
|
||||
<a href="${webroot}/manage.jsp" class="nav-link link-body-emphasis" aria-current="page">
|
||||
>> 管理员登录
|
||||
</a>
|
||||
</li>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
@ -24,46 +24,43 @@
|
||||
|
||||
<main class="form-signin w-100 m-auto">
|
||||
|
||||
<form action="${webroot}/stu/edit.do" method="post" enctype="multipart/form-data">
|
||||
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||
<h1 class="h3 mb-3 fw-normal">个人资料</h1>
|
||||
<c:if test="${not empty requestScope.stuMess}">
|
||||
<h1 class="h3 mb-3 fw-normal">${title}</h1>
|
||||
|
||||
<c:if test="${not empty requestScope.stuEditMess}">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
${requestScope.stuMess}
|
||||
${requestScope.stuEditMess}
|
||||
</div>
|
||||
</c:if>
|
||||
<div class="form-floating">
|
||||
<form action="stu/data" method="post">
|
||||
<div class="form-floating">
|
||||
<label for="username">Username:</label><br>
|
||||
<input type="text" id="username" name="username" value="${stu.username}"><br><br>
|
||||
|
||||
<div>
|
||||
<label for="formFileLg" class="form-label">头像</label>
|
||||
<input class="form-control form-control-lg" id="formFileLg" type="file" name="myfile" required>
|
||||
</div>
|
||||
<label for="gender">Gender:</label><br>
|
||||
<div class="form-floating">
|
||||
<select id="gender" name="gender" >
|
||||
<br/>
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text">性别</span>
|
||||
<select class="form-select" name="gender" id="gender" required>
|
||||
<c:choose>
|
||||
<c:when test="${stu.gender == 'male'}">
|
||||
<option value="male" selected>Male</option>
|
||||
<option value="female">Female</option>
|
||||
<option value="male" selected='selected'>男</option>
|
||||
<option value="female">女</option>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<option value="male">Male</option>
|
||||
<option value="female" selected>Female</option>
|
||||
<option value="male">男</option>
|
||||
<option value="female" selected='selected'>女</option>
|
||||
</c:otherwise>
|
||||
|
||||
|
||||
</c:choose>
|
||||
|
||||
</select><br><br>
|
||||
</select>
|
||||
</div>
|
||||
<button class="btn btn-primary w-100 py-2" type="submit" id="submit">提交</button>
|
||||
|
||||
<br/>
|
||||
<input class="btn btn-primary w-100 py-2" type="submit" id="submit">
|
||||
<br/><br/>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<img src="${webroot}/upload/${sessionScope.stu.userNo}/photo.jpg" style="height: 150px; width: 150px"
|
||||
class="img-thumbnail">
|
||||
</main>
|
||||
|
||||
</main>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
0
src/main/webapp/upload/.gitkeep
Normal file
0
src/main/webapp/upload/.gitkeep
Normal file
@ -18,6 +18,7 @@
|
||||
<title>${title}</title>
|
||||
<link rel="stylesheet" href="${webroot}/styles/bootstrap.min.css" crossorigin="anonymous">
|
||||
<script src="${webroot}/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="${webroot}/js/record.js"></script>
|
||||
<link rel="stylesheet" href="${webroot}/styles/sidebar.css" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="${webroot}/styles/index.css" crossorigin="anonymous">
|
||||
</head>
|
||||
|
@ -10,7 +10,7 @@
|
||||
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
|
||||
<%@ page isELIgnored="false" %>
|
||||
<c:set var="title" value="worker_Login"/>
|
||||
<c:set var="title" value="维修人员登录"/>
|
||||
<c:set var="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
@ -42,7 +42,7 @@
|
||||
</div>
|
||||
<form action="${webroot}/worker/Login.do" method="post" >
|
||||
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||
<h1 class="h3 mb-3 fw-normal">请先登录</h1>
|
||||
<h1 class="h3 mb-3 fw-normal">维修人员登录</h1>
|
||||
|
||||
<c:if test="${not empty requestScope.workerLoginMess}">
|
||||
<div class="alert alert-warning" role="alert">
|
||||
|
Loading…
Reference in New Issue
Block a user