Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
gqcn committed Nov 24, 2024
1 parent 449d858 commit 5d1a8ee
Show file tree
Hide file tree
Showing 14 changed files with 73 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
- `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)
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
---
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]
description: "Design and apply MySQL data tables. We define the structure of data tables for user information and practice operations by running MySQL with Docker, including creating table structures and applying SQL statements, helping you quickly master database operation skills."
---


## 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:

Expand All @@ -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:

Expand Down Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
@@ -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:

Expand Down Expand Up @@ -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.

Expand Down
Original file line number Diff line number Diff line change
@@ -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]
Expand All @@ -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"`
Expand All @@ -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 {
Expand All @@ -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.
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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`).

Expand All @@ -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.

Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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).

Expand Down Expand Up @@ -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

Expand Down
Loading

0 comments on commit 5d1a8ee

Please sign in to comment.