Browse Source

shouldBind 修改为 shouldBindJSON 防止浏览器ajax交互时 content-type出现偶发性不同的问题

main
pixel 5 years ago
parent
commit
6e3c8bde51
  1. 2
      QMPlusServer/controller/api/exa_fileUploadAndDownload.go
  2. 4
      QMPlusServer/controller/api/sys_authority.go
  3. 4
      QMPlusServer/controller/api/sys_casbin.go
  4. 4
      QMPlusServer/controller/api/sys_system.go
  5. 2
      QMPlusServer/controller/api/sys_workFlow.go

2
QMPlusServer/controller/api/exa_fileUploadAndDownload.go

@ -56,7 +56,7 @@ func UploadFile(c *gin.Context) {
// @Router /fileUploadAndDownload/deleteFile [post] // @Router /fileUploadAndDownload/deleteFile [post]
func DeleteFile(c *gin.Context) { func DeleteFile(c *gin.Context) {
var file dbModel.ExaFileUploadAndDownload var file dbModel.ExaFileUploadAndDownload
_ = c.ShouldBind(&file)
_ = c.ShouldBindJSON(&file)
err, f := file.FindFile() err, f := file.FindFile()
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("删除失败,%v", err), gin.H{}) servers.ReportFormat(c, false, fmt.Sprintf("删除失败,%v", err), gin.H{})

4
QMPlusServer/controller/api/sys_authority.go

@ -23,7 +23,7 @@ type CreateAuthorityParams struct {
// @Router /authority/createAuthority [post] // @Router /authority/createAuthority [post]
func CreateAuthority(c *gin.Context) { func CreateAuthority(c *gin.Context) {
var auth sysModel.SysAuthority var auth sysModel.SysAuthority
_ = c.ShouldBind(&auth)
_ = c.ShouldBindJSON(&auth)
err, authBack := auth.CreateAuthority() err, authBack := auth.CreateAuthority()
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{ servers.ReportFormat(c, false, fmt.Sprintf("创建失败:%v", err), gin.H{
@ -94,7 +94,7 @@ func GetAuthorityList(c *gin.Context) {
// @Router /authority/setDataAuthority [post] // @Router /authority/setDataAuthority [post]
func SetDataAuthority(c *gin.Context) { func SetDataAuthority(c *gin.Context) {
var auth sysModel.SysAuthority var auth sysModel.SysAuthority
_ = c.ShouldBind(&auth)
_ = c.ShouldBindJSON(&auth)
err := auth.SetDataAuthority() err := auth.SetDataAuthority()
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("设置关联失败,%v", err), gin.H{}) servers.ReportFormat(c, false, fmt.Sprintf("设置关联失败,%v", err), gin.H{})

4
QMPlusServer/controller/api/sys_casbin.go

@ -17,7 +17,7 @@ import (
// @Router /casbin/casbinPUpdata [post] // @Router /casbin/casbinPUpdata [post]
func CasbinPUpdata(c *gin.Context) { func CasbinPUpdata(c *gin.Context) {
var cmr sysModel.CasbinInReceive var cmr sysModel.CasbinInReceive
_ = c.ShouldBind(&cmr)
_ = c.ShouldBindJSON(&cmr)
err := new(sysModel.CasbinModel).CasbinPUpdata(cmr.AuthorityId, cmr.CasbinInfos) err := new(sysModel.CasbinModel).CasbinPUpdata(cmr.AuthorityId, cmr.CasbinInfos)
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("添加规则失败,%v", err), gin.H{}) servers.ReportFormat(c, false, fmt.Sprintf("添加规则失败,%v", err), gin.H{})
@ -36,7 +36,7 @@ func CasbinPUpdata(c *gin.Context) {
// @Router /casbin/getPolicyPathByAuthorityId [post] // @Router /casbin/getPolicyPathByAuthorityId [post]
func GetPolicyPathByAuthorityId(c *gin.Context) { func GetPolicyPathByAuthorityId(c *gin.Context) {
var cmr sysModel.CasbinInReceive var cmr sysModel.CasbinInReceive
_ = c.ShouldBind(&cmr)
_ = c.ShouldBindJSON(&cmr)
paths := new(sysModel.CasbinModel).GetPolicyPathByAuthorityId(cmr.AuthorityId) paths := new(sysModel.CasbinModel).GetPolicyPathByAuthorityId(cmr.AuthorityId)
servers.ReportFormat(c, true, "获取规则成功", gin.H{"paths": paths}) servers.ReportFormat(c, true, "获取规则成功", gin.H{"paths": paths})
} }

4
QMPlusServer/controller/api/sys_system.go

@ -31,7 +31,7 @@ func GetSystemConfig(c *gin.Context) {
// @Router /system/setSystemConfig [post] // @Router /system/setSystemConfig [post]
func SetSystemConfig(c *gin.Context) { func SetSystemConfig(c *gin.Context) {
var sys sysModel.System var sys sysModel.System
_ = c.ShouldBind(&sys)
_ = c.ShouldBindJSON(&sys)
err := sys.SetSystemConfig() err := sys.SetSystemConfig()
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{}) servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{})
@ -49,7 +49,7 @@ func SetSystemConfig(c *gin.Context) {
// @Router /system/ReloadSystem [post] // @Router /system/ReloadSystem [post]
func ReloadSystem(c *gin.Context) { func ReloadSystem(c *gin.Context) {
var sys sysModel.System var sys sysModel.System
_ = c.ShouldBind(&sys)
_ = c.ShouldBindJSON(&sys)
err := sys.SetSystemConfig() err := sys.SetSystemConfig()
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{}) servers.ReportFormat(c, false, fmt.Sprintf("设置失败:%v", err), gin.H{})

2
QMPlusServer/controller/api/sys_workFlow.go

@ -15,7 +15,7 @@ import (
// @Router /workflow/createWorkFlow [post] // @Router /workflow/createWorkFlow [post]
func CreateWorkFlow(c *gin.Context) { func CreateWorkFlow(c *gin.Context) {
var wk sysModel.SysWorkflow var wk sysModel.SysWorkflow
_ = c.ShouldBind(&wk)
_ = c.ShouldBindJSON(&wk)
err := wk.Create() err := wk.Create()
if err != nil { if err != nil {
servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{}) servers.ReportFormat(c, false, fmt.Sprintf("获取失败:%v", err), gin.H{})

Loading…
Cancel
Save