xin
2025-05-30 625692be1b447d98e1a37f3981777bc14246aed9
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
94
95
96
97
98
99
100
101
102
103
104
105
package com.oying.modules.message.rest;
 
import com.oying.annotation.Log;
import com.oying.modules.message.domain.MessageSystem;
import com.oying.modules.message.service.MessageSystemService;
import com.oying.modules.message.domain.dto.MessageSystemQueryCriteria;
import lombok.RequiredArgsConstructor;
 
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
 
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.oying.utils.PageResult;
 
/**
 * @author 李萌
 * @date 2025-05-20
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "消息_系统")
@RequestMapping("/api/message/messageSystem")
public class MessageSystemController {
 
    private final MessageSystemService messageSystemService;
 
//    @ApiOperation("导出数据")
//    @GetMapping(value = "/download")
//    @PreAuthorize("@el.check('messageSystem:list')")
//    public void exportMessageSystem(HttpServletResponse response, MessageSystemQueryCriteria criteria) throws IOException {
//        messageSystemService.download(messageSystemService.queryAll(criteria), response);
//    }
 
    @GetMapping
    @ApiOperation("查询消息_系统")
    @PreAuthorize("@el.check('messageSystem:list')")
    public ResponseEntity<PageResult<MessageSystem>> queryMessageSystem(MessageSystemQueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(messageSystemService.queryAll(criteria,page),HttpStatus.OK);
    }
 
//    @PostMapping
//    @Log("新增消息_系统")
//    @ApiOperation("新增消息_系统")
//    @PreAuthorize("@el.check('messageSystem:add')")
//    public ResponseEntity<Object> createMessageSystem(@Validated @RequestBody MessageSystem resources){
//        messageSystemService.create(resources);
//        return new ResponseEntity<>(HttpStatus.CREATED);
//    }
 
//    @PutMapping
//    @Log("修改消息_系统")
//    @ApiOperation("修改消息_系统")
//    @PreAuthorize("@el.check('messageSystem:edit')")
//    public ResponseEntity<Object> updateMessageSystem(@Validated @RequestBody MessageSystem resources){
//        messageSystemService.update(resources);
//        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
//    }
 
//    @DeleteMapping
//    @Log("删除消息_系统")
//    @ApiOperation("删除消息_系统")
//    @PreAuthorize("@el.check('messageSystem:del')")
//    public ResponseEntity<Object> deleteMessageSystem(@ApiParam(value = "传ID数组[]") @RequestBody List<Integer> ids) {
//        messageSystemService.deleteAll(ids);
//        return new ResponseEntity<>(HttpStatus.OK);
//    }
 
    //查询一条系统消息
    @GetMapping("/{id}")
    @ApiOperation("查询一条系统消息")
    public ResponseEntity<MessageSystem> getMessageSystem(@PathVariable Integer id){
        MessageSystem messageSystem = messageSystemService.getById(id);
        return new ResponseEntity<>(messageSystem,HttpStatus.OK);
    }
    //插入一条系统消息 带两个参数start与end
    @PostMapping()
    @ApiOperation("插入一条系统消息")
    public ResponseEntity<Object> insertMessageSystem(
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date start,
            @RequestParam @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") Date end) {
 
        // 创建 MessageSystem 对象
        MessageSystem messageSystem = new MessageSystem();
        messageSystem.setStartTime(new Timestamp(start.getTime()));
        messageSystem.setEndTime(new Timestamp(end.getTime()));
 
        // 调用服务层保存数据
        messageSystemService.save(messageSystem);
 
        return new ResponseEntity<>(HttpStatus.OK);
    }
 
 
}