first commit
This commit is contained in:
31
apps/admin/Dockerfile
Normal file
31
apps/admin/Dockerfile
Normal file
@@ -0,0 +1,31 @@
|
||||
FROM golang:alpine AS builder
|
||||
|
||||
LABEL stage=gobuilder
|
||||
|
||||
ENV CGO_ENABLED 0
|
||||
ENV GOPROXY https://goproxy.cn,direct
|
||||
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
|
||||
|
||||
RUN apk update --no-cache && apk add --no-cache tzdata
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
ADD go.mod .
|
||||
ADD go.sum .
|
||||
RUN go mod download
|
||||
COPY . .
|
||||
COPY apps/admin/etc /app/etc
|
||||
RUN go build -ldflags="-s -w" -o /app/admin apps/admin/.\admin.go
|
||||
|
||||
|
||||
FROM scratch
|
||||
|
||||
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
|
||||
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
|
||||
ENV TZ Asia/Shanghai
|
||||
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/admin /app/admin
|
||||
COPY --from=builder /app/etc /app/etc
|
||||
|
||||
CMD ["./admin", "-f", "etc/admin-api.yaml"]
|
||||
154
apps/admin/admin.api
Normal file
154
apps/admin/admin.api
Normal file
@@ -0,0 +1,154 @@
|
||||
syntax = "v1"
|
||||
|
||||
info (
|
||||
title: "Enterprise API"
|
||||
desc: "API for managing enterprise reviews and authentication"
|
||||
author: "Your Name"
|
||||
date: "2024-09-25"
|
||||
)
|
||||
|
||||
type (
|
||||
LoginReq {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
LoginResp {}
|
||||
)
|
||||
|
||||
type (
|
||||
GetPendingEnterpriseReq {
|
||||
Page int64 `form:"page"`
|
||||
PageSize int64 `form:"pageSize"`
|
||||
}
|
||||
GetPendingEnterpriseResp {
|
||||
Total int64 `json:"total"`
|
||||
List []EnterpriseItem `json:"list"`
|
||||
}
|
||||
ReviewEnterpriseReq {
|
||||
EnterpriseID int64 `json:"enterpriseId"`
|
||||
Status string `json:"status"`
|
||||
Remarks string `json:"remarks"`
|
||||
}
|
||||
ReviewEnterpriseResp {}
|
||||
)
|
||||
|
||||
type EnterpriseItem {
|
||||
Id int64 `json:"id"` // 企业ID
|
||||
EnterpriseName string `json:"enterpriseName"` // 企业名称
|
||||
CreditCode string `json:"creditCode"` // 企业信用代码
|
||||
LegalPerson string `json:"legalPerson"` // 法人
|
||||
EnterpriseContact string `json:"enterpriseContact"` // 企业联系方式
|
||||
AuthStatus string `json:"authStatus"` // 认证状态
|
||||
BusinessLicense string `json:"businessLicense"`
|
||||
CreatedAt string `json:"createdAt"` // 创建时间
|
||||
UpdatedAt string `json:"updatedAt"` // 更新时间
|
||||
}
|
||||
|
||||
type (
|
||||
UserInfoResp {
|
||||
username string `json:"username"`
|
||||
}
|
||||
)
|
||||
|
||||
@server (
|
||||
group: auth
|
||||
prefix: /api/admin/auth
|
||||
)
|
||||
service admin-api {
|
||||
@handler login
|
||||
post /login (LoginReq) returns (LoginResp)
|
||||
}
|
||||
|
||||
@server (
|
||||
group: user
|
||||
prefix: /api/admin/user
|
||||
middleware: AuthInterceptor
|
||||
)
|
||||
service admin-api {
|
||||
@handler getUserInfo
|
||||
get /info returns (UserInfoResp)
|
||||
}
|
||||
|
||||
@server (
|
||||
group: review
|
||||
prefix: /api/admin/enterprise
|
||||
middleware: AuthInterceptor
|
||||
)
|
||||
service admin-api {
|
||||
@handler reviewEnterprise
|
||||
post /review (ReviewEnterpriseReq) returns (ReviewEnterpriseResp)
|
||||
|
||||
@handler getPendingEnterprise
|
||||
get /pending (GetPendingEnterpriseReq) returns (GetPendingEnterpriseResp)
|
||||
}
|
||||
|
||||
type (
|
||||
CreateProductReq {
|
||||
ProductName string `json:"productName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductDescription string `json:"productDescription"`
|
||||
ProductContent string `json:"productContent"`
|
||||
ProductGroup string `json:"productGroup"`
|
||||
ProductPrice float64 `json:"productPrice"`
|
||||
}
|
||||
UpdateProductReq {
|
||||
ProductId int64 `json:"productId"`
|
||||
ProductName string `json:"productName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductDescription string `json:"productDescription"`
|
||||
ProductContent string `json:"productContent"`
|
||||
ProductGroup string `json:"productGroup"`
|
||||
ProductPrice float64 `json:"productPrice"`
|
||||
}
|
||||
DeleteProductReq {
|
||||
ProductId int64 `json:"productId"`
|
||||
}
|
||||
GetProductByIdReq {
|
||||
ProductId int64 `path:"productId"`
|
||||
}
|
||||
GetProductByIdResp {
|
||||
ProductItem
|
||||
}
|
||||
GetProductListReq {
|
||||
Page int64 `form:"page"`
|
||||
PageSize int64 `form:"pageSize"`
|
||||
}
|
||||
GetProductListResp {
|
||||
Total int64 `json:"total"`
|
||||
List []ProductItem `json:"list"`
|
||||
}
|
||||
ProductItem {
|
||||
ProductId int64 `json:"productId"`
|
||||
ProductName string `json:"productName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductDescription string `json:"productDescription"`
|
||||
ProductContent string `json:"productContent"`
|
||||
ProductGroup string `json:"productGroup"`
|
||||
ProductPrice float64 `json:"productPrice"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
)
|
||||
|
||||
@server (
|
||||
group: product
|
||||
prefix: /api/admin/product
|
||||
middleware: AuthInterceptor
|
||||
)
|
||||
service admin-api {
|
||||
@handler createProduct
|
||||
post /create (CreateProductReq)
|
||||
|
||||
@handler updateProduct
|
||||
post /update (UpdateProductReq)
|
||||
|
||||
@handler deleteProduct
|
||||
post /delete (DeleteProductReq)
|
||||
|
||||
@handler getProductById
|
||||
get /:productId (GetProductByIdReq) returns (GetProductByIdResp)
|
||||
|
||||
@handler getProductList
|
||||
get /list (GetProductListReq) returns (GetProductListResp)
|
||||
}
|
||||
|
||||
31
apps/admin/admin.go
Normal file
31
apps/admin/admin.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/config"
|
||||
"tianyuan-api/apps/admin/internal/handler"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/conf"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
var configFile = flag.String("f", "etc/admin-api.yaml", "the config file")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
var c config.Config
|
||||
conf.MustLoad(*configFile, &c)
|
||||
|
||||
server := rest.MustNewServer(c.RestConf)
|
||||
defer server.Stop()
|
||||
|
||||
ctx := svc.NewServiceContext(c)
|
||||
handler.RegisterHandlers(server, ctx)
|
||||
|
||||
fmt.Printf("Starting server at %s:%d...\n", c.Host, c.Port)
|
||||
server.Start()
|
||||
}
|
||||
22
apps/admin/etc/admin-api.yaml
Normal file
22
apps/admin/etc/admin-api.yaml
Normal file
@@ -0,0 +1,22 @@
|
||||
Name: admin-api
|
||||
Host: 0.0.0.0
|
||||
Port: 10002
|
||||
DataSource: "tianyuanapi:g3h98u0291j@tcp(127.0.0.1:3307)/tianyuanapi?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
AuthJWT:
|
||||
AccessSecret: "Mf5Xph3PoyKzVpRw0Zy1+X4uR/tM7JvGMEV/5p2M/tU="
|
||||
AccessExpire: 86400 # JWT过期时间
|
||||
CacheRedis:
|
||||
- Host: "127.0.0.1:6379"
|
||||
Pass: "" # Redis 密码,如果未设置则留空
|
||||
Type: "node" # 单节点模式
|
||||
|
||||
UserRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: user.rpc
|
||||
SentinelRpc:
|
||||
Etcd:
|
||||
Hosts:
|
||||
- 127.0.0.1:2379
|
||||
Key: sentinel.rpc
|
||||
22
apps/admin/internal/config/config.go
Normal file
22
apps/admin/internal/config/config.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/core/stores/cache"
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
rest.RestConf
|
||||
DataSource string // 数据库连接的 DSN 字符串
|
||||
AuthJWT AuthConfig // JWT 鉴权相关配置
|
||||
CacheRedis cache.CacheConf // 缓存配置,使用 go-zero 自带的缓存配置结构体
|
||||
UserRpc zrpc.RpcClientConf
|
||||
SentinelRpc zrpc.RpcClientConf
|
||||
}
|
||||
|
||||
// AuthConfig 用于 JWT 鉴权配置
|
||||
type AuthConfig struct {
|
||||
AccessSecret string // JWT 密钥,用于签发 Token
|
||||
AccessExpire int64 // Token 过期时间,单位为秒
|
||||
}
|
||||
40
apps/admin/internal/handler/auth/loginhandler.go
Normal file
40
apps/admin/internal/handler/auth/loginhandler.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/admin/internal/logic/auth"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
)
|
||||
|
||||
func LoginHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.LoginReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := auth.NewLoginLogic(r.Context(), svcCtx)
|
||||
token, err := l.Login(&req)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "Authorization",
|
||||
Value: token, // JWT 令牌
|
||||
HttpOnly: true, // 防止 JavaScript 访问
|
||||
Secure: false, // HTTPS 使用
|
||||
SameSite: http.SameSiteLaxMode, // 防止 CSRF 攻击
|
||||
Path: "/",
|
||||
Expires: time.Now().Add(time.Duration(svcCtx.Config.AuthJWT.AccessExpire) * time.Second), // 过期时间
|
||||
})
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/admin/internal/handler/product/createproducthandler.go
Normal file
30
apps/admin/internal/handler/product/createproducthandler.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/admin/internal/handler/product/deleteproducthandler.go
Normal file
30
apps/admin/internal/handler/product/deleteproducthandler.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/admin/internal/handler/product/getproductbyidhandler.go
Normal file
30
apps/admin/internal/handler/product/getproductbyidhandler.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/admin/internal/handler/product/getproductlisthandler.go
Normal file
30
apps/admin/internal/handler/product/getproductlisthandler.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
30
apps/admin/internal/handler/product/updateproducthandler.go
Normal file
30
apps/admin/internal/handler/product/updateproducthandler.go
Normal 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package review
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/admin/internal/logic/review"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
)
|
||||
|
||||
func GetPendingEnterpriseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.GetPendingEnterpriseReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := review.NewGetPendingEnterpriseLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetPendingEnterprise(&req)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package review
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest/httpx"
|
||||
"tianyuan-api/apps/admin/internal/logic/review"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
)
|
||||
|
||||
func ReviewEnterpriseHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
var req types.ReviewEnterpriseReq
|
||||
if err := httpx.Parse(r, &req); err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
return
|
||||
}
|
||||
|
||||
l := review.NewReviewEnterpriseLogic(r.Context(), svcCtx)
|
||||
resp, err := l.ReviewEnterprise(&req)
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
96
apps/admin/internal/handler/routes.go
Normal file
96
apps/admin/internal/handler/routes.go
Normal file
@@ -0,0 +1,96 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.2
|
||||
|
||||
package handler
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
auth "tianyuan-api/apps/admin/internal/handler/auth"
|
||||
product "tianyuan-api/apps/admin/internal/handler/product"
|
||||
review "tianyuan-api/apps/admin/internal/handler/review"
|
||||
user "tianyuan-api/apps/admin/internal/handler/user"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
)
|
||||
|
||||
func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
|
||||
server.AddRoutes(
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/login",
|
||||
Handler: auth.LoginHandler(serverCtx),
|
||||
},
|
||||
},
|
||||
rest.WithPrefix("/api/admin/auth"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.AuthInterceptor},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/:productId",
|
||||
Handler: product.GetProductByIdHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/create",
|
||||
Handler: product.CreateProductHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/delete",
|
||||
Handler: product.DeleteProductHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/list",
|
||||
Handler: product.GetProductListHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/update",
|
||||
Handler: product.UpdateProductHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithPrefix("/api/admin/product"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.AuthInterceptor},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/pending",
|
||||
Handler: review.GetPendingEnterpriseHandler(serverCtx),
|
||||
},
|
||||
{
|
||||
Method: http.MethodPost,
|
||||
Path: "/review",
|
||||
Handler: review.ReviewEnterpriseHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithPrefix("/api/admin/enterprise"),
|
||||
)
|
||||
|
||||
server.AddRoutes(
|
||||
rest.WithMiddlewares(
|
||||
[]rest.Middleware{serverCtx.AuthInterceptor},
|
||||
[]rest.Route{
|
||||
{
|
||||
Method: http.MethodGet,
|
||||
Path: "/info",
|
||||
Handler: user.GetUserInfoHandler(serverCtx),
|
||||
},
|
||||
}...,
|
||||
),
|
||||
rest.WithPrefix("/api/admin/user"),
|
||||
)
|
||||
}
|
||||
21
apps/admin/internal/handler/user/getuserinfohandler.go
Normal file
21
apps/admin/internal/handler/user/getuserinfohandler.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
"tianyuan-api/apps/admin/internal/logic/user"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
)
|
||||
|
||||
func GetUserInfoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
l := user.NewGetUserInfoLogic(r.Context(), svcCtx)
|
||||
resp, err := l.GetUserInfo()
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, err)
|
||||
} else {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, resp)
|
||||
}
|
||||
}
|
||||
}
|
||||
45
apps/admin/internal/logic/auth/loginlogic.go
Normal file
45
apps/admin/internal/logic/auth/loginlogic.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package auth
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
jwtx "tianyuan-api/pkg/jwt"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type LoginLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewLoginLogic(ctx context.Context, svcCtx *svc.ServiceContext) *LoginLogic {
|
||||
return &LoginLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *LoginLogic) Login(req *types.LoginReq) (token string, err error) {
|
||||
if req.Username == "" || req.Password == "" {
|
||||
return "", errors.New("用户名或密码不能为空")
|
||||
}
|
||||
|
||||
if req.Username != "SkyWalker_8273" && req.Password != "mD$9tPzQ&1kB2z%L" {
|
||||
return "", errors.New("密码错误")
|
||||
}
|
||||
|
||||
// 生成 JWT token,调用封装好的函数
|
||||
token, err = jwtx.GenerateJwtToken(1, l.svcCtx.Config.AuthJWT.AccessSecret, l.svcCtx.Config.AuthJWT.AccessExpire)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 返回成功的登录响应
|
||||
return token, nil
|
||||
}
|
||||
40
apps/admin/internal/logic/product/createproductlogic.go
Normal file
40
apps/admin/internal/logic/product/createproductlogic.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
"tianyuan-api/apps/sentinel/client/product"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type CreateProductLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewCreateProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CreateProductLogic {
|
||||
return &CreateProductLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *CreateProductLogic) CreateProduct(req *types.CreateProductReq) error {
|
||||
_, err := l.svcCtx.ProductRpc.CreateProduct(l.ctx, &product.CreateProductRequest{
|
||||
ProductName: req.ProductName,
|
||||
ProductCode: req.ProductCode,
|
||||
ProductDescription: req.ProductDescription,
|
||||
ProductContent: req.ProductContent,
|
||||
ProductPrice: req.ProductPrice,
|
||||
ProductGroup: req.ProductGroup,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
36
apps/admin/internal/logic/product/deleteproductlogic.go
Normal file
36
apps/admin/internal/logic/product/deleteproductlogic.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/sentinel/client/product"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type DeleteProductLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewDeleteProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteProductLogic {
|
||||
return &DeleteProductLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *DeleteProductLogic) DeleteProduct(req *types.DeleteProductReq) error {
|
||||
_, err := l.svcCtx.ProductRpc.DeleteProduct(l.ctx, &product.DeleteProductRequest{
|
||||
Id: req.ProductId,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
46
apps/admin/internal/logic/product/getproductbyidlogic.go
Normal file
46
apps/admin/internal/logic/product/getproductbyidlogic.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/sentinel/client/product"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetProductByIdLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetProductByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductByIdLogic {
|
||||
return &GetProductByIdLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetProductByIdLogic) GetProductById(req *types.GetProductByIdReq) (resp *types.GetProductByIdResp, err error) {
|
||||
productResp, err := l.svcCtx.ProductRpc.GetProductById(l.ctx, &product.GetRecordByIdRequest{
|
||||
Id: req.ProductId,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &types.GetProductByIdResp{
|
||||
ProductItem: types.ProductItem{
|
||||
ProductId: productResp.Id,
|
||||
ProductName: productResp.ProductName,
|
||||
ProductCode: productResp.ProductCode,
|
||||
ProductDescription: productResp.ProductDescription,
|
||||
ProductContent: productResp.ProductContent,
|
||||
ProductPrice: productResp.ProductPrice,
|
||||
ProductGroup: productResp.ProductGroup,
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
50
apps/admin/internal/logic/product/getproductlistlogic.go
Normal file
50
apps/admin/internal/logic/product/getproductlistlogic.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
"tianyuan-api/apps/sentinel/client/product"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetProductListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetProductListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetProductListLogic {
|
||||
return &GetProductListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetProductListLogic) GetProductList(req *types.GetProductListReq) (resp *types.GetProductListResp, err error) {
|
||||
productList, err := l.svcCtx.ProductRpc.GetProductPageList(l.ctx, &product.PageListRequest{Page: req.Page, PageSize: req.PageSize})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var list []types.ProductItem
|
||||
|
||||
for _, p := range productList.Products {
|
||||
list = append(list, types.ProductItem{
|
||||
ProductId: p.Id,
|
||||
ProductName: p.ProductName,
|
||||
ProductCode: p.ProductCode,
|
||||
ProductDescription: p.ProductDescription,
|
||||
ProductPrice: p.ProductPrice,
|
||||
ProductGroup: p.ProductGroup,
|
||||
CreatedAt: p.CreatedAt,
|
||||
UpdatedAt: p.UpdatedAt,
|
||||
})
|
||||
}
|
||||
resp = &types.GetProductListResp{
|
||||
Total: productList.Total,
|
||||
List: list,
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
42
apps/admin/internal/logic/product/updateproductlogic.go
Normal file
42
apps/admin/internal/logic/product/updateproductlogic.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package product
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/sentinel/client/product"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type UpdateProductLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewUpdateProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UpdateProductLogic {
|
||||
return &UpdateProductLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *UpdateProductLogic) UpdateProduct(req *types.UpdateProductReq) error {
|
||||
_, err := l.svcCtx.ProductRpc.UpdateProduct(l.ctx, &product.UpdateProductRequest{
|
||||
Id: req.ProductId,
|
||||
ProductName: req.ProductName,
|
||||
ProductCode: req.ProductCode,
|
||||
ProductDescription: req.ProductDescription,
|
||||
ProductContent: req.ProductContent,
|
||||
ProductPrice: req.ProductPrice,
|
||||
ProductGroup: req.ProductGroup,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package review
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/user/client/enterprise"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetPendingEnterpriseLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetPendingEnterpriseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetPendingEnterpriseLogic {
|
||||
return &GetPendingEnterpriseLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetPendingEnterpriseLogic) GetPendingEnterprise(req *types.GetPendingEnterpriseReq) (resp *types.GetPendingEnterpriseResp, err error) {
|
||||
pendingEnterpriseList, err := l.svcCtx.EntRpc.GetPendingEnterprise(l.ctx, &enterprise.GetPendingEnterpriseReq{Page: req.Page, PageSize: req.PageSize})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var list []types.EnterpriseItem
|
||||
|
||||
for _, ent := range pendingEnterpriseList.List {
|
||||
list = append(list, types.EnterpriseItem{
|
||||
Id: ent.Id,
|
||||
EnterpriseName: ent.EnterpriseName,
|
||||
EnterpriseContact: ent.EnterpriseContact,
|
||||
CreditCode: ent.CreditCode,
|
||||
LegalPerson: ent.LegalPerson,
|
||||
AuthStatus: ent.AuthStatus,
|
||||
BusinessLicense: ent.BusinessLicense,
|
||||
UpdatedAt: ent.UpdatedAt,
|
||||
CreatedAt: ent.CreatedAt,
|
||||
})
|
||||
}
|
||||
resp = &types.GetPendingEnterpriseResp{
|
||||
Total: pendingEnterpriseList.Total,
|
||||
List: list,
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
37
apps/admin/internal/logic/review/reviewenterpriselogic.go
Normal file
37
apps/admin/internal/logic/review/reviewenterpriselogic.go
Normal file
@@ -0,0 +1,37 @@
|
||||
package review
|
||||
|
||||
import (
|
||||
"context"
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
"tianyuan-api/apps/user/client/enterprise"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type ReviewEnterpriseLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewReviewEnterpriseLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReviewEnterpriseLogic {
|
||||
return &ReviewEnterpriseLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *ReviewEnterpriseLogic) ReviewEnterprise(req *types.ReviewEnterpriseReq) (resp *types.ReviewEnterpriseResp, err error) {
|
||||
|
||||
_, err = l.svcCtx.EntRpc.ReviewEnterprise(l.ctx, &enterprise.ReviewEnterpriseReq{
|
||||
EnterpriseId: req.EnterpriseID,
|
||||
Status: req.Status,
|
||||
Remarks: req.Remarks,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &types.ReviewEnterpriseResp{}, nil
|
||||
}
|
||||
30
apps/admin/internal/logic/user/getuserinfologic.go
Normal file
30
apps/admin/internal/logic/user/getuserinfologic.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"tianyuan-api/apps/admin/internal/svc"
|
||||
"tianyuan-api/apps/admin/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetUserInfoLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
func NewGetUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetUserInfoLogic {
|
||||
return &GetUserInfoLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetUserInfoLogic) GetUserInfo() (resp *types.UserInfoResp, err error) {
|
||||
return &types.UserInfoResp{
|
||||
Username: "admin",
|
||||
}, nil
|
||||
}
|
||||
54
apps/admin/internal/middleware/authinterceptormiddleware.go
Normal file
54
apps/admin/internal/middleware/authinterceptormiddleware.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
xhttp "github.com/zeromicro/x/http"
|
||||
"tianyuan-api/apps/admin/internal/config"
|
||||
jwtx "tianyuan-api/pkg/jwt"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
type AuthInterceptorMiddleware struct {
|
||||
Config config.Config
|
||||
}
|
||||
|
||||
func NewAuthInterceptorMiddleware(c config.Config) *AuthInterceptorMiddleware {
|
||||
return &AuthInterceptorMiddleware{
|
||||
Config: c,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *AuthInterceptorMiddleware) Handle(next http.HandlerFunc) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
// 从 Cookie 中获取 JWT
|
||||
cookie, err := r.Cookie("Authorization")
|
||||
if err != nil {
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, errors.New("用户未登录"))
|
||||
return
|
||||
}
|
||||
|
||||
tokenStr := cookie.Value
|
||||
// 验证并解析 JWT
|
||||
userId, err := jwtx.ParseJwtToken(tokenStr, m.Config.AuthJWT.AccessSecret)
|
||||
if err != nil {
|
||||
// 设置过期的 Cookie 来删除无效的 Token
|
||||
http.SetCookie(w, &http.Cookie{
|
||||
Name: "Authorization",
|
||||
Value: "",
|
||||
Path: "/",
|
||||
HttpOnly: true,
|
||||
Expires: time.Unix(0, 0), // 过期时间设置为过去
|
||||
})
|
||||
logx.Error("Invalid JWT: ", err)
|
||||
xhttp.JsonBaseResponseCtx(r.Context(), w, errors.New("未经授权的访问"))
|
||||
return
|
||||
}
|
||||
|
||||
// 将 userId 存入 context,供后续逻辑使用
|
||||
ctx := context.WithValue(r.Context(), "userId", userId)
|
||||
next(w, r.WithContext(ctx))
|
||||
}
|
||||
}
|
||||
28
apps/admin/internal/svc/servicecontext.go
Normal file
28
apps/admin/internal/svc/servicecontext.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package svc
|
||||
|
||||
import (
|
||||
"github.com/zeromicro/go-zero/rest"
|
||||
"github.com/zeromicro/go-zero/zrpc"
|
||||
"tianyuan-api/apps/admin/internal/config"
|
||||
"tianyuan-api/apps/admin/internal/middleware"
|
||||
"tianyuan-api/apps/sentinel/sentinel"
|
||||
"tianyuan-api/apps/user/user"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
AuthInterceptor rest.Middleware
|
||||
EntRpc user.EnterpriseClient
|
||||
UserRpc user.UserClient
|
||||
ProductRpc sentinel.ProductClient
|
||||
}
|
||||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
AuthInterceptor: middleware.NewAuthInterceptorMiddleware(c).Handle,
|
||||
EntRpc: user.NewEnterpriseClient(zrpc.MustNewClient(c.UserRpc).Conn()),
|
||||
UserRpc: user.NewUserClient(zrpc.MustNewClient(c.UserRpc).Conn()),
|
||||
ProductRpc: sentinel.NewProductClient(zrpc.MustNewClient(c.SentinelRpc).Conn()),
|
||||
}
|
||||
}
|
||||
100
apps/admin/internal/types/types.go
Normal file
100
apps/admin/internal/types/types.go
Normal file
@@ -0,0 +1,100 @@
|
||||
// Code generated by goctl. DO NOT EDIT.
|
||||
// goctl 1.7.2
|
||||
|
||||
package types
|
||||
|
||||
type CreateProductReq struct {
|
||||
ProductName string `json:"productName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductDescription string `json:"productDescription"`
|
||||
ProductContent string `json:"productContent"`
|
||||
ProductGroup string `json:"productGroup"`
|
||||
ProductPrice float64 `json:"productPrice"`
|
||||
}
|
||||
|
||||
type DeleteProductReq struct {
|
||||
ProductId int64 `json:"productId"`
|
||||
}
|
||||
|
||||
type EnterpriseItem struct {
|
||||
Id int64 `json:"id"` // 企业ID
|
||||
EnterpriseName string `json:"enterpriseName"` // 企业名称
|
||||
CreditCode string `json:"creditCode"` // 企业信用代码
|
||||
LegalPerson string `json:"legalPerson"` // 法人
|
||||
EnterpriseContact string `json:"enterpriseContact"` // 企业联系方式
|
||||
AuthStatus string `json:"authStatus"` // 认证状态
|
||||
BusinessLicense string `json:"businessLicense"`
|
||||
CreatedAt string `json:"createdAt"` // 创建时间
|
||||
UpdatedAt string `json:"updatedAt"` // 更新时间
|
||||
}
|
||||
|
||||
type GetPendingEnterpriseReq struct {
|
||||
Page int64 `form:"page"`
|
||||
PageSize int64 `form:"pageSize"`
|
||||
}
|
||||
|
||||
type GetPendingEnterpriseResp struct {
|
||||
Total int64 `json:"total"`
|
||||
List []EnterpriseItem `json:"list"`
|
||||
}
|
||||
|
||||
type GetProductByIdReq struct {
|
||||
ProductId int64 `path:"productId"`
|
||||
}
|
||||
|
||||
type GetProductByIdResp struct {
|
||||
ProductItem
|
||||
}
|
||||
|
||||
type GetProductListReq struct {
|
||||
Page int64 `form:"page"`
|
||||
PageSize int64 `form:"pageSize"`
|
||||
}
|
||||
|
||||
type GetProductListResp struct {
|
||||
Total int64 `json:"total"`
|
||||
List []ProductItem `json:"list"`
|
||||
}
|
||||
|
||||
type LoginReq struct {
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
}
|
||||
|
||||
type LoginResp struct {
|
||||
}
|
||||
|
||||
type ProductItem struct {
|
||||
ProductId int64 `json:"productId"`
|
||||
ProductName string `json:"productName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductDescription string `json:"productDescription"`
|
||||
ProductContent string `json:"productContent"`
|
||||
ProductGroup string `json:"productGroup"`
|
||||
ProductPrice float64 `json:"productPrice"`
|
||||
CreatedAt string `json:"createdAt"`
|
||||
UpdatedAt string `json:"updatedAt"`
|
||||
}
|
||||
|
||||
type ReviewEnterpriseReq struct {
|
||||
EnterpriseID int64 `json:"enterpriseId"`
|
||||
Status string `json:"status"`
|
||||
Remarks string `json:"remarks"`
|
||||
}
|
||||
|
||||
type ReviewEnterpriseResp struct {
|
||||
}
|
||||
|
||||
type UpdateProductReq struct {
|
||||
ProductId int64 `json:"productId"`
|
||||
ProductName string `json:"productName"`
|
||||
ProductCode string `json:"productCode"`
|
||||
ProductDescription string `json:"productDescription"`
|
||||
ProductContent string `json:"productContent"`
|
||||
ProductGroup string `json:"productGroup"`
|
||||
ProductPrice float64 `json:"productPrice"`
|
||||
}
|
||||
|
||||
type UserInfoResp struct {
|
||||
Username string `json:"username"`
|
||||
}
|
||||
Reference in New Issue
Block a user