You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.6 KiB
79 lines
2.6 KiB
package com.teaching.backend.controller.message; |
|
|
|
|
|
import com.teaching.backend.common.BaseResponse; |
|
import com.teaching.backend.common.ResultUtils; |
|
import com.teaching.backend.filter.ValidateParams; |
|
import com.teaching.backend.model.dto.courses.PageDTO; |
|
import com.teaching.backend.model.dto.message.SysMessageDTO; |
|
import com.teaching.backend.model.entity.message.SysMessages; |
|
import com.teaching.backend.model.query.CourseQuery; |
|
import com.teaching.backend.model.query.MessagesQuery; |
|
import com.teaching.backend.model.vo.courses.CoursesVO; |
|
import com.teaching.backend.model.vo.message.SysMessageVO; |
|
import com.teaching.backend.service.message.IMessagesService; |
|
import io.swagger.annotations.Api; |
|
import io.swagger.annotations.ApiOperation; |
|
import org.springframework.beans.factory.annotation.Autowired; |
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import java.time.LocalDateTime; |
|
import java.util.List; |
|
|
|
/** |
|
* <p> |
|
* 前端控制器 |
|
* </p> |
|
* |
|
* @author zjh |
|
* @since 2024-08-06 |
|
*/ |
|
@Api(tags = "系统消息管理接口") |
|
@RestController |
|
@RequestMapping("/messages") |
|
public class MessagesController { |
|
|
|
@Autowired |
|
private IMessagesService messagesService; |
|
|
|
@ApiOperation("发送消息") |
|
@ValidateParams({"senderId","title","content","receiverId"}) // 需要校验的参数 |
|
@PostMapping("/addmessage") |
|
public BaseResponse<String> sendMessage(@RequestBody SysMessageDTO sysMessageDTO){ |
|
String data = messagesService.sendMessageToUserInbox(sysMessageDTO); |
|
return ResultUtils.success(data); |
|
} |
|
|
|
//TODO 功能待完善 |
|
@ApiOperation("删除发件箱的消息--批删--逻辑删除") |
|
@ValidateParams({"messageIds"}) // 需要校验的参数 |
|
@DeleteMapping ("/deletesendmessage") |
|
public BaseResponse<String> deleteMessages(@RequestParam List<Long> messageIds){ |
|
String data = messagesService.deleteSendMessagesByLogical(messageIds); |
|
return ResultUtils.success(data); |
|
} |
|
|
|
|
|
|
|
@ApiOperation("根据id查询消息") |
|
@ValidateParams({"id"}) // 需要校验的参数 |
|
@GetMapping ("/getmessage/{id}") |
|
public BaseResponse<SysMessages> getMessageById(@PathVariable("id") Long id){ |
|
SysMessages data = messagesService.getById(id); |
|
return ResultUtils.success(data); |
|
} |
|
|
|
/** |
|
* 修改消息 |
|
* @param sysMessageDTO |
|
* @return |
|
*/ |
|
@ApiOperation("修改消息--仅限于未发送成功的消息(草稿功能)") |
|
@PutMapping ("/modifymessage") |
|
public BaseResponse<String> modifyMessage(@RequestBody SysMessageDTO sysMessageDTO){ |
|
boolean b = messagesService.updateById(sysMessageDTO); |
|
return ResultUtils.success(b ? "修改成功" : "修改失败"); |
|
} |
|
|
|
|
|
}
|
|
|