首页>代码>基于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);
    }
}
最近下载更多
陈小灏  LV18 2月23日
dsffssff  LV4 2024年12月17日
educationAAA  LV11 2024年12月13日
zolscy  LV24 2024年11月27日
WHY-small  LV15 2024年11月23日
1231321321212  LV1 2024年9月18日
tangyongheng08  LV6 2024年5月23日
mariolc  LV6 2024年4月3日
janly989713  LV3 2024年3月4日
n2352441  LV4 2024年3月3日
最近浏览更多
汤汤汤要学编程  LV11 5月6日
18650066502  LV12 4月27日
zjjhzjb  LV15 4月16日
jigong  LV1 3月27日
W670597  LV2 3月25日
lipiao161  LV16 3月15日
atheking  LV18 3月6日
wyx065747  LV67 1月29日
YafengLiang  LV15 1月7日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友