fix: stu current comment

This commit is contained in:
xtaodada 2024-06-10 16:06:04 +08:00
parent 37e539727d
commit c5c41d51ec
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
8 changed files with 44 additions and 49 deletions

View File

@ -5,13 +5,10 @@ import cn.edu.cqwu.repair.dao.StuDao;
import cn.edu.cqwu.repair.entity.Order;
import cn.edu.cqwu.repair.entity.OrderStatus;
import cn.edu.cqwu.repair.entity.Stu;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttribute;
import javax.servlet.http.HttpServletRequest;
@ -23,9 +20,9 @@ public class StuCommentsController {
OrderDao orderDao;
@Autowired
public StuCommentsController(StuDao stuDao,OrderDao orderDao) {
public StuCommentsController(StuDao stuDao, OrderDao orderDao) {
this.stuDao = stuDao;
this.orderDao = orderDao;
this.orderDao = orderDao;
}
@RequestMapping("/stu/comment")
@ -35,14 +32,14 @@ public class StuCommentsController {
}
@RequestMapping("/stu/comment.do")
public String stuComment(int rating, int id, HttpServletRequest request,@SessionAttribute Stu stu){
public String stuComment(int rating, int id, HttpServletRequest request, @SessionAttribute Stu stu) {
Order byOrderId = orderDao.findByOrderId(id);
byOrderId.setOrderStatus(OrderStatus.SCORED.value);
byOrderId.setScore(rating);
int update = orderDao.update(byOrderId);
if(update>0){
request.setAttribute("stuCurrentMess","评价成功");
if (update > 0) {
request.setAttribute("stuCurrentMess", "评价成功");
ArrayList<Order> orders = orderDao.findCurrent(stu.getUserid());
if (orders != null) {
request.setAttribute("Orders", orders);
@ -51,11 +48,8 @@ public class StuCommentsController {
}
return "/stu/current";
}
request.setAttribute("stuUpdateScoreMess","评价失败");
request.setAttribute("stuUpdateScoreMess", "评价失败");
return "/stu/updateScore";
}
}
}

View File

@ -3,19 +3,10 @@ package cn.edu.cqwu.repair.controller.stu;
import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.dao.StuDao;
import cn.edu.cqwu.repair.entity.Order;
import cn.edu.cqwu.repair.entity.OrderStatus;
import cn.edu.cqwu.repair.entity.Stu;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.SessionAttribute;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
@Controller
public class StuDetailController {
@ -23,24 +14,19 @@ public class StuDetailController {
OrderDao orderDao;
@Autowired
public StuDetailController(StuDao stuDao,OrderDao orderDao) {
public StuDetailController(StuDao stuDao, OrderDao orderDao) {
this.stuDao = stuDao;
this.orderDao = orderDao;
this.orderDao = orderDao;
}
@RequestMapping("/stu/detail")
public String stuComment1(int id,Model model) {
@RequestMapping("/stu/detail.do")
public String stuComment1(int id, Model model) {
Order byOrderId = orderDao.findByOrderId(id);
if(byOrderId!=null){
model.addAttribute("detail", byOrderId);
model.addAttribute("stuDetailMess", "成功");
if (byOrderId != null) {
model.addAttribute("detail", byOrderId);
return "/stu/detail";
}
model.addAttribute("stuDetailMess", "失败");
return "/stu/current";
}
}
}

View File

@ -29,7 +29,7 @@ public class StuLoginController {
@PostMapping("/login.do")
public String login(String username, String password, String code, Model model, HttpSession session,
HttpServletRequest request){
HttpServletRequest request) {
String mess = Verify.validateForm(username, password, code);
if (!mess.isEmpty()) {
model.addAttribute("stuLoginMess", mess);

View File

@ -16,24 +16,23 @@ import javax.servlet.http.HttpSession;
import java.util.List;
/**
* @author sobear
*/
@Controller
public class WorkerEvalueReportController extends HttpServlet{
public class WorkerEvalueReportController extends HttpServlet {
private final OrderDao orderDao;
private final WorkerDao workerDao;
@Autowired
public WorkerEvalueReportController(OrderDao orderDao,WorkerDao workerDao){
public WorkerEvalueReportController(OrderDao orderDao, WorkerDao workerDao) {
this.orderDao = orderDao;
this.workerDao = workerDao;
}
@RequestMapping ("/worker/EvalueReport.do")
@RequestMapping("/worker/EvalueReport.do")
public String getScore(Model model, HttpSession session,
HttpServletRequest request){
HttpServletRequest request) {
// 获取Session对象
session = request.getSession();
@ -61,8 +60,8 @@ public class WorkerEvalueReportController extends HttpServlet{
}
double numAverage = (double) totalScore / numTotal; // 平均数
ScoreDates scDatas = new ScoreDates(num12,num3,num45,numTotal,totalScore,numAverage);
model.addAttribute("scDatas",scDatas);
ScoreDates scDatas = new ScoreDates(num12, num3, num45, numTotal, totalScore, numAverage);
model.addAttribute("scDatas", scDatas);
return "/worker/worker_evalue_report";
}

View File

@ -1,7 +1,6 @@
package cn.edu.cqwu.repair.controller.worker;
import cn.edu.cqwu.repair.dao.OrderDao;
import cn.edu.cqwu.repair.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
@ -10,14 +9,15 @@ import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;
/**
* @author sobear
*/
@Controller
public class WorkerOrderStatusController {
private OrderDao orderDao;
OrderService orderService;
@Autowired
public WorkerOrderStatusController(OrderDao orderDao, OrderService orderService) {
this.orderDao = orderDao;
public WorkerOrderStatusController(OrderService orderService) {
this.orderService = orderService;
}
@ -25,7 +25,7 @@ public class WorkerOrderStatusController {
@RequestMapping("/worker/updateOrderStatus.do")
public String updateOrderStatus(HttpServletRequest request, Model model) {
int orderId = Integer.parseInt(request.getParameter("orderId"));
if (orderDao.statusModify(orderId) != 0) {
if (orderService.markOrderOk(orderId) != 0) {
model.addAttribute("workerListStatusMes", "* 状态更新成功!");
orderService.submitWorkers();
} else {

View File

@ -10,4 +10,5 @@ public interface OrderService {
void submitWorkers();
int modifyOrderStatus(int orderId, int workerId);
int modifyOrderStatus(Order order, Worker worker);
int markOrderOk(int orderId);
}

View File

@ -81,4 +81,17 @@ public class OrderServiceImpl implements OrderService {
}
System.out.println("[submitWorkers] end");
}
@Override
public int markOrderOk(int orderId) {
Order order = orderDao.findByOrderId(orderId);
Worker worker = workerDao.findByUserId(order.getWorkerId());
if (worker != null) {
worker.setOrderStatus(WorkerStatus.FREE.value);
order.setOrderStatus(OrderStatus.FINISHED.value);
workerDao.update(worker);
return orderDao.update(order);
}
return 0;
}
}

View File

@ -78,8 +78,10 @@
</c:choose>
</td>
<td>
<a href="${webroot}/stu/detail?id=${repairOrder.orderId}">详情</a>
<a href="${webroot}/stu/comment?id=${repairOrder.orderId}">评价</a>
<a href="${webroot}/stu/detail.do?id=${repairOrder.orderId}">详情</a>
<c:if test="${repairOrder.orderStatus==2}">
<a href="${webroot}/stu/comment?id=${repairOrder.orderId}">评价</a>
</c:if>
</td>
</tr>
</c:forEach>