All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.mingsoft.msend.action.web.SendAction Maven / Gradle / Ivy

There is a newer version: 2.2.5
Show newest version
/**
 * The MIT License (MIT)
 * Copyright (c) 2020 铭软科技(mingsoft.net)
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:

 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.

 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package net.mingsoft.msend.action.web;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.msend.entity.MailEntity;
import net.mingsoft.msend.util.SendUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * 邮件管理控制层
 * 
 * @author 铭飞开发团队
 * @version 版本号:0.0
* 创建日期:2017-8-24 14:41:18
* 历史修订:
*/ @Api(value = "邮件管理接口") @Controller("sendAction") @RequestMapping("/msend") public class SendAction extends net.mingsoft.msend.action.BaseAction { @ApiOperation(value = "自由调用邮箱接口") @SuppressWarnings({ "rawtypes", "unchecked" }) @ApiImplicitParams({ @ApiImplicitParam(name = "receive", value = "接收者(邮箱或手机号)", required =true,paramType="query"), @ApiImplicitParam(name = "modelCode", value = "模块编码(后台AES加密过的)", required = true,paramType="query"), @ApiImplicitParam(name = "content", value = "消息内容", required = true,paramType="query"), @ApiImplicitParam(name = "type", value = "消息类型mail|sms", required = true,paramType="query"), }) @PostMapping("/send") @ResponseBody public ResultData send(HttpServletRequest request, HttpServletResponse response) { String receive = request.getParameter("receive"); String modelCode = request.getParameter("modelCode"); String content = request.getParameter("content"); String type = request.getParameter("type"); String sendType = "html";//request.getParameter("sendType"); // 验证模块编码是否为空 if (StringUtils.isBlank(modelCode)) { return ResultData.build().error( this.getResString("err.error", this.getResString("model.code"))); } String _modelCode = this.decryptByAES(request, modelCode); // 将邮箱地址压如String数组 if (_modelCode == null) { return ResultData.build().error( this.getResString("err.error", this.getResString("model.code"))); } Map params = null; try { params = JSONObject.parseObject(content, Map.class); } catch (Exception e) { LOG.error("content 参数不正确"); return ResultData.build().error( this.getResString("err.error", "content")); } // 发送邮箱 boolean status = SendUtil.send(_modelCode, receive, params, type,MailEntity.SendTypeEnum.HTML); if(status){ return ResultData.build().success(); }else { return ResultData.build().error(); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy