parent
f9142064c9
commit
9c5090d606
@ -0,0 +1,45 @@
|
|||||||
|
package com.ruoyi.system.controller;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.http.Channel;
|
||||||
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
||||||
|
import com.ruoyi.common.core.web.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
||||||
|
import com.ruoyi.common.log.annotation.Log;
|
||||||
|
import com.ruoyi.common.log.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.security.annotation.RequiresPermissions;
|
||||||
|
import com.ruoyi.system.service.IChannelService;
|
||||||
|
import com.ruoyi.system.service.ICommonService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道配置Controller
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2024-09-15
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/common")
|
||||||
|
public class CommonController extends BaseController
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private ICommonService commonService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* H5发送验证码
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/getChannelBySign")
|
||||||
|
public AjaxResult getChannelBySign(@RequestParam("phone")String phone, HttpServletRequest request){
|
||||||
|
return commonService.sendSms(phone);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.ruoyi.system.domain.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MerchantListDto {
|
||||||
|
|
||||||
|
//商户名
|
||||||
|
String merchantName;
|
||||||
|
|
||||||
|
//商户跳转地址
|
||||||
|
String merchantUrl;
|
||||||
|
|
||||||
|
//商户描述
|
||||||
|
String merchantDescribe;
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package com.ruoyi.system.service;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.domain.http.Channel;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道配置Service接口
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2024-09-15
|
||||||
|
*/
|
||||||
|
public interface ICommonService
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* H5发送验证码
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult sendSms(String phone);
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
|
import com.ruoyi.common.core.constant.RedisConstant;
|
||||||
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.redis.service.RedisService;
|
||||||
|
import com.ruoyi.system.service.ICommonService;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渠道配置Service业务层处理
|
||||||
|
*
|
||||||
|
* @author ruoyi
|
||||||
|
* @date 2024-09-15
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CommonServiceImpl implements ICommonService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private RedisService redisService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public AjaxResult sendSms(String phone) {
|
||||||
|
if (StringUtils.isEmpty(phone)){
|
||||||
|
return AjaxResult.error("手机号未空");
|
||||||
|
}
|
||||||
|
if (phone.length()!=11){
|
||||||
|
return AjaxResult.error("手机号长度异常");
|
||||||
|
}
|
||||||
|
//发送验证码
|
||||||
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
int code = secureRandom.nextInt(9000) + 1000;
|
||||||
|
|
||||||
|
//发送验证码工具类
|
||||||
|
|
||||||
|
//放入缓存 3分钟
|
||||||
|
redisService.setCacheObject(RedisConstant.H5_LOGIN_CACHE+phone,1234,3*60l, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
return AjaxResult.success("发送成功");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue