package com.tofly.xrtygis.custom.controller.gs;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.common.core.entity.ResultRespone;
import com.tofly.common.log.annotation.ToFlyAppLog;
import com.tofly.xrtygis.custom.entity.gs.NoteSearch;
import com.tofly.xrtygis.custom.entity.gs.note.SendNoteEn;
import com.tofly.xrtygis.custom.service.SendNoteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author FlashWJL
 * @date 2021/4/6 11:33
 */
@RestController
@AllArgsConstructor
@RequestMapping("/send")
@Api(tags = "热线--短信接口")
public class SendNoteController {

    private final SendNoteService sendNoteService;

    @ApiOperation(value = "短信查看")
    @GetMapping("/getNote")
    @ToFlyAppLog(title = "短信查看")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "phone", value = "电话号码，多个用逗号隔开", required = true, dataType = "Sring"),
//            @ApiImplicitParam(name = "content", value = "短信内蓉", required = true, dataType = "Sring")
//    })
    public ResultRespone getNote(Page page, NoteSearch noteSearch) {
        return ResultRespone.success(sendNoteService.getNote(page, noteSearch));
    }


    @ApiOperation(value = "短信数量查看")
    @GetMapping("/getNoteNum")
    @ToFlyAppLog(title = "短信数量查看")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "phone", value = "电话号码，多个用逗号隔开", required = true, dataType = "Sring"),
//            @ApiImplicitParam(name = "content", value = "短信内蓉", required = true, dataType = "Sring")
//    })
    public ResultRespone getNoteNum() {
        return ResultRespone.success(sendNoteService.getNoteNum());
    }


    /**
     * 发送短信接口
     *
     * @return
     */
    //(title = "对指定的多个用户发送短信")
    @ApiOperation(value = "对指定的多个用户发送短信")
    @PostMapping("/note")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话号码，多个用逗号隔开", required = true, dataType = "Sring"),
            @ApiImplicitParam(name = "content", value = "短信内蓉", required = true, dataType = "Sring")
    })
    @ToFlyAppLog(title = "对指定的多个用户发送短信")
    public ResultRespone sendNote(@RequestBody SendNoteEn note) {
        String phone = note.getPhone();
        String content = note.getContent();
        return ResultRespone.success(sendNoteService.sendNote(phone, content));
    }

    @ApiOperation(value = "对指定的多个用户发送报警短信")
    @PostMapping("/sendNoteFeign")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phone", value = "电话号码，多个用逗号隔开", required = true, dataType = "Sring"),
            @ApiImplicitParam(name = "content", value = "短信内蓉", required = true, dataType = "Sring")
    })
    @ToFlyAppLog(title = "对指定的多个用户发送报警短信")
    public void sendNoteFeign(@RequestParam("phone") String phone, @RequestParam("content") String content) {
        sendNoteService.sendNoteFeign(phone, content);
    }


    /**
     * 发送模板短信
     *
     * @return
     */
    //(title = "发送模板短信")
    @ApiOperation(value = "发送模板短信")
    @PostMapping("/tempNote")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "clientId", value = "需要发送短信的客户编号，多个用逗号隔开", required = true, dataType = "Sring"),
            @ApiImplicitParam(name = "temp", value = "发送的短信模板内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "id", value = "发送模板的Id", required = true, dataType = "Long")
    })
    @ToFlyAppLog(title = "发送模板短信")
    public ResultRespone sendNoteTemplate(@RequestBody NoteSearch noteSearch) {
        String clientId = noteSearch.getClientId();
        String temp = noteSearch.getTemp();
        String tempId = noteSearch.getId().toString();
        return ResultRespone.success(sendNoteService.sendNoteTemplate(clientId, temp, tempId));
    }

    @ApiOperation(value = "重发短信")
    @PostMapping("/aginSend")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "短信ID", required = true, dataType = "Sring")
    })
    @ToFlyAppLog(title = "重发短信")
    public ResultRespone aginSendNote(@RequestBody NoteSearch noteSearch) {
        return ResultRespone.success(sendNoteService.aginSendNote(noteSearch));
    }

}
