diff --git a/mall.sql b/mall.sql deleted file mode 100644 index 6bf662d..0000000 --- a/mall.sql +++ /dev/null @@ -1,209 +0,0 @@ -/* - Navicat Premium Data Transfer - - Source Server : 40.83.126.15mall - Source Server Type : MySQL - Source Server Version : 50649 - Source Host : 40.83.126.15:3306 - Source Schema : mall - - Target Server Type : MySQL - Target Server Version : 50649 - File Encoding : 65001 - - Date: 04/12/2020 16:53:42 -*/ - -SET NAMES utf8mb4; -SET FOREIGN_KEY_CHECKS = 0; - --- ---------------------------- --- Table structure for category --- ---------------------------- -DROP TABLE IF EXISTS `category`; -CREATE TABLE `category` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `pid` int(11) NULL DEFAULT NULL, - `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `details` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `onnav` int(1) NULL DEFAULT 0, - `sort` int(2) NOT NULL DEFAULT 99, - PRIMARY KEY (`id`) USING BTREE, - INDEX `pidpk`(`pid`) USING BTREE, - CONSTRAINT `pidpk` FOREIGN KEY (`pid`) REFERENCES `category` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT -) ENGINE = InnoDB AUTO_INCREMENT = 13 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT; - --- ---------------------------- --- Records of category --- ---------------------------- -INSERT INTO `category` VALUES (1, NULL, '/', '/', 0, 99); -INSERT INTO `category` VALUES (2, 1, '水果', '新鲜水果', 1, 2); -INSERT INTO `category` VALUES (3, 1, '手机', '二手手机', 1, 1); -INSERT INTO `category` VALUES (4, 2, '苹果', '乐山苹果', 1, 99); -INSERT INTO `category` VALUES (12, 1, '4545415', NULL, 5, 3); - --- ---------------------------- --- Table structure for identity --- ---------------------------- -DROP TABLE IF EXISTS `identity`; -CREATE TABLE `identity` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `identity` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `details` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT; - --- ---------------------------- --- Records of identity --- ---------------------------- -INSERT INTO `identity` VALUES (1, '1', 'root'); -INSERT INTO `identity` VALUES (2, '2', '快递员'); -INSERT INTO `identity` VALUES (3, '3', '普通用户'); - --- ---------------------------- --- Table structure for w_account --- ---------------------------- -DROP TABLE IF EXISTS `w_account`; -CREATE TABLE `w_account` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `phone` varchar(11) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `username` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `password` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `email` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - `sex` int(1) NOT NULL, - `birthday` date NULL DEFAULT NULL, - `identity_id` int(11) NOT NULL, - `registration_time` datetime(0) NOT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT; - --- ---------------------------- --- Records of w_account --- ---------------------------- -INSERT INTO `w_account` VALUES (1, '18283140142', 'clay', '123456789', '20932067@zju.edu.cn', 1, '2000-04-10', 1, '2020-12-03 17:23:11'); -INSERT INTO `w_account` VALUES (2, '18283140141', '12354', '123456789', '收到', 1, NULL, 2, '2020-12-02 17:23:15'); -INSERT INTO `w_account` VALUES (3, '18283140143', '你好呀', '123456789', '1829446465465649363@qq.com', 2, NULL, 3, '2020-12-02 05:56:51'); -INSERT INTO `w_account` VALUES (4, '18283140145', '12354', '123456789', '收到', 1, NULL, 2, '2020-12-02 06:08:19'); -INSERT INTO `w_account` VALUES (5, '18283140146', '12354', '123456', '4515@qq.com', 1, NULL, 3, '2020-12-02 06:09:59'); - --- ---------------------------- --- Table structure for m_flats --- ---------------------------- -DROP TABLE IF EXISTS `m_flats`; -CREATE TABLE `m_flats` ( - `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, - `flats_name` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL, - `desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT; - --- ---------------------------- --- Records of m_flats --- ---------------------------- -INSERT INTO `m_flats` VALUES (1, '1栋', '测试'); -INSERT INTO `m_flats` VALUES (2, '2栋', NULL); -INSERT INTO `m_flats` VALUES (3, '3栋', NULL); -INSERT INTO `m_flats` VALUES (4, '4栋', NULL); -INSERT INTO `m_flats` VALUES (5, '5栋', NULL); -INSERT INTO `m_flats` VALUES (6, '6栋', NULL); -INSERT INTO `m_flats` VALUES (7, '7栋', NULL); -INSERT INTO `m_flats` VALUES (8, '8栋', NULL); -INSERT INTO `m_flats` VALUES (9, '9栋', NULL); -INSERT INTO `m_flats` VALUES (10, '10栋', NULL); -INSERT INTO `m_flats` VALUES (11, '11栋', NULL); -INSERT INTO `m_flats` VALUES (12, '12栋', NULL); -INSERT INTO `m_flats` VALUES (13, '13栋', NULL); -INSERT INTO `m_flats` VALUES (14, '14栋', NULL); -INSERT INTO `m_flats` VALUES (15, '15栋', NULL); - --- ---------------------------- --- Table structure for w_order --- ---------------------------- -DROP TABLE IF EXISTS `w_order`; -CREATE TABLE `w_order` ( - `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'id', - `account_id` int(11) NOT NULL COMMENT '用户id', - `courier_id` int(11) NULL DEFAULT 0 COMMENT '快递员id', - `number` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '取单号', - `company` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '快递公司', - `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '姓名', - `phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL COMMENT '手机号码', - `flats_id` int(11) NOT NULL COMMENT '公寓id', - `hostel` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '宿舍号', - `create_time` datetime(0) NOT NULL COMMENT '创建时间', - `last_time` datetime(0) NULL DEFAULT NULL COMMENT '最后一次操作时间', - `status` int(1) NOT NULL COMMENT '状态1:待取件 2:运输 3:送到 4:收取 前端返回值为5->4 6->3 7->2 8->1', - `type` int(1) NOT NULL COMMENT '大小件 1:大 2:中 3:小', - `payment_status` int(1) NOT NULL COMMENT '支付状态 1:支付 2:未支付 3:支付失败', - `decs` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '备注', - `price` decimal(10, 2) UNSIGNED NOT NULL COMMENT '价格', - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 45 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT; - --- ---------------------------- --- Records of w_order --- ---------------------------- -INSERT INTO `w_order` VALUES (1, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:17:46', '2020-12-02 13:17:46', 1, 1, 2, '你', 4.00); -INSERT INTO `w_order` VALUES (2, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:40', '2020-12-02 13:19:40', 1, 1, 2, '你', 4.00); -INSERT INTO `w_order` VALUES (3, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:41', '2020-12-02 13:19:41', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (4, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:42', '2020-12-02 13:19:42', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (5, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:43', '2020-12-02 13:19:43', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (6, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:44', '2020-12-02 13:19:44', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (7, 3, 2, '45454', '电脑', '张开怀', '18283140142', 1, '2322', '2020-12-02 13:19:44', '2020-12-03 09:40:32', 3, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (8, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:44', '2020-12-03 07:54:42', 2, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (9, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:45', '2020-12-02 13:19:45', 2, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (10, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:45', '2020-12-02 13:19:45', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (11, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:45', '2020-12-02 13:19:45', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (12, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:45', '2020-12-02 13:19:45', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (13, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:45', '2020-12-02 13:19:45', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (14, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:45', '2020-12-02 13:19:45', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (15, 3, 0, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:46', '2020-12-02 13:19:46', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (16, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:46', '2020-12-02 13:19:46', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (17, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:46', '2020-12-02 13:19:46', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (18, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:46', '2020-12-02 13:19:46', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (19, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:46', '2020-12-02 13:19:46', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (20, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:47', '2020-12-02 13:19:47', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (21, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:47', '2020-12-02 13:19:47', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (22, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:47', '2020-12-02 13:19:47', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (23, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:47', '2020-12-02 13:19:47', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (24, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:47', '2020-12-02 13:19:47', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (25, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:48', '2020-12-02 13:19:48', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (26, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:48', '2020-12-02 13:19:48', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (27, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:48', '2020-12-02 13:19:48', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (28, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:48', '2020-12-02 13:19:48', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (29, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:48', '2020-12-02 13:19:48', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (30, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:49', '2020-12-02 13:19:49', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (31, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:49', '2020-12-02 13:19:49', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (32, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:49', '2020-12-02 13:19:49', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (33, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:49', '2020-12-02 13:19:49', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (34, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:49', '2020-12-02 13:19:49', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (35, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:49', '2020-12-02 13:19:49', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (36, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:50', '2020-12-02 13:19:50', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (37, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:50', '2020-12-02 13:19:50', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (38, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:50', '2020-12-02 13:19:50', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (39, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:50', '2020-12-02 13:19:50', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (40, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:19:50', '2020-12-02 13:19:50', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (41, 3, NULL, '45454', '电脑', '你好', '18283140142', 1, '2322', '2020-12-02 13:20:00', '2020-12-02 13:20:00', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (42, 3, NULL, '45454', '电脑', '你好', '18283140142', 12, '2322', '2020-12-03 05:53:10', '2020-12-03 05:53:10', 1, 1, 2, '你', 1.00); -INSERT INTO `w_order` VALUES (43, 4, NULL, '1215454', '顺丰快递', '张三', '15682132183', 1, NULL, '2020-12-03 14:03:58', '2020-12-03 14:03:58', 1, 1, 2, '放在楼下', 1.00); -INSERT INTO `w_order` VALUES (44, 2, NULL, '45454', '顺丰快递', '张开怀', '18283140149', 1, '2322', '2020-12-04 05:26:23', '2020-12-04 05:26:23', 1, 1, 2, '你', 5.00); - --- ---------------------------- --- Table structure for m_price --- ---------------------------- -DROP TABLE IF EXISTS `m_price`; -CREATE TABLE `m_price` ( - `id` int(11) NOT NULL AUTO_INCREMENT, - `price` decimal(10, 2) NULL DEFAULT NULL, - `desc` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL, - PRIMARY KEY (`id`) USING BTREE -) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = COMPACT; - --- ---------------------------- --- Records of m_price --- ---------------------------- -INSERT INTO `m_price` VALUES (1, 5.00, '大件'); -INSERT INTO `m_price` VALUES (2, 3.00, '中件'); -INSERT INTO `m_price` VALUES (3, 2.00, '小件'); - -SET FOREIGN_KEY_CHECKS = 1; diff --git a/src/main/java/live/tomey/api/express/controller/AccountController.java b/src/main/java/live/tomey/api/express/controller/AccountController.java index 4073be0..c6e8efd 100644 --- a/src/main/java/live/tomey/api/express/controller/AccountController.java +++ b/src/main/java/live/tomey/api/express/controller/AccountController.java @@ -187,7 +187,7 @@ public class AccountController { Account eaccount = new Account(account.getId(),ncryptedProble,ncryptedAnswers); boolean start = accountService.editAccountEncrypted(eaccount); if (start){ - return new Result(true, 0, "密码设置成功!"); + return new Result(true, 0, "密保设置成功!"); }else { return new Result(false, 0, "密保设置失败!"); } diff --git a/src/main/java/live/tomey/api/express/controller/MessageController.java b/src/main/java/live/tomey/api/express/controller/MessageController.java new file mode 100644 index 0000000..1a92005 --- /dev/null +++ b/src/main/java/live/tomey/api/express/controller/MessageController.java @@ -0,0 +1,113 @@ +package live.tomey.api.express.controller; + +import live.tomey.api.express.aop.Public; +import live.tomey.api.express.dto.MessageSelect; +import live.tomey.api.express.dto.Result; +import live.tomey.api.express.dto.ServerResult; +import live.tomey.api.express.entity.Account; +import live.tomey.api.express.enums.OrderEnum; +import live.tomey.api.express.service.MessageService; +import live.tomey.api.express.unit.HttpServletRequestUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.HashMap; +import java.util.Map; + +/** + * @author clay + * @version 1.0 + * @mail 20932067@zju.edu.cn + * @date 2020/12/16 16:56 + */ +@RestController +public class MessageController { + + private Logger logger = LoggerFactory.getLogger(MessageController.class); + @Autowired + private MessageService messageService; + + @Public + @RequestMapping(value = "removemessage",method = RequestMethod.POST) + private Result removeMessage(HttpServletRequest request){ + Account account = (Account) request.getSession().getAttribute("account"); + if (account == null) { + return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo()); + } + try { + Integer id = HttpServletRequestUtil.getInteger(request,"id"); + if (id<0){ + return new Result(false,-1,"id不能为空!"); + } + ServerResult serverResult = messageService.removeMessage(id,account.getId()); + if (serverResult.isStart()){ + return new Result(serverResult.isStart(),0,serverResult.getMsg()); + }else { + return new Result(serverResult.isStart(),-1,serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new Result(false,0,"系统错误"); + } + } + + @Public + @RequestMapping(value = "readmessage",method = RequestMethod.POST) + private Result readMessage(HttpServletRequest request){ + Account account = (Account) request.getSession().getAttribute("account"); + if (account == null) { + return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo()); + } + try { + Integer id = HttpServletRequestUtil.getInteger(request,"id"); + if (id<0){ + return new Result(false,-1,"id不能为空!"); + } + ServerResult serverResult = messageService.readMessage(id,account.getId()); + if (serverResult.isStart()){ + return new Result(serverResult.isStart(),0,serverResult.getMsg()); + }else { + return new Result(serverResult.isStart(),-1,serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new Result(false,0,"系统错误"); + } + } + + @Public + @RequestMapping(value = "getmessage",method = RequestMethod.POST) + private Result getMessage(HttpServletRequest request){ + Account account = (Account) request.getSession().getAttribute("account"); + if (account == null) { + return new Result(false, OrderEnum.OFFLINE.getState(), OrderEnum.OFFLINE.getStateInfo()); + } + try { + Integer size = HttpServletRequestUtil.getInteger(request, "size"); + Integer page = HttpServletRequestUtil.getInteger(request, "page"); + String title = HttpServletRequestUtil.getString(request, "title"); + if (size == -1 || page == -1) { + return new Result(false, 0, "数量和页数不能为空"); + } + MessageSelect messageSelect = new MessageSelect(page,size,account.getId(),title); + ServerResult serverResult = messageService.getmessage(messageSelect); + if (serverResult.isStart()){ + Map modelMap = new HashMap(); + modelMap.put("list",serverResult.getData()); + modelMap.put("count",serverResult.getCount()); + return new Result(true,modelMap); + }else { + return new Result(false,0,serverResult.getMsg()); + } + }catch (RuntimeException e){ + logger.error(e.getMessage()); + return new Result(false,0,"系统错误"); + } + } + +} diff --git a/src/main/java/live/tomey/api/express/controller/OrderController.java b/src/main/java/live/tomey/api/express/controller/OrderController.java index 694053d..ba815d4 100644 --- a/src/main/java/live/tomey/api/express/controller/OrderController.java +++ b/src/main/java/live/tomey/api/express/controller/OrderController.java @@ -99,7 +99,7 @@ public class OrderController { try { Integer id = HttpServletRequestUtil.getInteger(request, "id"); OrderModifyState orderModifyState = new OrderModifyState(id, account.getId(), 3); - OrderExcution orderExcution = orderService.changDelivery(orderModifyState); + OrderExcution orderExcution = orderService.changDelivery(orderModifyState,account ); if (orderExcution.getState() == 1) { return new Result(true, 1, "派送成功"); } else { @@ -169,7 +169,7 @@ public class OrderController { try { Integer id = HttpServletRequestUtil.getInteger(request, "id"); OrderModifyState orderModifyState = new OrderModifyState(id, account.getId(), 2); - OrderExcution orderExcution = orderService.changeState(orderModifyState); + OrderExcution orderExcution = orderService.changeState(orderModifyState, account); if (orderExcution.getState() == 1) { return new Result(true, 1, "任务领取成功"); } else { diff --git a/src/main/java/live/tomey/api/express/dao/MessagesDao.java b/src/main/java/live/tomey/api/express/dao/MessagesDao.java new file mode 100644 index 0000000..94b0e2d --- /dev/null +++ b/src/main/java/live/tomey/api/express/dao/MessagesDao.java @@ -0,0 +1,50 @@ +package live.tomey.api.express.dao; + +import live.tomey.api.express.dto.MessageSelect; +import live.tomey.api.express.entity.Messages; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author clay + * @version 1.0 + * @mail 20932067@zju.edu.cn + * @date 2020/12/16 11:33 + */ +public interface MessagesDao { + /** + * 添加信息 + * @param messages + * @return + */ + Integer insertMessage(@Param("messages") Messages messages); + + /** + * 阅读信息 + * @param id + * @param accountId + * @return + */ + Integer readMessage(@Param("id") Integer id ,@Param("accountId") Integer accountId); + + /** + * 删除信息 + * @param id + * @param accountId + * @return + */ + Integer deleteMessage(@Param("id") Integer id,@Param("accountId") Integer accountId); + + /** + * 获取用户信息 + * @param messageSelect + * @return + */ + List selectMessage(@Param("messageSelect") MessageSelect messageSelect); + + Integer selectMessageCount(@Param("messageSelect") MessageSelect messageSelect); + + + +} diff --git a/src/main/java/live/tomey/api/express/dto/MessageSelect.java b/src/main/java/live/tomey/api/express/dto/MessageSelect.java new file mode 100644 index 0000000..fec0a8f --- /dev/null +++ b/src/main/java/live/tomey/api/express/dto/MessageSelect.java @@ -0,0 +1,54 @@ +package live.tomey.api.express.dto; + +/** + * @author clay + * @version 1.0 + * @mail 20932067@zju.edu.cn + * @date 2020/12/16 17:02 + */ +public class MessageSelect { + private Integer page; + private Integer size; + private Integer accountId; + private String title; + + + public MessageSelect(Integer page, Integer size, Integer accountId, String title) { + this.page = page; + this.size = size; + this.accountId = accountId; + this.title = title; + } + + public Integer getPage() { + return page; + } + + public void setPage(Integer page) { + this.page = page; + } + + public Integer getSize() { + return size; + } + + public void setSize(Integer size) { + this.size = size; + } + + public Integer getAccountId() { + return accountId; + } + + public void setAccountId(Integer accountId) { + this.accountId = accountId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } +} diff --git a/src/main/java/live/tomey/api/express/entity/Messages.java b/src/main/java/live/tomey/api/express/entity/Messages.java new file mode 100644 index 0000000..6bc836b --- /dev/null +++ b/src/main/java/live/tomey/api/express/entity/Messages.java @@ -0,0 +1,74 @@ +package live.tomey.api.express.entity; + +import java.util.Date; + +public class Messages { + + private long id; + private long accountId; + private String title; + private String content; + private Integer isRead; + private Date sendTime; + + public Messages() { + } + + public Messages(long accountId, String title, String content) { + this.accountId = accountId; + this.title = title; + this.content = content; + this.isRead = 1; + this.sendTime = new Date(); + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + + public long getAccountId() { + return accountId; + } + + public void setAccountId(long accountId) { + this.accountId = accountId; + } + + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public Integer getIsRead() { + return isRead; + } + + public void setIsRead(Integer isRead) { + this.isRead = isRead; + } + + public Date getSendTime() { + return sendTime; + } + + public void setSendTime(Date sendTime) { + this.sendTime = sendTime; + } +} diff --git a/src/main/java/live/tomey/api/express/service/MessageService.java b/src/main/java/live/tomey/api/express/service/MessageService.java new file mode 100644 index 0000000..f8c8b32 --- /dev/null +++ b/src/main/java/live/tomey/api/express/service/MessageService.java @@ -0,0 +1,39 @@ +package live.tomey.api.express.service; + +import live.tomey.api.express.dto.MessageSelect; +import live.tomey.api.express.dto.ServerResult; + +/** + * @author clay + * @version 1.0 + * @mail 20932067@zju.edu.cn + * @date 2020/12/16 16:57 + */ +public interface MessageService { + + /** + * 获取信息 + * @param messageSelect + * @return + */ + ServerResult getmessage(MessageSelect messageSelect); + + /** + * 阅读信息 + * @param id + * @param accountId + * @return + */ + ServerResult readMessage(Integer id,Integer accountId); + + /** + * 删除通知 + * @param id + * @param accountId + * @return + */ + ServerResult removeMessage(Integer id,Integer accountId); + + + +} diff --git a/src/main/java/live/tomey/api/express/service/OrderService.java b/src/main/java/live/tomey/api/express/service/OrderService.java index ee119df..40d76e1 100644 --- a/src/main/java/live/tomey/api/express/service/OrderService.java +++ b/src/main/java/live/tomey/api/express/service/OrderService.java @@ -1,6 +1,7 @@ package live.tomey.api.express.service; import live.tomey.api.express.dto.*; +import live.tomey.api.express.entity.Account; import java.util.List; @@ -21,11 +22,11 @@ public interface OrderService { OrderExcution> courierGetAllList(OrderSelect orderSelect); - OrderExcution changeState(OrderModifyState orderModifyState); + OrderExcution changeState(OrderModifyState orderModifyState,Account courier); OrderExcution courierGetSelfList(OrderSelect orderSelect,Integer courierId); - OrderExcution changDelivery(OrderModifyState orderModifyState); + OrderExcution changDelivery(OrderModifyState orderModifyState,Account courier); OrderExcution changCharge(OrderModifyState orderModifyState); diff --git a/src/main/java/live/tomey/api/express/service/impl/AccountServiceImpl.java b/src/main/java/live/tomey/api/express/service/impl/AccountServiceImpl.java index a5e6743..b3b3e62 100644 --- a/src/main/java/live/tomey/api/express/service/impl/AccountServiceImpl.java +++ b/src/main/java/live/tomey/api/express/service/impl/AccountServiceImpl.java @@ -6,6 +6,7 @@ import live.tomey.api.express.dto.AccountRoot; import live.tomey.api.express.dto.AccountRootExcution; import live.tomey.api.express.dto.AccountSelect; import live.tomey.api.express.entity.Account; +import live.tomey.api.express.entity.Messages; import live.tomey.api.express.enums.LoginEnum; import live.tomey.api.express.exceptions.AccountOperationException; import live.tomey.api.express.service.AccountService; @@ -116,9 +117,13 @@ public class AccountServiceImpl implements AccountService { * @return */ @Override + @Transactional public boolean addAccount(Account account) { try { Integer init = accountDao.insertAccount(account); +// String title = "欢迎新用户"; +// String content = "欢迎您注册校园闪电侠,快递代拿系统,祝您使用愉快!"; +// Messages messages = new Messages(init,title,content); if (init == 1) { return true; } else { diff --git a/src/main/java/live/tomey/api/express/service/impl/MessageServiceImpl.java b/src/main/java/live/tomey/api/express/service/impl/MessageServiceImpl.java new file mode 100644 index 0000000..2c6bd35 --- /dev/null +++ b/src/main/java/live/tomey/api/express/service/impl/MessageServiceImpl.java @@ -0,0 +1,74 @@ +package live.tomey.api.express.service.impl; + +import live.tomey.api.express.dao.MessagesDao; +import live.tomey.api.express.dto.MessageSelect; +import live.tomey.api.express.dto.ServerResult; +import live.tomey.api.express.entity.Messages; +import live.tomey.api.express.service.MessageService; +import live.tomey.api.express.unit.PageCalculator; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * @author clay + * @version 1.0 + * @mail 20932067@zju.edu.cn + * @date 2020/12/16 17:11 + */ +@Service +public class MessageServiceImpl implements MessageService { + private Logger logger = LoggerFactory.getLogger(MessageServiceImpl.class); + + @Autowired + private MessagesDao messagesDao; + + @Override + @Transactional + public ServerResult getmessage(MessageSelect messageSelect) { + try { + messageSelect.setPage(PageCalculator.calculateRowIndex(messageSelect.getPage(), messageSelect.getSize())); + List messagesList = messagesDao.selectMessage(messageSelect); + Integer count = messagesDao.selectMessageCount(messageSelect); + if (messagesList.size()>0&&count>0){ + return new ServerResult(true,messagesList,count); + }else { + return new ServerResult(false,"查询结果为空!"); + } + }catch (RuntimeException e){ + return new ServerResult(false,"系统错误!"); + } + } + + @Override + public ServerResult readMessage(Integer id, Integer accountId) { + try { + Integer type = messagesDao.readMessage(id,accountId); + if (type == 1){ + return new ServerResult(true,"操作成功!"); + }else { + return new ServerResult(false,"操作失败!"); + } + }catch (RuntimeException e){ + return new ServerResult(false,"系统错误!"); + } + } + + @Override + public ServerResult removeMessage(Integer id, Integer accountId) { + try { + Integer type = messagesDao.deleteMessage(id,accountId); + if (type == 1){ + return new ServerResult(true,"操作成功!"); + }else { + return new ServerResult(false,"操作失败!"); + } + }catch (RuntimeException e){ + return new ServerResult(false,"系统错误!"); + } + } +} diff --git a/src/main/java/live/tomey/api/express/service/impl/OrderServiceImpl.java b/src/main/java/live/tomey/api/express/service/impl/OrderServiceImpl.java index 91e0dda..3965484 100644 --- a/src/main/java/live/tomey/api/express/service/impl/OrderServiceImpl.java +++ b/src/main/java/live/tomey/api/express/service/impl/OrderServiceImpl.java @@ -1,12 +1,10 @@ package live.tomey.api.express.service.impl; -import live.tomey.api.express.dao.AccountDao; -import live.tomey.api.express.dao.MailConfigDao; -import live.tomey.api.express.dao.OrderDao; -import live.tomey.api.express.dao.PriceDao; +import live.tomey.api.express.dao.*; import live.tomey.api.express.dto.*; import live.tomey.api.express.entity.Account; import live.tomey.api.express.entity.MailConfig; +import live.tomey.api.express.entity.Messages; import live.tomey.api.express.entity.Price; import live.tomey.api.express.enums.OrderEnum; import live.tomey.api.express.exceptions.OrderOperationException; @@ -19,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @@ -40,6 +39,8 @@ public class OrderServiceImpl implements OrderService { private AccountDao accountDao; @Autowired private MailConfigDao mailConfigDao; + @Autowired + private MessagesDao messagesDao; /** * 添加订单 @@ -140,10 +141,12 @@ public class OrderServiceImpl implements OrderService { * 快递员获取任务 * * @param orderModifyState + * @param courier * @return */ @Override - public OrderExcution changeState(OrderModifyState orderModifyState) { + @Transactional + public OrderExcution changeState(OrderModifyState orderModifyState, Account courier) { try { Integer state = orderDao.queryStart(orderModifyState.getId()); if (state != 1) { @@ -152,8 +155,17 @@ public class OrderServiceImpl implements OrderService { Integer type = orderDao.editCourierPicks(orderModifyState); if (type == 1) { // todo 发送快递员领取任务邮件 + Date nowDate = new Date(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); + String title = "接单成功"; + String content = "您发布的订单在"+simpleDateFormat.format(nowDate.getTime())+"被配送员 "+courier.getUsername()+" 接单啦,联系电话为:"+courier.getPhone()+"邮箱为:"+courier.getEmail()+"详情在我的订单>>当前订单 查看"; Account account = accountDao.queryAccountForOrderId(orderModifyState.getId()); - sendMail(account,state); + Messages messages = new Messages(account.getId(),title,content); + Integer mtype = messagesDao.insertMessage(messages); + if (mtype !=1 ){ + logger.error("信息发送失败"); + } + sendMail(account,title,content); return new OrderExcution>(OrderEnum.SUCCESS); } else { return new OrderExcution>(OrderEnum.EREE); @@ -192,10 +204,11 @@ public class OrderServiceImpl implements OrderService { /** * 快递员送达快递 * @param orderModifyState + * @param courier * @return */ @Override - public OrderExcution changDelivery(OrderModifyState orderModifyState) { + public OrderExcution changDelivery(OrderModifyState orderModifyState, Account courier) { try { Integer state = orderDao.queryCourierStart(orderModifyState); if (state != 2) { @@ -204,7 +217,18 @@ public class OrderServiceImpl implements OrderService { Integer type = orderDao.editCourierPicks(orderModifyState); if (type == 1) { Account account = accountDao.queryAccountForOrderId(orderModifyState.getId()); - sendMail(account,state); + Date nowDate = new Date(); + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); + String title = "快递送达"; + String content = "派送员与:"+simpleDateFormat.format(nowDate.getTime())+"申请订单完成!
派送员姓名:"+courier.getUsername()+"
联系电话为:"+courier.getPhone()+"
邮箱为:"+courier.getEmail()+"
您是否收到快递? \n" + + " 收到快递则可在 我的订单>>当前订单 选择完成订单.\n" + + " 很高兴为您服务,欢迎再次使用"; + Messages messages = new Messages(account.getId(),title,content); + Integer mtype = messagesDao.insertMessage(messages); + if (mtype !=1 ){ + logger.error("信息发送失败"); + } + sendMail(account,title,content); return new OrderExcution>(OrderEnum.SUCCESS); } else { return new OrderExcution>(OrderEnum.EREE); @@ -266,10 +290,10 @@ public class OrderServiceImpl implements OrderService { } } - public void sendMail(Account account,Integer state){ + public void sendMail(Account account,String title,String content){ // todo 后期加入邮件发送表 MailConfig mailConfig = mailConfigDao.getMailConfig(); - boolean type = MailUnit.sendTheMail(account,mailConfig,state); + boolean type = MailUnit.sendTheMail(account,mailConfig,title,content); if (type){ logger.info(account.getEmail()+"与"+new Date() + "发送邮件成功"); }else { diff --git a/src/main/java/live/tomey/api/express/unit/MailUnit.java b/src/main/java/live/tomey/api/express/unit/MailUnit.java index ff6da64..cb5b115 100644 --- a/src/main/java/live/tomey/api/express/unit/MailUnit.java +++ b/src/main/java/live/tomey/api/express/unit/MailUnit.java @@ -23,7 +23,7 @@ import java.util.Properties; public class MailUnit { private static Logger logger = LoggerFactory.getLogger(MailUnit.class); - public static boolean sendTheMail(Account account, MailConfig mailConfig, Integer state) { + public static boolean sendTheMail(Account account, MailConfig mailConfig,String title,String content) { Transport transport = null; try { // 1. 创建参数配置, 用于连接邮件服务器的参数配置 @@ -46,8 +46,6 @@ public class MailUnit { // 4: Subject: 邮件主题 message.setSubject("校园小飞侠系统提示", "UTF-8"); // 5: Content: 邮件正文(可以使用html标签) - Date nowDate = new Date(); - SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-mm-dd HH:mm:ss"); message.setContent("\n" + "\n" + "\n" + @@ -67,11 +65,11 @@ public class MailUnit { "\n" + "
\n" + "
\n" + - "

快递动态

\n" + + "

"+title+"

\n" + "
\n" + "
\n" + "

尊敬的"+account.getUsername()+":

\n" + - "

您的快递于:"+simpleDateFormat.format(nowDate.getTime())+"被快递小哥领取

\n" + + "

"+content+"

\n" + "

感谢你的访问,祝您使用愉快!

\n" + "

此致

\n" + "

此邮件为系统自动发送,请勿回复。

\n" + diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4284ba0..b091062 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -26,9 +26,9 @@ jdbc.driver=8zQIdS8RzOBmd4qRctgYdYM/fdvrjnIJHyQH1bD/jNs= #服务器本地127.0.0.1 jdbc.urla=xW6OiZLo8/kYFd+0f9nXNXXZg17CJWnfoV5JrAnJaOAhvoLVW/PHqSV0jFnpOIVAxA0arcvd8KTK5pmV8Pi3bPJxQoH6zwkUve3efptPE0f+GUBKpacl+rFIuiDIGGARWhD3wSn+1Q8t+jGw15GlDz/ASsSv8SiOXSlZnsWSVKIbTqDgaMM1VA== #azure -jdbc.urls=xW6OiZLo8/kiW6baGG4kKlxB11i7ytYuDXFcirNE/QxgG6+R9g0kSMNfA3gR9TiRFSQZJ52gM2PVPnmwI8p1dBl0yiCdG7wJXEojUovXnEeESCOUiTu5t9AAB0WAn4P/HJUrZHOeJHdRwMGTTMrHyS4RDb+iakxCQOVpH5Ht8qe3dXTHHXY65A== +jdbc.url=xW6OiZLo8/kiW6baGG4kKlxB11i7ytYuDXFcirNE/QxgG6+R9g0kSMNfA3gR9TiRFSQZJ52gM2PVPnmwI8p1dBl0yiCdG7wJXEojUovXnEeESCOUiTu5t9AAB0WAn4P/HJUrZHOeJHdRwMGTTMrHyS4RDb+iakxCQOVpH5Ht8qe3dXTHHXY65A== #服务器ip -jdbc.url=xW6OiZLo8/ly0RW0vIm4nFrLZaXQTX62SFF7HwCqLmpgG6+R9g0kSMNfA3gR9TiRFSQZJ52gM2PVPnmwI8p1dBl0yiCdG7wJXEojUovXnEeESCOUiTu5t9AAB0WAn4P/HJUrZHOeJHdRwMGTTMrHyS4RDb+iakxCQOVpH5Ht8qe3dXTHHXY65A== +jdbc.urls=xW6OiZLo8/ly0RW0vIm4nFrLZaXQTX62SFF7HwCqLmpgG6+R9g0kSMNfA3gR9TiRFSQZJ52gM2PVPnmwI8p1dBl0yiCdG7wJXEojUovXnEeESCOUiTu5t9AAB0WAn4P/HJUrZHOeJHdRwMGTTMrHyS4RDb+iakxCQOVpH5Ht8qe3dXTHHXY65A== jdbc.username=j00C+YEiqH4= jdbc.password=gBWrKLHw61rRzq6cZbP0Hh8kB9Ww/4zb diff --git a/src/main/resources/mapper/AccountDao.xml b/src/main/resources/mapper/AccountDao.xml index 90a3569..83d6ac6 100644 --- a/src/main/resources/mapper/AccountDao.xml +++ b/src/main/resources/mapper/AccountDao.xml @@ -64,7 +64,7 @@ INSERT INTO - w_account( + t_account( phone, username, password, diff --git a/src/main/resources/mapper/FlatsDao.xml b/src/main/resources/mapper/FlatsDao.xml index 6c5d108..a493899 100644 --- a/src/main/resources/mapper/FlatsDao.xml +++ b/src/main/resources/mapper/FlatsDao.xml @@ -4,22 +4,22 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - INSERT INTO m_flats(m_flats.flats_name,m_flats.desc) VALUES (#{flats.flatsName},#{flats.desc}) + INSERT INTO w_flats(w_flats.flats_name,w_flats.desc) VALUES (#{flats.flatsName},#{flats.desc}) - UPDATE m_flats + UPDATE w_flats - m_flats.desc = #{flats.desc}, - m_flats.flats_name = #{flats.flatsName} + w_flats.desc = #{flats.desc}, + w_flats.flats_name = #{flats.flatsName} - WHERE m_flats.id = #{flats.id} + WHERE w_flats.id = #{flats.id} - DELETE FROM m_flats WHERE id = #{id} + DELETE FROM w_flats WHERE id = #{id} \ No newline at end of file diff --git a/src/main/resources/mapper/MessagesDao.xml b/src/main/resources/mapper/MessagesDao.xml new file mode 100644 index 0000000..7f41f2d --- /dev/null +++ b/src/main/resources/mapper/MessagesDao.xml @@ -0,0 +1,46 @@ + + + + + INSERT INTO + w_message( + account_id, + title, + content, + is_read, + send_time + ) VALUES ( + #{messages.accountId}, + #{messages.title}, + #{messages.content}, + #{messages.isRead}, + #{messages.sendTime} + ) + + + UPDATE w_message SET is_read = 2 WHERE id = #{id} AND account_id = #{accountId} + + + DELETE FROM w_message WHERE id = #{id} AND account_id = #{accountId} + + + + + \ No newline at end of file diff --git a/src/main/resources/mapper/OrderDao.xml b/src/main/resources/mapper/OrderDao.xml index 6daf7fc..285db39 100644 --- a/src/main/resources/mapper/OrderDao.xml +++ b/src/main/resources/mapper/OrderDao.xml @@ -363,7 +363,7 @@ FROM w_account WHERE id = #{courierId} INSERT INTO diff --git a/src/main/resources/mapper/PriceDao.xml b/src/main/resources/mapper/PriceDao.xml index c15f472..c0472ae 100644 --- a/src/main/resources/mapper/PriceDao.xml +++ b/src/main/resources/mapper/PriceDao.xml @@ -4,17 +4,17 @@ "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - UPDATE m_price + UPDATE w_price - m_price.desc = #{price.desc}, - m_price.price = #{price.price} + w_price.desc = #{price.desc}, + w_price.price = #{price.price} - WHERE m_price.id = #{price.id} + WHERE w_price.id = #{price.id} \ No newline at end of file