From 5d1a8ee80468731d4533d265b1a6a4a2dc9145bd Mon Sep 17 00:00:00 2001 From: John Date: Sun, 24 Nov 2024 11:46:54 +0800 Subject: [PATCH] up --- .../What's Next.md" | 2 +- ...75\344\270\216\344\275\277\347\224\250.md" | 2 +- ...66\345\210\235\350\257\225\347\224\250.md" | 2 +- ...04\350\214\203\350\267\257\347\224\261.md" | 2 +- ...67\346\261\202\345\217\202\346\225\260.md" | 2 +- .../What's Next.md" | 60 +++++++++---------- ...41\346\225\260\346\215\256\350\241\250.md" | 8 +-- ... \347\224\237\346\210\220dao_do_entity.md" | 6 +- ...45\345\217\243\345\256\232\344\271\211.md" | 12 ++-- ...\220controller\344\273\243\347\240\201.md" | 12 ++-- ...73\350\276\221\345\256\236\347\216\260.md" | 14 ++--- ...56\344\270\216\350\267\257\347\224\261.md" | 10 ++-- ...50\344\270\216\346\265\213\350\257\225.md" | 13 ++-- ...45\345\217\243\345\274\200\345\217\221.md" | 2 +- 14 files changed, 73 insertions(+), 74 deletions(-) diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/What's Next.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/What's Next.md" index 655f0a8cb3b..45547601e7e 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/What's Next.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/What's Next.md" @@ -7,7 +7,7 @@ keywords: [GoFrame,GoFrame Framework,Web Server,Development Manual,Modular Desig description: "Quickly understand the development process and features of the Web Server interface by viewing the development manual sections to resolve any doubts. GoFrame is a low-coupling, modular design framework with independent module designs, and independently written documentation. The community provides introductory video tutorials, and later a complete business project will be developed using the GoFrame framework project scaffold." --- -## Study Summary +## Learning Summary Through the quick sections, you should have understood the complete development process of the `Web Server` interface and mastered some practical features. In these sections, we only touched on them briefly; for more detailed explanations and introductions to functional features, please refer to the corresponding development manual sections. When you feel confused about the use of a particular module, it is recommended to carefully read the corresponding development manual sections, which provide detailed explanations of the important functional features, usage methods, and common issues of each component. :::info diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\213\350\275\275\344\270\216\344\275\277\347\224\250.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\213\350\275\275\344\270\216\344\275\277\347\224\250.md" index 184daa6eac8..47d4edf685b 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\213\350\275\275\344\270\216\344\275\277\347\224\250.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\213\350\275\275\344\270\216\344\275\277\347\224\250.md" @@ -1,6 +1,6 @@ --- slug: '/quick/install' -title: 'Download and Use' +title: 'Installation' hide_title: true sidebar_position: 1 keywords: [GoFrame, GoFrame Framework, Install GoFrame, Modular Framework, Low Coupling Design, Web Server Interface Development, Go Language Environment, Project Framework, Basic Components, HTTP Server] diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\255\351\227\264\344\273\266\345\210\235\350\257\225\347\224\250.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\255\351\227\264\344\273\266\345\210\235\350\257\225\347\224\250.md" index 4e4a20ecdca..ef94b661ed4 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\255\351\227\264\344\273\266\345\210\235\350\257\225\347\224\250.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\270\255\351\227\264\344\273\266\345\210\235\350\257\225\347\224\250.md" @@ -1,6 +1,6 @@ --- slug: '/quick/middleware' -title: 'Introduction to Middleware' +title: 'Using Middleware' hide_title: true sidebar_position: 6 keywords: [GoFrame, Middleware, Web Server, ErrorHandler, Request Interception, Pre-middleware, Post-middleware, Custom Error Handling, GoFrame Framework, Request Flow Control] diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\275\277\347\224\250\350\247\204\350\214\203\350\267\257\347\224\261.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\275\277\347\224\250\350\247\204\350\214\203\350\267\257\347\224\261.md" index e630759779b..648db5418a2 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\275\277\347\224\250\350\247\204\350\214\203\350\267\257\347\224\261.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\344\275\277\347\224\250\350\247\204\350\214\203\350\267\257\347\224\261.md" @@ -1,6 +1,6 @@ --- slug: '/quick/strict-router' -title: 'Using Strict Routing' +title: 'Using Standard Routing' hide_title: true sidebar_position: 5 keywords: [GoFrame, GoFrame framework, strict routing, route registration, data structure, route object management, Go language, web server, HTTP methods, route callbacks] diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\350\216\267\345\217\226\350\257\267\346\261\202\345\217\202\346\225\260.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\350\216\267\345\217\226\350\257\267\346\261\202\345\217\202\346\225\260.md" index 970c440c889..dafcd5b2560 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\350\216\267\345\217\226\350\257\267\346\261\202\345\217\202\346\225\260.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\345\277\253\351\200\237\345\274\200\345\247\213/\350\216\267\345\217\226\350\257\267\346\261\202\345\217\202\346\225\260.md" @@ -1,6 +1,6 @@ --- slug: '/quick/request-input' -title: 'Getting Request Parameters' +title: 'Parameters Retrieving' hide_title: true sidebar_position: 3 keywords: [GoFrame, GoFrame Framework, Request Parameters, HTTP Parameter Retrieval, Web Server Development, Query String, HTTP Methods, Parameter Handling, ghttp, Go Programming] diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/What's Next.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/What's Next.md" index e2808c14973..a3732d5b8d0 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/What's Next.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/What's Next.md" @@ -3,60 +3,60 @@ slug: /quick/scaffold-next title: "What's Next" hide_title: true sidebar_position: 3 -keywords: [GoFrame框架,Web项目,微服务开发,核心组件,业务项目,API项目,服务组件,配置组件,数据库组件,框架学习] -description: "总结了使用GoFrame框架进行业务项目搭建、项目启动、配置组件使用、数据库组件使用的基础知识,并提供了Web项目和微服务开发的学习路径。建议通过丰富的示例项目,提高对GoFrame框架的掌握,特别是其核心组件的使用。" +keywords: [GoFrame framework, Web project, microservice development, core components, business project, API project, service components, configuration components, database components, framework learning] +description: "Summarizes the basic knowledge of using the GoFrame framework for building business projects, starting projects, using configuration components, using database components, and provides a learning path for Web projects and microservice development. It is recommended to improve your mastery of the GoFrame framework, especially its core components, through rich example projects." --- -## 简单总结 +## Simple Summary -好的,当您已经学习完前面的基础章节后,你应该学习到以下的内容: +Alright, after you have studied the basic chapters, you should have learned the following content: 1. Business project setup 2. Project startup logic -3. Understand the overall design concept of the framework -4. Write a simple `api` project +3. Understanding the overall framework design approach +4. Writing a simple `api` project -## 接下来的学习 +## Upcoming Study -那么接下来,我们应该怎么进一步学习框架内容呢? +What's the next step in further learning about the framework? -### 社区教程 +### Community Tutorials -The teachers in the `GoFrame` community have shared some great learning materials for everyone. Interested students can further explore 🚀:[社区教程](../../course/社区教程.md) +Teachers from the `GoFrame` community have shared some great learning materials. Interested students can explore more 🚀: [Community Tutorials](../../course/社区教程.md) -### 服务组件的进一步学习 +### Further Study of Service Components -Most students learn the framework to better develop their own business projects, which are based on two types: Web projects or microservices. +Most students learn the framework to better develop their business projects, which are mainly based on two types: Web projects or microservices. -#### Web项目学习 +#### Web Project Study -If it is an `HTTP WEB` project, please enter this section to learn: [WEB服务开发](../../docs/WEB服务开发/WEB服务开发.md) +If it's an `HTTP WEB` project, please proceed to this chapter for study: [WEB Service Development](../../docs/WEB服务开发/WEB服务开发.md) -Starting from this section, it will introduce the development of WEB services and the use of related components step by step. +This chapter will progressively introduce the development of WEB services and the use of related components. -#### 微服务学习 +#### Microservice Study -If it is a microservice project, please enter this section to learn: [微服务开发](../../docs/微服务开发/微服务开发.md) +If it's a microservice project, please proceed to this chapter for study: [Microservice Development](../../docs/微服务开发/微服务开发.md) -This section mainly introduces how to use the framework for microservice development. +This chapter primarily introduces how to use the framework to develop microservices. -### 框架组件的进一步学习 +### Further Study of Framework Components -If you encounter a component that is not quite usable during development and learning, you can first read the source code or check the corresponding component introduction section on the official website. In addition, some students use the framework as a basic component library, and they can also view the description and usage section of the corresponding components individually. +If you encounter a component you're not familiar with during development and study, you can first read the source code or check the corresponding component introduction chapter on the official website. Additionally, some students may use the framework as a basic component library, so you can also individually check the introduction chapter for each component. -#### 核心组件 +#### Core Components -Core components are an indispensable part of the framework, which are basically used in business projects and are a focus of framework learning. Section address: [核心组件(🔥重点🔥)](../../docs/核心组件/核心组件.md) +Core components are an indispensable part of the framework; most business projects will use them. They are a key focus for learning the framework. Chapter link: [Core Components (🔥Important🔥)](../../docs/核心组件/核心组件.md) -#### 组件列表 +#### Component List -The component list summarizes all the components of the framework in one section. Section address: [组件列表](../../docs/组件列表/组件列表.md) +The component list presents a summary chapter of all the components of the framework. Chapter link: [Component List](../../docs/组件列表/组件列表.md) -## 重要的Tips +## Important Tips -Learning the framework through examples is much more effective, and the framework provides a wealth of example projects: +Learning the framework through examples is much more effective. The framework provides a wealth of example projects: -- `Web API` development: [https://github.com/gogf/gf-demo-user](https://github.com/gogf/gf-demo-user) -- `Web MVC` development: [https://github.com/gogf/gf-demo-chat](https://github.com/gogf/gf-demo-chat) -- Microservice development: [https://github.com/gogf/gf-demo-grpc](https://github.com/gogf/gf-demo-grpc) -- More example projects: [https://github.com/gogf/awesome-gf](https://github.com/gogf/awesome-gf) \ No newline at end of file +- `Web API` Development: [https://github.com/gogf/gf-demo-user](https://github.com/gogf/gf-demo-user) +- `Web MVC` Development: [https://github.com/gogf/gf-demo-chat](https://github.com/gogf/gf-demo-chat) +- Microservice Development: [https://github.com/gogf/gf-demo-grpc](https://github.com/gogf/gf-demo-grpc) +- More Example Projects: [https://github.com/gogf/awesome-gf](https://github.com/gogf/awesome-gf) \ No newline at end of file diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step1 - \350\256\276\350\256\241\346\225\260\346\215\256\350\241\250.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step1 - \350\256\276\350\256\241\346\225\260\346\215\256\350\241\250.md" index e7f1fa5523d..b7f633e3c90 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step1 - \350\256\276\350\256\241\346\225\260\346\215\256\350\241\250.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step1 - \350\256\276\350\256\241\346\225\260\346\215\256\350\241\250.md" @@ -1,6 +1,6 @@ --- slug: '/quick/scaffold-api-sql' -title: 'Step1 - Design Data Table' +title: 'Step1 - Design Data Structure' hide_title: true sidebar_position: 0 keywords: [GoFrame, Data Table Design, MySQL Database, Docker, SQL Statements, InnoDB, Auto Increment, varchar, Database Connection, User Status] @@ -8,7 +8,7 @@ description: "Design and apply MySQL data tables. We define the structure of dat --- -## Design Data Table +## Design Data Structure SQL First, we define a data table. The following is the `SQL` file of the data table to be used in this chapter's example: @@ -22,7 +22,7 @@ CREATE TABLE `user` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ``` -## Apply Data Table +## Apply Data Structure SQL We need to apply this data table to the `mysql` database for subsequent use. If you don't have a `mysql` database service locally, you can use `docker` to run one: @@ -67,7 +67,7 @@ mysql> -## Study Summary +## Learning Summary It is a good development practice to design database tables before interface development. Here we are using the `mysql` database, which requires setting up/running the database service first. diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step2 - \347\224\237\346\210\220dao_do_entity.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step2 - \347\224\237\346\210\220dao_do_entity.md" index dd2abdb07f1..a4ad8065ef3 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step2 - \347\224\237\346\210\220dao_do_entity.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step2 - \347\224\237\346\210\220dao_do_entity.md" @@ -1,13 +1,13 @@ --- slug: '/quick/scaffold-api-gen-dao' -title: 'Step2 - Generate/dao/do/entity' +title: 'Step2 - Generate dao/do/entity' hide_title: true sidebar_position: 2 keywords: [GoFrame,CLI Tool,Data Access Object,Automated Generation,Data Model,Database Configuration,Make Command,Data Transformation,Code Generation,ORM Component] description: "Use the scaffolding tool in the GoFrame framework for automated data access object generation, ensure the CLI tool is configured correctly, then execute the code generation through commands, and generate corresponding dao, do, and entity files after creating the database tables to simplify CRUD operations. It demonstrates the specific file structure and usage, as well as the principles of generating different types of files." --- -## Check Tool Configuration +## CLI Tool Configuration Before using the scaffolding tool, please check whether the local `cli` tool configuration is correct. The default configuration is as follows: @@ -149,7 +149,7 @@ type User struct { We can see that this `entity` data structure definition corresponds directly to the data table fields. -## Summary of Learning +## Learning Summary It can be felt that using the convenient scaffolding tools of the `GoFrame` framework, we are liberated from some repetitive coding labor, greatly improving production efficiency. Operations on the database will become very simple. diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step3 - \347\274\226\345\206\231api\346\216\245\345\217\243\345\256\232\344\271\211.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step3 - \347\274\226\345\206\231api\346\216\245\345\217\243\345\256\232\344\271\211.md" index 7c0c9069bc8..46e9e7487ea 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step3 - \347\274\226\345\206\231api\346\216\245\345\217\243\345\256\232\344\271\211.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step3 - \347\274\226\345\206\231api\346\216\245\345\217\243\345\256\232\344\271\211.md" @@ -1,6 +1,6 @@ --- slug: '/quick/scaffold-api-definition' -title: 'Step3 - Write API Interface Definition' +title: 'Step3 - Write API Definition' hide_title: true sidebar_position: 3 keywords: [GoFrame, Interface Definition, RESTful, HTTP Method, Versioning, Parameter Validation, User Management, Metadata Management, Data Return, Golang] @@ -13,7 +13,7 @@ In the `api` directory of the project, we begin defining our `CRUD` interfaces. ![user api definition](QQ_1732094808338.png) -## Create Interface +## `Create` ```go title="api/user/v1/user.go" type CreateReq struct { g.Meta `path:"/user" method:"post" tags:"User" summary:"Create user"` @@ -38,7 +38,7 @@ Brief Introduction: In a `RESTful` style interface design, we typically use `POST` from the `HTTP Method` to denote write operations and `PUT` to denote update operations. ::: -## Delete Interface +## `Delete` ```go title="api/user/v1/user.go" type DeleteReq struct { @@ -52,7 +52,7 @@ The route tag `path` uses `/user/{id}`, where `{id}` indicates a field-matching For example: In the route `/user/1`, the `id` parameter value is `1`; in the route `/user/100`, the `id` parameter value is `100`. -## Update Interface +## `Update` ```go title="api/user/v1/user.go" // Status marks user status. @@ -78,7 +78,7 @@ Here: - The validation for the `Status` parameter uses the `in:0,1` rule, which checks that the passed `Status` value must be one of the two constants we defined, `StatusOK/StatusDisabled`, i.e., `0/1`. - The interface parameters use pointers to avoid default type values affecting our update interface. For example, if `Status` is not defined as a pointer, it will be affected by the default value `0`. During processing logic, it's hard to determine whether the caller has passed the parameter and whether to actually change the value to `0`. By using pointers, when users don't pass the parameter, its default value is `nil`, making it easy to judge in processing logic. -## Query Interface (Single) +## `GetOne` ```go title="api/user/v1/user.go" type GetOneReq struct { @@ -92,7 +92,7 @@ type GetOneRes struct { Here, the return result uses the `*entity.User` structure, which was generated by the `make dao` command earlier. This data structure corresponds to the database table fields one-to-one. -## Query Interface (List) +## `GetList` ```go title="api/user/v1/user.go" type GetListReq struct { diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step4 - \347\224\237\346\210\220controller\344\273\243\347\240\201.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step4 - \347\224\237\346\210\220controller\344\273\243\347\240\201.md" index 4b69ed2dc23..5debb30cf68 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step4 - \347\224\237\346\210\220controller\344\273\243\347\240\201.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step4 - \347\224\237\346\210\220controller\344\273\243\347\240\201.md" @@ -1,13 +1,13 @@ --- slug: '/quick/scaffold-api-controller' -title: 'Step4 - Generate Controller Code' +title: 'Step4 - Generate Controller' hide_title: true sidebar_position: 4 keywords: [GoFrame, API Code Generation, Controller Code, Generate Controller, Code Auto Generation, Interface Implementation, GoFrame Framework, Route Object Management, Interface Route Implementation, Code Template] description: "Generate controller code based on API definition, including API interface files, route object management, and route implementation code, using GoFrame framework's command tool to quickly generate relevant code templates, ensuring complete implementation of the interface, and demonstrating how to implement specific business logic through files." --- -## Generate Code from `api` +## Generate Codes From API Definition Once the `api` definition is completed, we generate the controller code through the `make ctrl` command (or `gf gen ctrl`). @@ -28,7 +28,7 @@ done! The generated codes mainly include `3` types of files. -## `api` Interface Abstraction File +## Abstraction Interface For API Defines the `api interface` to ensure the completeness of the controller's interface implementation, avoiding issues of missing interface implementations in `controller`. Since `GoFrame` is a rigorous development framework, it controls such details well. Whether or not this feature is used by developers can be decided based on specific scenarios and needs. @@ -61,7 +61,7 @@ type IUserV1 interface { } ``` -## `controller` Route Object Management +## Controller Router Object Used to manage the initialization of the controller, as well as data structures and constant definitions used internally by the control. @@ -104,7 +104,7 @@ Both of these files will only be generated once, after which developers can free If later we need to define a `v2` interface, the `make ctrl` command will similarly generate a `type ControllerV2 struct{}` structure definition and a `func NewV2() user.IUserV2` initialization method. ::: -## `controller` Route Implementation Code +## Controller Router Implementation Used for the implementation code files of specific `api` interfaces. By default, codes are generated in the form of one source file per `api` interface. Of course, it is also possible to control the aggregation of interfaces defined in `api` files into a corresponding single source file. For specific command introductions and configurations, please refer to the chapter [Interface Specification-gen ctrl](../../../docs/开发工具/代码生成-gen/接口规范-gen%20ctrl.md). @@ -136,7 +136,7 @@ func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.C ``` As we can see, this is just the implementation template for the create interface we defined. We just need to complete the specific business logic of this route function. -## Summary of Learning +## Learning Summary Example source code for this chapter: https://github.com/gogf/quick-demo/tree/main/internal/controller/user diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step5 - \345\256\214\346\210\220\346\216\245\345\217\243\351\200\273\350\276\221\345\256\236\347\216\260.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step5 - \345\256\214\346\210\220\346\216\245\345\217\243\351\200\273\350\276\221\345\256\236\347\216\260.md" index 8f303e92137..412daaad959 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step5 - \345\256\214\346\210\220\346\216\245\345\217\243\351\200\273\350\276\221\345\256\236\347\216\260.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step5 - \345\256\214\346\210\220\346\216\245\345\217\243\351\200\273\350\276\221\345\256\236\347\216\260.md" @@ -1,6 +1,6 @@ --- slug: '/quick/scaffold-api-implements' -title: 'Step5 - Complete API Logic Implementation' +title: 'Step5 - Implement API Logic' hide_title: true sidebar_position: 5 keywords: [GoFrame, CURD Logic, API Creation, Parameter Validation, Update API, Delete API, Retrieve API, Database Operations, Scaffold Tool, Business Logic Implementation] @@ -9,7 +9,7 @@ description: "Use GoFrame framework to complete API logic implementation. By usi As you can see, with the project scaffold tool, a lot of code unrelated to the project's business logic has already been pre-generated, so we only need to focus on the business logic implementation. Let's take a look at how to implement the specific `CURD` logic. -## Create API +## `Create` ### Implementation of Creation Logic ```go title="internal/controller/user/user_v1_create.go" @@ -63,7 +63,7 @@ developers only need to focus on the business logic implementation in this route :::info Of course, if there are some additional, customized business logic validations, they need to be implemented in the route function by yourself. ::: -## Delete API +## `Delete` ```go title="internal/controller/user/user_v1_delete.go" package user @@ -82,7 +82,7 @@ func (c *ControllerV1) Delete(ctx context.Context, req *v1.DeleteReq) (res *v1.D ``` The deletion logic is relatively straightforward. Here, we use a `WherePri` method, which takes the given parameter `req.Id` as the primary key for `Where` condition restriction. -## Update API +## `Update` ```go title="internal/controller/user/user_v1_update.go" package user @@ -106,7 +106,7 @@ func (c *ControllerV1) Update(ctx context.Context, req *v1.UpdateReq) (res *v1.U ``` The update interface is also straightforward. Besides the already introduced `WherePri` method, it also requires using the `Data` method to pass the data to be updated when updating the data. -## Retrieve API (Single) +## `GetOne` ```go title="internal/controller/user/user_v1_get_one.go" package user @@ -126,7 +126,7 @@ func (c *ControllerV1) GetOne(ctx context.Context, req *v1.GetOneReq) (res *v1.G ``` In the data retrieval interface, we use a `Scan` method, which can intelligently map the retrieved single data table record to a structure object. It should be noted that the `User` attribute object in `&res.User` is actually not initialized and its value is `nil`. If data is retrieved, the `Scan` method will initialize and assign it. If no data is retrieved, the `Scan` method will do nothing, and its value will remain `nil`. -## Retrieve API (List) +## `GetList` ```go title="internal/controller/user/user_v1_get_list.go" package user @@ -150,7 +150,7 @@ func (c *ControllerV1) GetList(ctx context.Context, req *v1.GetListReq) (res *v1 ``` When retrieving list data, we also use the `Scan` method, which is very powerful. Like retrieving single data's logic, it only initializes `&res.List` when data is retrieved. -## Study Summary +## Learning Summary Example source code for this chapter: https://github.com/gogf/quick-demo/tree/main/internal/controller/user diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step6 - \351\205\215\347\275\256\344\270\216\350\267\257\347\224\261.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step6 - \351\205\215\347\275\256\344\270\216\350\267\257\347\224\261.md" index 062a9616ae5..9b9a66553dd 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step6 - \351\205\215\347\275\256\344\270\216\350\267\257\347\224\261.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step6 - \351\205\215\347\275\256\344\270\216\350\267\257\347\224\261.md" @@ -1,15 +1,15 @@ --- slug: '/quick/scaffold-api-config-and-route' -title: 'Step6 - Configuration and Routing' +title: 'Step6 - Configuration' hide_title: true sidebar_position: 6 keywords: [GoFrame, GoFrame Framework, Database Driver, MySQL, Routing, Configuration, API, Server Configuration, Log Module, Business Module] description: "Introduce MySQL database driver, with steps for adding database configuration and route registration. Detailed explanation of configurations in the scaffold project template, including tool configuration and business configuration, and how to modify configuration files." --- -## Introduce Database Driver +## Import Database Driver -The `GoFrame` database component uses an interface-based design, separating interface and implementation to provide better abstraction and extensibility. Here, we use the `MySQL` database, so we need to introduce the specific `MySQL` driver implementation. We can add `_ "github.com/gogf/gf/contrib/drivers/mysql/v2"` in `main.go`. +The `GoFrame` database component uses an interface-based design, separating interface and implementation to provide better abstraction and extensibility. Here, we use the `MySQL` database, so we need to import the specific `MySQL` driver implementation. We can add `_ "github.com/gogf/gf/contrib/drivers/mysql/v2"` in `main.go`. Sample source code: https://github.com/gogf/quick-demo/blob/main/main.go @@ -42,11 +42,11 @@ cannot find database driver for specified database type "mysql", did you misspel In the scaffold project template `main.go`, the `import` statement contains `_ "demo/internal/packed"`, indicating the resource management of the `GoFrame` framework, which is an advanced feature. This feature allows any resource to be packaged into the binary file, so when publishing, only one binary file needs to be released. We do not use this feature here, so just understand it for now, and if you're interested, you can check out the relevant section in the development manual later. ::: -## Add Database Configuration +## Database Configuration There are mainly two configuration files in the scaffold project template. -### Tool Configuration `hack/config.yaml` +### CLI Tool Configuration `hack/config.yaml` Introduced in previous sections, this configuration file is mainly used for local development. When the `cli` scaffold tool executes, it will automatically read the configuration content in it. Sample source code: https://github.com/gogf/quick-demo/blob/main/hack/config.yaml diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step7 - \345\220\257\345\212\250\344\270\216\346\265\213\350\257\225.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step7 - \345\220\257\345\212\250\344\270\216\346\265\213\350\257\225.md" index 13f726b67bf..28e1c947c7b 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step7 - \345\220\257\345\212\250\344\270\216\346\265\213\350\257\225.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/Step7 - \345\220\257\345\212\250\344\270\216\346\265\213\350\257\225.md" @@ -1,6 +1,6 @@ --- slug: '/quick/scaffold-api-run-and-test' -title: 'Step7 - Start and Test' +title: 'Step7 - Run and Test' hide_title: true sidebar_position: 6 keywords: [GoFrame, start service, API documentation, API testing, RESTful API, CRUD, API validation, data query, data modification, data deletion] @@ -57,7 +57,7 @@ To simplify testing operations, we use the `curl` command for testing and submit The `$` symbol at the front of the execution commands below represents the terminal command line tool's prompt and is not a part of the command we enter. Different terminal command lines have different prompt symbols. ::: -### Create Interface +### `Create` A creation request needs to be submitted using the `POST` method. @@ -82,9 +82,8 @@ $ curl -X POST 'http://127.0.0.1:8000/user' -d '{"name":"sm","age":18}' As we can see, the validation rules have taken effect and returned specific validation error messages. The error code `51` is a built-in error code in the framework, indicating a validation error. Developers can also customize error codes. For more information on error codes, please refer to the relevant sections of the developer's manual. -### Query Interface -#### Query a single piece of data +### `GetOne` ```bash $ curl -X GET 'http://127.0.0.1:8000/user/1' {"code":0,"message":"","data":{"id":1,"name":"john","status":0,"age":20}} @@ -93,7 +92,7 @@ $ curl -X GET 'http://127.0.0.1:8000/user/2' {"code":0,"message":"","data":{"id":2,"name":"alice","status":0,"age":18}} ``` -#### Query data list +### `GetList` ```bash $ curl -X GET 'http://127.0.0.1:8000/user' @@ -103,7 +102,7 @@ $ curl -X GET 'http://127.0.0.1:8000/user?age=18' {"code":0,"message":"","data":{"list":[{"id":2,"name":"alice","status":0,"age":18}]}} ``` -### Update Interface +### `Update` An update request needs to be submitted using the `PUT` method. @@ -119,7 +118,7 @@ $ curl -X GET 'http://127.0.0.1:8000/user/1' {"code":0,"message":"","data":{"id":1,"name":"john","status":0,"age":26}} ``` -### Delete Interface +### `Delete` A deletion request needs to be submitted using the `DELETE` method. diff --git "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/\346\216\245\345\217\243\345\274\200\345\217\221.md" "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/\346\216\245\345\217\243\345\274\200\345\217\221.md" index 1cb55d4a383..844874e3341 100644 --- "a/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/\346\216\245\345\217\243\345\274\200\345\217\221.md" +++ "b/i18n/en/docusaurus-plugin-content-docs/current/quick/\351\241\271\347\233\256\350\204\232\346\211\213\346\236\266/\346\216\245\345\217\243\345\274\200\345\217\221/\346\216\245\345\217\243\345\274\200\345\217\221.md" @@ -1,6 +1,6 @@ --- slug: '/quick/scaffold-api' -title: 'API Development🌟' +title: 'API Development Tutorial🌟' hide_title: true sidebar_position: 1 keywords: [API Development, Golang, CURD Interface, GoFrame, GoFrame Framework, API Development, Scaffolding Tool, Quick Demo, Source Code Example, Go Development]