### Install and Use Database Schema Code Generator Source: https://context7.com/feihua/zero-admin/llms.txt Install the generate-code tool globally and then use it to generate Go code for the Zero framework from a database schema. Provide the DSN, table names, a prefix, and RPC client name. ```bash go install github.com/feihua/generate-code@latest generate-code golang zero \ --dsn "root:123456@tcp(127.0.0.1:3306)/demo" \ --tableNames sys_ --prefix sys_ \ --rpcClient sysclient --author yourname ``` -------------------------------- ### Install goctl-helper Code Generation Tool Source: https://github.com/feihua/zero-admin/blob/master/README.md Install the goctl-helper tool globally using go install. This tool assists in generating API and protobuf files from database schemas for use with goctl. ```shell go install github.com/feihua/generate-code@latest generate-code golang zero --dsn "root:123456@tcp(127.0.0.1:3306)/demo" --tableNames sys_ --prefix sys_ --rpcClient sysclient --author liufeihua ``` -------------------------------- ### Get Full Product Detail Source: https://context7.com/feihua/zero-admin/llms.txt Retrieve comprehensive details for a specific product, including its SKUs, pricing, attributes, and associated coupons. Requires product ID. ```bash curl -X GET "http://localhost:8888/api/pms/product/queryProductSpuDetail?id=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Get Full Product Detail Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves the complete details of a specific product, including its SKUs, pricing, attributes, and associated coupons. ```APIDOC ## GET /api/pms/product/queryProductSpuDetail ### Description Retrieves the full details of a product, including SKUs, pricing, attributes, and coupons. ### Method GET ### Endpoint /api/pms/product/queryProductSpuDetail ### Query Parameters - **id** (integer) - Required - The ID of the product to retrieve. ``` -------------------------------- ### Product RPC Service Configuration Source: https://context7.com/feihua/zero-admin/llms.txt Example YAML configuration for the Product RPC Service (pms). Includes service name, listen address, Etcd for discovery, MySQL datasource, RabbitMQ connection details, MongoDB datasource, Redis configuration, and logging settings. ```yaml Name: pms.rpc ListenOn: 0.0.0.0:8082 Etcd: Hosts: [127.0.0.1:2379] Key: pms.rpc Mysql: Datasource: root:password@tcp(127.0.0.1:3306)/gozero?charset=utf8mb4&parseTime=true&loc=Asia%2FShanghai Rabbitmq: Host: 127.0.0.1 Port: 5672 UserName: guest Password: guest Mongo: Datasource: mongodb://admin:password@127.0.0.1:27017 Db: pms Redis: Host: 127.0.0.1:6379 Type: node Pass: "yourpassword" Key: "pms:" Log: ServiceName: pms-service Mode: file Path: logs/pms ``` -------------------------------- ### Get Coupon Detail Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves the detailed information for a specific coupon, including its scope items. Requires authentication token. ```bash curl -X GET "http://localhost:8888/api/sms/coupon/queryCouponDetail?id=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### RabbitMQ Consumer Service Configuration Source: https://context7.com/feihua/zero-admin/llms.txt Example YAML configuration for a RabbitMQ Consumer Service. This defines the service name, host, port, RabbitMQ connection details, and configurations for dependent RPC services (OmsRpc, PmsRpc, SearchRpc). ```yaml Name: consumer-api Host: 0.0.0.0 Port: 8087 Rabbitmq: Host: 127.0.0.1 Port: 5672 UserName: guest Password: guest OmsRpc: Etcd: Hosts: [localhost:2379] Key: oms.rpc NonBlock: true PmsRpc: Etcd: Hosts: [localhost:2379] Key: pms.rpc NonBlock: true SearchRpc: Etcd: Hosts: [localhost:2379] Key: search.rpc NonBlock: true ``` -------------------------------- ### Admin API Gateway Configuration Source: https://context7.com/feihua/zero-admin/llms.txt Example YAML configuration for the Admin API Gateway. This includes service name, host, port, RPC service configurations (Etcd, NonBlock), authentication settings, Redis, Swagger, logging, and Prometheus. ```yaml Name: admin-api Host: 0.0.0.0 Port: 8888 SysRpc: Etcd: Hosts: [localhost:2379] Key: sys.rpc NonBlock: true PmsRpc: Etcd: Hosts: [localhost:2379] Key: pms.rpc NonBlock: true OmsRpc: Etcd: Hosts: [localhost:2379] Key: oms.rpc NonBlock: true SmsRpc: Etcd: Hosts: [localhost:2379] Key: sms.rpc NonBlock: true CmsRpc: Etcd: Hosts: [localhost:2379] Key: cms.rpc NonBlock: true UmsRpc: Etcd: Hosts: [localhost:2379] Key: ums.rpc NonBlock: true Auth: AccessSecret: ad879037-c7a4-4063-9236-6bfc35d54b7d AccessExpire: 86400 ExcludeUrl: "/api/sys/user/info,/api/sys/user/queryAllRelations" Redis: Address: 127.0.0.1:6379 Pass: "yourpassword" Swagger: IsTest: true # Set false in production Path: "api/admin/static" Log: ServiceName: admin-api Mode: file Path: logs/admin Prometheus: Host: 127.0.0.1 Port: 8188 Path: /metrics ``` -------------------------------- ### Get Order Detail Source: https://context7.com/feihua/zero-admin/llms.txt Retrieve detailed information for a specific order, including items, payment, delivery, promotions, and operation logs. Requires order ID. ```bash curl -X GET "http://localhost:8888/api/oms/order/queryOrderMainDetail?id=10001" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Get coupon detail Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves the detailed information of a specific coupon, including its scope items. ```APIDOC ## GET /api/sms/coupon/queryCouponDetail ### Description Retrieves the detailed information of a specific coupon, including its scope items. ### Method GET ### Endpoint /api/sms/coupon/queryCouponDetail ### Query Parameters - **id** (integer) - Required - The ID of the coupon to retrieve. ### Request Example ```bash curl -X GET "http://localhost:8888/api/sms/coupon/queryCouponDetail?id=1" \ -H "Authorization: Bearer $TOKEN" ``` ``` -------------------------------- ### Get Order Detail Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves the detailed information for a specific order, including items, payment, delivery, promotion, and operation logs. ```APIDOC ## GET /api/oms/order/queryOrderMainDetail ### Description Retrieves the detailed information for a specific order. ### Method GET ### Endpoint /api/oms/order/queryOrderMainDetail ### Query Parameters - **id** (integer) - Required - The ID of the order to retrieve. ``` -------------------------------- ### Get Current Logged-in User Info and Menu Tree Source: https://context7.com/feihua/zero-admin/llms.txt Retrieve information about the currently logged-in user, including their avatar, name, and associated menu tree. Requires a valid JWT token in the Authorization header. ```bash # Get current logged-in user info + menu tree curl -X GET http://localhost:8888/api/sys/user/info \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Go-Zero Build and Management Commands Source: https://context7.com/feihua/zero-admin/llms.txt Provides essential commands for managing the Zero-Admin project, including code generation, building, Docker image creation, deployment, and service control. ```bash # Install code generation tool go install github.com/zeromicro/go-zero/tools/goctl@latest # Generate all service code from .api and .proto definitions make gen # Generate GORM model code for all RPC services make model # Build all binaries to ./target/ make build # Build Docker images (all services tagged 0.0.1) make image # Start all Docker containers (host networking) make run # Deploy to Kubernetes make kubectl # Start all services locally (nohup background) make start # Stop all services make stop # Restart services make restart ``` -------------------------------- ### Place Order Source: https://context7.com/feihua/zero-admin/llms.txt Step 2: After generating the confirmation, place the order using the provided cart IDs, coupon ID, address ID, payment type, and integration points. Requires member token. ```bash curl -X POST http://localhost:8889/api/order/generateOrder \ -H "Authorization: Bearer $MEMBER_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "cartIds": [101, 102], "couponId": 5, "memberReceiveAddressId": 3, "payType": 1, "useIntegration": 100 }' ``` -------------------------------- ### Query Help List RPC Implementation with GORM Source: https://context7.com/feihua/zero-admin/llms.txt Implements the QueryHelpList RPC using GORM Gen, supporting dynamic filtering and pagination. It maps the database results to the RPC response structure. ```go // rpc/cms/internal/logic/helpservice/queryhelplistlogic.go func (l *QueryHelpListLogic) QueryHelpList(in *cmsclient.QueryHelpListReq) (*cmsclient.QueryHelpListResp, error) { help := query.CmsHelp q := help.WithContext(l.ctx) // Dynamic filter building if in.CategoryId != 2 { q = q.Where(help.CategoryID.Eq(in.CategoryId)) } if len(in.Title) > 0 { q = q.Where(help.Title.Like("%" + in.Title + "%")) } if in.ShowStatus != 2 { q = q.Where(help.ShowStatus.Eq(in.ShowStatus)) } result, count, err := q.FindByPage(int((in.PageNum-1)*in.PageSize), int(in.PageSize)) if err != nil { return nil, errors.New("query help list failed") } var list []*cmsclient.HelpListData for _, item := range result { list = append(list, &cmsclient.HelpListData{ Id: item.ID, Title: item.Title, ShowStatus: item.ShowStatus, Content: item.Content, CreateTime: time_util.TimeToStr(item.CreateTime), UpdateTime: time_util.TimeToString(item.UpdateTime), }) } return &cmsclient.QueryHelpListResp{Total: count, List: list}, nil } ``` -------------------------------- ### Add New Product SPU with SKUs and Tiered Pricing Source: https://context7.com/feihua/zero-admin/llms.txt Use this endpoint to add a new product, including its SKUs, member pricing, and attributes. Ensure all required product and SKU data is provided in the JSON payload. ```bash curl -X POST http://localhost:8888/api/pms/product/addProductSpu \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "productData": { "name": "Wireless Headphones X200", "productSn": "WH-X200-001", "categoryId": 10, "categoryName": "Electronics", "brandId": 3, "brandName": "SoundPro", "unit": "piece", "weight": 0.35, "keywords": "wireless,bluetooth,headphones", "mainPic": "https://cdn.example.com/wh-x200.jpg", "publishStatus": 1, "newStatus": 1, "recommendStatus": 1, "verifyStatus": 1, "sort": 10, "stock": 500, "lowStock": 20, "promotionType": 2, "subTitle": "Premium sound, 30hr battery", "detailHtml": "

Full product description...

", "detailMobileHtml": "

Mobile version...

" }, "skuList": [ {"skuCode": "WH-X200-BLK", "price": 299.00, "stock": 200, "spData": "[{"key":"Color","value":"Black"}]"}, {"skuCode": "WH-X200-WHT", "price": 299.00, "stock": 300, "spData": "[{"key":"Color","value":"White"}]"} ], "memberPriceList": [ {"memberLevelId": 1, "memberPrice": 269.00}, {"memberLevelId": 2, "memberPrice": 249.00} ], "attributeValueList": [ {"attributeId": 5, "value": "Bluetooth 5.0"}, {"attributeId": 6, "value": "30 hours"} ] }' ``` -------------------------------- ### Create a Coupon Source: https://context7.com/feihua/zero-admin/llms.txt Creates a new discount coupon with specified parameters including scope, validity period, and limits. Requires authentication token and JSON payload. ```bash curl -X POST http://localhost:8888/api/sms/coupon/addCoupon \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "typeId": 1, "name": "Summer Sale ¥50 Off", "code": "SUMMER50", "amount": 50.00, "minAmount": 200.00, "startTime": "2024-06-01 00:00:00", "endTime": "2024-08-31 23:59:59", "totalCount": 1000, "receivedCount": 0, "usedCount": 0, "perLimit": 1, "status": 1, "isEnabled": 1, "description": "Min spend ¥200, get ¥50 off", "couponScopeData": [ {"scopeType": 1, "scopeId": 10}, {"scopeType": 2, "scopeId": 55} ] }' ``` -------------------------------- ### Add Help RPC Implementation with GORM Source: https://context7.com/feihua/zero-admin/llms.txt Implements the AddHelp RPC using GORM Gen for persistence. It creates a new CmsHelp record in the database. ```go // rpc/cms/internal/logic/helpservice/addhelplogic.go func (l *AddHelpLogic) AddHelp(in *cmsclient.AddHelpReq) (*cmsclient.AddHelpResp, error) { q := query.CmsHelp item := &model.CmsHelp{ CategoryID: in.CategoryId, Icon: in.Icon, Title: in.Title, ShowStatus: in.ShowStatus, ReadCount: in.ReadCount, Content: in.Content, CreateBy: in.CreateBy, } if err := q.WithContext(l.ctx).Create(item); err != nil { logc.Errorf(l.ctx, "add help failed, params:%+v, err:%s", item, err.Error()) return nil, errors.New("add help failed") } return &cmsclient.AddHelpResp{}, nil } ``` -------------------------------- ### Query Product List with Filters Source: https://context7.com/feihua/zero-admin/llms.txt Retrieve a paginated list of products based on specified filters such as publish status and new status. Requires authentication. ```bash curl -X GET "http://localhost:8888/api/pms/product/queryProductSpuList?current=1&pageSize=20&publishStatus=1&newStatus=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Generate Order Confirmation Page Source: https://context7.com/feihua/zero-admin/llms.txt Step 1: Before placing an order, generate a confirmation page to preview cart items, addresses, and available coupons. Requires member token. ```bash curl -X POST http://localhost:8889/api/order/generateConfirmOrder \ -H "Authorization: Bearer $MEMBER_TOKEN" \ -H "Content-Type: application/json" \ -d '{"ids": [101, 102]}' ``` -------------------------------- ### Add a New System User Source: https://context7.com/feihua/zero-admin/llms.txt Create a new system user with specified details including mobile, username, password, status, department, posts, and roles. Requires a valid JWT token. ```bash # Add a new user curl -X POST http://localhost:8888/api/sys/user/addUser \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "mobile": "13800138000", "userName": "john", "nickName": "John Doe", "email": "john@example.com", "password": "Secret@123", "status": 1, "deptId": 1, "postIds": [1], "roleIds": [2] }' ``` -------------------------------- ### Create a coupon Source: https://context7.com/feihua/zero-admin/llms.txt Creates a new discount coupon with specified details including scope, time limits, and usage limits. ```APIDOC ## POST /api/sms/coupon/addCoupon ### Description Creates a new discount coupon with specified details including scope, time limits, and usage limits. ### Method POST ### Endpoint /api/sms/coupon/addCoupon ### Headers - **Authorization**: Bearer $TOKEN - **Content-Type**: application/json ### Request Body - **typeId** (integer) - Required - The type of the coupon. - **name** (string) - Required - The name of the coupon. - **code** (string) - Required - The coupon code. - **amount** (number) - Required - The discount amount. - **minAmount** (number) - Optional - The minimum purchase amount required to use the coupon. - **startTime** (string) - Required - The start time for the coupon validity (YYYY-MM-DD HH:MM:SS). - **endTime** (string) - Required - The end time for the coupon validity (YYYY-MM-DD HH:MM:SS). - **totalCount** (integer) - Required - The total number of coupons available. - **receivedCount** (integer) - Required - The number of coupons already received. - **usedCount** (integer) - Required - The number of coupons already used. - **perLimit** (integer) - Required - The maximum number of coupons a user can use. - **status** (integer) - Required - The status of the coupon (0: not started, 1: active, 2: ended, 3: cancelled). - **isEnabled** (integer) - Required - Whether the coupon is enabled (1: enabled, 0: disabled). - **description** (string) - Optional - A description of the coupon. - **couponScopeData** (array) - Optional - Data defining the scope of the coupon. - **scopeType** (integer) - Required - The type of scope (0: site-wide, 1: category, 2: specific product). - **scopeId** (integer) - Required - The ID related to the scope type. ### Request Example ```json { "typeId": 1, "name": "Summer Sale ¥50 Off", "code": "SUMMER50", "amount": 50.00, "minAmount": 200.00, "startTime": "2024-06-01 00:00:00", "endTime": "2024-08-31 23:59:59", "totalCount": 1000, "receivedCount": 0, "usedCount": 0, "perLimit": 1, "status": 1, "isEnabled": 1, "description": "Min spend ¥200, get ¥50 off", "couponScopeData": [ {"scopeType": 1, "scopeId": 10}, {"scopeType": 2, "scopeId": 55} ] } ``` ``` -------------------------------- ### List Coupons with Filters Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves a list of coupons with filtering options for status and enabled state. Requires authentication token. ```bash curl -X GET "http://localhost:8888/api/sms/coupon/queryCouponList?current=1&pageSize=20&status=1&isEnabled=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Generate gRPC Code from Proto Source: https://context7.com/feihua/zero-admin/llms.txt Generate Go and gRPC code for a service (e.g., sys service) from a proto file using goctl. This command specifies the proto file, output directories for Go and gRPC, and the zrpc output. ```bash goctl rpc protoc rpc/sys/sys.proto \ --go_out=./rpc/sys/ \ --go-grpc_out=./rpc/sys/ \ --zrpc_out=./rpc/sys/ -m ``` -------------------------------- ### Generate Admin API Handler and Logic Source: https://context7.com/feihua/zero-admin/llms.txt Use goctl to generate Go code for the Admin API handler and logic from a .api DSL file. Specify the input API file and the output directory. ```bash goctl api go -api ./api/admin/doc/api/admin.api -dir ./api/admin/ ``` -------------------------------- ### Generate Front-end API Code Source: https://context7.com/feihua/zero-admin/llms.txt Generate Go code for the front-end API using goctl. This command specifies the API definition file, output directory, and the go_zero style. ```bash goctl api go -api ./api/front/doc/api/front.api -dir ./api/front/ --style go_zero ``` -------------------------------- ### List Users (Paginated and Filterable) Source: https://context7.com/feihua/zero-admin/llms.txt Fetch a paginated list of system users. Supports filtering by status. Requires a valid JWT token. ```bash # List users (paginated, filterable) curl -X GET "http://localhost:8888/api/sys/user/queryUserList?current=1&pageSize=20&status=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Ship an Order Source: https://context7.com/feihua/zero-admin/llms.txt Mark an order as shipped by providing the order ID, delivery company, and tracking number. Requires authentication and permissions. ```bash curl -X POST http://localhost:8888/api/oms/order/delivery \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "orderId": 10001, "deliveryCompany": "SF Express", "deliverySn": "SF1234567890" }' ``` -------------------------------- ### Apply for Order Return/Refund Source: https://context7.com/feihua/zero-admin/llms.txt Applies for a return or refund for a specific order. Requires authentication token and a JSON payload with return details. ```bash curl -X POST http://localhost:8889/api/order/returnApply \ -H "Authorization: Bearer $MEMBER_TOKEN" \ -H "Content-Type: application/json" \ -d '{ "orderId": 10001, "status": 0, "type": 0, "reason": "Product damaged", "description": "Screen cracked on arrival", "proofPic": "https://cdn.example.com/proof1.jpg", "refundAmount": 299.00, "returnName": "John Doe", "returnPhone": "13800138000", "companyAddress": "123 Warehouse St, Beijing", "returnItemData": [ {"orderId": 10001, "orderItemId": 201, "skuId": 15, "quantity": 1, "productPrice": 299.00, "realAmount": 299.00} ] }' ``` -------------------------------- ### Batch Update Product Recommendation Status Source: https://context7.com/feihua/zero-admin/llms.txt Update the recommendation status for multiple products. Specify the product IDs and the desired recommendation status. ```bash curl -X POST http://localhost:8888/api/pms/product/updateRecommendStatus \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"ids": [1], "status": 1}' ``` -------------------------------- ### Add a Subject/Feature Page Source: https://context7.com/feihua/zero-admin/llms.txt Adds a new subject or feature page with content, title, and status settings. Requires authentication token and a JSON payload. ```bash curl -X POST http://localhost:8888/api/cms/subject/addSubject \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{ "categoryId": 2, "title": "Summer Collection 2024", "pic": "https://cdn.example.com/summer2024.jpg", "productCount": 20, "recommendStatus": 1, "showStatus": 1, "description": "Discover our summer lineup", "content": "

Summer 2024

...

", "sort": 5 }' ``` -------------------------------- ### Query Product List Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves a list of products with filtering options. Supports pagination and filtering by publication and new product statuses. ```APIDOC ## GET /api/pms/product/queryProductSpuList ### Description Queries a list of products with filters and pagination. ### Method GET ### Endpoint /api/pms/product/queryProductSpuList ### Query Parameters - **current** (integer) - Required - The current page number. - **pageSize** (integer) - Required - The number of items per page. - **publishStatus** (integer) - Optional - Filter by publication status (e.g., 1 for published). - **newStatus** (integer) - Optional - Filter by new product status (e.g., 1 for new). ``` -------------------------------- ### List coupons with filters Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves a list of coupons with filtering options for status and enabled state. Supports pagination. ```APIDOC ## GET /api/sms/coupon/queryCouponList ### Description Retrieves a list of coupons with filtering options for status and enabled state. Supports pagination. ### Method GET ### Endpoint /api/sms/coupon/queryCouponList ### Query Parameters - **current** (integer) - Required - The current page number. - **pageSize** (integer) - Required - The number of items per page. - **status** (integer) - Optional - Filter by coupon status (0: not started, 1: active, 2: ended, 3: cancelled). - **isEnabled** (integer) - Optional - Filter by enabled status (1: enabled, 0: disabled). ### Request Example ```bash curl -X GET "http://localhost:8888/api/sms/coupon/queryCouponList?current=1&pageSize=20&status=1&isEnabled=1" \ -H "Authorization: Bearer $TOKEN" ``` ``` -------------------------------- ### List User Orders by Status Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves a list of user orders filtered by their status. Requires authentication token. ```bash curl -X GET "http://localhost:8889/api/order/queryOrderList?current=1&pageSize=5&status=1" \ -H "Authorization: Bearer $MEMBER_TOKEN" ``` -------------------------------- ### Add Subject RPC Logic Source: https://context7.com/feihua/zero-admin/llms.txt Handles adding a new subject via the SubjectService RPC. It extracts user information from the context and maps request parameters to the RPC client request. ```go // Logic layer usage in api/admin/internal/logic/cms/subject/addsubjectlogic.go func (l *AddSubjectLogic) AddSubject(req *types.AddSubjectReq) (resp *types.BaseResp, err error) { createBy := l.ctx.Value("userName").(string) _, err = l.svcCtx.SubjectService.AddSubject(l.ctx, &cmsclient.AddSubjectReq{ CategoryId: req.CategoryId, Title: req.Title, Pic: req.Pic, ProductCount: req.ProductCount, RecommendStatus: req.RecommendStatus, ShowStatus: req.ShowStatus, Content: req.Content, Sort: req.Sort, CreateBy: createBy, }) if err != nil { s, _ := status.FromError(err) return nil, errorx.NewDefaultError(s.Message()) } return res.Success() } ``` -------------------------------- ### List Orders with Filters Source: https://context7.com/feihua/zero-admin/llms.txt Retrieve a paginated list of orders with the ability to filter by order status and payment type. Requires JWT authentication. ```bash curl -X GET "http://localhost:8888/api/oms/order/queryOrderMainList?current=1&pageSize=20&orderStatus=2&payType=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Add Product SPU with SKUs and Tiered Pricing Source: https://context7.com/feihua/zero-admin/llms.txt Adds a new product SPU (Stock Keeping Unit) along with its associated SKUs and member pricing information. This endpoint allows for detailed product configuration including product data, SKU details, member-specific prices, and attributes. ```APIDOC ## POST /api/pms/product/addProductSpu ### Description Adds a new product SPU with SKUs and tiered pricing. ### Method POST ### Endpoint /api/pms/product/addProductSpu ### Request Body - **productData** (object) - Required - Contains the main product information. - **name** (string) - Required - The name of the product. - **productSn** (string) - Required - The unique product serial number. - **categoryId** (integer) - Required - The ID of the product category. - **categoryName** (string) - Required - The name of the product category. - **brandId** (integer) - Required - The ID of the product brand. - **brandName** (string) - Required - The name of the product brand. - **unit** (string) - Required - The unit of measurement for the product. - **weight** (number) - Required - The weight of the product. - **keywords** (string) - Optional - Comma-separated keywords for the product. - **mainPic** (string) - Required - URL of the main product image. - **publishStatus** (integer) - Required - The publication status of the product (e.g., 1 for published). - **newStatus** (integer) - Required - The new product status (e.g., 1 for new). - **recommendStatus** (integer) - Required - The recommendation status (e.g., 1 for recommended). - **verifyStatus** (integer) - Required - The verification status (e.g., 1 for verified). - **sort** (integer) - Optional - The sort order of the product. - **stock** (integer) - Required - The total stock quantity. - **lowStock** (integer) - Required - The low stock threshold. - **promotionType** (integer) - Required - The type of promotion. - **subTitle** (string) - Optional - The subtitle of the product. - **detailHtml** (string) - Optional - The detailed description in HTML format. - **detailMobileHtml** (string) - Optional - The detailed description for mobile in HTML format. - **skuList** (array) - Required - List of SKUs for the product. - **skuCode** (string) - Required - The SKU code. - **price** (number) - Required - The price of the SKU. - **stock** (integer) - Required - The stock quantity for the SKU. - **spData** (string) - Required - SKU specific data, typically JSON string. - **memberPriceList** (array) - Optional - List of member prices for the SKU. - **memberLevelId** (integer) - Required - The ID of the member level. - **memberPrice** (number) - Required - The member price. - **attributeValueList** (array) - Optional - List of attribute values for the product. - **attributeId** (integer) - Required - The ID of the attribute. - **value** (string) - Required - The value of the attribute. ### Request Example ```json { "productData": { "name": "Wireless Headphones X200", "productSn": "WH-X200-001", "categoryId": 10, "categoryName": "Electronics", "brandId": 3, "brandName": "SoundPro", "unit": "piece", "weight": 0.35, "keywords": "wireless,bluetooth,headphones", "mainPic": "https://cdn.example.com/wh-x200.jpg", "publishStatus": 1, "newStatus": 1, "recommendStatus": 1, "verifyStatus": 1, "sort": 10, "stock": 500, "lowStock": 20, "promotionType": 2, "subTitle": "Premium sound, 30hr battery", "detailHtml": "

Full product description...

", "detailMobileHtml": "

Mobile version...

" }, "skuList": [ {"skuCode": "WH-X200-BLK", "price": 299.00, "stock": 200, "spData": "[{"key":"Color","value":"Black"}]"}, {"skuCode": "WH-X200-WHT", "price": 299.00, "stock": 300, "spData": "[{"key":"Color","value":"White"}]"} ], "memberPriceList": [ {"memberLevelId": 1, "memberPrice": 269.00}, {"memberLevelId": 2, "memberPrice": 249.00} ], "attributeValueList": [ {"attributeId": 5, "value": "Bluetooth 5.0"}, {"attributeId": 6, "value": "30 hours"} ] } ``` ``` -------------------------------- ### Query Subject List Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves a paginated list of subjects with filtering options for recommendation and show status. Requires authentication token. ```bash curl -X GET "http://localhost:8888/api/cms/subject/querySubjectList?current=1&pageSize=20&recommendStatus=1&showStatus=1" \ -H "Authorization: Bearer $TOKEN" ``` -------------------------------- ### Login and Retrieve JWT Token Source: https://context7.com/feihua/zero-admin/llms.txt Use this endpoint to authenticate admin users and obtain a JWT token. The token is required for all subsequent authenticated API calls. ```bash # Login and retrieve JWT token curl -X POST http://localhost:8888/api/sys/user/login \ -H "Content-Type: application/json" \ -d '{ "account": "admin", "password": "123456" }' # Response: # { # "code": "000000", # "message": "success", # "data": { # "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." # } # } # Use token in subsequent requests TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." ``` -------------------------------- ### Apply for return/refund Source: https://context7.com/feihua/zero-admin/llms.txt Applies for a return or refund for an order item. Requires detailed information about the reason and items. ```APIDOC ## POST /api/order/returnApply ### Description Applies for a return or refund for an order item. Requires detailed information about the reason and items. ### Method POST ### Endpoint /api/order/returnApply ### Headers - **Authorization**: Bearer $MEMBER_TOKEN - **Content-Type**: application/json ### Request Body - **orderId** (integer) - Required - The ID of the order. - **status** (integer) - Required - The status of the return/refund application. - **type** (integer) - Required - The type of application (e.g., return, refund). - **reason** (string) - Required - The reason for the return/refund. - **description** (string) - Optional - A detailed description of the issue. - **proofPic** (string) - Optional - URL to a proof image. - **refundAmount** (number) - Required - The amount to be refunded. - **returnName** (string) - Optional - Name of the person returning. - **returnPhone** (string) - Optional - Phone number of the person returning. - **companyAddress** (string) - Optional - The return shipping address. - **returnItemData** (array) - Required - An array of items to be returned. - **orderId** (integer) - Required - The ID of the order for the item. - **orderItemId** (integer) - Required - The ID of the order item. - **skuId** (integer) - Required - The SKU ID of the product. - **quantity** (integer) - Required - The quantity of the item. - **productPrice** (number) - Required - The price of the product. - **realAmount** (number) - Required - The actual amount paid for the item. ### Request Example ```json { "orderId": 10001, "status": 0, "type": 0, "reason": "Product damaged", "description": "Screen cracked on arrival", "proofPic": "https://cdn.example.com/proof1.jpg", "refundAmount": 299.00, "returnName": "John Doe", "returnPhone": "13800138000", "companyAddress": "123 Warehouse St, Beijing", "returnItemData": [ {"orderId": 10001, "orderItemId": 201, "skuId": 15, "quantity": 1, "productPrice": 299.00, "realAmount": 299.00} ] } ``` ``` -------------------------------- ### Batch Update Product Publish Status Source: https://context7.com/feihua/zero-admin/llms.txt Update the publish status for multiple products simultaneously. Provide a list of product IDs and the desired status (e.g., 1 for published). ```bash curl -X POST http://localhost:8888/api/pms/product/updatePublishStatus \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"ids": [1, 2, 3], "status": 1}' ``` -------------------------------- ### Query Subject List RPC Logic Source: https://context7.com/feihua/zero-admin/llms.txt Retrieves a list of subjects with pagination and filtering capabilities using the SubjectService RPC. It trims whitespace from the title filter. ```go // Query list with pagination and filters func (l *QuerySubjectListLogic) QuerySubjectList(req *types.QuerySubjectListReq) (*types.QuerySubjectListResp, error) { result, err := l.svcCtx.SubjectService.QuerySubjectList(l.ctx, &cmsclient.QuerySubjectListReq{ PageNum: req.Current, PageSize: req.PageSize, Title: strings.TrimSpace(req.Title), RecommendStatus: req.RecommendStatus, ShowStatus: req.ShowStatus, }) if err != nil { return nil, errorx.NewDefaultError("query subject failed") } // Map RPC response to API types... return &types.QuerySubjectListResp{ Current: req.Current, PageSize: req.PageSize, Total: result.Total, Success: true, Code: "000000", }, nil } ``` -------------------------------- ### System API - User Management Source: https://context7.com/feihua/zero-admin/llms.txt Provides endpoints for managing system users, including retrieving user information, listing users, adding new users, updating user status, resetting passwords, assigning roles, and deleting users. All endpoints are protected by JWT and RBAC middleware. ```APIDOC ## GET /api/sys/user/info ### Description Retrieves the current logged-in user's information, including their avatar, name, and associated menu tree. ### Method GET ### Endpoint /api/sys/user/info ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). ### Response #### Success Response (200) - **avatar** (string) - User's avatar URL. - **name** (string) - User's name. - **menuTree** (array) - User's menu tree structure. - **menuTreeVue** (array) - User's menu tree structure for Vue. ``` ```APIDOC ## GET /api/sys/user/queryUserList ### Description Lists users with pagination and filtering capabilities. Supports filtering by status. ### Method GET ### Endpoint /api/sys/user/queryUserList ### Parameters #### Query Parameters - **current** (integer) - Optional - The current page number. - **pageSize** (integer) - Optional - The number of items per page. - **status** (integer) - Optional - The status of the user to filter by (e.g., 1 for active, 0 for inactive). #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). ``` ```APIDOC ## POST /api/sys/user/addUser ### Description Adds a new system user to the platform. ### Method POST ### Endpoint /api/sys/user/addUser ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). - **Content-Type** (string) - Required - `application/json`. #### Request Body - **mobile** (string) - Required - User's mobile number. - **userName** (string) - Required - User's account name. - **nickName** (string) - Required - User's nickname. - **email** (string) - Required - User's email address. - **password** (string) - Required - User's password. - **status** (integer) - Required - User's status (e.g., 1 for active). - **deptId** (integer) - Required - The ID of the department the user belongs to. - **postIds** (array) - Required - Array of post IDs assigned to the user. - **roleIds** (array) - Required - Array of role IDs assigned to the user. ### Request Example ```json { "mobile": "13800138000", "userName": "john", "nickName": "John Doe", "email": "john@example.com", "password": "Secret@123", "status": 1, "deptId": 1, "postIds": [1], "roleIds": [2] } ``` ``` ```APIDOC ## POST /api/sys/user/updateUserStatus ### Description Updates the status of one or more users (e.g., enable or disable). ### Method POST ### Endpoint /api/sys/user/updateUserStatus ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). - **Content-Type** (string) - Required - `application/json`. #### Request Body - **ids** (array) - Required - Array of user IDs to update. - **status** (integer) - Required - The new status for the users (e.g., 0 for inactive, 1 for active). ### Request Example ```json { "ids": [3, 4], "status": 0 } ``` ``` ```APIDOC ## POST /api/sys/user/reSetPassword ### Description Resets the password for a specified user. ### Method POST ### Endpoint /api/sys/user/reSetPassword ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). - **Content-Type** (string) - Required - `application/json`. #### Request Body - **userId** (integer) - Required - The ID of the user whose password needs to be reset. ### Request Example ```json { "userId": 5 } ``` ``` ```APIDOC ## POST /api/sys/user/updateUserRoleList ### Description Assigns or updates the roles for a specific user. ### Method POST ### Endpoint /api/sys/user/updateUserRoleList ### Parameters #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). - **Content-Type** (string) - Required - `application/json`. #### Request Body - **userId** (integer) - Required - The ID of the user. - **roleIds** (array) - Required - Array of role IDs to assign to the user. ### Request Example ```json { "userId": 3, "roleIds": [1, 2] } ``` ``` ```APIDOC ## GET /api/sys/user/deleteUser ### Description Deletes one or more users from the system. ### Method GET ### Endpoint /api/sys/user/deleteUser ### Parameters #### Query Parameters - **ids** (string) - Required - A comma-separated string of user IDs to delete. #### Headers - **Authorization** (string) - Required - Bearer token for authentication (e.g., `Bearer `). ### Request Example `curl -X GET "http://localhost:8888/api/sys/user/deleteUser?ids=6,7" -H "Authorization: Bearer $TOKEN"` ``` -------------------------------- ### Place Order Source: https://context7.com/feihua/zero-admin/llms.txt Places an order after the confirmation details have been generated. This endpoint takes cart information, selected address, payment type, and other relevant details to finalize the order. ```APIDOC ## POST /api/order/generateOrder ### Description Places an order based on the provided cart details, address, and payment information. ### Method POST ### Endpoint /api/order/generateOrder ### Request Body - **cartIds** (array of integers) - Required - A list of cart item IDs to include in the order. - **couponId** (integer) - Optional - The ID of the coupon to apply. - **memberReceiveAddressId** (integer) - Required - The ID of the member's shipping address. - **payType** (integer) - Required - The payment type (1-Alipay, 2-WeChat, 3-UnionPay). - **useIntegration** (integer) - Optional - The amount of integration points to use. ```