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

net.mingsoft.msend.action.SmsAction Maven / Gradle / Ivy

There is a newer version: 2.2.5
Show newest version
/**
The MIT License (MIT) * Copyright (c) 2018 铭飞科技

 * 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;

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.BaseEntity;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.basic.annotation.LogAnn;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.constant.e.BusinessTypeEnum;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.basic.util.StringUtil;
import net.mingsoft.msend.biz.ISmsBiz;
import net.mingsoft.msend.entity.SmsEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
	
/**
 * 短信管理控制层
 * @author 铭飞开发团队
 * @version 
 * 版本号:0.0
* 创建日期:2017-8-24 17:52:29
* 历史修订:
*/ @Api(value = "短信管理控制接口") @Controller @RequestMapping("/${ms.manager.path}/msend/sms") public class SmsAction extends net.mingsoft.msend.action.BaseAction{ /** * 注入短信业务层 */ @Autowired private ISmsBiz smsBiz; /** * 返回主界面index */ @GetMapping("/index") public String index(HttpServletResponse response,HttpServletRequest request){ return "/msend/sms/index"; } /** * 查询短信列表 * @param sms 短信实体 * sms参数包含字段信息参考:
* appId 应用编号
* smsType 短信接口类型
* smsUsername 账号
* smsPassword 密码
* smsSendUrl 发送地址
* smsAccountUrl
* smsManagerUrl 短信平台后台管理地址
* smsSignature 签名
* smsEnable 0启用 1禁用
*
返回

*
[
* {
* appId: 应用编号
* smsType: 短信接口类型
* smsUsername: 账号
* smsPassword: 密码
* smsSendUrl: 发送地址
* smsAccountUrl:
* smsManagerUrl: 短信平台后台管理地址
* smsSignature: 签名
* smsEnable: 0启用 1禁用
* }
* ]

*/ @ApiOperation(value = "查询短信列表接口") @ApiImplicitParams({ @ApiImplicitParam(name = "appId", value = "应用编号", required = false,paramType="query"), @ApiImplicitParam(name = "smsType", value = "短信接口类型", required = false,paramType="query"), @ApiImplicitParam(name = "smsUsername", value = "账号", required = false,paramType="query"), @ApiImplicitParam(name = "smsPassword", value = "密码", required = false,paramType="query"), @ApiImplicitParam(name = "smsSendUrl", value = "发送地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsAccountUrl", value = "账户地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsManagerUrl", value = "短信平台后台管理地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsSignature", value = "签名", required = false,paramType="query"), @ApiImplicitParam(name = "smsEnable", value = "0启用 1禁用", required = false,paramType="query") }) @GetMapping("/list") @ResponseBody public ResultData list(@ModelAttribute @ApiIgnore SmsEntity sms, HttpServletResponse response, HttpServletRequest request, ModelMap model) { BasicUtil.startPage(); List smsList = smsBiz.query(sms); return ResultData.build().success(new EUListBean(smsList,(int)BasicUtil.endPage(smsList).getTotal())); } /** * 返回编辑界面sms_form */ @GetMapping("/form") public String form(@ModelAttribute @ApiIgnore SmsEntity sms,HttpServletResponse response,HttpServletRequest request,ModelMap model){ BaseEntity smsEntity = smsBiz.getEntity(BasicUtil.getAppId()); model.addAttribute("smsEntity",com.alibaba.fastjson.JSONObject.toJSONString(smsEntity)); return "/msend/sms/form"; } /** * 获取短信 * @param sms 短信实体 * sms参数包含字段信息参考:
* appId 应用编号
* smsType 短信接口类型
* smsUsername 账号
* smsPassword 密码
* smsSendUrl 发送地址
* smsAccountUrl
* smsManagerUrl 短信平台后台管理地址
* smsSignature 签名
* smsEnable 0启用 1禁用
*
返回

*
{
* appId: 应用编号
* smsType: 短信接口类型
* smsUsername: 账号
* smsPassword: 密码
* smsSendUrl: 发送地址
* smsAccountUrl:
* smsManagerUrl: 短信平台后台管理地址
* smsSignature: 签名
* smsEnable: 0启用 1禁用
* }

*/ @ApiOperation(value = "获取短信接口") @ApiImplicitParam(name = "appId", value = "应用编号", required = true,paramType="query") @GetMapping("/get") @ResponseBody public ResultData get(@ModelAttribute @ApiIgnore SmsEntity sms,HttpServletResponse response, HttpServletRequest request,ModelMap model){ if(sms.getAppId()<=0) { return ResultData.build().error(getResString("err.error", this.getResString("app.id"))); } SmsEntity _sms = (SmsEntity)smsBiz.getEntity(sms.getAppId()); return ResultData.build().success(_sms); } /** * 保存短信实体 * @param sms 短信实体 * sms参数包含字段信息参考:
* appId 应用编号
* smsType 短信接口类型
* smsUsername 账号
* smsPassword 密码
* smsSendUrl 发送地址
* smsAccountUrl
* smsManagerUrl 短信平台后台管理地址
* smsSignature 签名
* smsEnable 0启用 1禁用
*
返回

*
{
* appId: 应用编号
* smsType: 短信接口类型
* smsUsername: 账号
* smsPassword: 密码
* smsSendUrl: 发送地址
* smsAccountUrl:
* smsManagerUrl: 短信平台后台管理地址
* smsSignature: 签名
* smsEnable: 0启用 1禁用
* }

*/ @ApiOperation(value = "保存短信接口") @ApiImplicitParams({ @ApiImplicitParam(name = "appId", value = "应用编号", required = true,paramType="query"), @ApiImplicitParam(name = "smsType", value = "短信接口类型", required = true,paramType="query"), @ApiImplicitParam(name = "smsUsername", value = "账号", required = true,paramType="query"), @ApiImplicitParam(name = "smsSignature", value = "签名", required = true,paramType="query"), @ApiImplicitParam(name = "smsPassword", value = "密码", required = true,paramType="query"), @ApiImplicitParam(name = "smsSendUrl", value = "发送地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsAccountUrl", value = "账户地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsManagerUrl", value = "短信平台后台管理地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsEnable", value = "0启用 1禁用", required = false,paramType="query") }) @LogAnn(title = "保存短信接口",businessType= BusinessTypeEnum.INSERT) @PostMapping("/save") @ResponseBody @RequiresPermissions("sms:save") public ResultData save(@ModelAttribute @ApiIgnore SmsEntity sms, HttpServletResponse response, HttpServletRequest request,BindingResult result) { //验证短信接口类型的值是否合法 if(StringUtil.isBlank(sms.getSmsType())){ return ResultData.build().error(getResString("err.empty", this.getResString("sms.type"))); } if(!StringUtil.checkLength(sms.getSmsType()+"", 1, 150)){ return ResultData.build().error(getResString("err.length", this.getResString("sms.type"), "1", "150")); } sms.setAppId(BasicUtil.getAppId()); smsBiz.saveEntity(sms); return ResultData.build().success(sms); } /** * @param sms 短信实体 * sms参数包含字段信息参考:
* appId:多个appId直接用逗号隔开,例如appId=1,2,3,4 * 批量删除短信 *
返回

*
{code:"错误编码",
* result:"true|false",
* resultMsg:"错误信息"
* }
*/ @ApiOperation(value = "批量删除短信接口") @LogAnn(title = "批量删除短信接口",businessType= BusinessTypeEnum.DELETE) @PostMapping("/delete") @ResponseBody @RequiresPermissions("sms:del") public ResultData delete(@RequestBody List smss,HttpServletResponse response, HttpServletRequest request) { int[] ids = new int[smss.size()]; for(int i = 0;isms参数包含字段信息参考:
* appId 应用编号
* smsType 短信接口类型
* smsUsername 账号
* smsPassword 密码
* smsSendUrl 发送地址
* smsAccountUrl
* smsManagerUrl 短信平台后台管理地址
* smsSignature 签名
* smsEnable 0启用 1禁用
*
返回

*
{
* appId: 应用编号
* smsType: 短信接口类型
* smsUsername: 账号
* smsPassword: 密码
* smsSendUrl: 发送地址
* smsAccountUrl:
* smsManagerUrl: 短信平台后台管理地址
* smsSignature: 签名
* smsEnable: 0启用 1禁用
* }

*/ @ApiOperation(value = "更新短信接口") @ApiImplicitParams({ @ApiImplicitParam(name = "appId", value = "应用编号", required = true,paramType="query"), @ApiImplicitParam(name = "smsType", value = "短信接口类型", required = true,paramType="query"), @ApiImplicitParam(name = "smsUsername", value = "账号", required = false,paramType="query"), @ApiImplicitParam(name = "smsPassword", value = "密码", required = false,paramType="query"), @ApiImplicitParam(name = "smsSendUrl", value = "发送地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsAccountUrl", value = "账户地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsManagerUrl", value = "短信平台后台管理地址", required = false,paramType="query"), @ApiImplicitParam(name = "smsSignature", value = "签名", required = false,paramType="query"), @ApiImplicitParam(name = "smsEnable", value = "0启用 1禁用", required = false,paramType="query") }) @LogAnn(title = "更新短信接口",businessType= BusinessTypeEnum.UPDATE) @PostMapping("/update") @ResponseBody @RequiresPermissions("sms:update") public ResultData update(@ModelAttribute @ApiIgnore SmsEntity sms, HttpServletResponse response, HttpServletRequest request) { //验证短信接口类型的值是否合法 if(StringUtil.isBlank(sms.getSmsType())){ return ResultData.build().error(getResString("err.empty", this.getResString("sms.type"))); } if(!StringUtil.checkLength(sms.getSmsType()+"", 1, 150)){ return ResultData.build().error(getResString("err.length", this.getResString("sms.type"), "1", "150")); } smsBiz.updateEntity(sms); return ResultData.build().success(sms); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy