Parcourir la source

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

pixel il y a 5 ans
Parent
commit
6e3c8bde51

+ 1 - 1
QMPlusServer/controller/api/exa_fileUploadAndDownload.go

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

+ 2 - 2
QMPlusServer/controller/api/sys_authority.go

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

+ 2 - 2
QMPlusServer/controller/api/sys_casbin.go

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

+ 2 - 2
QMPlusServer/controller/api/sys_system.go

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

+ 1 - 1
QMPlusServer/controller/api/sys_workFlow.go

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