Browse Source

update

master
shenjiachi 1 month ago
parent
commit
9a7e2400a0
3 changed files with 73 additions and 0 deletions
  1. +10
    -0
      src/dao/module_style_dao.go
  2. +50
    -0
      src/implement/module_style_implement.go
  3. +13
    -0
      src/model/module_style.go

+ 10
- 0
src/dao/module_style_dao.go View File

@@ -0,0 +1,10 @@
package dao

import "code.fnuoos.com/EggPlanet/egg_models.git/src/model"

type ModuleStyleDao interface {
//TODO:: You can add specific method definitions here
ModuleStyleGetOneByParams(params map[string]interface{}) (*model.ModuleStyle, error)
ModuleStyleInsert(moduleStyle *model.ModuleStyle) (int, error)
ModuleStyleUpdate(id interface{}, moduleStyle *model.ModuleStyle, forceColumns ...string) (int64, error)
}

+ 50
- 0
src/implement/module_style_implement.go View File

@@ -0,0 +1,50 @@
package implement

import (
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao"
"code.fnuoos.com/EggPlanet/egg_models.git/src/model"
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx"
"fmt"
"xorm.io/xorm"
)

func NewModuleStyleDb(engine *xorm.Engine) dao.ModuleStyleDao {
return &ModuleStyleDb{Db: engine}
}

type ModuleStyleDb struct {
Db *xorm.Engine
}

func (m ModuleStyleDb) ModuleStyleGetOneByParams(params map[string]interface{}) (*model.ModuleStyle, error) {
var moduleStyle model.ModuleStyle
var query = fmt.Sprintf("%s = ?", params["key"])
if has, err := m.Db.Where(query, params["value"]).Get(&moduleStyle); err != nil || has == false {
return nil, zhios_order_relate_logx.Error(err)
}
return &moduleStyle, nil
}

func (m ModuleStyleDb) ModuleStyleInsert(moduleStyle *model.ModuleStyle) (int, error) {
_, err := m.Db.InsertOne(moduleStyle)
if err != nil {
return 0, err
}
return moduleStyle.ModId, nil
}

func (m ModuleStyleDb) ModuleStyleUpdate(id interface{}, moduleStyle *model.ModuleStyle, forceColumns ...string) (int64, error) {
var (
affected int64
err error
)
if forceColumns != nil {
affected, err = m.Db.Where("mod_id=?", id).MustCols(forceColumns...).Update(moduleStyle)
} else {
affected, err = m.Db.Where("mod_id=?", id).Update(moduleStyle)
}
if err != nil {
return 0, err
}
return affected, nil
}

+ 13
- 0
src/model/module_style.go View File

@@ -0,0 +1,13 @@
package model

type ModuleStyle struct {
ModId int `json:"mod_id" xorm:"not null pk autoincr INT(10)"`
ModName string `json:"mod_name" xorm:"not null default '' comment('模块名称') VARCHAR(250)"`
Position string `json:"position" xorm:"not null default '' comment('位置') VARCHAR(250)"`
SkipIdentifier string `json:"skip_identifier" xorm:"not null default '' comment('跳转标识') VARCHAR(250)"`
Title string `json:"title" xorm:"not null default '' comment('标题') VARCHAR(128)"`
Subtitle string `json:"subtitle" xorm:"not null default '' comment('副标题') VARCHAR(255)"`
Data string `json:"data" xorm:"comment('内容') LONGTEXT"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
}

Loading…
Cancel
Save