From 4dbb77b3067769a17b332ce164b74bbea57befc4 Mon Sep 17 00:00:00 2001 From: eson <9673575+githubcontent@user.noreply.gitee.com> Date: Wed, 12 Jul 2023 14:11:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=9A=84api=E8=B7=AF?= =?UTF-8?q?=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- concatenate_apis.sh | 32 --------------- echo_service_path.sh | 21 ---------- fs_gen_api.sh | 39 ++++++++++++++----- proxyserver/get_zero_Info.go | 5 ++- proxyserver/main.go | 39 +++++++++++-------- server/backend/internal/handler/routes.go | 4 +- server/backend/internal/types/types.go | 14 +++++++ server/canteen/internal/handler/routes.go | 4 +- server/canteen/internal/types/types.go | 25 ++++++++---- .../data-transfer/internal/handler/routes.go | 4 +- .../home-user-auth/internal/handler/routes.go | 22 +++++------ server/inventory/internal/handler/routes.go | 8 ++-- server/inventory/internal/types/types.go | 7 ++++ server/map-library/internal/handler/routes.go | 4 +- server/map-library/internal/types/types.go | 25 ++++++++---- server/orders/internal/handler/routes.go | 4 +- server/orders/internal/types/types.go | 25 ++++++++---- .../product-model/internal/handler/routes.go | 6 +-- server/product-model/internal/types/types.go | 14 +++++++ .../internal/handler/routes.go | 10 ++--- .../product-template/internal/types/types.go | 14 +++++++ server/product/internal/handler/routes.go | 18 ++++----- .../internal/handler/routes.go | 14 +++---- .../internal/types/types.go | 7 ++++ server/upload/internal/handler/routes.go | 8 ++-- server/webset/internal/handler/routes.go | 2 +- server_api/basic.api | 2 +- server_api/product-template.api | 4 +- server_api/shopping-cart-confirmation.api | 2 +- 29 files changed, 221 insertions(+), 162 deletions(-) delete mode 100644 concatenate_apis.sh delete mode 100644 echo_service_path.sh diff --git a/concatenate_apis.sh b/concatenate_apis.sh deleted file mode 100644 index 9761987e..00000000 --- a/concatenate_apis.sh +++ /dev/null @@ -1,32 +0,0 @@ - #!/bin/bash - -# 定义输出文件名 -output_file="allapis.txt" - -# 清空输出文件(如果存在) -> "$output_file" - -# 定义要处理的 .api 文件列表 -api_files=("server_api/basic.api" "server_api/home-user-auth.api") - - -# 遍历 server_api 目录下的指定 .api 文件 -# for api_file in server_api/*.api; do -for api_file in "${api_files[@]}"; do - # 获取文件名(不包含扩展名) - filename=$(basename "$api_file" .api) - - # 将文件名添加到输出文件 - echo "// ${filename}.api" >> "$output_file" - - # 删除指定内容并将过滤后的 .api 文件内容追加到输出文件 - sed -e '/syntax = "v1"/d' \ - -e '/info (/,/)/d' \ - -e '/title: \/\/ TODO: add title/d' \ - -e '/desc: \/\/ TODO: add description/d' \ - -e '/author: ""/d' \ - -e '/email: ""/d' "$api_file" >> "$output_file" - - # 在不同 .api 文件内容之间添加一个空行 - echo "" >> "$output_file" -done \ No newline at end of file diff --git a/echo_service_path.sh b/echo_service_path.sh deleted file mode 100644 index 0d510f45..00000000 --- a/echo_service_path.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# 初始化输出文件 -output_file="server.txt" -echo "" > $output_file - -# 遍历所有 *.api 文件 -for api_file in server_api/*.api; do - # 提取服务名称 - service_name=$(grep -oP 'service\s+\K\w+' $api_file) - - # 提取所有以 get 或 post 开头的行,并使用 awk 获取路径 - # 将结果保存在一个名为 paths 的数组中 - paths=($(grep -E '^\s+(get|post)' $api_file | grep -oP '/\K[^/]*(?=/)' | sort | uniq | awk '{print "/"$1}' | tr '\n' ' ')) - - # 检查 $paths 是否为空,仅在非空时输出结果 - if [[ ! -z "${paths}" ]]; then - # 将服务名称和路径组合成所需的格式,并将结果追加到输出文件 - echo "$service_name [${paths[*]}]" >> $output_file - fi -done \ No newline at end of file diff --git a/fs_gen_api.sh b/fs_gen_api.sh index d52d84bf..fedb12b8 100755 --- a/fs_gen_api.sh +++ b/fs_gen_api.sh @@ -1,15 +1,36 @@ -#! /bin/bash -name=${1%%\\*} +#!/bin/bash +name=${1%%\\*} -options=("backend" "product-template" "product-model") -for option in "${options[@]}"; do - if [ "$name" = "$option" ]; then - echo "不能在"$name"里使用" +excluded_names=("backend" "product-template" "product-model" "basic") + +for excluded_name in "${excluded_names[@]}"; do + if [ "$name" = "$excluded_name" ]; then + echo "不能在$name里使用" exit - fi + fi done echo $name goctl api go -api server_api/$name.api -dir server/$name --home ./goctl_template/ -# ctxName=server/$name/internal/svc/servicecontext.go -# gofmt -w $ctxName \ No newline at end of file + +# List of API filenames without the '.api' extension +# api_names=("backend" "canteen" "home-user-auth" "map-library" "product" "product-template" "shopping-cart-confirmation" "webset" "data-transfer" "inventory" "orders" "product-model" "render" "upload") + +# # Iterate over API filenames and generate Go code, excluding certain names +# for api_name in "${api_names[@]}"; do +# skip=false + +# for excluded_name in "${excluded_names[@]}"; do +# if [ "$api_name" = "$excluded_name" ]; then +# skip=true +# break +# fi +# done + +# if [ "$skip" = true ]; then +# continue +# fi + +# echo "Generating Go code for $api_name" +# goctl api go -api server_api/"$api_name".api -dir server/"$api_name" --home ./goctl_template/ +# done \ No newline at end of file diff --git a/proxyserver/get_zero_Info.go b/proxyserver/get_zero_Info.go index 543554fa..db74dc77 100644 --- a/proxyserver/get_zero_Info.go +++ b/proxyserver/get_zero_Info.go @@ -113,8 +113,9 @@ func extractPrefixRouteValues(content string) map[string]bool { for _, line := range lines { if strings.Contains(line, "Path:") { path := strings.TrimSpace(strings.TrimPrefix(line, "Path:")) - path1 := strings.Split(strings.Trim(path, `"`), "/")[1] - path1 = "/" + path1 + paths := strings.Split(strings.Trim(path, `"`), "/") + path1 := "/" + paths[1] + "/" + paths[2] + if _, ok := prefixPath[path1]; !ok { prefixPath[path1] = true } diff --git a/proxyserver/main.go b/proxyserver/main.go index 7e4f93b3..45a8a395 100644 --- a/proxyserver/main.go +++ b/proxyserver/main.go @@ -9,6 +9,7 @@ import ( "net/http/httputil" "net/url" "strings" + "sync" "time" ) @@ -28,7 +29,16 @@ func SetCors(w http.ResponseWriter, r *http.Request) { } } +var pathdict sync.Map = sync.Map{} + func main() { + pathdict.Store("/css", true) + pathdict.Store("/fonts", true) + pathdict.Store("/img", true) + pathdict.Store("/js", true) + pathdict.Store("/svg", true) + pathdict.Store("/favicon.ico", true) + rootDir := "../server" // Change this to your root directory vueBuild := "/home/eson/workspace/fusenpack-vue-created" apiURL, err := url.Parse("http://localhost:9900") @@ -59,27 +69,24 @@ func main() { fs := http.FileServer(http.Dir(vueBuild)) indexHtmlPath := vueBuild + "/index.html" mux.Handle("/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - var prefix string - idx := strings.Index(r.URL.Path[1:], "/") - if idx == -1 { - prefix = r.URL.Path - } else { - prefix = r.URL.Path[:idx] - } - - // log.Println(r.URL.Path, prefix) - if _, ok := allRoutes[prefix]; ok { + if strings.HasPrefix(r.URL.Path, "/api") { proxy := httputil.NewSingleHostReverseProxy(apiURL) proxy.ServeHTTP(w, r) } else { - // fs.ServeHTTP(w, r) - if strings.HasPrefix(prefix, "/type") { - http.ServeFile(w, r, indexHtmlPath) - } else if strings.HasPrefix(prefix, "/dt-") { - http.ServeFile(w, r, indexHtmlPath) + idx := strings.Index(r.URL.Path[1:], "/") + var prefix string + if idx != -1 { + prefix = r.URL.Path[:idx+1] } else { - fs.ServeHTTP(w, r) + prefix = r.URL.Path } + + if _, ok := pathdict.Load(prefix); ok { + fs.ServeHTTP(w, r) + } else { + http.ServeFile(w, r, indexHtmlPath) + } + } })) diff --git a/server/backend/internal/handler/routes.go b/server/backend/internal/handler/routes.go index 2b9652ff..d875e035 100644 --- a/server/backend/internal/handler/routes.go +++ b/server/backend/internal/handler/routes.go @@ -14,12 +14,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/quotation/detail", + Path: "/api/quotation/detail", Handler: QuotationDetailHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/backend-user/login", + Path: "/api/backend-user/login", Handler: BackendUserLoginHandler(serverCtx), }, }, diff --git a/server/backend/internal/types/types.go b/server/backend/internal/types/types.go index e52e288c..97129408 100644 --- a/server/backend/internal/types/types.go +++ b/server/backend/internal/types/types.go @@ -33,6 +33,20 @@ type Auth struct { RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server/canteen/internal/handler/routes.go b/server/canteen/internal/handler/routes.go index 308edfa7..c6c26a1e 100644 --- a/server/canteen/internal/handler/routes.go +++ b/server/canteen/internal/handler/routes.go @@ -14,12 +14,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodPost, - Path: "/canteen-type/detail", + Path: "/api/canteen-type/detail", Handler: GetCanteenDetailHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/canteen-type/save", + Path: "/api/canteen-type/save", Handler: SaveCanteenTypeProductHandler(serverCtx), }, }, diff --git a/server/canteen/internal/types/types.go b/server/canteen/internal/types/types.go index 8ea29494..62d37004 100644 --- a/server/canteen/internal/types/types.go +++ b/server/canteen/internal/types/types.go @@ -35,26 +35,35 @@ type SaveCanteenProduct struct { SId string `json:"s_id"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` Data interface{} `json:"data"` } -type ResponseJwt struct { - Code int `json:"code"` - Message string `json:"msg"` - Data interface{} `json:"data"` - AccessSecret string `json:"accessSecret"` - AccessExpire int64 `json:"accessExpire"` -} - type Auth struct { AccessSecret string `json:"accessSecret"` AccessExpire int64 `json:"accessExpire"` RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server/data-transfer/internal/handler/routes.go b/server/data-transfer/internal/handler/routes.go index 1c9fc143..67bc3059 100644 --- a/server/data-transfer/internal/handler/routes.go +++ b/server/data-transfer/internal/handler/routes.go @@ -14,12 +14,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/standard-logo/list", + Path: "/api/standard-logo/list", Handler: GetStandardLogoListHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/qrcode-set/list", + Path: "/api/qrcode-set/list", Handler: GetQrCodeSetListHandler(serverCtx), }, }, diff --git a/server/home-user-auth/internal/handler/routes.go b/server/home-user-auth/internal/handler/routes.go index d5a3ba1e..aab65dff 100644 --- a/server/home-user-auth/internal/handler/routes.go +++ b/server/home-user-auth/internal/handler/routes.go @@ -14,57 +14,57 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodPost, - Path: "/user/login", + Path: "/api/user/login", Handler: UserLoginHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/user/accept-cookie", + Path: "/api/user/accept-cookie", Handler: AcceptCookieHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/user/fonts", + Path: "/api/user/fonts", Handler: UserFontsHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/user/get-type", + Path: "/api/user/get-type", Handler: UserGetTypeHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/user/basic-info", + Path: "/api/user/basic-info", Handler: UserSaveBasicInfoHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/user/status-config", + Path: "/api/user/status-config", Handler: UserStatusConfigHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/user/basic-info", + Path: "/api/user/basic-info", Handler: UserBasicInfoHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/user/address-list", + Path: "/api/user/address-list", Handler: UserAddressListHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/user/add-address", + Path: "/api/user/add-address", Handler: UserAddAddressHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/user/contact-service", + Path: "/api/user/contact-service", Handler: UserContactServiceHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/user/order-delete", + Path: "/api/user/order-delete", Handler: UserOderDeleteHandler(serverCtx), }, }, diff --git a/server/inventory/internal/handler/routes.go b/server/inventory/internal/handler/routes.go index ac11f0b2..3809a2cb 100644 --- a/server/inventory/internal/handler/routes.go +++ b/server/inventory/internal/handler/routes.go @@ -14,22 +14,22 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodPost, - Path: "/inventory/take", + Path: "/api/inventory/take", Handler: TakeHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/inventory/list", + Path: "/api/inventory/list", Handler: GetCloudListHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/inventory/supplement", + Path: "/api/inventory/supplement", Handler: SupplementHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/inventory/pick-up-list", + Path: "/api/inventory/pick-up-list", Handler: GetPickupListHandler(serverCtx), }, }, diff --git a/server/inventory/internal/types/types.go b/server/inventory/internal/types/types.go index b4599a41..480970e8 100644 --- a/server/inventory/internal/types/types.go +++ b/server/inventory/internal/types/types.go @@ -125,6 +125,13 @@ type Auth struct { RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + type Meta struct { TotalCount int64 `json:"totalCount"` PageCount int64 `json:"pageCount"` diff --git a/server/map-library/internal/handler/routes.go b/server/map-library/internal/handler/routes.go index b5128ec5..83f9fa00 100644 --- a/server/map-library/internal/handler/routes.go +++ b/server/map-library/internal/handler/routes.go @@ -14,12 +14,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/map-library/list", + Path: "/api/map-library/list", Handler: GetMapLibraryListHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/map-library/save", + Path: "/api/map-library/save", Handler: SaveMapLibraryHandler(serverCtx), }, }, diff --git a/server/map-library/internal/types/types.go b/server/map-library/internal/types/types.go index d37ba9c2..c92a33c3 100644 --- a/server/map-library/internal/types/types.go +++ b/server/map-library/internal/types/types.go @@ -87,26 +87,35 @@ type CameraStand struct { Z int64 `json:"z,optional"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` Data interface{} `json:"data"` } -type ResponseJwt struct { - Code int `json:"code"` - Message string `json:"msg"` - Data interface{} `json:"data"` - AccessSecret string `json:"accessSecret"` - AccessExpire int64 `json:"accessExpire"` -} - type Auth struct { AccessSecret string `json:"accessSecret"` AccessExpire int64 `json:"accessExpire"` RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server/orders/internal/handler/routes.go b/server/orders/internal/handler/routes.go index a07d88a5..467c0530 100644 --- a/server/orders/internal/handler/routes.go +++ b/server/orders/internal/handler/routes.go @@ -14,12 +14,12 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/order/invoice", + Path: "/api/order/invoice", Handler: GetOrderInvoiceHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/order/detail", + Path: "/api/order/detail", Handler: GetOrderDetailHandler(serverCtx), }, }, diff --git a/server/orders/internal/types/types.go b/server/orders/internal/types/types.go index 84a46f21..703e7835 100644 --- a/server/orders/internal/types/types.go +++ b/server/orders/internal/types/types.go @@ -76,26 +76,35 @@ type Deposit struct { TransNo string `json:"trans_no"` } +type Request struct { +} + type Response struct { Code int `json:"code"` Message string `json:"msg"` Data interface{} `json:"data"` } -type ResponseJwt struct { - Code int `json:"code"` - Message string `json:"msg"` - Data interface{} `json:"data"` - AccessSecret string `json:"accessSecret"` - AccessExpire int64 `json:"accessExpire"` -} - type Auth struct { AccessSecret string `json:"accessSecret"` AccessExpire int64 `json:"accessExpire"` RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server/product-model/internal/handler/routes.go b/server/product-model/internal/handler/routes.go index fbbc141d..3a5101fd 100644 --- a/server/product-model/internal/handler/routes.go +++ b/server/product-model/internal/handler/routes.go @@ -14,17 +14,17 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/product-model/detail", + Path: "/api/product-model/detail", Handler: GetModelDetailHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product-model/other-info", + Path: "/api/product-model/other-info", Handler: GetModelOtherInfoHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/product-model/update-model", + Path: "/api/product-model/update-model", Handler: UpdateProductModelHandler(serverCtx), }, }, diff --git a/server/product-model/internal/types/types.go b/server/product-model/internal/types/types.go index b068bc6d..d42f85c6 100644 --- a/server/product-model/internal/types/types.go +++ b/server/product-model/internal/types/types.go @@ -90,6 +90,20 @@ type Auth struct { RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server/product-template/internal/handler/routes.go b/server/product-template/internal/handler/routes.go index 95802ac0..e385f785 100644 --- a/server/product-template/internal/handler/routes.go +++ b/server/product-template/internal/handler/routes.go @@ -14,27 +14,27 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/product-template/detail", + Path: "/api/product-template/detail", Handler: GetTemplatevDetailHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product-template/base-map-list", + Path: "/api/product-template/base-map-list", Handler: GetBaseMapListHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/product-template/base-map-update", + Path: "/api/product-template/base-map-update", Handler: SaveBaseMapHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/product-template/base-map-add", + Path: "/api/product-template/base-map-add", Handler: AddBaseMapHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/product-template/update-template", + Path: "/api/product-template/update-template", Handler: UpdateTemplateHandler(serverCtx), }, }, diff --git a/server/product-template/internal/types/types.go b/server/product-template/internal/types/types.go index b3214193..b846ea1c 100644 --- a/server/product-template/internal/types/types.go +++ b/server/product-template/internal/types/types.go @@ -81,6 +81,20 @@ type Auth struct { RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + +type Meta struct { + TotalCount int64 `json:"totalCount"` + PageCount int64 `json:"pageCount"` + CurrentPage int `json:"currentPage"` + PerPage int `json:"perPage"` +} + // Set 设置Response的Code和Message值 func (resp *Response) Set(Code int, Message string) *Response { return &Response{ diff --git a/server/product/internal/handler/routes.go b/server/product/internal/handler/routes.go index 0e296da2..31b80260 100644 --- a/server/product/internal/handler/routes.go +++ b/server/product/internal/handler/routes.go @@ -14,47 +14,47 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/product/list", + Path: "/api/product/list", Handler: GetProductListHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product/success-recommand", + Path: "/api/product/success-recommand", Handler: GetSuccessRecommandHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product/get-size-by-product", + Path: "/api/product/get-size-by-product", Handler: GetSizeByProductHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product/design", + Path: "/api/product/design", Handler: GetProductDesignHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/product/design-gather", + Path: "/api/product/design-gather", Handler: DesignGatherHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product/info", + Path: "/api/product/info", Handler: GetProductInfoHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/product/save-design", + Path: "/api/product/save-design", Handler: SaveDesignHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product/other-list", + Path: "/api/product/other-list", Handler: OtherProductListHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/product/recommand", + Path: "/api/product/recommand", Handler: GetRecommandProductListHandler(serverCtx), }, }, diff --git a/server/shopping-cart-confirmation/internal/handler/routes.go b/server/shopping-cart-confirmation/internal/handler/routes.go index 12b9e809..2360dc72 100644 --- a/server/shopping-cart-confirmation/internal/handler/routes.go +++ b/server/shopping-cart-confirmation/internal/handler/routes.go @@ -14,37 +14,37 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodPost, - Path: "/cart/add", + Path: "/api/cart/add", Handler: CartAddHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/cart/del", + Path: "/api/cart/del", Handler: CartDeleteHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/cart/num", + Path: "/api/cart/num", Handler: CartNumberHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/cart/list", + Path: "/api/cart/list", Handler: CartListHandler(serverCtx), }, { Method: http.MethodGet, - Path: "/cart/order-detail", + Path: "/api/cart/order-detail", Handler: CartOrderDetailHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/cart/chang-order-method", + Path: "/api/cart/chang-order-method", Handler: ChangeOrderMethodHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/cart/create-order", + Path: "/api/cart/create-order", Handler: CreateOrderHandler(serverCtx), }, }, diff --git a/server/shopping-cart-confirmation/internal/types/types.go b/server/shopping-cart-confirmation/internal/types/types.go index 9dbf1774..0edf4269 100644 --- a/server/shopping-cart-confirmation/internal/types/types.go +++ b/server/shopping-cart-confirmation/internal/types/types.go @@ -132,6 +132,13 @@ type Auth struct { RefreshAfter int64 `json:"refreshAfter"` } +type File struct { + Filename string `fsfile:"filename"` + Header map[string][]string `fsfile:"header"` + Size int64 `fsfile:"size"` + Data []byte `fsfile:"data"` +} + type Meta struct { TotalCount int64 `json:"totalCount"` PageCount int64 `json:"pageCount"` diff --git a/server/upload/internal/handler/routes.go b/server/upload/internal/handler/routes.go index a2e52541..b3a3cee2 100644 --- a/server/upload/internal/handler/routes.go +++ b/server/upload/internal/handler/routes.go @@ -14,22 +14,22 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/upload/up-file", + Path: "/api/upload/up-file", Handler: UploadUpFileHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/upload/upload-file-frontend", + Path: "/api/upload/upload-file-frontend", Handler: UploadFileFrontendHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/upload/upload-file-backend", + Path: "/api/upload/upload-file-backend", Handler: UploadFileBackendHandler(serverCtx), }, { Method: http.MethodPost, - Path: "/upload/qrcode", + Path: "/api/upload/qrcode", Handler: UploadQrcodeHandler(serverCtx), }, }, diff --git a/server/webset/internal/handler/routes.go b/server/webset/internal/handler/routes.go index d446b0f7..76532ebb 100644 --- a/server/webset/internal/handler/routes.go +++ b/server/webset/internal/handler/routes.go @@ -14,7 +14,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) { []rest.Route{ { Method: http.MethodGet, - Path: "/web-set/setting", + Path: "/api/web-set/setting", Handler: WebSetSettingHandler(serverCtx), }, }, diff --git a/server_api/basic.api b/server_api/basic.api index 58dac0b5..7125abc4 100644 --- a/server_api/basic.api +++ b/server_api/basic.api @@ -26,7 +26,7 @@ type Auth { } // File 文件 -type File { +type File { Filename string `fsfile:"filename"` Header map[string][]string `fsfile:"header"` Size int64 `fsfile:"size"` diff --git a/server_api/product-template.api b/server_api/product-template.api index d276a92e..e101c805 100644 --- a/server_api/product-template.api +++ b/server_api/product-template.api @@ -15,10 +15,10 @@ service product-template { get /api/product-template/detail(GetTemplatevDetailReq) returns (response); //获取底图列表 @handler GetBaseMapListHandler - get /api/product-template/base-map-list( ) returns (response); + get /api/product-template/base-map-list(request) returns (response); //底图批量保存 @handler SaveBaseMapHandler - post /api/product-template/base-map-update ( ) returns (response); + post /api/product-template/base-map-update (request) returns (response); //新增底图 @handler AddBaseMapHandler post /api/product-template/base-map-add (AddBaseMapReq) returns (response); diff --git a/server_api/shopping-cart-confirmation.api b/server_api/shopping-cart-confirmation.api index be605481..502c75f6 100644 --- a/server_api/shopping-cart-confirmation.api +++ b/server_api/shopping-cart-confirmation.api @@ -18,7 +18,7 @@ service shopping-cart-confirmation { post /api/cart/del (CartDeleteReq) returns (response); //获取用户购物车数量 @handler CartNumberHandler - get /api/cart/num ( ) returns (response); + get /api/cart/num (request) returns (response); //获取用户购物车列表 @handler CartListHandler get /api/cart/list (CartListReq) returns (response);