Full project address: Go-shop-B2C

preface

Here will not explain too much basic knowledge, mainly introduced about the use of Beego framework from scratch a mall train of thought

The directory structure

├─ Common // Public Functions ├─ API │ ├─ Admin // API │ ├─ Web // Mobile Web app API ├─ The active part of the active part of the active part of the active part of the active part of the active part of the active part of the active part of the active part of the active part of the active part of the active part ├── Go shop-b2c // SQL file ├─ go-shop-bc.xml // XML ├─ Main.go // import Main.Go ├─ xxx.p12 // API CertificateCopy the code

Here’s a quick look at the directory code

controllers

Briefly take a snapshot of controller/admin’s controller

Json_controller.go and base_controller.go are introduced here

  • Json_controller. go inherits Beego. Controller and adds public functions such as return front-end JOSN data processing function and service report error handling, etc
  • Base_controller. go inherits json_controller.go, overloads the Prepare function, and verifies valid login information

Key code examples:

models

The Model layer generated by using Bee tool API commands provided by Beego mainly includes functions of adding, deleting, modifying and checking database

Screenshot An example of a fragment:

routers

Beego RESTful Controller routing

Key code examples:

setting

Shopping mall background management system system Settings are fast, stored in XML files, setting/setting.go is the encapsulation of go-shop-b2c

Corresponding mall management system set up the model fast, front-end display:

sysint

Beego performs various initialization operations, such as log printing, database connection, AND CORS configuration, before running

Key code examples: