refactor: 对齐后端样例工程规范
This commit is contained in:
31
backend/api/cmd/cli/main.go
Normal file
31
backend/api/cmd/cli/main.go
Normal file
@@ -0,0 +1,31 @@
|
||||
// 平台 API 的数据库迁移与版本命令行工具。
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/config"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/impl"
|
||||
_ "git.apinb.com/heqiapp/platforms/backend/api/internal/models"
|
||||
)
|
||||
|
||||
const serviceKey = "Platform"
|
||||
|
||||
func main() {
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Println("usage: platform-cli <version|migrate>")
|
||||
return
|
||||
}
|
||||
switch os.Args[1] {
|
||||
case "version":
|
||||
fmt.Println("platform-cli 0.1.0")
|
||||
case "migrate":
|
||||
config.New(serviceKey)
|
||||
impl.NewImpl()
|
||||
fmt.Println("platform database auto migrate completed")
|
||||
default:
|
||||
fmt.Fprintf(os.Stderr, "unknown command: %s\n", os.Args[1])
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user