|
|
@@ -0,0 +1,58 @@ |
|
|
|
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 NewUserLevelTaskDb(engine *xorm.Engine) dao.UserLevelTaskDao { |
|
|
|
return &UserLevelTaskDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type UserLevelTaskDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserLevelTaskDb) UserLevelTaskFindByParams(params map[string]interface{}) ([]model.UserLevelTask, error) { |
|
|
|
var m []model.UserLevelTask |
|
|
|
var query = fmt.Sprintf("%s = ?", params["key"]) |
|
|
|
if err := u.Db.Where(query, params["value"]).Find(&m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserLevelTaskDb) UserLevelTaskInsert(userLevelTask *model.UserLevelTask) (int, error) { |
|
|
|
_, err := u.Db.InsertOne(userLevelTask) |
|
|
|
if err != nil { |
|
|
|
return 0, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return userLevelTask.Id, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserLevelTaskDb) UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, forceColumns ...string) (int64, error) { |
|
|
|
var ( |
|
|
|
affected int64 |
|
|
|
err error |
|
|
|
) |
|
|
|
if forceColumns != nil { |
|
|
|
affected, err = u.Db.Where("id=?", userLevelTask.Id).MustCols(forceColumns...).Update(userLevelTask) |
|
|
|
} else { |
|
|
|
affected, err = u.Db.Where("id=?", userLevelTask.Id).Update(userLevelTask) |
|
|
|
} |
|
|
|
if err != nil { |
|
|
|
return 0, zhios_order_relate_logx.Error(err.Error()) |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (u UserLevelTaskDb) UserLevelTaskDelete(id interface{}) (int64, error) { |
|
|
|
affected, err := u.Db.Where("id = ?", id).Delete(&model.UserLevelTask{}) |
|
|
|
if err != nil { |
|
|
|
return 0, err |
|
|
|
} |
|
|
|
return affected, nil |
|
|
|
} |