|
|
@@ -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 |
|
|
|
} |