Skip to content

Commit

Permalink
Merge pull request #52 from rogerogers/feat/gomall
Browse files Browse the repository at this point in the history
feat: add gomall
  • Loading branch information
GuangmingLuo authored Jan 11, 2024
2 parents bbcebdf + 282b649 commit a0d0dad
Show file tree
Hide file tree
Showing 4,131 changed files with 327,543 additions and 10 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
4 changes: 2 additions & 2 deletions .github/workflows/pr-check.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: Pull Request Check

on: [ pull_request ]
on: [pull_request]

jobs:
compliant:
runs-on: [ self-hosted, X64 ]
runs-on: [self-hosted, X64]
steps:
- uses: actions/checkout@v3

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Tests

on: [ push, pull_request ]
on: [push, pull_request]

jobs:
ut:
Expand All @@ -10,9 +10,9 @@ jobs:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v3
uses: actions/setup-go@v4
with:
go-version: 1.18
go-version: 1.21

- uses: actions/cache@v3
with:
Expand Down
10 changes: 7 additions & 3 deletions .licenserc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ header:
copyright-owner: CloudWeGo Authors

paths:
- '**/*.go'
- '**/*.s'
- "**/*.go"
- "**/*.s"

paths-ignore:
- bookinfo/kitex_gen/**
Expand All @@ -19,5 +19,9 @@ header:
- easy_note/cmd/api/router_gen.go
- book-shop/kitex_gen/**
- book-shop/docs/**
- gomall/app/frontend/hertz_gen/**
- gomall/rpc_gen/**
- gomall/tutorial/**

comment: on-failure

comment: on-failure
10 changes: 9 additions & 1 deletion _typos.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
# Typo check: https://github.com/crate-ci/typos

[files]
extend-exclude = ["go.mod", "go.sum", "hack/*", "check_branch_name.sh", "*/licenses/*"]
extend-exclude = [
"go.mod",
"go.sum",
"hack/*",
"check_branch_name.sh",
"*/licenses/*",
"bootstrap.*.js",
"go.work.sum"
]

[default.extend-identifiers]
7 changes: 7 additions & 0 deletions gomall/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
app/cart/.env
app/**/nohup.out
.idea/
app/**/log/
app/**/tmp/
app/**/kitex_gen/
99 changes: 99 additions & 0 deletions gomall/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
.PHONY: all
all: help

default: help

.PHONY: help
help: ## Display this help.
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Initialize Project
.PHONY: init
init: ## Just copy `.env.example` to `.env` with one click, executed once.
@scripts/copy_env.sh

##@ Build

.PHONY: gen
gen: ## gen client code of {svc}. example: make gen svc=product
@scripts/gen.sh ${svc}

.PHONY: gen-client
gen-client: ## gen client code of {svc}. example: make gen svc=product
@cd rpc_gen && cwgo client --type RPC --service ${svc} --module github.com/cloudwego/biz-demo/gomall/rpc_gen -I ../idl --idl ../idl/${svc}.proto

.PHONY: gen-server
gen-server: ## gen service code of {svc}. example: make gen-server svc=product
@cd app/${svc} && cwgo server --type RPC --service ${svc} --module github.com/cloudwego/biz-demo/gomall/app/${svc} --pass "-use github.com/cloudwego/biz-demo/gomall/rpc_gen/kitex_gen" -I ../../idl --idl ../../idl/${svc}.proto

.PHONY: gen-checkout-client
gen-checkout-client:
@cd app/frontend && cwgo client -I ../../idl --type RPC --service checkout --module github.com/cloudwego/biz-demo/gomall/app/frontend --idl ../../idl/checkout.proto

.PHONY: gen-order-client
gen-order-client:
@cd app/frontend && cwgo client -I ../../idl --type RPC --service order --module github.com/cloudwego/biz-demo/gomall/app/frontend --idl ../../idl/order.proto

.PHONY: gen-frontend
gen-frontend:
@cd app/frontend && cwgo server -I ../../idl --type HTTP --service frontend --module github.com/cloudwego/biz-demo/gomall/app/frontend --idl ../../idl/frontend/checkout_page.proto

##@ Build

.PHONY: watch-frontend
watch-frontend:
@cd app/frontend && air

.PHONY: tidy
tidy: ## run `go mod tidy` for all go module
@scripts/tidy.sh

.PHONY: lint
lint: ## run `gofmt` for all go module
@gofmt -l -w app
@gofumpt -l -w app

.PHONY: vet
vet: ## run `go vet` for all go module
@scripts/vet.sh

.PHONY: lint-fix
lint-fix: ## run `golangci-lint` for all go module
@scripts/fix.sh

.PHONY: run
run: ## run {svc} server. example: make run svc=product
@scripts/run.sh ${svc}

##@ Development Env

.PHONY: env-start
env-start: ## launch all middleware software as the docker
@docker-compose up -d

.PHONY: env-stop
env-stop: ## stop all docker
@docker-compose down

.PHONY: clean
clean: ## clern up all the tmp files
@rm -r app/**/log/ app/**/tmp/

##@ Open Browser

.PHONY: open.gomall
open-gomall: ## open `gomall` website in the default browser
@open "http://localhost:8080/"

.PHONY: open.consul
open-consul: ## open `consul ui` in the default browser
@open "http://localhost:8500/ui/"

.PHONY: open.jaeger
open-jaeger: ## open `jaeger ui` in the default browser
@open "http://localhost:16686/search"

.PHONY: open.prometheus
open-prometheus: ## open `prometheus ui` in the default browser
@open "http://localhost:9090"

88 changes: 88 additions & 0 deletions gomall/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Gomall
[中文](README_cn.md)

This is a teaching project for newbie using CloudWeGo

## Technology Stack
| technology | introduce |
|---------------|----|
| cwgo | - |
| kitex | - |
| [bootstrap](https://getbootstrap.com/docs/5.3/getting-started/introduction/) | Bootstrap is a powerful, feature-packed frontend toolkit. Build anything—from prototype to production—in minutes. |
| Hertz | - |
| MySQL | - |
| Redis | - |
| ES | - |
| Prometheus | - |
| Jaeger | - |
| Docker | - |


## Biz Logic
- [x] The pages check auth
- [x] Register
- [x] Login
- [x] Logout
- [x] Product categories
- [x] Products
- [x] Add to cart
- [x] The number badge of cart products
- [x] Checkout
- [x] Payment
- [x] Orders center

## How to use
### Prepare
List required
- Go
- IDE / Code Editor
- Docker
- [cwgo](https://github.com/cloudwego/cwgo)
- kitex `go install github.com/cloudwego/kitex/tool/cmd/kitex@latest`
- [Air](https://github.com/cosmtrek/air)
- ...

### Clone code
```
git clone ...
```

### Copy `.env` file
```
make init
```
*Note:*`You must generate and input SESSION_SECRET random value for session`

### Download go module
```
make tidy
```

### Start Docker Compose
```
make env-start
```
if you want to stop their docker application,you can run `make env-stop`.

### Run Service
This cmd must appoint a service.

*Note:* `Run the Go server using air. So it must be installed`
```
make run svc=`svcName`
```
### View Gomall Website
```
make open-gomall
```
### Check Registry
```
make open-consul
```
### Make Usage
```
make
```
## Contributors
- [rogerogers](https://github.com/rogerogers)
- [baiyutang](https://github.com/baiyutang)
86 changes: 86 additions & 0 deletions gomall/README_cn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Gomall
[EN](README.md)

新人学习 CloudWeGo 的教学项目

## 技术栈
| 技术 | 介绍 |
|---------------|----|
| cwgo | - |
| kitex | - |
| [bootstrap](https://getbootstrap.com/docs/5.3/getting-started/introduction/) | Bootstrap is a powerful, feature-packed frontend toolkit. Build anything—from prototype to production—in minutes. |
| Hertz | - |
| MySQL | - |
| Redis | - |
| ES | - |
| Prometheus | - |
| Jaeger | - |
| Docker | - |

## 业务逻辑
- [x] 页面访问认证检查
- [x] 注册
- [x] 登录
- [x] 退出
- [x] 产品分类
- [x] 产品
- [x] 加购
- [x] 购物车数量角标
- [x] 下单
- [x] 支付
- [x] 订单中心

## 如何使用
### 准备
必备清单
- Go
- IDE / Code Editor
- Docker
- [cwgo](https://github.com/cloudwego/cwgo)
- kitex `go install github.com/cloudwego/kitex/tool/cmd/kitex@latest`
- [Air](https://github.com/cosmtrek/air)
- ...

### 克隆项目
```
git clone ...
```

### 拷贝 `.env` 文件
```
make init
```
*Note:*`必须生成并输入 SESSION_SECRET 值供 session 功能正常使用`
### 下载 Go 依赖
```
make tidy
```

### 启动容器
```
make env-start
```
if you want to stop their docker application,you can run `make env-stop`.

### 启动某服务
该命令必须执行一个服务

*注意:* `我们使用 air 运行并热加载,必须先安装好`
```
make run svc=`svcName`
```
### 浏览 Gomall 站点
```
make open-gomall
```
### 查看注册中心
```
make open-consul
```
### Make 用法
```
make
```
## 贡献者
- [rogerogers](https://github.com/rogerogers)
- [baiyutang](https://github.com/baiyutang)
7 changes: 7 additions & 0 deletions gomall/app/cart/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_HOST=127.0.0.1
OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=http://127.0.0.1:4317
OTEL_EXPORTER_OTLP_INSECURE=true
REGISTRY_ENABLE=true
REGISTRY_ADDR=127.0.0.1:8500
Loading

0 comments on commit a0d0dad

Please sign in to comment.