Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FLIPPED-AURORA
gin-vue-admin
提交
0acb0298
G
gin-vue-admin
项目概览
FLIPPED-AURORA
/
gin-vue-admin
大约 1 年 前同步成功
通知
343
Star
18155
Fork
5506
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
0acb0298
编写于
9月 13, 2019
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
username password
上级
8cb68612
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
77 addition
and
66 deletion
+77
-66
QMPlusServer/config/config.go
QMPlusServer/config/config.go
+1
-1
QMPlusServer/config/dbconfig/config.json
QMPlusServer/config/dbconfig/config.json
+1
-1
QMPlusServer/controller/api/user.go
QMPlusServer/controller/api/user.go
+18
-18
QMPlusServer/docs/docs.go
QMPlusServer/docs/docs.go
+9
-9
QMPlusServer/docs/swagger.json
QMPlusServer/docs/swagger.json
+9
-9
QMPlusServer/docs/swagger.yaml
QMPlusServer/docs/swagger.yaml
+9
-9
QMPlusServer/init/qmsql/initMysql.go
QMPlusServer/init/qmsql/initMysql.go
+1
-1
QMPlusServer/model/dbModel/user.go
QMPlusServer/model/dbModel/user.go
+11
-11
QMPlusServer/router/user.go
QMPlusServer/router/user.go
+1
-1
QMPlusVuePage/src/store/module/user.js
QMPlusVuePage/src/store/module/user.js
+17
-6
未找到文件。
QMPlusServer/config/config.go
浏览文件 @
0acb0298
...
...
@@ -10,7 +10,7 @@ type Config struct {
Admin
Admin
}
type
Admin
struct
{
User
N
ame
string
User
n
ame
string
Password
string
Path
string
Dbname
string
...
...
QMPlusServer/config/dbconfig/config.json
浏览文件 @
0acb0298
{
"admin"
:
{
"user
N
ame"
:
"root"
,
"user
n
ame"
:
"root"
,
"password"
:
"Aa@6447985"
,
"path"
:
"127.0.0.1:3306"
,
"dbname"
:
"QMPlus"
,
...
...
QMPlusServer/controller/api/user.go
浏览文件 @
0acb0298
...
...
@@ -18,8 +18,8 @@ var (
)
type
RegistAndLoginStuct
struct
{
User
Name
string
`json:"userN
ame"`
Pass
Word
string
`json:"passW
ord"`
User
name
string
`json:"usern
ame"`
Pass
word
string
`json:"passw
ord"`
}
// @Tags Base
...
...
@@ -32,7 +32,7 @@ func Regist(c *gin.Context) {
var
R
RegistAndLoginStuct
_
=
c
.
BindJSON
(
&
R
)
U
:=
&
dbModel
.
User
{
User
Name
:
R
.
UserName
,
PassWord
:
R
.
PassW
ord
}
U
:=
&
dbModel
.
User
{
User
name
:
R
.
Username
,
Password
:
R
.
Passw
ord
}
err
,
user
:=
U
.
Regist
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"%v"
,
err
),
gin
.
H
{
...
...
@@ -54,9 +54,9 @@ func Regist(c *gin.Context) {
func
Login
(
c
*
gin
.
Context
)
{
var
L
RegistAndLoginStuct
_
=
c
.
BindJSON
(
&
L
)
U
:=
&
dbModel
.
User
{
User
Name
:
L
.
UserName
,
PassWord
:
L
.
PassW
ord
}
U
:=
&
dbModel
.
User
{
User
name
:
L
.
Username
,
Password
:
L
.
Passw
ord
}
if
err
,
user
:=
U
.
Login
();
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"用户名密码错误或%v"
,
err
),
gin
.
H
{
"user"
:
user
})
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"用户名密码错误或%v"
,
err
),
gin
.
H
{})
}
else
{
tokenNext
(
c
,
*
user
)
}
...
...
@@ -86,24 +86,24 @@ func tokenNext(c *gin.Context, user dbModel.User) {
}
}
type
ChangePass
W
ordStutrc
struct
{
User
Name
string
`json:"userN
ame"`
Pass
Word
string
`json:"passW
ord"`
NewPass
Word
string
`json:"newPassW
ord"`
type
ChangePass
w
ordStutrc
struct
{
User
name
string
`json:"usern
ame"`
Pass
word
string
`json:"passw
ord"`
NewPass
word
string
`json:"newPassw
ord"`
}
// @Tags User
// @Summary 用户修改密码
// @Security ApiKeyAuth
// @Produce application/json
// @Param data body api.ChangePass
W
ordStutrc true "用户修改密码"
// @Param data body api.ChangePass
w
ordStutrc true "用户修改密码"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /user/changePass
W
ord [post]
func
ChangePass
W
ord
(
c
*
gin
.
Context
)
{
var
params
ChangePass
W
ordStutrc
// @Router /user/changePass
w
ord [post]
func
ChangePass
w
ord
(
c
*
gin
.
Context
)
{
var
params
ChangePass
w
ordStutrc
_
=
c
.
BindJSON
(
&
params
)
U
:=
&
dbModel
.
User
{
User
Name
:
params
.
UserName
,
PassWord
:
params
.
PassW
ord
}
if
err
,
_
:=
U
.
ChangePass
Word
(
params
.
NewPassW
ord
);
err
!=
nil
{
U
:=
&
dbModel
.
User
{
User
name
:
params
.
Username
,
Password
:
params
.
Passw
ord
}
if
err
,
_
:=
U
.
ChangePass
word
(
params
.
NewPassw
ord
);
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
"修改失败,请检查用户名密码"
,
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"修改成功"
,
gin
.
H
{})
...
...
@@ -120,7 +120,7 @@ type UserHeaderImg struct {
// @accept multipart/form-data
// @Produce application/json
// @Param headerImg formData file true "用户上传头像"
// @Param user
N
ame formData string true "用户上传头像"
// @Param user
n
ame formData string true "用户上传头像"
// @Success 200 {string} json "{"success":true,"data":{},"msg":"上传成功"}"
// @Router /user/uploadHeaderImg [post]
func
UploadHeaderImg
(
c
*
gin
.
Context
)
{
...
...
@@ -131,7 +131,7 @@ func UploadHeaderImg(c *gin.Context) {
fmt
.
Println
(
waitUse
.
NickName
)
_
,
header
,
err
:=
c
.
Request
.
FormFile
(
"headerImg"
)
//便于找到用户 以后从jwt中取
user
Name
:=
c
.
PostForm
(
"userN
ame"
)
user
name
:=
c
.
PostForm
(
"usern
ame"
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"上传文件失败,%v"
,
err
),
gin
.
H
{})
}
else
{
...
...
@@ -141,7 +141,7 @@ func UploadHeaderImg(c *gin.Context) {
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"接收返回值失败,%v"
,
err
),
gin
.
H
{})
}
else
{
//修改数据库后得到修改后的user并且返回供前端使用
err
,
user
:=
new
(
dbModel
.
User
)
.
UploadHeaderImg
(
user
N
ame
,
filePath
)
err
,
user
:=
new
(
dbModel
.
User
)
.
UploadHeaderImg
(
user
n
ame
,
filePath
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"修改数据库链接失败,%v"
,
err
),
gin
.
H
{})
...
...
QMPlusServer/docs/docs.go
浏览文件 @
0acb0298
...
...
@@ -244,7 +244,7 @@ var doc = `{
}
}
},
"/user/changePass
W
ord": {
"/user/changePass
w
ord": {
"post": {
"security": [
{
...
...
@@ -266,7 +266,7 @@ var doc = `{
"required": true,
"schema": {
"type": "object",
"$ref": "#/definitions/api.ChangePass
W
ordStutrc"
"$ref": "#/definitions/api.ChangePass
w
ordStutrc"
}
}
],
...
...
@@ -347,7 +347,7 @@ var doc = `{
{
"type": "string",
"description": "用户上传头像",
"name": "user
N
ame",
"name": "user
n
ame",
"in": "formData",
"required": true
}
...
...
@@ -364,16 +364,16 @@ var doc = `{
}
},
"definitions": {
"api.ChangePass
W
ordStutrc": {
"api.ChangePass
w
ordStutrc": {
"type": "object",
"properties": {
"newPass
W
ord": {
"newPass
w
ord": {
"type": "string"
},
"pass
W
ord": {
"pass
w
ord": {
"type": "string"
},
"user
N
ame": {
"user
n
ame": {
"type": "string"
}
}
...
...
@@ -414,10 +414,10 @@ var doc = `{
"api.RegistAndLoginStuct": {
"type": "object",
"properties": {
"pass
W
ord": {
"pass
w
ord": {
"type": "string"
},
"user
N
ame": {
"user
n
ame": {
"type": "string"
}
}
...
...
QMPlusServer/docs/swagger.json
浏览文件 @
0acb0298
...
...
@@ -227,7 +227,7 @@
}
}
},
"/user/changePass
W
ord"
:
{
"/user/changePass
w
ord"
:
{
"post"
:
{
"security"
:
[
{
...
...
@@ -249,7 +249,7 @@
"required"
:
true
,
"schema"
:
{
"type"
:
"object"
,
"$ref"
:
"#/definitions/api.ChangePass
W
ordStutrc"
"$ref"
:
"#/definitions/api.ChangePass
w
ordStutrc"
}
}
],
...
...
@@ -330,7 +330,7 @@
{
"type"
:
"string"
,
"description"
:
"用户上传头像"
,
"name"
:
"user
N
ame"
,
"name"
:
"user
n
ame"
,
"in"
:
"formData"
,
"required"
:
true
}
...
...
@@ -347,16 +347,16 @@
}
},
"definitions"
:
{
"api.ChangePass
W
ordStutrc"
:
{
"api.ChangePass
w
ordStutrc"
:
{
"type"
:
"object"
,
"properties"
:
{
"newPass
W
ord"
:
{
"newPass
w
ord"
:
{
"type"
:
"string"
},
"pass
W
ord"
:
{
"pass
w
ord"
:
{
"type"
:
"string"
},
"user
N
ame"
:
{
"user
n
ame"
:
{
"type"
:
"string"
}
}
...
...
@@ -397,10 +397,10 @@
"api.RegistAndLoginStuct"
:
{
"type"
:
"object"
,
"properties"
:
{
"pass
W
ord"
:
{
"pass
w
ord"
:
{
"type"
:
"string"
},
"user
N
ame"
:
{
"user
n
ame"
:
{
"type"
:
"string"
}
}
...
...
QMPlusServer/docs/swagger.yaml
浏览文件 @
0acb0298
basePath
:
/
definitions
:
api.ChangePass
W
ordStutrc
:
api.ChangePass
w
ordStutrc
:
properties
:
newPass
W
ord
:
newPass
w
ord
:
type
:
string
pass
W
ord
:
pass
w
ord
:
type
:
string
user
N
ame
:
user
n
ame
:
type
:
string
type
:
object
api.CreateApiParams
:
...
...
@@ -32,9 +32,9 @@ definitions:
type
:
object
api.RegistAndLoginStuct
:
properties
:
pass
W
ord
:
pass
w
ord
:
type
:
string
user
N
ame
:
user
n
ame
:
type
:
string
type
:
object
modelInterface.PageInfo
:
...
...
@@ -187,7 +187,7 @@ paths:
summary
:
用户注册账号
tags
:
-
Base
/user/changePass
W
ord
:
/user/changePass
w
ord
:
post
:
parameters
:
-
description
:
用户修改密码
...
...
@@ -195,7 +195,7 @@ paths:
name
:
data
required
:
true
schema
:
$ref
:
'
#/definitions/api.ChangePass
W
ordStutrc'
$ref
:
'
#/definitions/api.ChangePass
w
ordStutrc'
type
:
object
produces
:
-
application/json
...
...
@@ -245,7 +245,7 @@ paths:
type
:
file
-
description
:
用户上传头像
in
:
formData
name
:
user
N
ame
name
:
user
n
ame
required
:
true
type
:
string
produces
:
...
...
QMPlusServer/init/qmsql/initMysql.go
浏览文件 @
0acb0298
...
...
@@ -11,7 +11,7 @@ var DEFAULTDB *gorm.DB
//初始化数据库并产生数据库全局变量
func
InitMysql
(
admin
config
.
Admin
)
*
gorm
.
DB
{
if
db
,
err
:=
gorm
.
Open
(
"mysql"
,
admin
.
User
N
ame
+
":"
+
admin
.
Password
+
"@("
+
admin
.
Path
+
")/"
+
admin
.
Dbname
+
"?"
+
admin
.
Config
);
err
!=
nil
{
if
db
,
err
:=
gorm
.
Open
(
"mysql"
,
admin
.
User
n
ame
+
":"
+
admin
.
Password
+
"@("
+
admin
.
Path
+
")/"
+
admin
.
Dbname
+
"?"
+
admin
.
Config
);
err
!=
nil
{
log
.
Printf
(
"DEFAULTDB数据库启动异常%S"
,
err
)
}
else
{
DEFAULTDB
=
db
...
...
QMPlusServer/model/dbModel/user.go
浏览文件 @
0acb0298
...
...
@@ -13,8 +13,8 @@ import (
type
User
struct
{
gorm
.
Model
`json:"-"`
UUID
uuid
.
UUID
`json:"uuid"`
User
Name
string
`json:"userName
"`
Pass
Word
string
`json:"passWord
"`
User
name
string
`json:"-
"`
Pass
word
string
`json:"-
"`
NickName
string
`json:"nickName" gorm:"default:'QMPlusUser'"`
HeaderImg
string
`json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"`
Authority
Authority
`json:"authority" form:"ForeignKey:authority_id;AssociationForeignKey:authority_id"`
...
...
@@ -31,13 +31,13 @@ type User struct {
func
(
u
*
User
)
Regist
()
(
err
error
,
userInter
*
User
)
{
var
user
User
//判断用户名是否注册
findErr
:=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ?"
,
u
.
User
N
ame
)
.
First
(
&
user
)
.
Error
findErr
:=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ?"
,
u
.
User
n
ame
)
.
First
(
&
user
)
.
Error
//err为nil表明读取到了 不能注册
if
findErr
==
nil
{
return
errors
.
New
(
"用户名已注册"
),
nil
}
else
{
// 否则 附加uuid 密码md5简单加密 注册
u
.
Pass
Word
=
tools
.
MD5V
(
u
.
PassW
ord
)
u
.
Pass
word
=
tools
.
MD5V
(
u
.
Passw
ord
)
u
.
UUID
=
uuid
.
NewV4
()
err
=
qmsql
.
DEFAULTDB
.
Create
(
u
)
.
Error
}
...
...
@@ -45,11 +45,11 @@ func (u *User) Regist() (err error, userInter *User) {
}
//修改用户密码
func
(
u
*
User
)
ChangePass
Word
(
newPassW
ord
string
)
(
err
error
,
userInter
*
User
)
{
func
(
u
*
User
)
ChangePass
word
(
newPassw
ord
string
)
(
err
error
,
userInter
*
User
)
{
var
user
User
//后期修改jwt+password模式
u
.
Pass
Word
=
tools
.
MD5V
(
u
.
PassW
ord
)
err
=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ? AND pass_word = ?"
,
u
.
User
Name
,
u
.
PassWord
)
.
First
(
&
user
)
.
Update
(
"pass_word"
,
tools
.
MD5V
(
newPassW
ord
))
.
Error
u
.
Pass
word
=
tools
.
MD5V
(
u
.
Passw
ord
)
err
=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ? AND pass_word = ?"
,
u
.
User
name
,
u
.
Password
)
.
First
(
&
user
)
.
Update
(
"pass_word"
,
tools
.
MD5V
(
newPassw
ord
))
.
Error
return
err
,
u
}
...
...
@@ -62,16 +62,16 @@ func (u *User) UpdataUser() (err error, userInter *User) {
//用户登录
func
(
u
*
User
)
Login
()
(
err
error
,
userInter
*
User
)
{
var
user
User
u
.
Pass
Word
=
tools
.
MD5V
(
u
.
PassW
ord
)
err
=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ? AND pass_word = ?"
,
u
.
User
Name
,
u
.
PassW
ord
)
.
First
(
&
user
)
.
Error
u
.
Pass
word
=
tools
.
MD5V
(
u
.
Passw
ord
)
err
=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ? AND pass_word = ?"
,
u
.
User
name
,
u
.
Passw
ord
)
.
First
(
&
user
)
.
Error
err
=
qmsql
.
DEFAULTDB
.
Where
(
"authority_id = ?"
,
user
.
AuthorityId
)
.
First
(
&
user
.
Authority
)
.
Error
return
err
,
&
user
}
// 用户头像上传更新地址
func
(
u
*
User
)
UploadHeaderImg
(
user
N
ame
string
,
filePath
string
)
(
err
error
,
userInter
*
User
)
{
func
(
u
*
User
)
UploadHeaderImg
(
user
n
ame
string
,
filePath
string
)
(
err
error
,
userInter
*
User
)
{
var
user
User
err
=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ?"
,
user
N
ame
)
.
First
(
&
user
)
.
Update
(
"header_img"
,
filePath
)
.
First
(
&
user
)
.
Error
err
=
qmsql
.
DEFAULTDB
.
Where
(
"user_name = ?"
,
user
n
ame
)
.
First
(
&
user
)
.
Update
(
"header_img"
,
filePath
)
.
First
(
&
user
)
.
Error
return
err
,
&
user
}
...
...
QMPlusServer/router/user.go
浏览文件 @
0acb0298
...
...
@@ -9,7 +9,7 @@ import (
func
InitUserRouter
(
Router
*
gin
.
Engine
)
{
UserRouter
:=
Router
.
Group
(
"user"
)
.
Use
(
middleware
.
JWTAuth
())
{
UserRouter
.
POST
(
"changePass
Word"
,
api
.
ChangePassW
ord
)
UserRouter
.
POST
(
"changePass
word"
,
api
.
ChangePassw
ord
)
UserRouter
.
POST
(
"uploadHeaderImg"
,
api
.
UploadHeaderImg
)
UserRouter
.
POST
(
"getInfoList"
,
api
.
GetInfoList
)
}
...
...
QMPlusVuePage/src/store/module/user.js
浏览文件 @
0acb0298
import
{
login
}
from
'
@/api/user
'
export
const
user
=
{
namespaced
:
true
,
state
:
{
userInfo
:
{
uuid
:
""
,
nickName
:
""
nickName
:
""
,
headerImg
:
""
,
authority
:
""
,
},
token
:
""
},
...
...
@@ -18,13 +22,20 @@ export const user = {
}
},
actions
:
{
// AsyncSetUserInfo({ commit }, loginInfo) {
// }
LoginIn
({
commit
},
loginInfo
)
{
login
(
loginInfo
).
then
(
res
=>
{
commit
(
'
setUserInfo
'
,
res
.
data
.
user
)
commit
(
'
setToken
'
,
res
.
data
.
token
)
return
res
}).
catch
(
err
=>
{
console
.
error
(
err
)
return
Promise
.
reject
(
err
)
})
}
},
getters
:
{
user
Name
(
state
)
{
return
state
.
user
Name
user
Info
(
state
)
{
return
state
.
user
Info
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录