MessageController.java
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.subsidy.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.subsidy.common.ResponseData;
import com.subsidy.common.ResponseVO;
import com.subsidy.common.constant.Platform;
import com.subsidy.common.interceptor.LoginRequired;
import com.subsidy.dto.message.CreateMessageDTO;
import com.subsidy.dto.message.MessagePageDTO;
import com.subsidy.model.MessageDO;
import com.subsidy.service.MessageService;
import com.subsidy.util.DateFormatUtil;
import com.subsidy.vo.message.MessageVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 通知消息表 前端控制器
* </p>
*
* @author Tuyp
* @since 2025-01-08
*/
@RestController
@Api(tags = "赛事公告")
@RequestMapping("/message")
public class MessageController {
@Autowired
private MessageService messageService;
@PostMapping(value = "/getMessage")
@ApiOperation("查询通知")
public ResponseVO getMessage() {
List<MessageVO> messages = new ArrayList();
List<MessageDO> list = messageService.list(new QueryWrapper<MessageDO>()
.lambda()
.orderByDesc(MessageDO::getCreateDate));
for (MessageDO messageDO : list) {
MessageVO messageVO = new MessageVO();
BeanUtils.copyProperties(messageDO, messageVO);
messageVO.setReleaseTime(messageDO.getReleaseTime());
messages.add(messageVO);
}
return ResponseData.generateCreatedResponse(0, messages);
}
@PostMapping(value = "/getMessageById")
@ApiOperation("中心端 --- 根据ID查询详情:id/ID")
public ResponseVO getMessageById(@RequestBody MessageDO messageDO) {
return ResponseData.generateCreatedResponse(0, messageService.getById(messageDO.getId()));
}
@PostMapping(value = "/getMessagePage")
@ApiOperation("中心端 ---分页查询通知: pageNum/当前页数, pageSize/每页显示条数")
public ResponseVO getMessagePage(@RequestBody MessagePageDTO messagePageDTO) {
return ResponseData.generateCreatedResponse(0, messageService.getMessagePage(messagePageDTO));
}
@PostMapping(value = "/createMessage")
@ApiOperation("中心端 ---创建通知: title/标题, content/内容, attachmentUrl/附件地址, releaseTime/发布时间, attachmentName/附件名称, attachmentType/附件类型")
public ResponseVO createMessage(@RequestBody CreateMessageDTO createMessageDTO) {
messageService.createMessage(createMessageDTO);
return ResponseData.generateCreatedResponse(0);
}
@PostMapping(value = "/updateMessage")
@ApiOperation("中心端 ---编辑通知: id/ID, title/标题, content/内容, attachmentUrl/附件地址, attachmentName/附件名称, attachmentType/附件类型")
public ResponseVO updateMessage(@RequestBody MessageDO messageDO) {
messageService.updateById(messageDO);
return ResponseData.generateCreatedResponse(0);
}
@PostMapping(value = "/delete")
@ApiOperation("中心端 ---删除通知: id/ID, ")
public ResponseVO delete(@RequestBody MessageDO messageDO) {
messageService.removeById(messageDO.getId());
return ResponseData.generateCreatedResponse(0);
}
}