Skip to content

Commit

Permalink
refactor: empty classroom service of undergraduate student (#9)
Browse files Browse the repository at this point in the history
* refactor: classroom framework

* refactor: empty classroom service

* add: dockerfile

* fix: delete the header of id and cookies for classroom service

* feat: complete empty room service

* fix: normalize the framework

* fix: modify Dockerfile and docker-compose.yml

* fix: add judgement of /pkg/client and add config.example.yaml

* fix: modify CacheEmptyRooms

* fix: modify workqueue init

* refactor: refactor the classroom service

* add: utils.GetAvailablePort

* fix: refactor the logic of using logger

* fix: get_room_test.go

* fix: normalize

* fix: replace github.com/pkg/errors

* delete: remove the config of skywalking

* fix: fix according to golangci-lint

* fix: modify go version 1.23.0

* fix: modify go version 1.23

* fix: go.mod in version

* fix: modify golangci.yml

* fix: modify golangci.yml

* fix: modify golangci.yml
  • Loading branch information
SchwarzSail authored Oct 4, 2024
1 parent 431f65c commit caa22cf
Show file tree
Hide file tree
Showing 117 changed files with 9,763 additions and 3,809 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/golangci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ jobs:

- uses: actions/setup-go@v4
with:
go-version: '1.20'
go-version: '1.23'
cache: false

- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --timeout=10m
args: --timeout=10m
43 changes: 10 additions & 33 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# macOS rubbish
.DS_Store

# hertz
*.o
*.a
*.so
Expand Down Expand Up @@ -54,16 +34,13 @@ _testmain.go
/output
*.local.yml
dumped_hertz_remote_config.json

# Kitex output&client files
cmd/**/output
cmd/**/client
/output

# Hertz output binary
cmd/api/fzuhelper_api

# Hertz related
dumped_hertz_remote_config.json

/docker/data
/cmd/**/output
/config/elasticsearch
/config/redis
/config/grafana
/config/jaeger
/config/kibana
/config/prometheus
/config/sql
/docker/data/*
/config/config.yaml
3 changes: 1 addition & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ linters-settings:
require-specific: true

govet:
check-shadowing: true
shadow: true
check-unreachable: true
check-reangeloops: true
check-copylocks: true
enable-all: true
disable:
- fieldalignment
- lostcancel
- shadow
30 changes: 28 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CONFIG_PATH = $(DIR)/config
IDL_PATH = $(DIR)/idl
OUTPUT_PATH = $(DIR)/output

SERVICES := template empty_room
SERVICES := api user classroom
service = $(word 1, $@)

# mock gen
Expand Down Expand Up @@ -55,4 +55,30 @@ build-all:
# use docker instead to run projects
.PHONY: docker
docker:
docker build -t fzuhelper .
cd docker && docker build -t fzuhelper .

#允许传入特定服务进行构建,例如:make docker-build SERVICE=api
.PHONY: docker-build
docker-build:
@if [ -z "$(SERVICE)" ]; then \
for service in $(SERVICES); do \
echo "Building Docker image for $$service..."; \
docker build --build-arg SERVICE=$${service} -t $${service}_image -f docker/Dockerfile .; \
done \
else \
echo "Building Docker image for $(SERVICE)..."; \
docker build --build-arg SERVICE=$${SERVICE} -t $${SERVICE}_image -f docker/Dockerfile .; \
fi


#启动所有服务
.PHONY: deploy
deploy:
@ sh ./deploy/start-service-all.sh

#停止所有服务
.PHONY: stop
stop:
for service in $(SERVICES); do \
docker rm -f $${service}; \
done
6 changes: 6 additions & 0 deletions cmd/api/.hz
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Code generated by hz. DO NOT EDIT.

hz version: v0.9.1
handlerDir: ""
modelDir: ""
routerDir: ""
9 changes: 9 additions & 0 deletions cmd/api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@


update:
hz update -idl ../../idl/api.thrift



run:
sh build.sh && sh output/bootstrap.sh
42 changes: 42 additions & 0 deletions cmd/api/biz/handler/api/class_room_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions cmd/api/biz/handler/api/user_service.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions cmd/api/biz/handler/ping.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions cmd/api/biz/middleware/get_header.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package middleware

import (
"context"
"fmt"

"strings"

"github.com/cloudwego/hertz/pkg/app"
"github.com/west2-online/fzuhelper-server/cmd/api/biz/model/api"
"github.com/west2-online/fzuhelper-server/cmd/api/biz/pack"
"github.com/west2-online/fzuhelper-server/kitex_gen/model"
"github.com/west2-online/fzuhelper-server/pkg/errno"
)

// 获取请求头的信息

func GetHeaderParams() app.HandlerFunc {
return func(ctx context.Context, c *app.RequestContext) {
id := string(c.GetHeader("id"))
temp := string(c.GetHeader("cookies"))
if id == "" || len(temp) == 0 {
pack.RespError(c, errno.ParamMissingHeader)
c.Abort()
return
}
cookies := strings.Split(temp, ",")
// 将id和cookies放入context中
fmt.Println(id)
fmt.Println(cookies)
ctx = api.NewContext(ctx, &model.LoginData{
Id: id,
Cookies: cookies,
})
c.Next(ctx)
}
}
Loading

0 comments on commit caa22cf

Please sign in to comment.