package com.trade.client.enterprise.customer.controller;

import com.trade.client.enterprise.customer.service.CustomerMessageService;
import com.trade.common.core.domain.ResponseResult;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * <p>
 * 说明： 客户接口层
 * </P>
 *
 * @version: V1.0
 * @author: wanglang
 * @date: 2024年04月01日
 */
@Api(tags = "消息类接口", value = "客户消息类接口")
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    private CustomerMessageService customerMessageService;

    @ApiOperation(value = "发送短息", notes = "发送短息")
    @PostMapping("/sendSms")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "phoneNumber", value = "手机号", dataTypeClass = String.class, example = "18666666666", required = true),
            @ApiImplicitParam(name = "type", value = "类型", dataTypeClass = String.class, example = "register", required = true)
    })
    public ResponseResult<Boolean> sendSms(@ApiParam(name = "手机号", required = true) String phoneNumber,
            @ApiParam(name = "类型", required = true) String type) {
        return ResponseResult.success(customerMessageService.sendSms(phoneNumber, type));
    }

    @ApiOperation(value = "发送邮箱", notes = "发送邮箱")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "email", value = "邮箱", dataTypeClass = String.class, example = "aaa@xxx.com", required = true)
    })
    @PostMapping("/sendEmail")
    public ResponseResult<Boolean> sendEmail(@ApiParam(name = "邮箱", required = true) String email,
            @ApiParam(name = "邮件模板", required = true) String templateName) {
        return ResponseResult.success(customerMessageService.sendEmail(email, templateName));
    }
}
