From dc8eb6864e92f8d993dee41957713fc9538ba597 Mon Sep 17 00:00:00 2001 From: ttk Date: Tue, 22 Oct 2024 11:09:21 +0800 Subject: [PATCH] fix(api): create table --- backend/api/controller/command.go | 6 +++--- backend/db/mysql.go | 7 ++++--- backend/model/default.go | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/api/controller/command.go b/backend/api/controller/command.go index 50e0e02..808d30f 100644 --- a/backend/api/controller/command.go +++ b/backend/api/controller/command.go @@ -85,13 +85,13 @@ func (c *Controller) UpdateCommand(ctx *gin.Context) { // @Tags command // @Param page_index query int true "command id" // @Param page_size query int true "command id" -// @Param search query string false "name or cmds" +// @Param search query string false "name or cmd" // @Param id query int false "command id" // @Param ids query string false "command ids" // @Param name query string false "command name" // @Param enable query int false "command enable" // @Param info query bool false "is info mode" -// @Param search query string false "name or cmds" +// @Param search query string false "name or cmd" // @Success 200 {object} HttpResponse{data=ListData{list=[]model.Command}} // @Router /command [get] func (c *Controller) GetCommands(ctx *gin.Context) { @@ -101,7 +101,7 @@ func (c *Controller) GetCommands(ctx *gin.Context) { db := mysql.DB.Model(&model.Command{}) db = filterEqual(ctx, db, "id", "enable") db = filterLike(ctx, db, "name") - db = filterSearch(ctx, db, "name", "cmds") + db = filterSearch(ctx, db, "name", "cmd") if q, ok := ctx.GetQuery("ids"); ok { db = db.Where("id IN ?", lo.Map(strings.Split(q, ","), func(s string, _ int) int { return cast.ToInt(s) })) } diff --git a/backend/db/mysql.go b/backend/db/mysql.go index 6d03d3e..adc4cea 100644 --- a/backend/db/mysql.go +++ b/backend/db/mysql.go @@ -29,9 +29,10 @@ func init() { } err = DB.AutoMigrate( - &model.Account{}, &model.Asset{}, &model.Authorization{}, &model.Command{}, - &model.Config{}, &model.FileHistory{}, &model.Gateway{}, &model.History{}, - &model.Node{}, &model.PublicKey{}, &model.Session{}, &model.Share{}, + model.DefaultAccount, model.DefaultAsset, model.DefaultAuthorization, model.DefaultCommand, + model.DefaultConfig, model.DefaultFileHistory, model.DefaultGateway, model.DefaultHistory, + model.DefaultNode, model.DefaultPublicKey, model.DefaultSession, model.DefaultSessionCmd, + model.DefaultShare, ) if err != nil { logger.L().Fatal("auto migrate mysql failed", zap.Error(err)) diff --git a/backend/model/default.go b/backend/model/default.go index be75ff0..432d6b8 100644 --- a/backend/model/default.go +++ b/backend/model/default.go @@ -8,8 +8,10 @@ var ( DefaultConfig = &Config{} DefaultFileHistory = &FileHistory{} DefaultGateway = &Gateway{} + DefaultHistory = &History{} DefaultNode = &Node{} DefaultPublicKey = &PublicKey{} DefaultSession = &Session{} + DefaultSessionCmd = &SessionCmd{} DefaultShare = &Share{} )