Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

Time:2021-1-18

1. Type selection
1.1 web framework:iris. Reasonable structure, many examples, rich documents.
1.2 orm:gorm. Model struct is generated by xorm.
At present, there are more optimistic https://github.com/facebook/ent It’s not perfect yet.

2. Design specific code structure
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

3. Code layering
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm
Follow the cqrs principle, repo is responsible for query, and CMD is moved to the lower level models.

4. Implement the interface of commodity details
4.1 api/main.go
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

4.2 api/routes/routes.go
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

4.3 api/controllers/product/view.go
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

4.4 v2/service/product.go
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

4.5 v2/repo/product.go
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

4.6 v2/models/product.go
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm

5. Operation effect
Golang migration of Opencart high traffic interface of e-commerce website: using iris + Gorm