diff --git a/Makefile b/Makefile index 1b3b2e0..9e1300b 100644 --- a/Makefile +++ b/Makefile @@ -6,4 +6,4 @@ # run: - @go run ./cli/*.go -f ./cfg/dev.yml -l debug + @go run ./cli/*.go -f ./cfg/dev.yml -l debug -p 4001 diff --git a/api/app/access/create.go b/api/app/access/create.go index cde807e..045f56c 100644 --- a/api/app/access/create.go +++ b/api/app/access/create.go @@ -8,8 +8,8 @@ package access import ( "github.com/veypi/OneBD/rest" - "oa/cfg" - "oa/models" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type createOpts struct { diff --git a/api/app/access/del.go b/api/app/access/del.go index 97346ed..d8d472b 100644 --- a/api/app/access/del.go +++ b/api/app/access/del.go @@ -8,8 +8,8 @@ package access import ( "github.com/veypi/OneBD/rest" - "oa/cfg" - "oa/models" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type deleteOpts struct { diff --git a/api/app/access/get.go b/api/app/access/get.go index a4752c0..a3a582e 100644 --- a/api/app/access/get.go +++ b/api/app/access/get.go @@ -8,8 +8,8 @@ package access import ( "github.com/veypi/OneBD/rest" - "oa/cfg" - "oa/models" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Get("/:id", getAccess) diff --git a/api/app/access/list.go b/api/app/access/list.go index 62dea35..25295ad 100644 --- a/api/app/access/list.go +++ b/api/app/access/list.go @@ -8,8 +8,8 @@ package access import ( "github.com/veypi/OneBD/rest" - "oa/cfg" - "oa/models" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type listOpts struct { diff --git a/api/app/access/patch.go b/api/app/access/patch.go index b31053e..907797a 100644 --- a/api/app/access/patch.go +++ b/api/app/access/patch.go @@ -7,9 +7,9 @@ package access import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/cfg" - "oa/models" ) type updateOpts struct { diff --git a/api/app/app.go b/api/app/app.go index 7b2fdb8..2d547e8 100644 --- a/api/app/app.go +++ b/api/app/app.go @@ -3,12 +3,12 @@ package app import ( "fmt" "math/rand" - "oa/cfg" - "oa/errs" - "oa/libs/auth" - "oa/models" "time" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/errs" + "github.com/veypi/OneAuth/libs/auth" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" "github.com/veypi/utils" "gorm.io/gorm" diff --git a/api/app/app_user/create.go b/api/app/app_user/create.go index 31e66b0..c146c05 100644 --- a/api/app/app_user/create.go +++ b/api/app/app_user/create.go @@ -2,8 +2,8 @@ package app_user import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type createOpts struct { diff --git a/api/app/app_user/del.go b/api/app/app_user/del.go index 70f33aa..e6e5696 100644 --- a/api/app/app_user/del.go +++ b/api/app/app_user/del.go @@ -1,9 +1,9 @@ package app_user import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" ) type deleteOpts struct { diff --git a/api/app/app_user/get.go b/api/app/app_user/get.go index 4dd6eef..ab2b215 100644 --- a/api/app/app_user/get.go +++ b/api/app/app_user/get.go @@ -1,9 +1,9 @@ package app_user import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" ) var _ = Router.Get("/:user_id", getAppUser) diff --git a/api/app/app_user/list.go b/api/app/app_user/list.go index 7156622..af8333a 100644 --- a/api/app/app_user/list.go +++ b/api/app/app_user/list.go @@ -2,8 +2,8 @@ package app_user import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type listOpts struct { diff --git a/api/app/app_user/patch.go b/api/app/app_user/patch.go index 6c3198f..bf2cad6 100644 --- a/api/app/app_user/patch.go +++ b/api/app/app_user/patch.go @@ -2,8 +2,8 @@ package app_user import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type updateOpts struct { diff --git a/api/app/init.go b/api/app/init.go index a76f8b1..0bca08f 100644 --- a/api/app/init.go +++ b/api/app/init.go @@ -8,11 +8,10 @@ package app import ( - "oa/api/app/access" - "oa/api/app/app_user" - "oa/api/app/resource" - "oa/api/user/role" - + "github.com/veypi/OneAuth/api/app/access" + "github.com/veypi/OneAuth/api/app/app_user" + "github.com/veypi/OneAuth/api/app/resource" + "github.com/veypi/OneAuth/api/app/role" "github.com/veypi/OneBD/rest" ) diff --git a/api/app/resource/create.go b/api/app/resource/create.go index c4c7a62..77dd772 100644 --- a/api/app/resource/create.go +++ b/api/app/resource/create.go @@ -2,8 +2,8 @@ package resource import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Post("/", createResource) diff --git a/api/app/resource/del.go b/api/app/resource/del.go index 5f15cfa..350a7fc 100644 --- a/api/app/resource/del.go +++ b/api/app/resource/del.go @@ -2,8 +2,8 @@ package resource import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Delete("/:resource_id", deleteResource) diff --git a/api/app/resource/get.go b/api/app/resource/get.go index 70991fa..ceef4e9 100644 --- a/api/app/resource/get.go +++ b/api/app/resource/get.go @@ -2,8 +2,8 @@ package resource import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Get("/:resource_id", getResource) diff --git a/api/app/resource/list.go b/api/app/resource/list.go index b5a29c1..7c346a5 100644 --- a/api/app/resource/list.go +++ b/api/app/resource/list.go @@ -2,8 +2,8 @@ package resource import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) type listOpts struct { diff --git a/api/app/resource/patch.go b/api/app/resource/patch.go index 8c03258..be05f82 100644 --- a/api/app/resource/patch.go +++ b/api/app/resource/patch.go @@ -2,8 +2,8 @@ package resource import ( "github.com/veypi/OneBD/rest" - "oa/cfg" - "oa/models" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Patch("/:resource_id", updateResource) diff --git a/api/app/role/create.go b/api/app/role/create.go index 89ff618..e170887 100644 --- a/api/app/role/create.go +++ b/api/app/role/create.go @@ -1,9 +1,9 @@ package role import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" ) var _ = Router.Post("/", createRole) diff --git a/api/app/role/del.go b/api/app/role/del.go index 01a2945..a44e242 100644 --- a/api/app/role/del.go +++ b/api/app/role/del.go @@ -2,8 +2,8 @@ package role import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Delete("/:role_id", deleteRole) diff --git a/api/app/role/get.go b/api/app/role/get.go index 6d62c0d..39f3338 100644 --- a/api/app/role/get.go +++ b/api/app/role/get.go @@ -2,8 +2,8 @@ package role import ( "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" ) var _ = Router.Get("/:role_id", getRole) diff --git a/api/app/role/list.go b/api/app/role/list.go index 3a7b067..1465d6a 100644 --- a/api/app/role/list.go +++ b/api/app/role/list.go @@ -1,23 +1,23 @@ package role import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" ) var _ = Router.Get("/", listRoles) type listOpts struct { - Page int `parse:"query" default:"1"` - PageSize int `parse:"query" default:"20"` - Keyword string `parse:"query" default:""` - SortBy string `parse:"query" default:"created_at"` - Order string `parse:"query" default:"desc"` + Page int `parse:"query" default:"1"` + PageSize int `parse:"query" default:"20"` + Keyword string `parse:"query" default:""` + SortBy string `parse:"query" default:"created_at"` + Order string `parse:"query" default:"desc"` } type listResponse struct { - Total int64 `json:"total"` + Total int64 `json:"total"` Items []*models.Role `json:"items"` } diff --git a/api/app/role/patch.go b/api/app/role/patch.go index bc731f7..941ad6f 100644 --- a/api/app/role/patch.go +++ b/api/app/role/patch.go @@ -1,17 +1,17 @@ package role import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/models" - "oa/cfg" ) var _ = Router.Patch("/:role_id", updateRole) type updateOpts struct { - RoleID string `parse:"path"` // 角色 ID - Name *string `json:"name"` // 可选,角色名称 - Des *string `json:"des"` // 可选,角色描述 + RoleID string `parse:"path"` // 角色 ID + Name *string `json:"name"` // 可选,角色名称 + Des *string `json:"des"` // 可选,角色描述 } func updateRole(x *rest.X) (any, error) { diff --git a/api/init.go b/api/init.go index efbea07..945cce9 100644 --- a/api/init.go +++ b/api/init.go @@ -9,10 +9,10 @@ package api import ( "fmt" - "oa/api/app" - "oa/api/token" - "oa/api/user" + "github.com/veypi/OneAuth/api/app" + "github.com/veypi/OneAuth/api/token" + "github.com/veypi/OneAuth/api/user" "github.com/veypi/OneBD/rest" "github.com/veypi/OneBD/rest/middlewares" ) @@ -20,7 +20,7 @@ import ( var Router = rest.NewRouter().UseAfter(middlewares.JsonResponse, middlewares.JsonErrorResponse) var ( - _ = Router.Extend("user", user.Router) + _ = Router.Extend("user", user.Router,) _ = Router.Extend("token", token.Router) _ = Router.Extend("app", app.Router) ) diff --git a/api/token/base.go b/api/token/base.go index 60b9be7..607c03c 100644 --- a/api/token/base.go +++ b/api/token/base.go @@ -1,10 +1,10 @@ package token import ( - "oa/cfg" - "oa/models" "time" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" ) diff --git a/api/token/create.go b/api/token/create.go index 19aa35b..f32b717 100644 --- a/api/token/create.go +++ b/api/token/create.go @@ -9,12 +9,12 @@ package token import ( "net/http" - "oa/cfg" - "oa/libs/auth" - "oa/models" "time" "github.com/golang-jwt/jwt/v5" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/libs/auth" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" "github.com/veypi/utils/logv" ) diff --git a/api/token/get.go b/api/token/get.go index 548c969..dc1ce27 100644 --- a/api/token/get.go +++ b/api/token/get.go @@ -8,9 +8,8 @@ package token import ( - "oa/cfg" - "oa/models" - + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" ) diff --git a/api/user/create.go b/api/user/create.go index 066158e..7ad5588 100644 --- a/api/user/create.go +++ b/api/user/create.go @@ -10,14 +10,14 @@ package user import ( "encoding/base64" "fmt" - "oa/cfg" - M "oa/models" "strings" "time" "math/rand" "github.com/google/uuid" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" "github.com/veypi/utils" "gorm.io/gorm" @@ -40,7 +40,7 @@ func userPost(x *rest.X) (any, error) { if err != nil { return nil, err } - data := &M.User{} + data := &models.User{} data.ID = strings.ReplaceAll(uuid.New().String(), "-", "") data.Username = opts.Username @@ -82,7 +82,7 @@ func userPost(x *rest.X) (any, error) { if err != nil { return err } - app := &M.App{} + app := &models.App{} err = tx.Where("id = ?", cfg.Config.ID).First(app).Error if err != nil { return err @@ -98,7 +98,7 @@ func userPost(x *rest.X) (any, error) { if app.Typ != "public" { } - return tx.Create(&M.AppUser{ + return tx.Create(&models.AppUser{ UserID: data.ID, AppID: cfg.Config.ID, Status: status, diff --git a/api/user/init.go b/api/user/init.go index b9ebb03..0ad5461 100644 --- a/api/user/init.go +++ b/api/user/init.go @@ -8,8 +8,7 @@ package user import ( - "oa/api/user/role" - + "github.com/veypi/OneAuth/api/user/role" "github.com/veypi/OneBD/rest" ) diff --git a/api/user/login.go b/api/user/login.go index b9f8fa3..261b296 100644 --- a/api/user/login.go +++ b/api/user/login.go @@ -9,12 +9,12 @@ package user import ( "encoding/base64" - "oa/cfg" - "oa/libs/auth" - "oa/models" "time" "github.com/golang-jwt/jwt/v5" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/libs/auth" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" "github.com/veypi/utils" "github.com/veypi/utils/logv" diff --git a/api/user/role/create.go b/api/user/role/create.go index 29ac9c3..7a75e3f 100644 --- a/api/user/role/create.go +++ b/api/user/role/create.go @@ -8,9 +8,9 @@ package role import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/cfg" - M "oa/models" ) var _ = Router.Post("/", userRolePost) @@ -28,7 +28,7 @@ func userRolePost(x *rest.X) (any, error) { if err != nil { return nil, err } - data := &M.UserRole{} + data := &models.UserRole{} data.UserID = opts.UserID data.RoleID = opts.RoleID diff --git a/api/user/role/del.go b/api/user/role/del.go index a4c395b..bd0f847 100644 --- a/api/user/role/del.go +++ b/api/user/role/del.go @@ -8,9 +8,8 @@ package role import ( - "oa/cfg" - "oa/models" - + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" ) diff --git a/api/user/role/get.go b/api/user/role/get.go index ae5029b..e926a97 100644 --- a/api/user/role/get.go +++ b/api/user/role/get.go @@ -8,8 +8,8 @@ package role import ( - "oa/cfg" - M "oa/models" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" ) @@ -19,7 +19,7 @@ var _ = Router.Get("/:id", ` `, userRoleGet) func userRoleGet(x *rest.X) (any, error) { - data := &M.UserRole{} + data := &models.UserRole{} err := cfg.DB().Where("id = ?", x.Params.Get("id")).First(data).Error return data, err } @@ -42,7 +42,7 @@ func userRoleList(x *rest.X) (any, error) { return nil, err } data := make([]*struct { - M.UserRole + models.UserRole Username string `json:"username"` Nickname string `json:"nickname"` Icon string `json:"icon"` diff --git a/api/user/role/patch.go b/api/user/role/patch.go index f1f6ac9..8004c2a 100644 --- a/api/user/role/patch.go +++ b/api/user/role/patch.go @@ -8,9 +8,9 @@ package role import ( + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" - "oa/cfg" - M "oa/models" ) type patchOpts struct { @@ -26,8 +26,7 @@ func userRolePatch(x *rest.X) (any, error) { if err != nil { return nil, err } - data := &M.UserRole{} - + data := &models.UserRole{} err = cfg.DB().Where("id = ?", opts.ID).First(data).Error if err != nil { return nil, err diff --git a/api/user/user.go b/api/user/user.go index 2d33921..f426933 100644 --- a/api/user/user.go +++ b/api/user/user.go @@ -1,17 +1,16 @@ package user import ( - "oa/cfg" - "oa/libs/auth" - M "oa/models" - + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/libs/auth" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" ) var _ = Router.Delete("/:user_id", auth.Check("user", "user_id", auth.DoDelete), userDelete) func userDelete(x *rest.X) (any, error) { - data := &M.User{} + data := &models.User{} err := cfg.DB().Where("id = ?", x.Params.Get("user_id")).Delete(data).Error return data, err } @@ -28,14 +27,14 @@ func userGet(x *rest.X) (any, error) { if err != nil { return nil, err } - data := &M.User{} + data := &models.User{} err = cfg.DB().Where("id = ?", opts.ID).First(data).Error return data, err } -var _ = Router.Get("/", auth.Check("user", "", auth.DoRead), userList) +var _ = Router.Get("/", "list user", listOpts{}, auth.Check("user", "", auth.DoRead), userList) type listOpts struct { Username *string `json:"username" parse:"query"` @@ -51,7 +50,7 @@ func userList(x *rest.X) (any, error) { if err != nil { return nil, err } - data := make([]*M.User, 0, 10) + data := make([]*models.User, 0, 10) query := cfg.DB() if opts.Username != nil { @@ -92,7 +91,7 @@ func userPatch(x *rest.X) (any, error) { if err != nil { return nil, err } - data := &M.User{} + data := &models.User{} err = cfg.DB().Where("id = ?", opts.ID).First(data).Error if err != nil { diff --git a/cfg/cfg.go b/cfg/cfg.go index ad0a1e9..bcb24a1 100644 --- a/cfg/cfg.go +++ b/cfg/cfg.go @@ -7,15 +7,11 @@ package cfg -type config struct { - Host string `json:"host"` - Port int `json:"port"` - LoggerPath string `json:"logger_path,omitempty"` - LoggerLevel string `json:"logger_level,omitempty"` - DSN string `json:"dsn"` - DB string `json:"db"` - ID string `json:"id"` - Key string `json:"key"` +type Options struct { + DSN string `json:"dsn"` // Data Source Name + DB string `json:"db"` // DB type: mysql, postgres, sqlite + ID string `json:"id"` + Key string `json:"key"` } -var Config = &config{} +var Config = &Options{} diff --git a/cli/main.go b/cli/main.go index c7bc499..3126ef3 100644 --- a/cli/main.go +++ b/cli/main.go @@ -8,57 +8,65 @@ package main import ( - app "oa" - "oa/cfg" - "oa/models" - + "github.com/veypi/OneAuth" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/models" "github.com/veypi/OneBD/rest" "github.com/veypi/utils/flags" "github.com/veypi/utils/logv" ) -var CMD = flags.New("app", "the backend server of app") -var cmdCfg = CMD.SubCommand("cfg", "generate cfg file") -var cmdDB = CMD.SubCommand("db", "database operations") +var cmdMain = flags.New("app", "the backend server of app") +var cmdCfg = cmdMain.SubCommand("cfg", "generate cfg file") +var cmdDB = cmdMain.SubCommand("db", "database operations") + +var configFile = cmdMain.String("f", "./dev.yaml", "the config file") -var configFile = CMD.String("f", "./dev.yaml", "the config file") +var cliOpts = &struct { + Host string `json:"host"` + Port int `json:"port"` + LoggerPath string `json:"logger_path,omitempty"` + LoggerLevel string `json:"logger_level,omitempty"` + Core *cfg.Options +}{ + Core: cfg.Config, +} func init() { - CMD.StringVar(&cfg.Config.Host, "host", "0.0.0.0", "host") - CMD.IntVar(&cfg.Config.Port, "p", 4000, "port") - CMD.StringVar(&cfg.Config.LoggerLevel, "l", "info", "log level") - CMD.StringVar(&cfg.Config.DSN, "dsn", "root:123456@tcp(127.0.0.1:3306)/test?charset=utf8&parseTime=True&loc=Local", "data source name") - CMD.StringVar(&cfg.Config.DB, "db", "mysql", "data source type: mysql/postgre/sqlite") - CMD.Before = func() error { + cmdMain.StringVar(&cliOpts.Host, "host", "0.0.0.0", "host") + cmdMain.IntVar(&cliOpts.Port, "p", 4000, "port") + cmdMain.StringVar(&cliOpts.LoggerLevel, "l", "info", "log level") + + cmdMain.Before = func() error { flags.LoadCfg(*configFile, cfg.Config) - CMD.Parse() - logv.SetLevel(logv.AssertFuncErr(logv.ParseLevel(cfg.Config.LoggerLevel))) + cmdMain.Parse() + logv.SetLevel(logv.AssertFuncErr(logv.ParseLevel(cliOpts.LoggerLevel))) return nil } - CMD.Command = runWeb + cmdMain.Command = runWeb cmdCfg.Command = func() error { - flags.DumpCfg(*configFile, cfg.Config) - return nil + return flags.DumpCfg(*configFile, cfg.Config) } cmdDB.SubCommand("migrate", "migrate database").Command = models.Migrate cmdDB.SubCommand("drop", "drop database").Command = models.Drop - cmdDB.SubCommand("init", "init db data").Command = models.Init + cmdDB.SubCommand("init", "init db data").Command = models.InitDB } func main() { - CMD.Parse() - err := CMD.Run() + cmdMain.Parse() + err := cmdMain.Run() if err != nil { logv.Warn().Msg(err.Error()) } } func runWeb() error { - server, err := rest.New(rest.WithHost(cfg.Config.Host), rest.WithPort(cfg.Config.Port)) + server, err := rest.New(rest.WithHost(cliOpts.Host), rest.WithPort(cliOpts.Port)) if err != nil { return err } - server.SetRouter(app.Router) + server.SetRouter(OneAuth.Router) + server.EnableAI() server.Router().Print() return server.Run() } diff --git a/go.mod b/go.mod index 74b5ea6..b369016 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module oa +module github.com/veypi/OneAuth go 1.23.2 diff --git a/init.go b/init.go index 71d4703..92aef44 100644 --- a/init.go +++ b/init.go @@ -4,12 +4,11 @@ // Distributed under terms of the MIT license. // -package oa +package OneAuth import ( "embed" - "oa/api" - + "github.com/veypi/OneAuth/api" "github.com/veypi/OneBD/rest" "github.com/veypi/OneBD/rest/middlewares/vyes" "github.com/veypi/vyes-ui" diff --git a/libs/auth/jwt.go b/libs/auth/jwt.go index 6876f8e..64e2368 100644 --- a/libs/auth/jwt.go +++ b/libs/auth/jwt.go @@ -11,12 +11,12 @@ import ( "context" "errors" "fmt" - "oa/cfg" - "oa/errs" "strings" "time" "github.com/golang-jwt/jwt/v5" + "github.com/veypi/OneAuth/cfg" + "github.com/veypi/OneAuth/errs" "github.com/veypi/OneBD/rest" ) diff --git a/libs/webdav/xml.go b/libs/webdav/xml.go index b4923f7..b2922a2 100644 --- a/libs/webdav/xml.go +++ b/libs/webdav/xml.go @@ -32,7 +32,7 @@ import ( // In the long term, this package should use the standard library's version // only, and the internal fork deleted, once // https://github.com/golang/go/issues/13400 is resolved. - ixml "oa/libs/webdav/internal/xml" + ixml "github.com/veypi/OneAuth/libs/webdav/internal/xml" ) // http://www.webdav.org/specs/rfc4918.html#ELEMENT_lockinfo diff --git a/libs/webdav/xml_test.go b/libs/webdav/xml_test.go index 811ac16..0238a75 100644 --- a/libs/webdav/xml_test.go +++ b/libs/webdav/xml_test.go @@ -16,7 +16,7 @@ import ( "strings" "testing" - ixml "oa/libs/webdav/internal/xml" + ixml "github.com/veypi/OneAuth/libs/webdav/internal/xml" ) func TestReadLockInfo(t *testing.T) { diff --git a/models/init.go b/models/init.go index 4dcc1f0..c6d2552 100644 --- a/models/init.go +++ b/models/init.go @@ -7,7 +7,7 @@ package models import ( - "oa/cfg" + "github.com/veypi/OneAuth/cfg" "strings" "time" @@ -31,7 +31,6 @@ func (m *BaseModel) BeforeCreate(tx *gorm.DB) error { return nil } - var AllModels = crud.New() func init() { @@ -51,7 +50,7 @@ func Drop() error { return crud.AutoDrop(cfg.DB(), AllModels) } -func Init() error { +func InitDB() error { app := &App{} app.ID = cfg.Config.ID app.Name = "OA" diff --git a/ui/assets/animate.min.css b/ui/assets/libs/animate/animate.min.css similarity index 100% rename from ui/assets/animate.min.css rename to ui/assets/libs/animate/animate.min.css diff --git a/ui/assets/awesomefont/css/all.min.css b/ui/assets/libs/font-awesome/css/all.min.css similarity index 100% rename from ui/assets/awesomefont/css/all.min.css rename to ui/assets/libs/font-awesome/css/all.min.css diff --git a/ui/assets/libs/font-awesome/webfonts/fa-brands-400.ttf b/ui/assets/libs/font-awesome/webfonts/fa-brands-400.ttf new file mode 100644 index 0000000..0f82a83 Binary files /dev/null and b/ui/assets/libs/font-awesome/webfonts/fa-brands-400.ttf differ diff --git a/ui/assets/awesomefont/webfonts/fa-brands-400.woff2 b/ui/assets/libs/font-awesome/webfonts/fa-brands-400.woff2 similarity index 100% rename from ui/assets/awesomefont/webfonts/fa-brands-400.woff2 rename to ui/assets/libs/font-awesome/webfonts/fa-brands-400.woff2 diff --git a/ui/assets/libs/font-awesome/webfonts/fa-regular-400.ttf b/ui/assets/libs/font-awesome/webfonts/fa-regular-400.ttf new file mode 100644 index 0000000..9ee1919 Binary files /dev/null and b/ui/assets/libs/font-awesome/webfonts/fa-regular-400.ttf differ diff --git a/ui/assets/libs/font-awesome/webfonts/fa-regular-400.woff2 b/ui/assets/libs/font-awesome/webfonts/fa-regular-400.woff2 new file mode 100644 index 0000000..57d9179 Binary files /dev/null and b/ui/assets/libs/font-awesome/webfonts/fa-regular-400.woff2 differ diff --git a/ui/assets/libs/font-awesome/webfonts/fa-solid-900.ttf b/ui/assets/libs/font-awesome/webfonts/fa-solid-900.ttf new file mode 100644 index 0000000..1c10972 Binary files /dev/null and b/ui/assets/libs/font-awesome/webfonts/fa-solid-900.ttf differ diff --git a/ui/assets/awesomefont/webfonts/fa-solid-900.woff2 b/ui/assets/libs/font-awesome/webfonts/fa-solid-900.woff2 similarity index 100% rename from ui/assets/awesomefont/webfonts/fa-solid-900.woff2 rename to ui/assets/libs/font-awesome/webfonts/fa-solid-900.woff2 diff --git a/ui/assets/libs/font-awesome/webfonts/fa-v4compatibility.ttf b/ui/assets/libs/font-awesome/webfonts/fa-v4compatibility.ttf new file mode 100644 index 0000000..3bcb67f Binary files /dev/null and b/ui/assets/libs/font-awesome/webfonts/fa-v4compatibility.ttf differ diff --git a/ui/assets/libs/font-awesome/webfonts/fa-v4compatibility.woff2 b/ui/assets/libs/font-awesome/webfonts/fa-v4compatibility.woff2 new file mode 100644 index 0000000..fbafb22 Binary files /dev/null and b/ui/assets/libs/font-awesome/webfonts/fa-v4compatibility.woff2 differ diff --git a/ui/assets/tailwind.min.css b/ui/assets/libs/tailwind/tailwind.min.css similarity index 100% rename from ui/assets/tailwind.min.css rename to ui/assets/libs/tailwind/tailwind.min.css diff --git a/ui/ico.html b/ui/ico.html index 9526909..95a1026 100644 --- a/ui/ico.html +++ b/ui/ico.html @@ -1,36 +1,71 @@ - @@ -38,18 +73,20 @@
用户头像 {{ user.name }} - +
- 未登录 - + 登录
+ + + diff --git a/ui/root.html b/ui/root.html index 93721d2..838b15d 100644 --- a/ui/root.html +++ b/ui/root.html @@ -4,12 +4,10 @@ oa - - - + + +