|
|
@@ -2,6 +2,11 @@ |
|
|
|
|
|
|
|
import ( |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/dao" |
|
|
|
"code.fnuoos.com/EggPlanet/egg_models.git/src/model" |
|
|
|
zhios_order_relate_utils "code.fnuoos.com/EggPlanet/egg_models.git/utils" |
|
|
|
zhios_order_relate_logx "code.fnuoos.com/EggPlanet/egg_models.git/utils/logx" |
|
|
|
"fmt" |
|
|
|
"reflect" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
@@ -12,3 +17,33 @@ func NewEggSignInDb(engine *xorm.Engine) dao.EggSignInDao { |
|
|
|
type EggSignInDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (e EggSignInDb) EggSignInGetOne(startAt, endAt string, uid int64) (bool, *model.EggSignIn, error) { |
|
|
|
var eggSignIn model.EggSignIn |
|
|
|
has, err := e.Db.Where("start_time > ?", startAt). |
|
|
|
And("end_time < ?", endAt). |
|
|
|
And("uid = ?", uid). |
|
|
|
And("is_completed = 0"). |
|
|
|
Get(&eggSignIn) |
|
|
|
if err != nil { |
|
|
|
return false, nil, err |
|
|
|
} |
|
|
|
return has, &eggSignIn, nil |
|
|
|
} |
|
|
|
|
|
|
|
func (e EggSignInDb) EggSignInFindByParams(params map[string]interface{}) ([]*model.EggSignIn, error) { |
|
|
|
var m []*model.EggSignIn |
|
|
|
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { |
|
|
|
//指定In查询 |
|
|
|
if err := e.Db.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]).Find(m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Warn(err) |
|
|
|
} |
|
|
|
} else { |
|
|
|
var query = fmt.Sprintf("%s =?", params["key"]) |
|
|
|
err := e.Db.Where(query, params["value"]).Find(m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |