feat(bookmark): 初始化书签服务并配置路由与权限控制
新增书签服务主程序,使用 Gin 框架搭建 HTTP 服务器,并注册书签相关接口处理器。 配置 CORS 中间件以支持跨域请求。服务监听端口为 8081。 feat(user_np): 初始化用户权限服务并注册认证接口 新增用户权限服务主程序,使用 Gin 框架搭建 HTTP 服务器,并注册登录、注册及修改密码等接口处理器。 服务监听端口为 8082。 refactor(config): 重构 OpenAPI 配置文件结构并拆分模块 将原有合并的 OpenAPI 配置文件按功能模块拆分为 bookmark 和 user_np 两个独立目录, 分别管理各自的 server、client 及 API 定义文件,便于后续维护和扩展。 refactor(vfs): 调整虚拟文件系统 API 接口路径与参数定义 更新 VFS API 配置文件,修改部分接口路径及参数结构, 如将文件路径参数由 path 转为 query 参数,并优化响应结构体定义。
This commit is contained in:
86
magefile.go
86
magefile.go
@ -7,76 +7,64 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/magefile/mage/mg" // mg contains helpful utility functions, like Deps
|
||||
// mg contains helpful utility functions, like Deps
|
||||
)
|
||||
|
||||
// Default target to run when none is specified
|
||||
// If not set, running mage will list available targets
|
||||
// var Default = Build
|
||||
|
||||
// A build step that requires additional params, or platform specific steps for example
|
||||
// Build builds the application for multiple platforms.
|
||||
func Build() error {
|
||||
mg.Deps(InstallDeps)
|
||||
func BuildAll() error {
|
||||
services := []struct {
|
||||
Name string
|
||||
Path string
|
||||
}{
|
||||
{"openapi", "."},
|
||||
{"bookmark", "./cmd/bookmark"},
|
||||
{"user_np", "./cmd/user_np"},
|
||||
}
|
||||
|
||||
// Define target platforms
|
||||
platforms := []struct {
|
||||
OS string
|
||||
Arch string
|
||||
}{
|
||||
{"linux", "amd64"},
|
||||
{"linux", "arm64"},
|
||||
{"darwin", "amd64"},
|
||||
{"darwin", "arm64"},
|
||||
{"windows", "amd64"},
|
||||
}
|
||||
|
||||
for _, p := range platforms {
|
||||
fmt.Printf("Building for %s/%s...\n", p.OS, p.Arch)
|
||||
for _, service := range services {
|
||||
for _, p := range platforms {
|
||||
fmt.Printf("Building service %s for %s/%s...\n", service.Name, p.OS, p.Arch)
|
||||
|
||||
// Set environment variables for cross-compilation
|
||||
env := append(os.Environ(),
|
||||
fmt.Sprintf("GOOS=%s", p.OS),
|
||||
fmt.Sprintf("GOARCH=%s", p.Arch))
|
||||
// 设置环境变量
|
||||
env := append(os.Environ(),
|
||||
fmt.Sprintf("GOOS=%s", p.OS),
|
||||
fmt.Sprintf("GOARCH=%s", p.Arch))
|
||||
|
||||
// Determine output name
|
||||
outputName := fmt.Sprintf("./bin/zzyxyz_go_api-%s-%s", p.OS, p.Arch)
|
||||
if p.OS == "windows" {
|
||||
outputName += ".exe"
|
||||
}
|
||||
// 确定输出名称
|
||||
outputName := fmt.Sprintf("./bin/%s/%s-%s-%s", p.OS, service.Name, p.OS, p.Arch)
|
||||
if p.OS == "windows" {
|
||||
outputName += ".exe"
|
||||
}
|
||||
|
||||
// Run build command
|
||||
cmd := exec.Command("go", "build", "-o", outputName, ".")
|
||||
cmd.Env = env
|
||||
// // 执行构建命令
|
||||
// cmd := exec.Command("go", "build", "-o", outputName, service.Path)
|
||||
// cmd.Env = env
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return err
|
||||
// 使用 release 模式构建并显示链接信息
|
||||
cmd := exec.Command("go", "build",
|
||||
"-x",
|
||||
"-ldflags", "-s -w -extldflags -static", // 去除调试信息,减小体积
|
||||
"-v", // 显示编译过程中的包信息
|
||||
"-o", outputName,
|
||||
service.Path)
|
||||
cmd.Env = env
|
||||
|
||||
if err := cmd.Run(); err != nil {
|
||||
return fmt.Errorf("failed to build %s: %w", service.Name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// A custom install step if you need your bin someplace other than go/bin
|
||||
func Install() error {
|
||||
mg.Deps(Build)
|
||||
// fmt.Println("Installing...")
|
||||
// return os.Rename("./MyApp", "/usr/bin/MyApp")
|
||||
return nil
|
||||
}
|
||||
|
||||
// Manage your deps, or running package managers.
|
||||
func InstallDeps() error {
|
||||
fmt.Println("Installing Deps...")
|
||||
// TODO downloads swagger-ui-5.29.0 /dist/*
|
||||
// cmd := exec.Command("go", "get", "github.com/stretchr/piglatin")
|
||||
// return cmd.Run()
|
||||
return nil
|
||||
}
|
||||
|
||||
// Clean up after yourself
|
||||
func Clean() {
|
||||
fmt.Println("Cleaning...")
|
||||
// os.RemoveAll("MyApp")
|
||||
}
|
||||
|
Reference in New Issue
Block a user