Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞鱼0526
gin-vue-admin
提交
2abf4013
G
gin-vue-admin
项目概览
飞鱼0526
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2abf4013
编写于
4月 04, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
gin-vue-admin 2.0代码重构
上级
91659efa
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
26 addition
and
25 deletion
+26
-25
server/api/v1/sys_captcha.go
server/api/v1/sys_captcha.go
+8
-7
server/utils/captcha.go
server/utils/captcha.go
+6
-6
server/utils/des.go
server/utils/des.go
+1
-1
server/utils/directory.go
server/utils/directory.go
+1
-1
server/utils/hasGap.go
server/utils/hasGap.go
+1
-1
server/utils/md5.go
server/utils/md5.go
+1
-1
server/utils/struct_to_map.go
server/utils/struct_to_map.go
+3
-3
server/utils/upload.go
server/utils/upload.go
+4
-4
server/utils/zipfiles.go
server/utils/zipfiles.go
+1
-1
未找到文件。
server/api/v1/sys_captcha.go
浏览文件 @
2abf4013
package
api
package
v1
import
(
"gin-vue-admin/config"
"gin-vue-admin/controller/servers"
"gin-vue-admin/global"
"gin-vue-admin/global/response"
"gin-vue-admin/utils"
"github.com/dchest/captcha"
"github.com/gin-gonic/gin"
)
...
...
@@ -16,11 +17,11 @@ import (
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /base/captcha [post]
func
Captcha
(
c
*
gin
.
Context
)
{
captchaId
:=
captcha
.
NewLen
(
config
.
GinVueAdminconfig
.
Captcha
.
KeyLong
)
servers
.
ReportFormat
(
c
,
true
,
"验证码获取成功"
,
gin
.
H
{
captchaId
:=
captcha
.
NewLen
(
global
.
GVA_CONFIG
.
Captcha
.
KeyLong
)
response
.
Result
(
response
.
SUCCESS
,
gin
.
H
{
"captchaId"
:
captchaId
,
"picPath"
:
"/base/captcha/"
+
captchaId
+
".png"
,
})
}
,
"验证码获取成功"
,
c
)
}
// @Tags base
...
...
@@ -31,5 +32,5 @@ func Captcha(c *gin.Context) {
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /base/captcha/:captchaId [get]
func
CaptchaImg
(
c
*
gin
.
Context
)
{
servers
.
GinCapthc
aServeHTTP
(
c
.
Writer
,
c
.
Request
)
utils
.
GinCaptch
aServeHTTP
(
c
.
Writer
,
c
.
Request
)
}
QMPlusServer/controller/server
s/captcha.go
→
server/util
s/captcha.go
浏览文件 @
2abf4013
package
server
s
package
util
s
import
(
"bytes"
"fmt"
"gin-vue-admin/
config
"
"gin-vue-admin/
global
"
"github.com/dchest/captcha"
"net/http"
"path"
...
...
@@ -12,7 +12,7 @@ import (
)
// 这里需要自行实现captcha 的gin模式
func
GinCapt
hc
aServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
func
GinCapt
ch
aServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
dir
,
file
:=
path
.
Split
(
r
.
URL
.
Path
)
ext
:=
path
.
Ext
(
file
)
id
:=
file
[
:
len
(
file
)
-
len
(
ext
)]
...
...
@@ -26,7 +26,7 @@ func GinCapthcaServeHTTP(w http.ResponseWriter, r *http.Request) {
}
lang
:=
strings
.
ToLower
(
r
.
FormValue
(
"lang"
))
download
:=
path
.
Base
(
dir
)
==
"download"
if
Serve
(
w
,
r
,
id
,
ext
,
lang
,
download
,
config
.
GinVueAdminconfig
.
Captcha
.
ImgWidth
,
config
.
GinVueAdminconfig
.
Captcha
.
ImgHeight
)
==
captcha
.
ErrNotFound
{
if
Serve
(
w
,
r
,
id
,
ext
,
lang
,
download
,
global
.
GVA_CONFIG
.
Captcha
.
ImgWidth
,
global
.
GVA_CONFIG
.
Captcha
.
ImgHeight
)
==
captcha
.
ErrNotFound
{
http
.
NotFound
(
w
,
r
)
}
}
...
...
@@ -39,10 +39,10 @@ func Serve(w http.ResponseWriter, r *http.Request, id, ext, lang string, downloa
switch
ext
{
case
".png"
:
w
.
Header
()
.
Set
(
"Content-Type"
,
"image/png"
)
captcha
.
WriteImage
(
&
content
,
id
,
width
,
height
)
_
=
captcha
.
WriteImage
(
&
content
,
id
,
width
,
height
)
case
".wav"
:
w
.
Header
()
.
Set
(
"Content-Type"
,
"audio/x-wav"
)
captcha
.
WriteAudio
(
&
content
,
id
,
lang
)
_
=
captcha
.
WriteAudio
(
&
content
,
id
,
lang
)
default
:
return
captcha
.
ErrNotFound
}
...
...
server/utils/des.go
浏览文件 @
2abf4013
package
too
ls
package
uti
ls
import
(
"bytes"
...
...
server/utils/directory.go
浏览文件 @
2abf4013
package
too
ls
package
uti
ls
import
"os"
...
...
server/utils/hasGap.go
浏览文件 @
2abf4013
// 空值校验工具 仅用于检验空字符串 其余类型请勿使用
package
too
ls
package
uti
ls
import
(
"errors"
...
...
server/utils/md5.go
浏览文件 @
2abf4013
package
too
ls
package
uti
ls
import
(
"crypto/md5"
...
...
QMPlusServer/too
ls/struct_to_map.go
→
server/uti
ls/struct_to_map.go
浏览文件 @
2abf4013
package
too
ls
package
uti
ls
import
"reflect"
// 利用反射将结构体转化为map
func
StructToMap
(
obj
interface
{})
map
[
string
]
interface
{}{
func
StructToMap
(
obj
interface
{})
map
[
string
]
interface
{}
{
obj1
:=
reflect
.
TypeOf
(
obj
)
obj2
:=
reflect
.
ValueOf
(
obj
)
...
...
@@ -12,4 +12,4 @@ func StructToMap(obj interface{}) map[string]interface{}{
data
[
obj1
.
Field
(
i
)
.
Name
]
=
obj2
.
Field
(
i
)
.
Interface
()
}
return
data
}
\ No newline at end of file
}
server/utils/upload.go
浏览文件 @
2abf4013
package
server
s
package
util
s
import
(
"context"
"fmt"
"gin-vue-admin/
config
"
"gin-vue-admin/
global
"
"github.com/qiniu/api.v7/auth/qbox"
"github.com/qiniu/api.v7/storage"
"mime/multipart"
"time"
)
var
accessKey
string
=
config
.
GinVueAdminconfig
.
Qiniu
.
AccessKey
// 你在七牛云的accessKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
var
secretKey
string
=
config
.
GinVueAdminconfig
.
Qiniu
.
SecretKey
// 你在七牛云的secretKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
var
accessKey
string
=
global
.
GVA_CONFIG
.
Qiniu
.
AccessKey
// 你在七牛云的accessKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
var
secretKey
string
=
global
.
GVA_CONFIG
.
Qiniu
.
SecretKey
// 你在七牛云的secretKey 这里是我个人测试号的key 仅供测试使用 恳请大家不要乱传东西
// 接收两个参数 一个文件流 一个 bucket 你的七牛云标准空间的名字
func
Upload
(
file
*
multipart
.
FileHeader
,
bucket
string
,
urlPath
string
)
(
err
error
,
path
string
,
key
string
)
{
...
...
server/utils/zipfiles.go
浏览文件 @
2abf4013
package
too
ls
package
uti
ls
import
(
"archive/zip"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录