Browse Source

fix: 修复返回结构不统一的bug

BaiLuoYan 4 days ago
parent
commit
f506783412

+ 1 - 1
cli/goctl/api/handler.tpl

@@ -25,7 +25,7 @@ func {{.HandlerName}}(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			{{if .HasResp}}httpx.OkJsonCtx(r.Context(), w, resp){{else}}httpx.Ok(w){{end}}
+			{{if .HasResp}}httpx.OkJsonCtx(r.Context(), w, resp){{else}}httpx.OkJsonCtx(r.Context(), w, nil){{end}}
 		}
 	}
 }

+ 1 - 1
internal/handler/auth/changePasswordHandler.go

@@ -27,7 +27,7 @@ func ChangePasswordHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/auth/logoutHandler.go

@@ -19,7 +19,7 @@ func LogoutHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/auth/updateSelfInfoHandler.go

@@ -26,7 +26,7 @@ func UpdateSelfInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/dept/deleteDeptHandler.go

@@ -26,7 +26,7 @@ func DeleteDeptHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/dept/updateDeptHandler.go

@@ -26,7 +26,7 @@ func UpdateDeptHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/member/removeMemberHandler.go

@@ -26,7 +26,7 @@ func RemoveMemberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/member/updateMemberHandler.go

@@ -26,7 +26,7 @@ func UpdateMemberHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/product/updateProductHandler.go

@@ -26,7 +26,7 @@ func UpdateProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/role/bindRolePermsHandler.go

@@ -26,7 +26,7 @@ func BindRolePermsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/role/deleteRoleHandler.go

@@ -26,7 +26,7 @@ func DeleteRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/role/updateRoleHandler.go

@@ -26,7 +26,7 @@ func UpdateRoleHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/user/bindRolesHandler.go

@@ -26,7 +26,7 @@ func BindRolesHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/user/setUserPermsHandler.go

@@ -26,7 +26,7 @@ func SetUserPermsHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/user/updateUserHandler.go

@@ -26,7 +26,7 @@ func UpdateUserHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }

+ 1 - 1
internal/handler/user/updateUserStatusHandler.go

@@ -26,7 +26,7 @@ func UpdateUserStatusHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
 		if err != nil {
 			httpx.ErrorCtx(r.Context(), w, err)
 		} else {
-			httpx.Ok(w)
+			httpx.OkJsonCtx(r.Context(), w, nil)
 		}
 	}
 }