From e648dfe7f0cb6861017bd34796e395518a9b1f93 Mon Sep 17 00:00:00 2001 From: pixel <303176530@qq.com> Date: Fri, 20 Mar 2020 13:46:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=B8=BAshouldBindJson=20?= =?UTF-8?q?=E4=B8=8D=E4=B8=BB=E5=8A=A8=E4=BF=AE=E6=94=B9=20400?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- QMPlusServer/controller/api/exa_customer.go | 18 +++++++-------- .../api/exa_fileUploadAndDownload.go | 2 +- QMPlusServer/controller/api/sys_api.go | 8 +++---- QMPlusServer/controller/api/sys_authority.go | 4 ++-- QMPlusServer/controller/api/sys_menu.go | 14 ++++++------ QMPlusServer/controller/api/sys_user.go | 22 +++++++++---------- QMPlusVuePage/src/view/login/login.vue | 2 +- 7 files changed, 35 insertions(+), 35 deletions(-) diff --git a/QMPlusServer/controller/api/exa_customer.go b/QMPlusServer/controller/api/exa_customer.go index 03c09c9a..4f158964 100644 --- a/QMPlusServer/controller/api/exa_customer.go +++ b/QMPlusServer/controller/api/exa_customer.go @@ -19,7 +19,7 @@ import ( // @Router /customer/createExaCustomer [post] func CreateExaCustomer(c *gin.Context) { var cu dbModel.ExaCustomer - _ = c.BindJSON(&cu) + _ = c.ShouldBindJSON(&cu) claims, _ := c.Get("claims") waitUse := claims.(*middleware.CustomClaims) cu.SysUserID = waitUse.ID @@ -42,7 +42,7 @@ func CreateExaCustomer(c *gin.Context) { // @Router /customer/deleteExaCustomer [post] func DeleteExaCustomer(c *gin.Context) { var cu dbModel.ExaCustomer - _ = c.BindJSON(&cu) + _ = c.ShouldBindJSON(&cu) err := cu.DeleteExaCustomer() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) @@ -61,7 +61,7 @@ func DeleteExaCustomer(c *gin.Context) { // @Router /customer/updataExaCustomer [post] func UpdataExaCustomer(c *gin.Context) { var cu dbModel.ExaCustomer - _ = c.BindJSON(&cu) + _ = c.ShouldBindJSON(&cu) err := cu.UpdataExaCustomer() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) @@ -80,13 +80,13 @@ func UpdataExaCustomer(c *gin.Context) { // @Router /customer/getExaCustomer [post] func GetExaCustomer(c *gin.Context) { var cu dbModel.ExaCustomer - _ = c.BindJSON(&cu) - err,customer := cu.GetExaCustomer() + _ = c.ShouldBindJSON(&cu) + err, customer := cu.GetExaCustomer() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) } else { servers.ReportFormat(c, true, "创建成功", gin.H{ - "customer":customer, + "customer": customer, }) } } @@ -105,16 +105,16 @@ func GetExaCustomerList(c *gin.Context) { var cu dbModel.ExaCustomer cu.SysUserAuthorityID = waitUse.AuthorityId var pageInfo modelInterface.PageInfo - _ = c.BindJSON(&pageInfo) + _ = c.ShouldBindJSON(&pageInfo) err, customerList, total := cu.GetInfoList(pageInfo) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) } else { servers.ReportFormat(c, true, "创建成功", gin.H{ - "customer":customerList, + "customer": customerList, "total": total, "page": pageInfo.Page, "pageSize": pageInfo.PageSize, }) } -} \ No newline at end of file +} diff --git a/QMPlusServer/controller/api/exa_fileUploadAndDownload.go b/QMPlusServer/controller/api/exa_fileUploadAndDownload.go index ff507037..93a64c2f 100644 --- a/QMPlusServer/controller/api/exa_fileUploadAndDownload.go +++ b/QMPlusServer/controller/api/exa_fileUploadAndDownload.go @@ -85,7 +85,7 @@ func DeleteFile(c *gin.Context) { // @Router /fileUploadAndDownload/getFileList [post] func GetFileList(c *gin.Context) { var pageInfo modelInterface.PageInfo - _ = c.BindJSON(&pageInfo) + _ = c.ShouldBindJSON(&pageInfo) err, list, total := new(dbModel.ExaFileUploadAndDownload).GetInfoList(pageInfo) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) diff --git a/QMPlusServer/controller/api/sys_api.go b/QMPlusServer/controller/api/sys_api.go index d10f2259..eae8ff6b 100644 --- a/QMPlusServer/controller/api/sys_api.go +++ b/QMPlusServer/controller/api/sys_api.go @@ -27,7 +27,7 @@ type DeleteApiParams struct { // @Router /api/createApi [post] func CreateApi(c *gin.Context) { var api sysModel.SysApi - _ = c.BindJSON(&api) + _ = c.ShouldBindJSON(&api) err := api.CreateApi() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{}) @@ -46,7 +46,7 @@ func CreateApi(c *gin.Context) { // @Router /api/deleteApi [post] func DeleteApi(c *gin.Context) { var a sysModel.SysApi - _ = c.BindJSON(&a) + _ = c.ShouldBindJSON(&a) err := a.DeleteApi() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("删除失败:%v", err), gin.H{}) @@ -102,7 +102,7 @@ func GetApiList(c *gin.Context) { // @Router /api/getApiById [post] func GetApiById(c *gin.Context) { var idInfo GetById - _ = c.BindJSON(&idInfo) + _ = c.ShouldBindJSON(&idInfo) err, api := new(sysModel.SysApi).GetApiById(idInfo.Id) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) @@ -124,7 +124,7 @@ func GetApiById(c *gin.Context) { // @Router /api/updataApi [post] func UpdataApi(c *gin.Context) { var api sysModel.SysApi - _ = c.BindJSON(&api) + _ = c.ShouldBindJSON(&api) err := api.UpdataApi() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("修改数据失败,%v", err), gin.H{}) diff --git a/QMPlusServer/controller/api/sys_authority.go b/QMPlusServer/controller/api/sys_authority.go index d01d0bc0..d86d50de 100644 --- a/QMPlusServer/controller/api/sys_authority.go +++ b/QMPlusServer/controller/api/sys_authority.go @@ -50,7 +50,7 @@ type DeleteAuthorityPatams struct { // @Router /authority/deleteAuthority [post] func DeleteAuthority(c *gin.Context) { var a sysModel.SysAuthority - _ = c.BindJSON(&a) + _ = c.ShouldBindJSON(&a) //删除角色之前需要判断是否有用户正在使用此角色 err := a.DeleteAuthority() if err != nil { @@ -70,7 +70,7 @@ func DeleteAuthority(c *gin.Context) { // @Router /authority/getAuthorityList [post] func GetAuthorityList(c *gin.Context) { var pageInfo modelInterface.PageInfo - _ = c.BindJSON(&pageInfo) + _ = c.ShouldBindJSON(&pageInfo) err, list, total := new(sysModel.SysAuthority).GetInfoList(pageInfo) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) diff --git a/QMPlusServer/controller/api/sys_menu.go b/QMPlusServer/controller/api/sys_menu.go index ce9582db..f60623c7 100644 --- a/QMPlusServer/controller/api/sys_menu.go +++ b/QMPlusServer/controller/api/sys_menu.go @@ -37,7 +37,7 @@ func GetMenu(c *gin.Context) { // @Router /menu/getMenuList [post] func GetMenuList(c *gin.Context) { var pageInfo modelInterface.PageInfo - _ = c.BindJSON(&pageInfo) + _ = c.ShouldBindJSON(&pageInfo) err, menuList, total := new(sysModel.SysBaseMenu).GetInfoList(pageInfo) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) @@ -61,7 +61,7 @@ func GetMenuList(c *gin.Context) { // @Router /menu/addBaseMenu [post] func AddBaseMenu(c *gin.Context) { var addMenu sysModel.SysBaseMenu - _ = c.BindJSON(&addMenu) + _ = c.ShouldBindJSON(&addMenu) err := addMenu.AddBaseMenu() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("添加失败,%v", err), gin.H{}) @@ -101,7 +101,7 @@ type AddMenuAuthorityInfo struct { // @Router /menu/addMenuAuthority [post] func AddMenuAuthority(c *gin.Context) { var addMenuAuthorityInfo AddMenuAuthorityInfo - _ = c.BindJSON(&addMenuAuthorityInfo) + _ = c.ShouldBindJSON(&addMenuAuthorityInfo) err := new(sysModel.SysMenu).AddMenuAuthority(addMenuAuthorityInfo.Menus, addMenuAuthorityInfo.AuthorityId) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("添加失败,%v", err), gin.H{}) @@ -124,7 +124,7 @@ type AuthorityIdInfo struct { // @Router /menu/addMenuAuthority [post] func GetMenuAuthority(c *gin.Context) { var authorityIdInfo AuthorityIdInfo - _ = c.BindJSON(&authorityIdInfo) + _ = c.ShouldBindJSON(&authorityIdInfo) err, menus := new(sysModel.SysMenu).GetMenuAuthority(authorityIdInfo.AuthorityId) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{"menus": menus}) @@ -147,7 +147,7 @@ type IdInfo struct { // @Router /menu/deleteBaseMenu [post] func DeleteBaseMenu(c *gin.Context) { var idInfo IdInfo - _ = c.BindJSON(&idInfo) + _ = c.ShouldBindJSON(&idInfo) err := new(sysModel.SysBaseMenu).DeleteBaseMenu(idInfo.Id) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("删除失败:%v", err), gin.H{}) @@ -166,7 +166,7 @@ func DeleteBaseMenu(c *gin.Context) { // @Router /menu/updataBaseMen [post] func UpdataBaseMenu(c *gin.Context) { var menu sysModel.SysBaseMenu - _ = c.BindJSON(&menu) + _ = c.ShouldBindJSON(&menu) err := menu.UpdataBaseMenu() if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("修改失败:%v", err), gin.H{}) @@ -189,7 +189,7 @@ type GetById struct { // @Router /menu/getBaseMenuById [post] func GetBaseMenuById(c *gin.Context) { var idInfo GetById - _ = c.BindJSON(&idInfo) + _ = c.ShouldBindJSON(&idInfo) err, menu := new(sysModel.SysBaseMenu).GetBaseMenuById(idInfo.Id) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("查询失败:%v", err), gin.H{}) diff --git a/QMPlusServer/controller/api/sys_user.go b/QMPlusServer/controller/api/sys_user.go index 8982fb28..cf3f1a09 100644 --- a/QMPlusServer/controller/api/sys_user.go +++ b/QMPlusServer/controller/api/sys_user.go @@ -22,10 +22,10 @@ var ( ) type RegistAndLoginStuct struct { - Username string `json:"username"` - Password string `json:"password"` - Captcha string `json:"captcha"` - CaptchaId string `json:"captchaId"` + Username string `json:"username"` + Password string `json:"password"` + Captcha string `json:"captcha"` + CaptchaId string `json:"captchaId"` } type RegestStuct struct { @@ -44,7 +44,7 @@ type RegestStuct struct { // @Router /base/regist [post] func Regist(c *gin.Context) { var R RegestStuct - _ = c.BindJSON(&R) + _ = c.ShouldBindJSON(&R) user := &sysModel.SysUser{Username: R.Username, NickName: R.NickName, Password: R.Password, HeaderImg: R.HeaderImg, AuthorityId: R.AuthorityId} err, user := user.Regist() if err != nil { @@ -66,15 +66,15 @@ func Regist(c *gin.Context) { // @Router /base/login [post] func Login(c *gin.Context) { var L RegistAndLoginStuct - _ = c.BindJSON(&L) - if captcha.VerifyString(L.CaptchaId,L.Captcha) { + _ = c.ShouldBindJSON(&L) + 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{ + } else { servers.ReportFormat(c, false, "验证码错误", gin.H{}) } @@ -149,7 +149,7 @@ type ChangePasswordStutrc struct { // @Router /user/changePassword [post] func ChangePassword(c *gin.Context) { var params ChangePasswordStutrc - _ = c.BindJSON(¶ms) + _ = c.ShouldBindJSON(¶ms) U := &sysModel.SysUser{Username: params.Username, Password: params.Password} if err, _ := U.ChangePassword(params.NewPassword); err != nil { servers.ReportFormat(c, false, "修改失败,请检查用户名密码", gin.H{}) @@ -208,7 +208,7 @@ func UploadHeaderImg(c *gin.Context) { // @Router /user/getUserList [post] func GetUserList(c *gin.Context) { var pageInfo modelInterface.PageInfo - _ = c.BindJSON(&pageInfo) + _ = c.ShouldBindJSON(&pageInfo) err, list, total := new(sysModel.SysUser).GetInfoList(pageInfo) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("获取数据失败,%v", err), gin.H{}) @@ -237,7 +237,7 @@ type SetUserAuth struct { // @Router /user/setUserAuthority [post] func SetUserAuthority(c *gin.Context) { var sua SetUserAuth - _ = c.BindJSON(&sua) + _ = c.ShouldBindJSON(&sua) err := new(sysModel.SysUser).SetUserAuthority(sua.UUID, sua.AuthorityId) if err != nil { servers.ReportFormat(c, false, fmt.Sprintf("修改失败,%v", err), gin.H{}) diff --git a/QMPlusVuePage/src/view/login/login.vue b/QMPlusVuePage/src/view/login/login.vue index ac988385..de6e55cd 100644 --- a/QMPlusVuePage/src/view/login/login.vue +++ b/QMPlusVuePage/src/view/login/login.vue @@ -20,7 +20,7 @@ 请输入验证码 -- GitLab