Skip to content

Commit

Permalink
fix(api): create table
Browse files Browse the repository at this point in the history
  • Loading branch information
ttktatakai committed Oct 22, 2024
1 parent f114cc6 commit dc8eb68
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions backend/api/controller/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) }))
}
Expand Down
7 changes: 4 additions & 3 deletions backend/db/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 2 additions & 0 deletions backend/model/default.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ var (
DefaultConfig = &Config{}
DefaultFileHistory = &FileHistory{}
DefaultGateway = &Gateway{}
DefaultHistory = &History{}
DefaultNode = &Node{}
DefaultPublicKey = &PublicKey{}
DefaultSession = &Session{}
DefaultSessionCmd = &SessionCmd{}
DefaultShare = &Share{}
)

0 comments on commit dc8eb68

Please sign in to comment.