package com.wteam.controller.sms;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.wteam.framework.common.enums.ResultUtil;
import com.wteam.framework.common.vo.PageVO;
import com.wteam.framework.common.vo.ResultMessage;
import com.wteam.framework.modules.sms.entity.dos.SmsSign;
import com.wteam.framework.modules.sms.service.SmsSignService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 管理端,短信签名接口
 *
 * @author Chopper
 * @since 2021/1/30 4:09 下午
 */
@RestController
@Tag(name = "管理端,短信签名接口")
@RequestMapping("/manager/sms/sign")
public class SmsSignManagerController {
    @Autowired
    private SmsSignService smsSignService;


    @Operation(summary ="新增短信签名")
    @PostMapping
    public ResultMessage<SmsSign> save(@Valid SmsSign smsSign) {
        smsSignService.addSmsSign(smsSign);
        return ResultUtil.success();
    }

    @Operation(summary ="删除短信签名")
    @DeleteMapping("/{id}")
    @Parameter(name = "id", description = "短信签名id", required = true, schema = @Schema(type = "string"), in = ParameterIn.PATH)
    public ResultMessage<SmsSign> delete(@PathVariable String id) {
        smsSignService.deleteSmsSign(id);
        return ResultUtil.success();
    }


    @Operation(summary ="查询签名详细")
    @GetMapping("/{id}")
    @Parameter(name = "id", description = "短信签名id", required = true, schema = @Schema(type = "string"), in = ParameterIn.PATH)
    public ResultMessage<SmsSign> getDetail(@PathVariable String id) {
        return ResultUtil.data(smsSignService.getById(id));
    }

    @Operation(summary = "查询短信签名状态")
    @PutMapping("/querySmsSign")
    public ResultMessage<SmsSign> querySmsSign() {
        smsSignService.querySmsSign();
        return ResultUtil.success();
    }

    @Operation(summary = "修改短信签名")
    @PutMapping("/modifySmsSign")
    public ResultMessage<SmsSign> modifySmsSign(@Valid SmsSign smsSign) {
        smsSignService.modifySmsSign(smsSign);
        return ResultUtil.success();
    }

    @Operation(summary = "查询短信签名分页")
    @GetMapping("/querySmsSignPage")
    public ResultMessage<IPage<SmsSign>> querySmsSignPage(PageVO page, Integer signStatus) {
        return ResultUtil.data(smsSignService.page(page, signStatus));
    }

}
