新增书签设置星标功能 ,新增redis工具类规定时间内请求限制次数,新增阿里大鱼手机号发送验证码功能
This commit is contained in:
@ -0,0 +1,58 @@
|
||||
package com.ruoyi.web.controller.common;
|
||||
|
||||
|
||||
import com.ruoyi.bookmark.service.ISqMenuService;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.utils.PhoneCode;
|
||||
import com.ruoyi.common.utils.bookmarkhtml.Const;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* 验证码操作处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
public class RegisterPhoneController extends BaseController
|
||||
{
|
||||
|
||||
@Autowired
|
||||
private ISqMenuService iSqMenuService;
|
||||
|
||||
|
||||
/**
|
||||
* 发送注册验证码
|
||||
*/
|
||||
@GetMapping("/registerPhoneCode")
|
||||
public AjaxResult registerPhoneCode(String phone)
|
||||
{
|
||||
AjaxResult ajaxResult = new AjaxResult();
|
||||
ajaxResult.put("code", HttpStatus.SUCCESS);
|
||||
//防止重复点击
|
||||
boolean phoneCodelFlag = iSqMenuService.countRepetition(Const.PHONE_REGISTER,getAuthUser().getUserId(),3600L,10); //3600秒 最多请求10次验证码
|
||||
|
||||
if(!phoneCodelFlag){
|
||||
ajaxResult.put("msg","短时间内发送频繁,请稍后再操作!");
|
||||
return ajaxResult;
|
||||
}
|
||||
|
||||
//通过手机号发送短信
|
||||
Boolean flag = PhoneCode.getPhonemsg(phone);
|
||||
|
||||
if (flag){
|
||||
ajaxResult.put("msg","短信发送成功,请在"+Constants.CAPTCHA_PHONE_EXPIRATION+"分钟内验证。");
|
||||
return ajaxResult;
|
||||
}else {
|
||||
ajaxResult.put("msg","短信发送失败");
|
||||
return ajaxResult;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -39,6 +39,25 @@ public class SysLoginController
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
|
||||
/**
|
||||
* 注册方法
|
||||
*
|
||||
* @param loginBody 注册信息
|
||||
* @return 结果
|
||||
*/
|
||||
@PostMapping("/registerUser")
|
||||
public AjaxResult registerUser(@RequestBody LoginBody loginBody)
|
||||
{
|
||||
AjaxResult ajax = AjaxResult.success();
|
||||
// 生成令牌
|
||||
String token = loginService.registerUser(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
|
||||
loginBody.getUuid(),loginBody.getEmail(),loginBody.getPhone());
|
||||
ajax.put(Constants.TOKEN, token);
|
||||
return ajax;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登录方法
|
||||
*
|
||||
|
@ -76,9 +76,8 @@ public class SqBookmarkController extends BaseController
|
||||
* 书签设置星标 取消星标
|
||||
*/
|
||||
@GetMapping("/updateBookmarkStarById")
|
||||
public AjaxResult updateBookmarkStarById(String bookmarkId,int bookmarkStr) {
|
||||
public AjaxResult updateBookmarkStarById(Long bookmarkId,Integer bookmarkStr) {
|
||||
return toAjax(sqBookmarkService.updateBookmarkStarById(getAuthUser().getUserId(),bookmarkId,bookmarkStr));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,6 +7,7 @@ import com.ruoyi.bookmark.mapper.SqMenuMapper;
|
||||
import com.ruoyi.bookmark.service.ISqBookmarkService;
|
||||
import com.ruoyi.bookmark.service.ISqMenuService;
|
||||
import com.ruoyi.bookmark.service.impl.SqMenuServiceImpl;
|
||||
import com.ruoyi.common.utils.bookmarkhtml.Const;
|
||||
import org.apache.ibatis.session.ExecutorType;
|
||||
import org.apache.ibatis.session.SqlSession;
|
||||
import org.apache.velocity.runtime.directive.Foreach;
|
||||
@ -162,4 +163,7 @@ public class SqMenuTest extends BaseSpringBootTest{
|
||||
long end = System.currentTimeMillis();
|
||||
System.out.println("---------------" + (start - end) + "---------------");
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,9 +1,15 @@
|
||||
package com.ruoyi.web.test.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.github.wujun234.uid.UidGenerator;
|
||||
import com.ruoyi.bookmark.service.ISqMenuService;
|
||||
import com.ruoyi.common.core.redis.RedisUtil;
|
||||
import com.ruoyi.common.utils.bookmarkhtml.Const;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Auther: Wang
|
||||
@ -17,6 +23,10 @@ public class UIDTest extends BaseSpringBootTest{
|
||||
private UidGenerator defaultUidGenerator;
|
||||
@Resource
|
||||
private UidGenerator cachedUidGenerator;
|
||||
@Autowired
|
||||
private ISqMenuService iSqMenuService;
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Test
|
||||
public void testSerialGenerate() {
|
||||
@ -34,4 +44,25 @@ public class UIDTest extends BaseSpringBootTest{
|
||||
// System.out.println(cachedUidGenerator.parseUID(uid));
|
||||
|
||||
}
|
||||
@Test
|
||||
public void dateTest(){
|
||||
//当前时间
|
||||
Date date3 = DateUtil.date(System.currentTimeMillis());
|
||||
System.out.println(date3);
|
||||
}
|
||||
|
||||
|
||||
//测试规定时间内 禁能访问次数
|
||||
@Test
|
||||
public void rest2(){
|
||||
boolean phoneCodelFlag = iSqMenuService.countRepetition(Const.PHONE_REGISTER,1L,600L,3);
|
||||
if (phoneCodelFlag){
|
||||
System.out.println("可以访问请求!");
|
||||
}else{
|
||||
System.out.println("访问请求失败了!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,8 @@ ruoyi:
|
||||
# 验证码类型 math 数组计算 char 字符验证
|
||||
captchaType: math
|
||||
|
||||
|
||||
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
|
Reference in New Issue
Block a user