feat: 替换swagger2为OpenAPI3

This commit is contained in:
zlt2000
2023-11-24 17:28:19 +08:00
parent 61640eb237
commit 387b524f67
67 changed files with 494 additions and 2380 deletions
@@ -1,11 +1,11 @@
package com.central.oauth.controller;
import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import com.central.common.constant.SecurityConstants;
import com.central.common.model.Result;
import com.central.oauth.service.IValidateCodeService;
import com.wf.captcha.base.Captcha;
import com.wf.captcha.GifCaptcha;
import com.wf.captcha.utils.CaptchaUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
@@ -13,7 +13,6 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
@@ -33,17 +32,19 @@ public class ValidateCodeController {
*/
@GetMapping(SecurityConstants.DEFAULT_VALIDATE_CODE_URL_PREFIX + "/{deviceId}")
public void createCode(@PathVariable String deviceId, HttpServletResponse response) throws IOException {
Assert.notNull(deviceId, "机器码不能为空");
Assert.notNull(deviceId, "机器码不能为空");
// 设置请求头为输出图片类型
CaptchaUtil.setHeader(response);
// 三个参数分别为宽、高、位数
GifCaptcha gifCaptcha = new GifCaptcha(100, 35, 4);
// 设置类型:字母数字混合
gifCaptcha.setCharType(Captcha.TYPE_DEFAULT);
response.setContentType("image/jpeg");
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
// 三个参数分别为宽、高、验证码字符数、干扰线宽度
LineCaptcha captcha = CaptchaUtil.createLineCaptcha(100, 35, 4, 10);
// 保存验证码
validateCodeService.saveImageCode(deviceId, gifCaptcha.text().toLowerCase());
validateCodeService.saveImageCode(deviceId, captcha.getCode().toLowerCase());
// 输出图片流
gifCaptcha.out(response.getOutputStream());
captcha.write(response.getOutputStream());
}
/**
@@ -17,7 +17,7 @@ public interface IValidateCodeService {
*/
void saveImageCode(String deviceId, String imageCode);
Result sendSmsCode(String mobile);
Result<String> sendSmsCode(String mobile);
/**
* 获取验证码
@@ -54,7 +54,7 @@ public class ValidateCodeServiceImpl implements IValidateCodeService {
* @return true、false
*/
@Override
public Result sendSmsCode(String mobile) {
public Result<String> sendSmsCode(String mobile) {
Object tempCode = redisRepository.get(buildKey(mobile));
if (tempCode != null) {
log.error("用户:{}验证码未失效{}", mobile, tempCode);
+20 -24
View File
@@ -13,17 +13,30 @@ mybatis-plus:
db-config:
id-type: auto
springdoc:
swagger-ui:
path: /swagger-ui.html
tags-sorter: alpha
operations-sorter: alpha
api-docs:
path: /v3/api-docs
group-configs:
- group: 'uaa'
paths-to-match: '/**'
packages-to-scan: com.central.oauth.controller
default-flat-param-object: true
knife4j:
enable: true
setting:
language: zh_cn
swagger-model-name: 认证中心接口文档
zlt:
oauth2:
token:
store:
type: redis
swagger:
enabled: true
title: 认证中心
description: 认证中心接口文档
version: 1.0
base-package: com.central.oauth.controller
security:
code:
# 忽略验证码的应用编号
@@ -43,21 +56,4 @@ zlt:
enabled: false
includeSqls:
# 应用列表
- com.central.oauth.mapper.ClientMapper.findList
springdoc:
swagger-ui:
path: /doc.html
api-docs:
path: /v3/api-docs
group-configs:
- group: 'uaa'
paths-to-match: '/**'
packages-to-scan: com.central.oauth.controller
default-flat-param-object: true
knife4j:
enable: true
setting:
language: zh_cn
swagger-model-name: 认证中心接口文档
- com.central.oauth.mapper.ClientMapper.findList