首页>代码>基于ssm的微信小程序商城综合管理后台,包括微信小程序和管理后台>/platform/platform-admin/src/main/java/com/platform/controller/ApiSmsController.java
package com.platform.controller;

import com.platform.annotation.IgnoreAuth;
import com.platform.entity.SysSmsLogEntity;
import com.platform.service.SysSmsLogService;
import com.platform.utils.DateUtils;
import com.platform.utils.R;
import com.platform.utils.RRException;
import com.platform.utils.RequestUtil;
import com.platform.utils.ResourceUtil;
import com.platform.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

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

/**
 * 名称:ApiSmsController <br>
 * 描述:Api<br>
 *
 * @author 李鹏军
 * @version 1.0
 * @since 1.0.0
 */
@RestController
@RequestMapping("api")
public class ApiSmsController {
    @Autowired
    private SysSmsLogService smsLogService;

    /**
     * 发送短信
     * mobile:电话号码字符串,中间用英文逗号间隔
     * content:内容字符串
     * stime:追加发送时间,可为空,为空为及时发送
     */
    @IgnoreAuth
    @RequestMapping("/sendSms")
    public R sendSms(HttpServletRequest request, @RequestParam Map<String, String> params) {
        SysSmsLogEntity smsLog = new SysSmsLogEntity();
        String validIP = RequestUtil.getIpAddrByRequest(request);
        if (ResourceUtil.getConfigByName("sms.validIp").indexOf(validIP) < 0) {
            throw new RRException("非法IP请求!");
        }
        smsLog.setMobile(params.get("mobile"));
        smsLog.setContent(params.get("content"));
        String stime = params.get("stime");
        if (StringUtils.isNotEmpty(stime)) {
            smsLog.setStime(DateUtils.convertStringToDate(stime));
        }
        SysSmsLogEntity sysSmsLogEntity = smsLogService.sendSms(smsLog);
        return R.ok().put("result", sysSmsLogEntity);
    }
}
最近下载更多
mariolc  LV6 4月3日
janly989713  LV3 3月4日
n2352441  LV4 3月3日
杨豫川  LV12 1月13日
光头强1024  LV7 1月5日
3263394665  LV9 2023年12月1日
lvllvl  LV4 2023年7月18日
shuigang1218  LV1 2023年6月18日
edpwyg  LV14 2023年6月8日
fewfsdaf  LV4 2023年4月18日
最近浏览更多
slslsl123 13小时前
暂无贡献等级
156260641401  LV1 4月9日
ruo12138  LV1 4月3日
mariolc  LV6 4月1日
WBelong  LV7 3月29日
 LV7 3月29日
吞吞吐吐她  LV4 3月27日
20201202038 3月27日
暂无贡献等级
zolscy  LV12 3月26日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友