refactor: move backend files to backend/ directory

Reorganize project structure:
- backend/cmd/openteam/ — entry point
- backend/internal/ — core packages
- backend/middleware/ — HTTP middleware
- backend/router/ — route setup
- backend/wire/ — dependency injection
- backend/pkg/ — shared utilities
- backend/go.mod, go.sum — Go module files

Updated Makefile to work from backend/ directory.
Removed old lowercase makefile.
This commit is contained in:
Sakurasan committed 2026-08-30 12:02:52 +08:00
1 parent ef3025dd80
commit 902ecaeacc
64 files changed
+12 -107

No files matched your search

+12 -11
View File
@@ -2,10 +2,11 @@
BINARY_NAME=openteam
BUILD_DIR=bin
BACKEND_DIR=backend
# Build
build:
go build -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/openteam
cd $(BACKEND_DIR) && CGO_ENABLED=1 go build -o ../$(BUILD_DIR)/$(BINARY_NAME) ./cmd/openteam
# Run
run: build
@@ -13,41 +14,41 @@ run: build
# Development run
dev:
go run ./cmd/openteam
cd $(BACKEND_DIR) && go run ./cmd/openteam
# Test
test:
go test ./internal/... -v
cd $(BACKEND_DIR) && go test ./internal/... -v
# Test with coverage
test-cover:
go test ./internal/... -coverprofile=coverage.out
go tool cover -html=coverage.out -o coverage.html
cd $(BACKEND_DIR) && go test ./internal/... -coverprofile=coverage.out
cd $(BACKEND_DIR) && go tool cover -html=coverage.out -o coverage.html
# Format code
fmt:
go fmt ./...
cd $(BACKEND_DIR) && go fmt ./...
# Lint
lint:
golangci-lint run
cd $(BACKEND_DIR) && golangci-lint run
# Clean
clean:
rm -rf $(BUILD_DIR)
rm -f coverage.out coverage.html
cd $(BACKEND_DIR) && rm -f coverage.out coverage.html
# Tidy dependencies
tidy:
go mod tidy
cd $(BACKEND_DIR) && go mod tidy
# Build for Linux
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/openteam
cd $(BACKEND_DIR) && CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ../$(BUILD_DIR)/$(BINARY_NAME)-linux-amd64 ./cmd/openteam
# Build for macOS
build-mac:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o $(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/openteam
cd $(BACKEND_DIR) && CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ../$(BUILD_DIR)/$(BINARY_NAME)-darwin-arm64 ./cmd/openteam
# Build all platforms
build-all: build-linux build-mac
File renamed without changes.
View File
File renamed without changes.
View File
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-96
View File
@@ -1,96 +0,0 @@
GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
# 获取源码最近一次 git commit log,包含 commit sha 值,以及 commit message
GitCommitLog=$(shell git log)
# 检查源码在最近一次 git commit 基础上,是否有本地修改,且未提交的文件
GitStatus=$(shell git status -s)
# 获取当前时间
BuildTime=$(shell date +'%Y.%m.%d %H:%M:%S')
# 获取Go的版本
BuildGoVersion=$(shell go version)
LDFlags=" \
-X 'main.Version=$(VERSION)' \
-X 'main.GitCommitLog=$(GitCommitLog)' \
-X 'main.BuildTime=$(BuildTime)' \
-X 'main.BuildGoVersion=$(BuildGoVersion)'"
.PHONY: web
# 构建前端并放入 Go embed 目录 (cmd/openteam/dist)
web:
cd frontend && (command -v pnpm >/dev/null 2>&1 || npm install -g pnpm) && pnpm install --frozen-lockfile && pnpm build
rm -rf cmd/openteam/dist
mkdir -p cmd/openteam
mv frontend/dist cmd/openteam/dist
touch cmd/openteam/dist/.gitkeep
.PHONY: dev-backend
# 本地启动后端 (端口 8080, 数据库 ./db/openteam.db)
dev-backend:
PORT=8080 go run ./cmd/openteam
.PHONY: dev-frontend
# 本地启动前端 dev server (端口 5173, /api 代理到后端)
dev-frontend:
cd frontend && pnpm dev
.PHONY: dev
# 并行启动前后端本地开发环境 (Ctrl+C 一起退出)
dev:
$(MAKE) -j2 dev-backend dev-frontend
.PHONY: build
# build
build:
# mkdir -p bin/ && go build -ldflags $(LDFlags) -o ./bin/ ./...
rm -rf bin
mkdir -p bin/ && CGO_ENABLED=0 go build -ldflags "-s -w" -o ./bin/openteam ./cmd/openteam/
command -v upx >/dev/null 2>&1 && upx -9 bin/openteam || echo "upx 未安装,跳过二进制压缩"
.PHONY:image
# build docker images
image:
docker build -t mirrors2/opencatd-open:latest -f deploy/docker/Dockerfile . --push
.PHONY:docker
# build docker images
docker:
docker run --privileged --rm tonistiigi/binfmt --install all
# docker buildx create --use --name xbuilder --driver docker-container
docker buildx inspect xbuilder --bootstrap
docker buildx build --platform linux/amd64,linux/arm64 -t mirrors2/opencatd-open:latest -f deploy/docker/Dockerfile . --push
.PHONY:image-dev
# build & push multi-arch dev image (PUSH=0 仅本地加载本机架构)
image-dev:
sh deploy/docker/build-dev.sh
.PHONY: clean
# clean
clean:
rm -rf bin/
.PHONY: all
# generate all
all:
make build;
# show help
help:
@echo ''
@echo 'Usage:'
@echo ' make [target]'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)
.DEFAULT_GOAL := help