Skip to content

Commit

Permalink
Merge pull request #177 from ArtisanCloud/dev/michaelhu
Browse files Browse the repository at this point in the history
Dev/michaelhu
  • Loading branch information
Matrix-X authored Jun 26, 2023
2 parents e70df6c + f0bef8d commit 9c2dbe4
Show file tree
Hide file tree
Showing 37 changed files with 1,353 additions and 53 deletions.
1 change: 1 addition & 0 deletions api/admin/crm/product/product.api
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ info(

import "./productcategory.api"
import "./productspecific.api"
import "./sku.api"
import "./pricebookentry.api"

@server(
Expand Down
24 changes: 14 additions & 10 deletions api/admin/crm/product/productspecific.api
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ service PowerX {
@handler CreateProductSpecific
post /product-specifics (CreateProductSpecificRequest) returns (CreateProductSpecificReply)

@doc "配置产品规格"
@handler ConfigProductSpecific
post /product-specifics/config (ConfigProductSpecificRequest) returns (ConfigProductSpecificReply)


@doc "全量产品规格"
@handler PutProductSpecific
Expand Down Expand Up @@ -57,16 +61,6 @@ type (
IsActivated bool `json:"isActivated,optional"`
}


SKU {
Id int64 `json:"id,optional"`
SkuNo string `json:"skuNo,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 (
Expand Down Expand Up @@ -97,6 +91,16 @@ type (
}
)

type (
ConfigProductSpecificRequest struct {
ProductSpecifics []ProductSpecific `json:"productSpecifics"`
}

ConfigProductSpecificReply struct {
Result bool `json:"result"`
}
)

type (
GetProductSpecificRequest struct {
ProductSpecificId int64 `path:"id"`
Expand Down
146 changes: 146 additions & 0 deletions api/admin/crm/product/sku.api
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"`
}
)


5 changes: 5 additions & 0 deletions api/admin/dictionary.api
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ service PowerX {
@handler ListDictionaryPageTypes
get /types/page-list (ListDictionaryTypesPageRequest) returns (ListDictionaryTypesPageReply)

@doc "获取字典类型列表"
@handler ListDictionaryTypes
get /types (ListDictionaryTypesPageRequest) returns (ListDictionaryTypesPageReply)


@doc "获取字典类型"
@handler GetDictionaryType
get /types/:type (GetDictionaryTypeRequest) returns (GetDictionaryTypeReply)
Expand Down
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)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/product/sku/configskuhandler.go
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)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/product/sku/createskuhandler.go
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)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/product/sku/deleteskuhandler.go
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)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/product/sku/getskuhandler.go
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)
}
}
}
28 changes: 28 additions & 0 deletions internal/handler/admin/product/sku/listskupagehandler.go
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)
}
}
}
Loading

0 comments on commit 9c2dbe4

Please sign in to comment.