|
|
@@ -0,0 +1,48 @@ |
|
|
|
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" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewNewUserRedPackageDb(engine *xorm.Engine) dao.NewUserRedPackageDao { |
|
|
|
return &NewUserRedPackageDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type NewUserRedPackageDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (n NewUserRedPackageDb) NewUserRedPackageGetOne() (*model.NewUserRedPackage, error) { |
|
|
|
var m model.NewUserRedPackage |
|
|
|
if has, err := n.Db.Where("id >= 1").Get(&m); err != nil || has == false { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (n NewUserRedPackageDb) NewUserRedPackageInsert(newUserRedPackage *model.NewUserRedPackage) (int, error) { |
|
|
|
_, err := n.Db.InsertOne(newUserRedPackage) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return newUserRedPackage.Id, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (n NewUserRedPackageDb) NewUserRedPackageUpdate(id interface{}, newUserRedPackage *model.NewUserRedPackage, forceColums ...string) (int64, error) { |
|
|
|
var ( |
|
|
|
affected int64 |
|
|
|
err error |
|
|
|
) |
|
|
|
if forceColums != nil { |
|
|
|
affected, err = n.Db.Where("id=?", id).Cols(forceColums...).Update(newUserRedPackage) |
|
|
|
} else { |
|
|
|
affected, err = n.Db.Where("id=?", id).Update(newUserRedPackage) |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |