-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from ArtisanCloud/dev/michaelhu
Dev/michaelhu
- Loading branch information
Showing
37 changed files
with
1,353 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
syntax = "v1" | ||
|
||
info( | ||
title: "SKU服务" | ||
desc: "SKU服务" | ||
author: "MichaelHu" | ||
email: "[email protected]" | ||
version: "v1" | ||
) | ||
|
||
@server( | ||
group: admin/product/sku | ||
prefix: /api/v1/admin/product | ||
middleware: EmployeeJWTAuth | ||
) | ||
|
||
service PowerX { | ||
@doc "查询SKU列表" | ||
@handler ListSKUPage | ||
get /skus/page-list (ListSKUPageRequest) returns (ListSKUPageReply) | ||
|
||
@doc "查询SKU详情" | ||
@handler GetSKU | ||
get /skus/:id (GetSKURequest) returns (GetSKUReply) | ||
|
||
|
||
@doc "创建SKU" | ||
@handler CreateSKU | ||
post /skus (CreateSKURequest) returns (CreateSKUReply) | ||
|
||
@doc "配置SKU" | ||
@handler ConfigSKU | ||
post /skus/config (ConfigSKURequest) returns (ConfigSKUReply) | ||
|
||
|
||
@doc "全量SKU" | ||
@handler PutSKU | ||
put /skus/:id (PutSKURequest) returns (PutSKUReply) | ||
|
||
@doc "增量SKU" | ||
@handler PatchSKU | ||
patch /skus/:id (PatchSKURequest) returns (PatchSKUReply) | ||
|
||
|
||
@doc "删除SKU" | ||
@handler DeleteSKU | ||
delete /skus/:id (DeleteSKURequest) returns (DeleteSKUReply) | ||
} | ||
|
||
type ( | ||
SKU { | ||
Id int64 `json:"id,optional"` | ||
UniqueId string `json:"uniqueId,optional"` | ||
SkuNo string `json:"skuNo,optional"` | ||
ProductId int64 `json:"productId,optional"` | ||
Inventory int `json:"inventory,optional"` | ||
UnitPrice float64 `json:"unitPrice,optional"` | ||
ListPrice float64 `json:"listPrice,optional"` | ||
IsActive bool `json:"isActive,optional"` | ||
OptionsIds []int64 `json:"optionsIds,optional"` | ||
} | ||
) | ||
|
||
type ( | ||
ListSKUPageRequest struct { | ||
LikeName string `form:"likeName,optional"` | ||
ProductId int64 `form:"productId"` | ||
OrderBy string `form:"orderBy,optional"` | ||
PageIndex int `form:"pageIndex,optional"` | ||
PageSize int `form:"pageSize,optional"` | ||
} | ||
|
||
|
||
ListSKUPageReply struct { | ||
List []*SKU `json:"list"` | ||
PageIndex int `json:"pageIndex"` | ||
PageSize int `json:"pageSize"` | ||
Total int64 `json:"total"` | ||
} | ||
) | ||
|
||
type ( | ||
CreateSKURequest struct { | ||
SKU | ||
} | ||
|
||
CreateSKUReply struct { | ||
SKUId int64 `json:"id"` | ||
} | ||
) | ||
|
||
type ( | ||
ConfigSKURequest struct { | ||
SKUs []SKU `json:"skus"` | ||
} | ||
|
||
ConfigSKUReply struct { | ||
Result bool `json:"result"` | ||
} | ||
) | ||
|
||
type ( | ||
GetSKURequest struct { | ||
SKUId int64 `path:"id"` | ||
} | ||
|
||
GetSKUReply struct { | ||
*SKU | ||
} | ||
) | ||
|
||
|
||
type ( | ||
PutSKURequest struct { | ||
SKUId int64 `path:"id"` | ||
SKU | ||
} | ||
|
||
PutSKUReply struct { | ||
*SKU | ||
} | ||
) | ||
|
||
type ( | ||
PatchSKURequest struct { | ||
SKUId int64 `path:"id"` | ||
SKU | ||
} | ||
|
||
PatchSKUReply struct { | ||
*SKU | ||
} | ||
) | ||
|
||
|
||
type ( | ||
DeleteSKURequest struct { | ||
SKUId int64 `path:"id"` | ||
} | ||
|
||
DeleteSKUReply struct { | ||
SKUId int64 `json:"id"` | ||
} | ||
) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
internal/handler/admin/product/productspecific/configproductspecifichandler.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package productspecific | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/product/productspecific" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func ConfigProductSpecificHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.ConfigProductSpecificRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := productspecific.NewConfigProductSpecificLogic(r.Context(), svcCtx) | ||
resp, err := l.ConfigProductSpecific(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sku | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/product/sku" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func ConfigSKUHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.ConfigSKURequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := sku.NewConfigSKULogic(r.Context(), svcCtx) | ||
resp, err := l.ConfigSKU(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sku | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/product/sku" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func CreateSKUHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.CreateSKURequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := sku.NewCreateSKULogic(r.Context(), svcCtx) | ||
resp, err := l.CreateSKU(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sku | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/product/sku" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func DeleteSKUHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.DeleteSKURequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := sku.NewDeleteSKULogic(r.Context(), svcCtx) | ||
resp, err := l.DeleteSKU(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sku | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/product/sku" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func GetSKUHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.GetSKURequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := sku.NewGetSKULogic(r.Context(), svcCtx) | ||
resp, err := l.GetSKU(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package sku | ||
|
||
import ( | ||
"net/http" | ||
|
||
"PowerX/internal/logic/admin/product/sku" | ||
"PowerX/internal/svc" | ||
"PowerX/internal/types" | ||
"github.com/zeromicro/go-zero/rest/httpx" | ||
) | ||
|
||
func ListSKUPageHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { | ||
return func(w http.ResponseWriter, r *http.Request) { | ||
var req types.ListSKUPageRequest | ||
if err := httpx.Parse(r, &req); err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
return | ||
} | ||
|
||
l := sku.NewListSKUPageLogic(r.Context(), svcCtx) | ||
resp, err := l.ListSKUPage(&req) | ||
if err != nil { | ||
httpx.ErrorCtx(r.Context(), w, err) | ||
} else { | ||
httpx.OkJsonCtx(r.Context(), w, resp) | ||
} | ||
} | ||
} |
Oops, something went wrong.