package com.prolog.rdc.tms.controller.message;

import com.prolog.framework.common.message.RestMessage;
import com.prolog.framework.core.pojo.Page;
import com.prolog.framework.log.aop.annotation.UserLog;
import com.prolog.rdc.tms.model.dto.message.MessageSendLogDTO;
import com.prolog.rdc.tms.model.vo.message.MessageSendLogQueryVO;
import com.prolog.rdc.tms.model.vo.message.RetrySendLogVO;
import com.prolog.rdc.tms.service.message.MessageSendLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;

/**
 * @author hongbo.pan
 * @date 2022/11/15
 */
@RestController
@Api(tags = "基础配置-消息日志控制层")
@RequestMapping("/messageSendLog")
public class MessageSendLogController {

    @Autowired
    private MessageSendLogService messageSendLogService;

    @UserLog("消息日志分页查询")
    @ApiOperation(httpMethod = "POST", value = "消息日志分页查询")
    @PostMapping(value = "/page")
    public RestMessage<Page<MessageSendLogDTO>> page(@RequestBody MessageSendLogQueryVO vo) {
        Page<MessageSendLogDTO> pageDTOs = messageSendLogService.query(vo);
        return RestMessage.newInstance(true, "查询成功", pageDTOs);
    }

    @UserLog("消息日志重试")
    @ApiOperation(httpMethod = "POST", value = "消息日志重试")
    @PostMapping(value = "/retry")
    public RestMessage retry(@RequestBody RetrySendLogVO vo) {
        messageSendLogService.retry(vo);
        return RestMessage.newInstance(true, "重试成功", null);
    }

}
