feat: message service
This commit is contained in:
parent
c5c41d51ec
commit
3ac281a2d7
@ -1,25 +0,0 @@
|
||||
package cn.edu.cqwu.repair.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.StuDao;
|
||||
import cn.edu.cqwu.repair.service.OrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.CookieValue;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
@Controller
|
||||
public class TestController {
|
||||
@Autowired
|
||||
OrderService orderService;
|
||||
|
||||
@RequestMapping("/index")
|
||||
public String index() {
|
||||
orderService.submitWorkers();
|
||||
return "index";
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@ package cn.edu.cqwu.repair.controller.admin;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.AdminUser;
|
||||
import cn.edu.cqwu.repair.service.AdminUserService;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.service.RecordService;
|
||||
import cn.edu.cqwu.repair.util.Encrypt;
|
||||
import cn.edu.cqwu.repair.util.Verify;
|
||||
@ -20,11 +21,13 @@ import javax.servlet.http.HttpSession;
|
||||
public class AdminLoginController {
|
||||
private final AdminUserService adminUserService;
|
||||
private final RecordService recordService;
|
||||
private final MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public AdminLoginController(AdminUserService adminUserService, RecordService recordService) {
|
||||
public AdminLoginController(AdminUserService adminUserService, RecordService recordService, MessageService messageService) {
|
||||
this.adminUserService = adminUserService;
|
||||
this.recordService = recordService;
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@RequestMapping("/adminLogin.do")
|
||||
@ -48,6 +51,7 @@ public class AdminLoginController {
|
||||
}
|
||||
if (recordService.add(user, request.getRemoteAddr()) != 0) {
|
||||
session.setAttribute("adminUser", user);
|
||||
messageService.updateSessionAdmin(session, user.getAdminId());
|
||||
return "redirect:/admin/state.jsp";
|
||||
} else {
|
||||
model.addAttribute("adminLoginMess", "* 登录异常!");
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.edu.cqwu.repair.controller.admin;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.AdminUser;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttribute;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Controller
|
||||
public class AdminMessageController {
|
||||
private final MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public AdminMessageController(MessageService messageService) {
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/message.do")
|
||||
public String adminRecord(
|
||||
@SessionAttribute AdminUser adminUser, Model model, HttpServletRequest request, HttpSession session) {
|
||||
String pageNoS = request.getParameter("pageNo");
|
||||
int pageNo = 1;
|
||||
try {
|
||||
pageNo = Integer.parseInt(pageNoS);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
PageModel pm = messageService.query(
|
||||
0, 0, adminUser.getAdminId(), 10, pageNo
|
||||
);
|
||||
pm.setPageNav("message.do");
|
||||
model.addAttribute("pm", pm);
|
||||
messageService.updateSessionAdmin(session, adminUser.getAdminId());
|
||||
return "/admin/message";
|
||||
}
|
||||
|
||||
@RequestMapping("/admin/message/read.do")
|
||||
public String read(@SessionAttribute AdminUser adminUser, int messageId, HttpSession session) {
|
||||
messageService.readAdminMessage(adminUser.getAdminId(), messageId);
|
||||
messageService.updateSessionAdmin(session, adminUser.getAdminId());
|
||||
return "redirect:/admin/message.do";
|
||||
}
|
||||
}
|
@ -48,6 +48,7 @@ public class AdminOrderController {
|
||||
@RequestMapping("/admin/order_manage/delete.do")
|
||||
public String delete(int id, Model model) {
|
||||
if (orderDao.delete(id) != 0) {
|
||||
|
||||
model.addAttribute("orderMess", "* 订单 " + id + " 已删除!");
|
||||
} else {
|
||||
model.addAttribute("orderMess", "* 订单 " + id + " 删除失败!");
|
||||
|
@ -2,9 +2,11 @@ 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.MessageContent;
|
||||
import cn.edu.cqwu.repair.entity.Order;
|
||||
import cn.edu.cqwu.repair.entity.OrderStatus;
|
||||
import cn.edu.cqwu.repair.entity.Stu;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -18,11 +20,13 @@ import java.util.ArrayList;
|
||||
public class StuCommentsController {
|
||||
StuDao stuDao;
|
||||
OrderDao orderDao;
|
||||
MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public StuCommentsController(StuDao stuDao, OrderDao orderDao) {
|
||||
public StuCommentsController(StuDao stuDao, OrderDao orderDao, MessageService messageService) {
|
||||
this.stuDao = stuDao;
|
||||
this.orderDao = orderDao;
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@RequestMapping("/stu/comment")
|
||||
@ -34,12 +38,15 @@ public class StuCommentsController {
|
||||
@RequestMapping("/stu/comment.do")
|
||||
public String stuComment(int rating, int id, HttpServletRequest request, @SessionAttribute Stu stu) {
|
||||
Order byOrderId = orderDao.findByOrderId(id);
|
||||
|
||||
if (byOrderId == null || byOrderId.getOrderStatus() != OrderStatus.FINISHED.value) {
|
||||
return "redirect:/stu/current.do";
|
||||
}
|
||||
byOrderId.setOrderStatus(OrderStatus.SCORED.value);
|
||||
byOrderId.setScore(rating);
|
||||
int update = orderDao.update(byOrderId);
|
||||
if (update > 0) {
|
||||
request.setAttribute("stuCurrentMess", "评价成功");
|
||||
messageService.addWorkerMessage(byOrderId.getWorkerId(), MessageContent.NewScore.value);
|
||||
ArrayList<Order> orders = orderDao.findCurrent(stu.getUserid());
|
||||
if (orders != null) {
|
||||
request.setAttribute("Orders", orders);
|
||||
|
@ -2,6 +2,7 @@ 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.service.MessageService;
|
||||
import cn.edu.cqwu.repair.service.RecordService;
|
||||
import cn.edu.cqwu.repair.util.Encrypt;
|
||||
import cn.edu.cqwu.repair.util.Verify;
|
||||
@ -20,11 +21,13 @@ import javax.servlet.http.HttpSession;
|
||||
public class StuLoginController {
|
||||
StuDao stuDao;
|
||||
RecordService recordService;
|
||||
private final MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public StuLoginController(StuDao stuDao, RecordService recordService) {
|
||||
public StuLoginController(StuDao stuDao, RecordService recordService, MessageService messageService) {
|
||||
this.stuDao = stuDao;
|
||||
this.recordService = recordService;
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@PostMapping("/login.do")
|
||||
@ -46,6 +49,7 @@ public class StuLoginController {
|
||||
}
|
||||
if (recordService.add(user, request.getRemoteAddr()) != 0) {
|
||||
session.setAttribute("stu", user);
|
||||
messageService.updateSessionStudent(session, user.getUserid());
|
||||
return "redirect:/stu/main.jsp";
|
||||
} else {
|
||||
model.addAttribute("stuLoginMess", "* 登录异常!");
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.edu.cqwu.repair.controller.stu;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.Stu;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttribute;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Controller
|
||||
public class StuMessageController {
|
||||
private final MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public StuMessageController(MessageService messageService) {
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@RequestMapping("/stu/message.do")
|
||||
public String adminRecord(
|
||||
@SessionAttribute Stu stu, Model model, HttpServletRequest request, HttpSession session) {
|
||||
String pageNoS = request.getParameter("pageNo");
|
||||
int pageNo = 1;
|
||||
try {
|
||||
pageNo = Integer.parseInt(pageNoS);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
PageModel pm = messageService.query(
|
||||
stu.getUserid(), 0, 0, 10, pageNo
|
||||
);
|
||||
pm.setPageNav("message.do");
|
||||
model.addAttribute("pm", pm);
|
||||
messageService.updateSessionStudent(session, stu.getUserid());
|
||||
return "/stu/message";
|
||||
}
|
||||
|
||||
@RequestMapping("/stu/message/read.do")
|
||||
public String read(@SessionAttribute Stu stu, int messageId, HttpSession session) {
|
||||
messageService.readUserMessage(stu.getUserid(), messageId);
|
||||
messageService.updateSessionStudent(session, stu.getUserid());
|
||||
return "redirect:/stu/message.do";
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package cn.edu.cqwu.repair.controller.worker;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.WorkerDao;
|
||||
import cn.edu.cqwu.repair.entity.Worker;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.service.RecordService;
|
||||
import cn.edu.cqwu.repair.util.Encrypt;
|
||||
import cn.edu.cqwu.repair.util.Verify;
|
||||
@ -21,11 +22,13 @@ import javax.servlet.http.HttpSession;
|
||||
public class WorkerLoginController {
|
||||
private final WorkerDao workerDao;
|
||||
private final RecordService recordService;
|
||||
private final MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public WorkerLoginController(WorkerDao workerDao, RecordService recordService) {
|
||||
public WorkerLoginController(WorkerDao workerDao, RecordService recordService, MessageService messageService) {
|
||||
this.workerDao = workerDao;
|
||||
this.recordService = recordService;
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@RequestMapping("/worker/Login.do")
|
||||
@ -49,6 +52,7 @@ public class WorkerLoginController {
|
||||
}
|
||||
if (recordService.add(user, request.getRemoteAddr()) != 0) {
|
||||
session.setAttribute("workerUser", user);
|
||||
messageService.updateSessionWorker(session, user.getUserid());
|
||||
return "redirect:/worker/worker_center_index.jsp";
|
||||
} else {
|
||||
model.addAttribute("workerLoginMess", "* 登录异常!");
|
||||
|
@ -0,0 +1,51 @@
|
||||
package cn.edu.cqwu.repair.controller.worker;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.Worker;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.SessionAttribute;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Controller
|
||||
public class WorkerMessageController {
|
||||
private final MessageService messageService;
|
||||
|
||||
@Autowired
|
||||
public WorkerMessageController(MessageService messageService) {
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
@RequestMapping("/worker/message.do")
|
||||
public String adminRecord(
|
||||
@SessionAttribute Worker workerUser, Model model, HttpServletRequest request, HttpSession session) {
|
||||
String pageNoS = request.getParameter("pageNo");
|
||||
int pageNo = 1;
|
||||
try {
|
||||
pageNo = Integer.parseInt(pageNoS);
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
PageModel pm = messageService.query(
|
||||
0, workerUser.getUserid(), 0, 10, pageNo
|
||||
);
|
||||
pm.setPageNav("message.do");
|
||||
model.addAttribute("pm", pm);
|
||||
messageService.updateSessionWorker(session, workerUser.getUserid());
|
||||
return "/worker/message";
|
||||
}
|
||||
|
||||
@RequestMapping("/worker/message/read.do")
|
||||
public String read(@SessionAttribute Worker workerUser, int messageId, HttpSession session) {
|
||||
messageService.readWorkerMessage(workerUser.getUserid(), messageId);
|
||||
messageService.updateSessionWorker(session, workerUser.getUserid());
|
||||
return "redirect:/worker/message.do";
|
||||
}
|
||||
}
|
@ -9,9 +9,14 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public interface AddressDao {
|
||||
int add(Address address);
|
||||
|
||||
int update(Address address);
|
||||
|
||||
ArrayList<Address> findAllAddress();
|
||||
|
||||
ArrayList<Address> findAddressByParent(int parent);
|
||||
|
||||
int deleteAddress(int id);
|
||||
|
||||
Address findAddressById(int id);
|
||||
}
|
||||
|
@ -9,10 +9,10 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public interface DeviceDao {
|
||||
|
||||
ArrayList<Device> findAllDevice();
|
||||
ArrayList<Device> findAllDevice();
|
||||
|
||||
ArrayList<Device> findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus);
|
||||
ArrayList<Device> findAllDevice(int deviceTypeId, int deviceAddressId, int deviceStatus);
|
||||
|
||||
Device findDevice(int deviceId);
|
||||
Device findDevice(int deviceId);
|
||||
|
||||
}
|
||||
|
@ -9,8 +9,12 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public interface FaultDao {
|
||||
int add(Fault fault);
|
||||
|
||||
int update(Fault fault);
|
||||
|
||||
ArrayList<Fault> findAllFault();
|
||||
|
||||
int deleteFault(int id);
|
||||
|
||||
Fault findFaultById(int id);
|
||||
}
|
||||
|
19
src/main/java/cn/edu/cqwu/repair/dao/MessageDao.java
Normal file
19
src/main/java/cn/edu/cqwu/repair/dao/MessageDao.java
Normal file
@ -0,0 +1,19 @@
|
||||
package cn.edu.cqwu.repair.dao;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.Message;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
public interface MessageDao {
|
||||
int add(Message message);
|
||||
|
||||
int update(Message message);
|
||||
|
||||
PageModel query(int studentId, int workerId, int adminId, int pageSize, int pageNo);
|
||||
|
||||
int read(int studentId, int workerId, int adminId, int messageId);
|
||||
|
||||
boolean hasUnread(int studentId, int workerId, int adminId);
|
||||
}
|
@ -7,17 +7,25 @@ import java.util.ArrayList;
|
||||
public interface OrderDao {
|
||||
|
||||
int add(Order order);
|
||||
|
||||
int update(Order order);
|
||||
|
||||
int delete(Order order);
|
||||
|
||||
int delete(int orderId);
|
||||
|
||||
ArrayList<Order> findByStudent_id(int stuId);
|
||||
|
||||
ArrayList<Order> findCurrent(int stuId);
|
||||
|
||||
ArrayList<Order> findByWorkerId(int workerId);
|
||||
|
||||
ArrayList<Order> findByStatus(int status);
|
||||
|
||||
ArrayList<Order> findByWorkerNoStatus(int status);
|
||||
|
||||
public int statusModify(int orderId);
|
||||
|
||||
public Order findByOrderId(int orderId);
|
||||
|
||||
public ArrayList<Order> findHistoryList(int workerId);
|
||||
|
@ -6,7 +6,9 @@ import java.util.ArrayList;
|
||||
|
||||
public interface StuDao {
|
||||
public int add(Stu stu);
|
||||
|
||||
public int update(Stu stu);
|
||||
|
||||
public Stu findByUsername(String username);
|
||||
|
||||
public Stu validateLogin(String username, String password);
|
||||
|
@ -1,10 +1,12 @@
|
||||
package cn.edu.cqwu.repair.dao;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.Worker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public interface WorkerDao {
|
||||
public Worker findByUserName(String username);
|
||||
|
||||
public Worker validateLogin(String username, String password);
|
||||
|
||||
public int passModify(String username, String newpass);
|
||||
@ -12,6 +14,7 @@ public interface WorkerDao {
|
||||
public ArrayList<Worker> findWorkersLikeUsername(String username);
|
||||
|
||||
ArrayList<Worker> findAll();
|
||||
|
||||
Worker findByUserId(int userId);
|
||||
|
||||
int deleteByUserName(String username);
|
||||
|
@ -0,0 +1,92 @@
|
||||
package cn.edu.cqwu.repair.dao.impl;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.MessageDao;
|
||||
import cn.edu.cqwu.repair.db.ConnectionFactory;
|
||||
import cn.edu.cqwu.repair.entity.Message;
|
||||
import cn.edu.cqwu.repair.entity.MessageStatus;
|
||||
import cn.edu.cqwu.repair.entity.mapper.MessageMapper;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static cn.edu.cqwu.repair.entity.table.MessageTableDef.MESSAGE;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Component
|
||||
public class MessageDaoImpl implements MessageDao {
|
||||
private static final MessageMapper MAPPER = ConnectionFactory.getMapper(MessageMapper.class);
|
||||
|
||||
@Override
|
||||
public int add(Message message) {
|
||||
return MAPPER.insert(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Message message) {
|
||||
return MAPPER.update(message);
|
||||
}
|
||||
|
||||
public Message findById(int id) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.where(MESSAGE.MESSAGE_ID.eq(id));
|
||||
return MAPPER.selectOneByQuery(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageModel query(int studentId, int workerId, int adminId, int pageSize, int pageNo) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
if (studentId != 0) {
|
||||
qw.where(MESSAGE.STUDENT_ID.eq(studentId));
|
||||
}
|
||||
if (workerId != 0) {
|
||||
qw.where(MESSAGE.WORKER_ID.eq(workerId));
|
||||
}
|
||||
if (adminId != 0) {
|
||||
qw.where(MESSAGE.ADMIN_ID.eq(adminId));
|
||||
}
|
||||
qw.orderBy(MESSAGE.MESSAGE_ID.desc());
|
||||
List<Message> messageList = MAPPER.selectListByQuery(qw);
|
||||
return new PageModel(pageSize, pageNo, messageList, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(int studentId, int workerId, int adminId, int messageId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.where(MESSAGE.MESSAGE_ID.eq(messageId));
|
||||
if (studentId != 0) {
|
||||
qw.where(MESSAGE.STUDENT_ID.eq(studentId));
|
||||
}
|
||||
if (workerId != 0) {
|
||||
qw.where(MESSAGE.WORKER_ID.eq(workerId));
|
||||
}
|
||||
if (adminId != 0) {
|
||||
qw.where(MESSAGE.ADMIN_ID.eq(adminId));
|
||||
}
|
||||
Message message = MAPPER.selectOneByQuery(qw);
|
||||
if (message == null) {
|
||||
return 0;
|
||||
}
|
||||
message.setMessageStatus(MessageStatus.READ.value);
|
||||
return MAPPER.update(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUnread(int studentId, int workerId, int adminId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.where(MESSAGE.MESSAGE_STATUS.eq(MessageStatus.UNREAD.value));
|
||||
if (studentId != 0) {
|
||||
qw.where(MESSAGE.STUDENT_ID.eq(studentId));
|
||||
}
|
||||
if (workerId != 0) {
|
||||
qw.where(MESSAGE.WORKER_ID.eq(workerId));
|
||||
}
|
||||
if (adminId != 0) {
|
||||
qw.where(MESSAGE.ADMIN_ID.eq(adminId));
|
||||
}
|
||||
return MAPPER.selectOneByQuery(qw) != null;
|
||||
}
|
||||
}
|
@ -4,18 +4,15 @@ import cn.edu.cqwu.repair.dao.OrderDao;
|
||||
import cn.edu.cqwu.repair.db.ConnectionFactory;
|
||||
import cn.edu.cqwu.repair.entity.Order;
|
||||
import cn.edu.cqwu.repair.entity.OrderStatus;
|
||||
import cn.edu.cqwu.repair.entity.Worker;
|
||||
import cn.edu.cqwu.repair.entity.mapper.DeviceMapper;
|
||||
import cn.edu.cqwu.repair.entity.mapper.OrderMapper;
|
||||
import cn.edu.cqwu.repair.entity.mapper.WorkerMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static cn.edu.cqwu.repair.entity.table.OrderTableDef.ORDER;
|
||||
import static cn.edu.cqwu.repair.entity.table.StuTableDef.STU;
|
||||
import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER;
|
||||
import static cn.edu.cqwu.repair.entity.table.OrderTableDef.ORDER;
|
||||
|
||||
@Component
|
||||
public class OrderDaoImpl implements OrderDao {
|
||||
@ -65,14 +62,14 @@ public class OrderDaoImpl implements OrderDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Order> findByWorkerId(int workerId){
|
||||
public ArrayList<Order> findByWorkerId(int workerId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)).where(ORDER.ORDER_STATUS.eq(1));
|
||||
return (ArrayList<Order>) mapper.selectListByQuery(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Order> findByWorkerNoStatus(int workerId){
|
||||
public ArrayList<Order> findByWorkerNoStatus(int workerId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId));
|
||||
return (ArrayList<Order>) mapper.selectListByQuery(qw);
|
||||
@ -86,16 +83,16 @@ public class OrderDaoImpl implements OrderDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Order findByOrderId(int orderId){
|
||||
public Order findByOrderId(int orderId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(ORDER.ALL_COLUMNS).where(ORDER.ORDER_ID.eq(orderId));
|
||||
return mapper.selectOneByQuery(qw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int statusModify(int orderId){
|
||||
public int statusModify(int orderId) {
|
||||
Order order = findByOrderId(orderId);
|
||||
if(order == null){
|
||||
if (order == null) {
|
||||
return 0;
|
||||
}
|
||||
order.setOrderStatus(OrderStatus.FINISHED.value);
|
||||
@ -103,9 +100,9 @@ public class OrderDaoImpl implements OrderDao {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ArrayList<Order> findHistoryList(int workerId){
|
||||
public ArrayList<Order> findHistoryList(int workerId) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId)).where(ORDER.ORDER_STATUS.eq(0));
|
||||
qw.select(ORDER.ALL_COLUMNS).where(ORDER.WORKER_ID.eq(workerId));
|
||||
return (ArrayList<Order>) mapper.selectListByQuery(qw);
|
||||
}
|
||||
|
||||
|
@ -2,17 +2,14 @@ package cn.edu.cqwu.repair.dao.impl;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.RecordDao;
|
||||
import cn.edu.cqwu.repair.db.ConnectionFactory;
|
||||
import cn.edu.cqwu.repair.entity.Order;
|
||||
import cn.edu.cqwu.repair.entity.Record;
|
||||
import cn.edu.cqwu.repair.entity.mapper.RecordMapper;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.edu.cqwu.repair.entity.table.OrderTableDef.ORDER;
|
||||
import static cn.edu.cqwu.repair.entity.table.RecordTableDef.RECORD;
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,7 @@ public class StuDaoImpl implements StuDao {
|
||||
public int add(Stu stu) {
|
||||
return MAPPER.insert(stu);
|
||||
}
|
||||
|
||||
public int update(Stu stu) {
|
||||
return MAPPER.update(stu);
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import cn.edu.cqwu.repair.entity.mapper.WorkerMapper;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static cn.edu.cqwu.repair.entity.table.WorkerTableDef.WORKER;
|
||||
@ -22,12 +21,13 @@ public class WorkerDaoImpl implements WorkerDao {
|
||||
|
||||
|
||||
@Override
|
||||
public Worker findByUserName(String username){
|
||||
public Worker findByUserName(String username) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
qw.select(WORKER.ALL_COLUMNS).where(WORKER.USERNAME.eq(username));
|
||||
return MAPPER.selectOneByQuery(qw);
|
||||
}
|
||||
// 判断用户密码组是否匹配
|
||||
|
||||
// 判断用户密码组是否匹配
|
||||
@Override
|
||||
public Worker validateLogin(String username, String password) {
|
||||
QueryWrapper qw = new QueryWrapper();
|
||||
|
@ -9,7 +9,7 @@ public enum DeviceStatus {
|
||||
|
||||
public final int value;
|
||||
|
||||
DeviceStatus(int value) {
|
||||
DeviceStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ public class Message {
|
||||
private int studentId;
|
||||
// 工人 id
|
||||
private int workerId;
|
||||
// 管理员 id
|
||||
private int adminId;
|
||||
// 消息状态 0 表示未读 1 表示已读 2 已删除
|
||||
private int messageStatus;
|
||||
// 消息时间
|
||||
@ -61,6 +63,22 @@ public class Message {
|
||||
this.workerId = workerId;
|
||||
}
|
||||
|
||||
public int getAdminId() {
|
||||
return adminId;
|
||||
}
|
||||
|
||||
public void setAdminId(int adminId) {
|
||||
this.adminId = adminId;
|
||||
}
|
||||
|
||||
public Timestamp getReadTime() {
|
||||
return readTime;
|
||||
}
|
||||
|
||||
public void setReadTime(Timestamp readTime) {
|
||||
this.readTime = readTime;
|
||||
}
|
||||
|
||||
public int getMessageStatus() {
|
||||
return messageStatus;
|
||||
}
|
||||
@ -69,6 +87,19 @@ public class Message {
|
||||
this.messageStatus = messageStatus;
|
||||
}
|
||||
|
||||
public String getMessageStatusStr() {
|
||||
switch (messageStatus) {
|
||||
case 0:
|
||||
return "未读";
|
||||
case 1:
|
||||
return "已读";
|
||||
case 2:
|
||||
return "已删除";
|
||||
default:
|
||||
return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
public Timestamp getCreateTime() {
|
||||
return createTime;
|
||||
}
|
||||
@ -84,8 +115,10 @@ public class Message {
|
||||
", messageContent='" + messageContent + '\'' +
|
||||
", studentId=" + studentId +
|
||||
", workerId=" + workerId +
|
||||
", adminId=" + adminId +
|
||||
", messageStatus=" + messageStatus +
|
||||
", createTime=" + createTime +
|
||||
", readTime=" + readTime +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
21
src/main/java/cn/edu/cqwu/repair/entity/MessageContent.java
Normal file
21
src/main/java/cn/edu/cqwu/repair/entity/MessageContent.java
Normal file
@ -0,0 +1,21 @@
|
||||
package cn.edu.cqwu.repair.entity;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
public enum MessageContent {
|
||||
AcceptedOrders("你的维修单已被接受,正在维修中"),
|
||||
Finished("你的维修单已被维修完成,请进行评价"),
|
||||
Removed("你的维修单已被管理员删除,清谨慎提交"),
|
||||
NewOrder("你有新的维修单,请及时处理"),
|
||||
NewScore("你有新的维修单被评分,请查看"),
|
||||
ReOrder("你正在进行中的维修单已被管理员重新分配,此维修单不再属于你"),
|
||||
RemovedOrder("你正在进行中的维修单已被管理员删除,此维修单无效");
|
||||
|
||||
public final String value;
|
||||
|
||||
MessageContent(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
18
src/main/java/cn/edu/cqwu/repair/entity/MessageStatus.java
Normal file
18
src/main/java/cn/edu/cqwu/repair/entity/MessageStatus.java
Normal file
@ -0,0 +1,18 @@
|
||||
package cn.edu.cqwu.repair.entity;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
|
||||
public enum MessageStatus {
|
||||
UNREAD(0),
|
||||
READ(1),
|
||||
REMOVED(2);
|
||||
|
||||
public final int value;
|
||||
|
||||
MessageStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
}
|
@ -12,7 +12,7 @@ public enum OrderStatus {
|
||||
|
||||
public final int value;
|
||||
|
||||
OrderStatus(int value) {
|
||||
OrderStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,7 @@ public class ScoreDates {
|
||||
private double numAverage;//记录平均数
|
||||
|
||||
// 构造函数
|
||||
public ScoreDates(int num12, int num3, int num45, int numTotal, int totalScore,double numAverage) {
|
||||
public ScoreDates(int num12, int num3, int num45, int numTotal, int totalScore, double numAverage) {
|
||||
this.num12 = num12;
|
||||
this.num3 = num3;
|
||||
this.num45 = num45;
|
||||
@ -27,6 +27,7 @@ public class ScoreDates {
|
||||
public void setnumAverage(double numAverage) {
|
||||
this.numAverage = numAverage;
|
||||
}
|
||||
|
||||
public int getNum12() {
|
||||
return num12;
|
||||
}
|
||||
@ -69,6 +70,6 @@ public class ScoreDates {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "{num12: "+num12 + ",num3:" + num3 + ",num45:" + num45 + ",numAverage: " + numAverage + ",}";
|
||||
return "{num12: " + num12 + ",num3:" + num3 + ",num45:" + num45 + ",numAverage: " + numAverage + ",}";
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public enum WorkerStatus {
|
||||
|
||||
public final int value;
|
||||
|
||||
WorkerStatus(int value) {
|
||||
WorkerStatus(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,5 @@
|
||||
package cn.edu.cqwu.repair.listener;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.AddressDao;
|
||||
import cn.edu.cqwu.repair.dao.DeviceDao;
|
||||
import cn.edu.cqwu.repair.dao.FaultDao;
|
||||
@ -12,6 +7,11 @@ import cn.edu.cqwu.repair.util.AppInit;
|
||||
import org.springframework.web.context.WebApplicationContext;
|
||||
import org.springframework.web.context.support.WebApplicationContextUtils;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletContextEvent;
|
||||
import javax.servlet.ServletContextListener;
|
||||
import javax.servlet.annotation.WebListener;
|
||||
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
|
32
src/main/java/cn/edu/cqwu/repair/service/MessageService.java
Normal file
32
src/main/java/cn/edu/cqwu/repair/service/MessageService.java
Normal file
@ -0,0 +1,32 @@
|
||||
package cn.edu.cqwu.repair.service;
|
||||
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
public interface MessageService {
|
||||
int addUserMessage(int userId, String content);
|
||||
|
||||
int addWorkerMessage(int workerId, String content);
|
||||
|
||||
int addAdminMessage(int adminId, String content);
|
||||
|
||||
int readUserMessage(int userId, int messageId);
|
||||
|
||||
int readWorkerMessage(int workerId, int messageId);
|
||||
|
||||
int readAdminMessage(int adminId, int messageId);
|
||||
|
||||
PageModel query(int studentId, int workerId, int adminId, int pageSize, int pageNo);
|
||||
|
||||
boolean hasUnread(int studentId, int workerId, int adminId);
|
||||
|
||||
void updateSessionAdmin(HttpSession session, int adminId);
|
||||
|
||||
void updateSessionWorker(HttpSession session, int workerId);
|
||||
|
||||
void updateSessionStudent(HttpSession session, int studentId);
|
||||
}
|
@ -8,7 +8,12 @@ import cn.edu.cqwu.repair.entity.Worker;
|
||||
*/
|
||||
public interface OrderService {
|
||||
void submitWorkers();
|
||||
|
||||
int modifyOrderStatus(int orderId, int workerId);
|
||||
|
||||
int modifyOrderStatus(Order order, Worker worker);
|
||||
|
||||
int markOrderOk(int orderId);
|
||||
|
||||
int deleteOrder(int orderId);
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import cn.edu.cqwu.repair.util.PageModel;
|
||||
|
||||
public interface RecordService {
|
||||
int add(AdminUser user, String ip);
|
||||
|
||||
int add(Worker user, String ip);
|
||||
|
||||
PageModel pageByLogname(String logname, String group, int pageSize, int pageNo);
|
||||
|
@ -0,0 +1,91 @@
|
||||
package cn.edu.cqwu.repair.service.impl;
|
||||
|
||||
import cn.edu.cqwu.repair.dao.MessageDao;
|
||||
import cn.edu.cqwu.repair.entity.Message;
|
||||
import cn.edu.cqwu.repair.entity.MessageStatus;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.util.PageModel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Service
|
||||
public class MessageServiceImpl implements MessageService {
|
||||
private final MessageDao messageDao;
|
||||
|
||||
@Autowired
|
||||
public MessageServiceImpl(MessageDao messageDao) {
|
||||
this.messageDao = messageDao;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addUserMessage(int userId, String content) {
|
||||
Message message = new Message();
|
||||
message.setStudentId(userId);
|
||||
message.setMessageContent(content);
|
||||
message.setMessageStatus(MessageStatus.UNREAD.value);
|
||||
return messageDao.add(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addWorkerMessage(int workerId, String content) {
|
||||
Message message = new Message();
|
||||
message.setWorkerId(workerId);
|
||||
message.setMessageContent(content);
|
||||
message.setMessageStatus(MessageStatus.UNREAD.value);
|
||||
return messageDao.add(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addAdminMessage(int adminId, String content) {
|
||||
Message message = new Message();
|
||||
message.setAdminId(adminId);
|
||||
message.setMessageContent(content);
|
||||
message.setMessageStatus(MessageStatus.UNREAD.value);
|
||||
return messageDao.add(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readUserMessage(int userId, int messageId) {
|
||||
return messageDao.read(userId, 0, 0, messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readWorkerMessage(int workerId, int messageId) {
|
||||
return messageDao.read(0, workerId, 0, messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readAdminMessage(int adminId, int messageId) {
|
||||
return messageDao.read(0, 0, adminId, messageId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageModel query(int studentId, int workerId, int adminId, int pageSize, int pageNo) {
|
||||
return messageDao.query(studentId, workerId, adminId, pageSize, pageNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasUnread(int studentId, int workerId, int adminId) {
|
||||
return messageDao.hasUnread(studentId, workerId, adminId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSessionAdmin(HttpSession session, int adminId) {
|
||||
session.setAttribute("hasUnreadMessage", hasUnread(0, 0, adminId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSessionWorker(HttpSession session, int workerId) {
|
||||
session.setAttribute("hasUnreadMessage", hasUnread(0, workerId, 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSessionStudent(HttpSession session, int studentId) {
|
||||
session.setAttribute("hasUnreadMessage", hasUnread(studentId, 0, 0));
|
||||
}
|
||||
}
|
@ -4,30 +4,34 @@ import cn.edu.cqwu.repair.dao.DeviceDao;
|
||||
import cn.edu.cqwu.repair.dao.OrderDao;
|
||||
import cn.edu.cqwu.repair.dao.WorkerDao;
|
||||
import cn.edu.cqwu.repair.entity.*;
|
||||
import cn.edu.cqwu.repair.service.MessageService;
|
||||
import cn.edu.cqwu.repair.service.OrderService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* @author xtaod
|
||||
*/
|
||||
@Component
|
||||
@Service
|
||||
public class OrderServiceImpl implements OrderService {
|
||||
OrderDao orderDao;
|
||||
WorkerDao workerDao;
|
||||
DeviceDao deviceDao;
|
||||
MessageService messageService;
|
||||
HashMap<Integer, Integer> deviceTypeMap;
|
||||
|
||||
@Autowired
|
||||
public OrderServiceImpl(OrderDao orderDao, WorkerDao workerDao, DeviceDao deviceDao) {
|
||||
public OrderServiceImpl(OrderDao orderDao, WorkerDao workerDao, DeviceDao deviceDao, MessageService messageService) {
|
||||
this.orderDao = orderDao;
|
||||
this.workerDao = workerDao;
|
||||
this.deviceDao = deviceDao;
|
||||
this.messageService = messageService;
|
||||
}
|
||||
|
||||
public Worker getFreeWorker(int typeId) {
|
||||
@ -37,7 +41,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
public void initDeviceMap() {
|
||||
ArrayList<Device> devices = deviceDao.findAllDevice();
|
||||
deviceTypeMap = new HashMap<>();
|
||||
for (Device device: devices) {
|
||||
for (Device device : devices) {
|
||||
deviceTypeMap.put(device.getDeviceId(), device.getDeviceTypeId());
|
||||
}
|
||||
}
|
||||
@ -55,12 +59,15 @@ public class OrderServiceImpl implements OrderService {
|
||||
Worker oldWorker = workerDao.findByUserId(order.getWorkerId());
|
||||
oldWorker.setOrderStatus(WorkerStatus.FREE.value);
|
||||
workerDao.update(oldWorker);
|
||||
messageService.addWorkerMessage(oldWorker.getUserid(), MessageContent.ReOrder.value);
|
||||
System.out.println("修改了 worker " + oldWorker.getUserid() + " - " + oldWorker.getOrderStatus());
|
||||
}
|
||||
order.setWorkerId(worker.getUserid());
|
||||
order.setOrderStatus(OrderStatus.PROGRESS.value);
|
||||
worker.setOrderStatus(WorkerStatus.BUSY.value);
|
||||
workerDao.update(worker);
|
||||
messageService.addWorkerMessage(worker.getUserid(), MessageContent.NewOrder.value);
|
||||
messageService.addUserMessage(order.getStudentId(), MessageContent.AcceptedOrders.value);
|
||||
System.out.println("修改了 order " + order.getOrderId() + " - " + order.getOrderStatus());
|
||||
System.out.println("修改了 worker " + worker.getUserid() + " - " + worker.getOrderStatus());
|
||||
return orderDao.update(order);
|
||||
@ -73,7 +80,7 @@ public class OrderServiceImpl implements OrderService {
|
||||
System.out.println("[submitWorkers] start");
|
||||
initDeviceMap();
|
||||
ArrayList<Order> orders = orderDao.findByStatus(OrderStatus.UNASSIGNED.value);
|
||||
for (Order order: orders) {
|
||||
for (Order order : orders) {
|
||||
Worker worker = getFreeWorker(deviceTypeMap.get(order.getDeviceId()));
|
||||
if (worker != null) {
|
||||
modifyOrderStatus(order, worker);
|
||||
@ -89,9 +96,27 @@ public class OrderServiceImpl implements OrderService {
|
||||
if (worker != null) {
|
||||
worker.setOrderStatus(WorkerStatus.FREE.value);
|
||||
order.setOrderStatus(OrderStatus.FINISHED.value);
|
||||
order.setFinishTime(new Timestamp(System.currentTimeMillis()));
|
||||
workerDao.update(worker);
|
||||
messageService.addUserMessage(order.getStudentId(), MessageContent.Finished.value);
|
||||
return orderDao.update(order);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteOrder(int orderId) {
|
||||
Order order = orderDao.findByOrderId(orderId);
|
||||
if (order != null) {
|
||||
Worker worker = workerDao.findByUserId(order.getWorkerId());
|
||||
if (worker != null) {
|
||||
worker.setOrderStatus(WorkerStatus.FREE.value);
|
||||
workerDao.update(worker);
|
||||
}
|
||||
messageService.addWorkerMessage(order.getWorkerId(), MessageContent.RemovedOrder.value);
|
||||
messageService.addUserMessage(order.getStudentId(), MessageContent.Removed.value);
|
||||
return orderDao.delete(orderId);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.edu.cqwu.repair.util;
|
||||
|
||||
import cn.edu.cqwu.repair.entity.Message;
|
||||
import cn.edu.cqwu.repair.entity.Record;
|
||||
|
||||
import java.io.Serializable;
|
||||
@ -15,6 +16,7 @@ public class PageModel implements Serializable {
|
||||
private int recordCount; //记录总数
|
||||
private int pageCount; //分页总数
|
||||
private List<Record> data; //当前页记录集列表
|
||||
private List<Message> data2;
|
||||
|
||||
private String pageNav; //翻页导航的HTML实现
|
||||
private int fromIndex;
|
||||
@ -48,6 +50,11 @@ public class PageModel implements Serializable {
|
||||
this.data = data.subList(this.fromIndex, this.toIndex);
|
||||
}
|
||||
|
||||
public PageModel(int pageSize, int pageNo, List<Message> data, int f) {
|
||||
init(pageSize, pageNo, data.size());
|
||||
this.data2 = data.subList(this.fromIndex, this.toIndex);
|
||||
}
|
||||
|
||||
public void setPageNav(String url) {
|
||||
if (url.lastIndexOf('?') != -1) {
|
||||
url += "&";
|
||||
@ -99,6 +106,10 @@ public class PageModel implements Serializable {
|
||||
return data;
|
||||
}
|
||||
|
||||
public List<Message> getData2() {
|
||||
return data2;
|
||||
}
|
||||
|
||||
public String getPageNav() {
|
||||
return pageNav;
|
||||
}
|
||||
|
64
src/main/webapp/admin/message.jsp
Normal file
64
src/main/webapp/admin/message.jsp
Normal file
@ -0,0 +1,64 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Administrator
|
||||
Date: 2024/5/12
|
||||
Time: 21:10
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ 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="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<c:set var="title" value="消息中心"/>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<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>
|
||||
<body>
|
||||
<main class="d-flex flex-nowrap">
|
||||
<%@ include file="../includes/header.jsp" %>
|
||||
|
||||
<main class="form-signin w-100 m-auto" style="max-width: 600px;">
|
||||
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||
<h1 class="h3 mb-3 fw-normal">${title}</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">序号</th>
|
||||
<th scope="col">消息内容</th>
|
||||
<th scope="col">时间</th>
|
||||
<th scope="col">状态</th>
|
||||
<th scope="col">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${pm.data2}" var="msg" varStatus="row">
|
||||
<tr>
|
||||
<td>${row.index + 1}</td>
|
||||
<td>${msg.messageContent}</td>
|
||||
<td>${msg.createTime}</td>
|
||||
<td>${msg.messageStatusStr}</td>
|
||||
<td>
|
||||
<c:if test="${msg.messageStatus == 0}">
|
||||
<a href="${webroot}/admin/message/read.do?id=${msg.messageId}" class="btn btn-primary">已读</a>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
${pm.pageNav}
|
||||
</main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -26,8 +26,15 @@
|
||||
class="rounded-circle me-2">
|
||||
</c:if>
|
||||
<strong>${sessionScope.stu.username}</strong>
|
||||
<c:if test="${sessionScope.hasUnreadMessage}">
|
||||
<span class="position-absolute top-50 translate-middle badge rounded-pill bg-danger" style="left: 85%">
|
||||
有新消息
|
||||
<span class="visually-hidden">unread messages</span>
|
||||
</span>
|
||||
</c:if>
|
||||
</a>
|
||||
<ul class="dropdown-menu text-small shadow">
|
||||
<li><a class="dropdown-item" href="${webroot}/stu/message.do">消息中心</a></li>
|
||||
<li><a class="dropdown-item" href="${webroot}/stu/record.do">我的登录历史</a></li>
|
||||
<li><a class="dropdown-item" href="${webroot}/stu/pass.jsp">修改密码</a></li>
|
||||
<li>
|
||||
@ -44,6 +51,12 @@
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<img src="${webroot}/images/logo.jpg" alt="" width="32" height="32" class="rounded-circle me-2">
|
||||
<strong>${sessionScope.adminUser.adminName}</strong>
|
||||
<c:if test="${sessionScope.hasUnreadMessage}">
|
||||
<span class="position-absolute top-50 translate-middle badge rounded-pill bg-danger" style="left: 85%">
|
||||
有新消息
|
||||
<span class="visually-hidden">unread messages</span>
|
||||
</span>
|
||||
</c:if>
|
||||
</a>
|
||||
<ul class="dropdown-menu text-small shadow">
|
||||
<li><a class="dropdown-item" href="${webroot}/admin/message.do">消息中心</a></li>
|
||||
@ -63,8 +76,15 @@
|
||||
data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<img src="${webroot}/images/logo.jpg" alt="" width="32" height="32" class="rounded-circle me-2">
|
||||
<strong>${sessionScope.workerUser.username}</strong>
|
||||
<c:if test="${sessionScope.hasUnreadMessage}">
|
||||
<span class="position-absolute top-50 translate-middle badge rounded-pill bg-danger" style="left: 85%">
|
||||
有新消息
|
||||
<span class="visually-hidden">unread messages</span>
|
||||
</span>
|
||||
</c:if>
|
||||
</a>
|
||||
<ul class="dropdown-menu text-small shadow">
|
||||
<li><a class="dropdown-item" href="${webroot}/worker/message.do">消息中心</a></li>
|
||||
<li><a class="dropdown-item" href="${webroot}/worker/worker_center_index.jsp">个人中心</a></li>
|
||||
<li><a class="dropdown-item" href="${webroot}/worker/HistoryLogin.do">我的登录历史</a></li>
|
||||
<li><a class="dropdown-item" href="${webroot}/worker/worker_modify.jsp">修改密码</a></li>
|
||||
|
64
src/main/webapp/stu/message.jsp
Normal file
64
src/main/webapp/stu/message.jsp
Normal file
@ -0,0 +1,64 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Administrator
|
||||
Date: 2024/5/12
|
||||
Time: 21:10
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ 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="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<c:set var="title" value="消息中心"/>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<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>
|
||||
<body>
|
||||
<main class="d-flex flex-nowrap">
|
||||
<%@ include file="../includes/header.jsp" %>
|
||||
|
||||
<main class="form-signin w-100 m-auto" style="max-width: 600px;">
|
||||
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||
<h1 class="h3 mb-3 fw-normal">${title}</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">序号</th>
|
||||
<th scope="col">消息内容</th>
|
||||
<th scope="col">时间</th>
|
||||
<th scope="col">状态</th>
|
||||
<th scope="col">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${pm.data2}" var="msg" varStatus="row">
|
||||
<tr>
|
||||
<td>${row.index + 1}</td>
|
||||
<td>${msg.messageContent}</td>
|
||||
<td>${msg.createTime}</td>
|
||||
<td>${msg.messageStatusStr}</td>
|
||||
<td>
|
||||
<c:if test="${msg.messageStatus == 0}">
|
||||
<a href="${webroot}/stu/message/read.do?id=${msg.messageId}" class="btn btn-primary">已读</a>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
${pm.pageNav}
|
||||
</main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
@ -50,8 +50,8 @@
|
||||
</html>
|
||||
<script type="text/javascript">
|
||||
window.onload = function(){
|
||||
var star = document.getElementsByTagName('a');
|
||||
var oDiv = document.getElementsByTagName('div')[0];
|
||||
var star = document.getElementsByClassName('aa');
|
||||
var ratingInput = document.getElementById('rating');
|
||||
var temp = 0;
|
||||
for(var i = 0, len = star.length; i < len; i++){
|
||||
star[i].index = i;
|
||||
@ -69,7 +69,6 @@
|
||||
}
|
||||
star[i].onclick = function(){
|
||||
temp = this.index + 1;
|
||||
document.getElementsByTagName('p')[0].innerHTML = temp + ' 颗星';
|
||||
current(temp);
|
||||
// 更新隐藏字段的值
|
||||
ratingInput.value = temp;
|
||||
|
64
src/main/webapp/worker/message.jsp
Normal file
64
src/main/webapp/worker/message.jsp
Normal file
@ -0,0 +1,64 @@
|
||||
<%--
|
||||
Created by IntelliJ IDEA.
|
||||
User: Administrator
|
||||
Date: 2024/5/12
|
||||
Time: 21:10
|
||||
To change this template use File | Settings | File Templates.
|
||||
--%>
|
||||
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||
<%@ 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="webroot" value="${pageContext.request.contextPath}"/>
|
||||
<c:set var="title" value="消息中心"/>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<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>
|
||||
<body>
|
||||
<main class="d-flex flex-nowrap">
|
||||
<%@ include file="../includes/header.jsp" %>
|
||||
|
||||
<main class="form-signin w-100 m-auto" style="max-width: 600px;">
|
||||
<img class="mb-4" src="${webroot}/images/logo.jpg" alt="" width="72" height="72">
|
||||
<h1 class="h3 mb-3 fw-normal">${title}</h1>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">序号</th>
|
||||
<th scope="col">消息内容</th>
|
||||
<th scope="col">时间</th>
|
||||
<th scope="col">状态</th>
|
||||
<th scope="col">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${pm.data2}" var="msg" varStatus="row">
|
||||
<tr>
|
||||
<td>${row.index + 1}</td>
|
||||
<td>${msg.messageContent}</td>
|
||||
<td>${msg.createTime}</td>
|
||||
<td>${msg.messageStatusStr}</td>
|
||||
<td>
|
||||
<c:if test="${msg.messageStatus == 0}">
|
||||
<a href="${webroot}/worker/message/read.do?id=${msg.messageId}" class="btn btn-primary">已读</a>
|
||||
</c:if>
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
${pm.pageNav}
|
||||
</main>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in New Issue
Block a user