parent
4ffc2cb815
commit
f4a698bc57
@ -0,0 +1,57 @@
|
||||
package cn.iocoder.mall.system.biz.dataobject.oauth2;
|
||||
|
||||
import cn.iocoder.common.framework.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* OAuth2 手机验证码
|
||||
*/
|
||||
@TableName("oauth2_mobile_code")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class OAuth2MobileCodeDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 验证码
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 创建 IP
|
||||
*/
|
||||
private String createIp;
|
||||
/**
|
||||
* 今日发送的第几条
|
||||
*/
|
||||
private Integer todayIndex;
|
||||
/**
|
||||
* 是否使用
|
||||
*/
|
||||
private Boolean used;
|
||||
/**
|
||||
* 使用的账号编号
|
||||
*/
|
||||
private Integer usedAccountId;
|
||||
/**
|
||||
* 使用时间
|
||||
*/
|
||||
private Date usedTime;
|
||||
/**
|
||||
* 使用 IP
|
||||
*/
|
||||
private Date usedIp;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.mall.system.biz.dto.oatuh2;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
// TODO 注释
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OAuth2MobileCodeAuthenticateDTO {
|
||||
|
||||
private String mobile;
|
||||
private String code;
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.mall.system.biz.dto.oatuh2;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
// TODO 注释
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class OAuth2MobileCodeSendDTO {
|
||||
|
||||
private String mobile;
|
||||
private String ip;
|
||||
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
package cn.iocoder.mall.system.biz.dto;
|
||||
@ -0,0 +1,10 @@
|
||||
package cn.iocoder.mall.system.biz.service.user;
|
||||
|
||||
/**
|
||||
* 用户 Service 接口
|
||||
*/
|
||||
public interface UserService {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
package cn.iocoder.mall.system.biz.service.user.impl;
|
||||
|
||||
import cn.iocoder.mall.system.biz.service.user.UserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
}
|
||||
@ -1,4 +1,8 @@
|
||||
##################### 业务模块 #####################
|
||||
## OAuth2CodeService
|
||||
modules.oauth2-code-service.access-token-expire-time-millis = 2880000
|
||||
modules.oauth2-code-service.refresh-token-expire-time-millis = 43200000
|
||||
modules.oauth2-code-service.refresh-token-expire-time-millis = 43200000
|
||||
## OAuth2MobileCodeService
|
||||
modules.oauth2-mobile-code-service.code-expire-time-millis = 600000
|
||||
modules.oauth2-mobile-code-service.send-maximum-quantity-per-day = 10
|
||||
modules.oauth2-mobile-code-service.send-frequency = 60000
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
package cn.iocoder.mall.system.rest.controller.users;
|
||||
|
||||
import cn.iocoder.common.framework.constant.MallConstants;
|
||||
import cn.iocoder.common.framework.util.HttpUtil;
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.mall.system.biz.dto.oatuh2.OAuth2MobileCodeSendDTO;
|
||||
import cn.iocoder.mall.system.biz.service.oauth2.OAuth2MobileCodeService;
|
||||
import cn.iocoder.mall.system.biz.service.oauth2.OAuth2Service;
|
||||
import cn.iocoder.mall.system.biz.service.user.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
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;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(MallConstants.ROOT_PATH_USER + "/oauth2")
|
||||
@Api(tags = "用户 - OAuth2 API")
|
||||
public class UsersOAuth2Controller {
|
||||
|
||||
@Autowired
|
||||
private OAuth2Service oauth2Service;
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private OAuth2MobileCodeService oauth2MobileCodeService;
|
||||
|
||||
@PostMapping("/send_mobile_code")
|
||||
@ApiOperation("发送手机验证码")
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, example = "15601691234")
|
||||
public CommonResult<Boolean> sendMobileCode(@RequestParam("mobile") String mobile,
|
||||
HttpServletRequest request) {
|
||||
// 执行发送验证码
|
||||
OAuth2MobileCodeSendDTO sendDTO = new OAuth2MobileCodeSendDTO()
|
||||
.setMobile(mobile).setIp(HttpUtil.getIp(request));
|
||||
oauth2MobileCodeService.sendMobileCode(sendDTO);
|
||||
// 返回成功
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in new issue