leomon
2025-05-14 3387f6754a07694dda1307849a3ab6fe8a24d7c5
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
package com.oying.modules.message.rest;
 
import com.oying.annotation.Log;
import com.oying.modules.message.domain.MessageCustomer;
import com.oying.modules.message.service.MessageCustomerService;
import com.oying.modules.message.domain.dto.MessageCustomerQueryCriteria;
import lombok.RequiredArgsConstructor;
import java.util.List;
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-14
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "消息_顾客")
@RequestMapping("/api/messageCustomer")
public class MessageCustomerController {
 
    private final MessageCustomerService messageCustomerService;
 
    @ApiOperation("导出数据")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('messageCustomer:list')")
    public void exportMessageCustomer(HttpServletResponse response, MessageCustomerQueryCriteria criteria) throws IOException {
        messageCustomerService.download(messageCustomerService.queryAll(criteria), response);
    }
 
    @GetMapping
    @ApiOperation("查询消息_顾客")
    @PreAuthorize("@el.check('messageCustomer:list')")
    public ResponseEntity<PageResult<MessageCustomer>> queryMessageCustomer(MessageCustomerQueryCriteria criteria){
        Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize());
        return new ResponseEntity<>(messageCustomerService.queryAll(criteria,page),HttpStatus.OK);
    }
 
    @PostMapping
    @Log("新增消息_顾客")
    @ApiOperation("新增消息_顾客")
    @PreAuthorize("@el.check('messageCustomer:add')")
    public ResponseEntity<Object> createMessageCustomer(@Validated @RequestBody MessageCustomer resources){
        messageCustomerService.create(resources);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }
 
    @PutMapping
    @Log("修改消息_顾客")
    @ApiOperation("修改消息_顾客")
    @PreAuthorize("@el.check('messageCustomer:edit')")
    public ResponseEntity<Object> updateMessageCustomer(@Validated @RequestBody MessageCustomer resources){
        messageCustomerService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
 
    @DeleteMapping
    @Log("删除消息_顾客")
    @ApiOperation("删除消息_顾客")
    @PreAuthorize("@el.check('messageCustomer:del')")
    public ResponseEntity<Object> deleteMessageCustomer(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) {
        messageCustomerService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}