管理员功能全部实现

grs
yjxx 2 weeks ago
parent 7dd2f481ac
commit 3b1fb1aa13

@ -2,6 +2,8 @@ package jty.expressdistributionsystem.DTO;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
@ -9,7 +11,9 @@ import java.io.Serializable;
@Data @Data
public class SendMessageDTO implements Serializable { public class SendMessageDTO implements Serializable {
@JsonSerialize(using = ToStringSerializer.class) @JsonSerialize(using = ToStringSerializer.class)
@NotNull(message = "请选择你的聊天对象")
private Long Id; private Long Id;
@NotBlank(message = "消息不能为空")
private String content; private String content;
} }

@ -12,6 +12,7 @@ import jty.expressdistributionsystem.utils.SendMessageUtil;
import jty.expressdistributionsystem.utils.ThreadLocalUtil; import jty.expressdistributionsystem.utils.ThreadLocalUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.ArrayList; import java.util.ArrayList;
@ -78,7 +79,7 @@ public class AdminController {
// 管理员发送消息 // 管理员发送消息
@PostMapping("/sendMessage") @PostMapping("/sendMessage")
public Result<String> sendMessage(@RequestBody @NotNull SendMessageDTO sendMessageDTO) { public Result<String> sendMessage(@RequestBody @Validated SendMessageDTO sendMessageDTO) {
Message message = SendMessageUtil.sendMessage(sendMessageDTO); Message message = SendMessageUtil.sendMessage(sendMessageDTO);
messageService.save(message); messageService.save(message);
return new Result<>(200, "发送成功", ""); return new Result<>(200, "发送成功", "");

Loading…
Cancel
Save