mirror of
https://gitcode.com/flipped-aurora/gin-vue-admin.git
synced 2026-05-14 03:12:44 +00:00
增加验证码接口 修改swagger某些参数错误
This commit is contained in:
@@ -17,7 +17,6 @@ import (
|
||||
// @Param file formData file true "断点续传示例"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"上传成功"}"
|
||||
// @Router /fileUploadAndDownload/breakpointContinue [post]
|
||||
|
||||
func BreakpointContinue(c *gin.Context) {
|
||||
fileMd5 := c.Request.FormValue("fileMd5")
|
||||
fileName := c.Request.FormValue("fileName")
|
||||
@@ -62,7 +61,7 @@ func BreakpointContinue(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param file params file true "查找文件"
|
||||
// @Param file formData file true "查找文件"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查找成功"}"
|
||||
// @Router /fileUploadAndDownload/findFile [post]
|
||||
func FindFile(c *gin.Context) {
|
||||
@@ -82,7 +81,7 @@ func FindFile(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param file params file true "查找文件"
|
||||
// @Param file formData file true "查找文件"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查找成功"}"
|
||||
// @Router /fileUploadAndDownload/findFile [post]
|
||||
func BreakpointContinueFinish(c *gin.Context) {
|
||||
@@ -101,7 +100,7 @@ func BreakpointContinueFinish(c *gin.Context) {
|
||||
// @Security ApiKeyAuth
|
||||
// @accept multipart/form-data
|
||||
// @Produce application/json
|
||||
// @Param file params file true "查找文件"
|
||||
// @Param file formData file true "查找文件"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查找成功"}"
|
||||
// @Router /fileUploadAndDownload/removeChunk [post]
|
||||
func RemoveChunk(c *gin.Context) {
|
||||
|
||||
@@ -1 +1,44 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"gin-vue-admin/controller/servers"
|
||||
"github.com/dchest/captcha"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
// 获取图片验证码id
|
||||
// @Tags base
|
||||
// @Summary 生成验证码
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body modelInterface.PageInfo true "生成验证码"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /base/captcha [post]
|
||||
func Captcha(c *gin.Context) {
|
||||
id := captcha.NewLen(6)
|
||||
captcha.Server(captcha.StdWidth,captcha.StdHeight)
|
||||
servers.ReportFormat(c,true,"test",gin.H{
|
||||
"id":id,
|
||||
"picPath":"/base/captcha/"+id+".png",
|
||||
})
|
||||
}
|
||||
|
||||
// @Tags base
|
||||
// @Summary 生成验证码图片路径
|
||||
// @Security ApiKeyAuth
|
||||
// @accept application/json
|
||||
// @Produce application/json
|
||||
// @Param data body modelInterface.PageInfo true "生成验证码图片路径"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
|
||||
// @Router /base/captcha/:id [get]
|
||||
func CaptchaImg(c *gin.Context) {
|
||||
servers.GinCapthcaServeHTTP(c.Writer, c.Request)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ func GetSystemConfig(c *gin.Context) {
|
||||
// @Summary 设置配置文件内容
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Param data body sysModel.System true
|
||||
// @Param data body sysModel.System true "设置配置文件内容"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
|
||||
// @Router /system/setSystemConfig [post]
|
||||
func SetSystemConfig(c *gin.Context) {
|
||||
@@ -40,11 +40,13 @@ func SetSystemConfig(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//本方法开发中 开发者windows系统 缺少linux系统所需的包 因此搁置
|
||||
// @Tags system
|
||||
// @Summary 设置配置文件内容
|
||||
// @Security ApiKeyAuth
|
||||
// @Produce application/json
|
||||
// @Param data body sysModel.System true
|
||||
// @Param data body sysModel.System true "设置配置文件内容"
|
||||
// @Success 200 {string} string "{"success":true,"data":{},"msg":"返回成功"}"
|
||||
// @Router /system/ReloadSystem [post]
|
||||
func ReloadSystem(c *gin.Context) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"gin-vue-admin/middleware"
|
||||
"gin-vue-admin/model/modelInterface"
|
||||
"gin-vue-admin/model/sysModel"
|
||||
"github.com/dchest/captcha"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-redis/redis"
|
||||
@@ -23,6 +24,8 @@ var (
|
||||
type RegistAndLoginStuct struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
Captcha string `json:"captcha"`
|
||||
CaptchaId string `json:"captchaId"`
|
||||
}
|
||||
|
||||
type RegestStuct struct {
|
||||
@@ -64,12 +67,17 @@ func Regist(c *gin.Context) {
|
||||
func Login(c *gin.Context) {
|
||||
var L RegistAndLoginStuct
|
||||
_ = c.BindJSON(&L)
|
||||
U := &sysModel.SysUser{Username: L.Username, Password: L.Password}
|
||||
if err, user := U.Login(); err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("用户名密码错误或%v", err), gin.H{})
|
||||
} else {
|
||||
tokenNext(c, *user)
|
||||
if captcha.VerifyString(L.CaptchaId,L.Captcha) {
|
||||
U := &sysModel.SysUser{Username: L.Username, Password: L.Password}
|
||||
if err, user := U.Login(); err != nil {
|
||||
servers.ReportFormat(c, false, fmt.Sprintf("用户名密码错误或%v", err), gin.H{})
|
||||
} else {
|
||||
tokenNext(c, *user)
|
||||
}
|
||||
}else{
|
||||
servers.ReportFormat(c, false, "验证码错误", gin.H{})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//登录以后签发jwt
|
||||
|
||||
Reference in New Issue
Block a user