first commit

This commit is contained in:
2024-10-02 00:57:17 +08:00
commit 6773f86bc5
312 changed files with 19169 additions and 0 deletions

View File

@@ -0,0 +1,30 @@
package product
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tianyuan-api/apps/admin/internal/logic/product"
"tianyuan-api/apps/admin/internal/svc"
"tianyuan-api/apps/admin/internal/types"
xhttp "github.com/zeromicro/x/http"
)
func CreateProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.CreateProductReq
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := product.NewCreateProductLogic(r.Context(), svcCtx)
err := l.CreateProduct(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, nil)
}
}
}

View File

@@ -0,0 +1,30 @@
package product
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tianyuan-api/apps/admin/internal/logic/product"
"tianyuan-api/apps/admin/internal/svc"
"tianyuan-api/apps/admin/internal/types"
xhttp "github.com/zeromicro/x/http"
)
func DeleteProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.DeleteProductReq
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := product.NewDeleteProductLogic(r.Context(), svcCtx)
err := l.DeleteProduct(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, nil)
}
}
}

View File

@@ -0,0 +1,30 @@
package product
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tianyuan-api/apps/admin/internal/logic/product"
"tianyuan-api/apps/admin/internal/svc"
"tianyuan-api/apps/admin/internal/types"
xhttp "github.com/zeromicro/x/http"
)
func GetProductByIdHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductByIdReq
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := product.NewGetProductByIdLogic(r.Context(), svcCtx)
resp, err := l.GetProductById(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,30 @@
package product
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tianyuan-api/apps/admin/internal/logic/product"
"tianyuan-api/apps/admin/internal/svc"
"tianyuan-api/apps/admin/internal/types"
xhttp "github.com/zeromicro/x/http"
)
func GetProductListHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.GetProductListReq
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := product.NewGetProductListLogic(r.Context(), svcCtx)
resp, err := l.GetProductList(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
}
}
}

View File

@@ -0,0 +1,30 @@
package product
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"tianyuan-api/apps/admin/internal/logic/product"
"tianyuan-api/apps/admin/internal/svc"
"tianyuan-api/apps/admin/internal/types"
xhttp "github.com/zeromicro/x/http"
)
func UpdateProductHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.UpdateProductReq
if err := httpx.Parse(r, &req); err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
return
}
l := product.NewUpdateProductLogic(r.Context(), svcCtx)
err := l.UpdateProduct(&req)
if err != nil {
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
} else {
xhttp.JsonBaseResponseCtx(r.Context(), w, nil)
}
}
}