/*******************************************************************************
 * Copyright (c) 2005, 2014 springside.github.io
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/

package com.cesgroup.cesmonitor.ws;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.cesgroup.cesmonitor.service.MediaService;

/**
 * 媒体服务控制器
 *
 * @author zhang.erwei
 * @version 1.0.0 2017年5月24日
 */
@Controller
@RequestMapping(value = "/ws/media")
public class MediaServiceController {

    @Autowired
    MediaService mediaService;

    /**
     * 发送微信
     *
     * @param request
     *            http请求
     * @return 微信发送返回xml字符串
     */
    @RequestMapping(value = "sendByWeixin")
    @ResponseStatus(value = HttpStatus.OK)
    @ResponseBody
    public String sendByWeixin(String sendTo, String subject, String content) {
        return mediaService.sendByWeixin(sendTo, subject, null);
    }

    /**
     * 发送短信
     *
     * @param request
     *            http请求
     * @return
     */
    @RequestMapping(value = "sendByShortMessage")
    @ResponseBody
    public String sendByShortMessage(String mobile, String content) {
        return mediaService.sendByShortMessage(mobile, content);
    }

    /**
     * 发送邮件
     *
     * @param mailAddress
     *            收件人地址
     * @param subject
     *            主题
     * @param content
     *            邮件内容
     */
    @RequestMapping(value = "sendByMail")
    @ResponseBody
    public void sendByMail(String mailAddress, String subject, String content) {
        mediaService.sendByMail(mailAddress, subject, content);
    }

}
