Browse Source

用户搜索微调

main
pixelqm 5 years ago
parent
commit
e521cd9068
  1. 2
      QMPlusServer/controller/api/user.go
  2. 6
      QMPlusServer/model/dbModel/user.go
  3. 77
      QMPlusVuePage/package-lock.json
  4. 3
      QMPlusVuePage/package.json
  5. 24
      QMPlusVuePage/src/store/module/user.js

2
QMPlusServer/controller/api/user.go

@ -56,7 +56,7 @@ func Login(c *gin.Context) {
_ = c.BindJSON(&L) _ = c.BindJSON(&L)
U := &dbModel.User{UserName: L.UserName, PassWord: L.PassWord} U := &dbModel.User{UserName: L.UserName, PassWord: L.PassWord}
if err, user := U.Login(); err != nil { if err, user := U.Login(); err != nil {
servers.ReportFormat(c, false, "用户名密码错误", gin.H{"user": user})
servers.ReportFormat(c, false, fmt.Sprintf("用户名密码错误或%v", err), gin.H{"user": user})
} else { } else {
tokenNext(c, *user) tokenNext(c, *user)
} }

6
QMPlusServer/model/dbModel/user.go

@ -17,8 +17,8 @@ type User struct {
PassWord string `json:"passWord"` PassWord string `json:"passWord"`
NickName string `json:"nickName" gorm:"default:'QMPlusUser'"` NickName string `json:"nickName" gorm:"default:'QMPlusUser'"`
HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"` HeaderImg string `json:"headerImg" gorm:"default:'http://www.henrongyi.top/avatar/lufu.jpg'"`
Authority Authority `json:"authority" form:"ForeignKey:AuthorityId;AssociationForeignKey:AuthorityId"`
AuthorityId float64 `json:"authorityId" gorm:"default:888"`
Authority Authority `json:"authority" form:"ForeignKey:authority_id;AssociationForeignKey:authority_id"`
AuthorityId float64 `json:"-" gorm:"default:888"`
//Propertie // 多余属性自行添加 //Propertie // 多余属性自行添加
//PropertieId uint // 自动关联 Propertie 的Id 附加属性过多 建议创建一对一关系 //PropertieId uint // 自动关联 Propertie 的Id 附加属性过多 建议创建一对一关系
} }
@ -64,7 +64,7 @@ func (u *User) Login() (err error, userInter *User) {
var user User var user User
u.PassWord = tools.MD5V(u.PassWord) u.PassWord = tools.MD5V(u.PassWord)
err = qmsql.DEFAULTDB.Where("user_name = ? AND pass_word = ?", u.UserName, u.PassWord).First(&user).Error err = qmsql.DEFAULTDB.Where("user_name = ? AND pass_word = ?", u.UserName, u.PassWord).First(&user).Error
err = qmsql.DEFAULTDB.Model(&user).Related(&user.Authority).Error
err = qmsql.DEFAULTDB.Where("authority_id = ?", user.AuthorityId).First(&user.Authority).Error
return err, &user return err, &user
} }

77
QMPlusVuePage/package-lock.json

@ -1970,6 +1970,43 @@
"resolved": "https://registry.npm.taobao.org/aws4/download/aws4-1.8.0.tgz", "resolved": "https://registry.npm.taobao.org/aws4/download/aws4-1.8.0.tgz",
"integrity": "sha1-8OAD2cqef1nHpQiUXXsu+aBKVC8=" "integrity": "sha1-8OAD2cqef1nHpQiUXXsu+aBKVC8="
}, },
"axios": {
"version": "0.19.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.0.tgz",
"integrity": "sha512-1uvKqKQta3KBxIz14F2v06AEHZ/dIoeKfbTRkK1E5oqjDnuEerLmYTgJB5AiQZHJcljpg1TuRzdjDR06qNk0DQ==",
"requires": {
"follow-redirects": "1.5.10",
"is-buffer": "^2.0.2"
},
"dependencies": {
"debug": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
"requires": {
"ms": "2.0.0"
}
},
"follow-redirects": {
"version": "1.5.10",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz",
"integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==",
"requires": {
"debug": "=3.1.0"
}
},
"is-buffer": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.3.tgz",
"integrity": "sha512-U15Q7MXTuZlrbymiz95PJpZxu8IlipAp4dtS3wOdgPXx3mqBnslrWU14kxfHB+Py/+2PVKSr37dMAgM2A4uArw=="
},
"ms": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
}
}
},
"babel-code-frame": { "babel-code-frame": {
"version": "6.26.0", "version": "6.26.0",
"resolved": "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz", "resolved": "https://registry.npm.taobao.org/babel-code-frame/download/babel-code-frame-6.26.0.tgz",
@ -8321,6 +8358,30 @@
"integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=",
"dev": true "dev": true
}, },
"path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"requires": {
"process": "^0.11.1",
"util": "^0.10.3"
},
"dependencies": {
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"requires": {
"inherits": "2.0.3"
}
}
}
},
"path-browserify": { "path-browserify": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npm.taobao.org/path-browserify/download/path-browserify-0.0.1.tgz", "resolved": "https://registry.npm.taobao.org/path-browserify/download/path-browserify-0.0.1.tgz",
@ -9072,8 +9133,7 @@
"process": { "process": {
"version": "0.11.10", "version": "0.11.10",
"resolved": "https://registry.npm.taobao.org/process/download/process-0.11.10.tgz", "resolved": "https://registry.npm.taobao.org/process/download/process-0.11.10.tgz",
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=",
"dev": true
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
}, },
"process-nextick-args": { "process-nextick-args": {
"version": "2.0.1", "version": "2.0.1",
@ -9177,9 +9237,9 @@
"dev": true "dev": true
}, },
"qs": { "qs": {
"version": "6.5.2",
"resolved": "https://registry.npm.taobao.org/qs/download/qs-6.5.2.tgz?cache=0&sync_timestamp=1566009952956&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fqs%2Fdownload%2Fqs-6.5.2.tgz",
"integrity": "sha1-yzroBuh0BERYTvFUzo7pjUA/PjY="
"version": "6.8.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.8.0.tgz",
"integrity": "sha512-tPSkj8y92PfZVbinY1n84i1Qdx75lZjMQYx9WZhnkofyxzw2r7Ho39G3/aEvSUdebxpnnM4LZJCtvE/Aq3+s9w=="
}, },
"query-string": { "query-string": {
"version": "5.1.1", "version": "5.1.1",
@ -9578,6 +9638,13 @@
"tough-cookie": "~2.4.3", "tough-cookie": "~2.4.3",
"tunnel-agent": "^0.6.0", "tunnel-agent": "^0.6.0",
"uuid": "^3.3.2" "uuid": "^3.3.2"
},
"dependencies": {
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
}
} }
}, },
"request-promise-core": { "request-promise-core": {

3
QMPlusVuePage/package.json

@ -8,9 +8,12 @@
"lint": "vue-cli-service lint" "lint": "vue-cli-service lint"
}, },
"dependencies": { "dependencies": {
"axios": "^0.19.0",
"core-js": "^2.6.5", "core-js": "^2.6.5",
"element-ui": "^2.12.0", "element-ui": "^2.12.0",
"node-sass": "^4.12.0", "node-sass": "^4.12.0",
"path": "^0.12.7",
"qs": "^6.8.0",
"sass-loader": "^8.0.0", "sass-loader": "^8.0.0",
"vue": "^2.6.10", "vue": "^2.6.10",
"vue-router": "^3.1.3", "vue-router": "^3.1.3",

24
QMPlusVuePage/src/store/module/user.js

@ -1,17 +1,25 @@
export const User = {
export const user = {
namespaced: true, namespaced: true,
state: { userName: "QM" },
state: {
userInfo: {
uuid: "",
nickName: ""
},
token: ""
},
mutations: { mutations: {
setUserName(state, name) {
setUserInfo(state, userInfo) {
// 这里的 `state` 对象是模块的局部状态
state.userInfo = userInfo
},
setToken(state, token) {
// 这里的 `state` 对象是模块的局部状态 // 这里的 `state` 对象是模块的局部状态
state.userName = name
state.token = token
} }
}, },
actions: { actions: {
AsyncSetUserName({ commit }, name) {
setTimeout(() => {
commit("setUserName", name)
}, 2000);
AsyncSetUserInfo({ commit }, loginInfo) {
} }
}, },
getters: { getters: {

Loading…
Cancel
Save