package com.mosty.base.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.base.SysMessageInfo;
import com.mosty.base.model.query.base.GetMyMessageQuery;
import com.mosty.base.model.dto.base.SysMessageInfoInsertDto;
import com.mosty.base.service.SysMessageService;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author dw
 * @since 2022/8/26
 * 布控车辆接口
 **/
@Api(tags = "消息相关接口")
@RestController
@AllArgsConstructor
@RequestMapping("/sysMessage")
public class SysMessageController {

    private final SysMessageService sysMessageService;

    @PostMapping("sendMsg")
    @ApiOperation(value = "发送消息")
    @Log(title = "发送消息", businessType = BusinessType.INSERT)
    @JwtSysUser
    public ResponseResult<Integer> sendMsg(@RequestBody SysMessageInfoInsertDto dto) {
        return ResponseResult.success(this.sysMessageService.sendMsg(dto));
    }

    @GetMapping("getPageList")
    @ApiOperation(value = "获取我的消息列表")
    @JwtSysUser
    public ResponseResult<IPage<SysMessageInfo>> getPageList(GetMyMessageQuery dto) {
        return ResponseResult.success(this.sysMessageService.getPageList(dto));
    }
}
