项目一阶段和二阶段通过测试验收

grs
yjxx 1 month ago
parent 9e65e55290
commit 038760b094

@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jty.expressdistributionsystem.DTO.SendMessageDTO; import jty.expressdistributionsystem.DTO.SendMessageDTO;
import jty.expressdistributionsystem.config.MyMetaObjectHandler; import jty.expressdistributionsystem.config.MyMetaObjectHandler;
import jty.expressdistributionsystem.entity.Message;
import jty.expressdistributionsystem.entity.Result; import jty.expressdistributionsystem.entity.Result;
import jty.expressdistributionsystem.entity.User; import jty.expressdistributionsystem.entity.User;
import jty.expressdistributionsystem.service.MessageService;
import jty.expressdistributionsystem.service.UserService; import jty.expressdistributionsystem.service.UserService;
import jty.expressdistributionsystem.utils.SendMessage; import jty.expressdistributionsystem.utils.SendMessage;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -17,6 +19,9 @@ public class AdminController {
@Resource @Resource
private UserService userService; private UserService userService;
@Resource
private MessageService messageService;
// 管理员查看用户或者快递员信息 // 管理员查看用户或者快递员信息
@GetMapping("/userList") @GetMapping("/userList")
public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize, @RequestParam int mark) { public Result<Page<User>> getUserList(@RequestParam int page, @RequestParam int pageSize, @RequestParam int mark) {
@ -57,7 +62,8 @@ public class AdminController {
// 管理员发送消息 // 管理员发送消息
@PostMapping("/sendMessage") @PostMapping("/sendMessage")
public Result<String> sendMessage(@RequestBody SendMessageDTO sendMessageDTO) { public Result<String> sendMessage(@RequestBody SendMessageDTO sendMessageDTO) {
SendMessage.sendMessage(sendMessageDTO); Message message = SendMessage.sendMessage(sendMessageDTO);
messageService.save(message);
return new Result<>(200, "发送成功", ""); return new Result<>(200, "发送成功", "");
} }
} }

@ -1,5 +1,6 @@
package jty.expressdistributionsystem.entity; package jty.expressdistributionsystem.entity;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@ -33,10 +34,10 @@ public class Message implements Serializable {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
private Long getUserId; private Long getUserId;
@TableField("create_time") @TableField(value = "create_time", fill = FieldFill.INSERT)
private LocalDateTime createTime; private LocalDateTime createTime;
@TableField("update_time") @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
private LocalDateTime updateTime; private LocalDateTime updateTime;
@TableField("mark") @TableField("mark")

@ -1,21 +1,17 @@
package jty.expressdistributionsystem.utils; package jty.expressdistributionsystem.utils;
import jakarta.annotation.Resource;
import jty.expressdistributionsystem.DTO.SendMessageDTO; import jty.expressdistributionsystem.DTO.SendMessageDTO;
import jty.expressdistributionsystem.entity.Message; import jty.expressdistributionsystem.entity.Message;
import jty.expressdistributionsystem.service.MessageService;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class SendMessage { public class SendMessage {
@Resource
private static MessageService messageService;
public static void sendMessage(@NotNull SendMessageDTO sendMessageDTO) { public static Message sendMessage(@NotNull SendMessageDTO sendMessageDTO) {
Long sendId = GetIdUtil.getId(); Long sendId = GetIdUtil.getId();
Message message = new Message(); Message message = new Message();
message.setSendUserId(sendId); message.setSendUserId(sendId);
message.setGetUserId(sendMessageDTO.getId()); message.setGetUserId(sendMessageDTO.getId());
message.setContent(sendMessageDTO.getContent()); message.setContent(sendMessageDTO.getContent());
messageService.save(message); return message;
} }
} }

Loading…
Cancel
Save