mg
2022-10-08 44a2ecbb4fd164be63390611849d69ed808247ec
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
package com.ycl.controller.message;
 
 
import com.ycl.api.CommonResult;
import com.ycl.bo.AdminUserDetails;
import com.ycl.dto.message.MessageParam;
import com.ycl.service.message.IMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * <p>
 *   消息管理  前端控制器
 * </p>
 *
 * @author mg
 * @since 2022-10-08
 */
@RestController
@RequestMapping("/message")
@Api(tags = "消息")
public class MessageController {
 
    @Autowired
    IMessageService iMessageService;
 
    @ApiOperation(value = "发送消息")
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @ResponseBody
    public CommonResult sendMessage(@Validated @RequestBody MessageParam messageParam) {
        AdminUserDetails user = (AdminUserDetails) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        //设置创建人
        messageParam.setCreateUser(user.getUserId());
        return CommonResult.success(iMessageService.sendMessage(messageParam));
    }
}