diff --git a/src/dao/egg_sign_in_dao.go b/src/dao/egg_sign_in_dao.go index 4b59cf9..41c6619 100644 --- a/src/dao/egg_sign_in_dao.go +++ b/src/dao/egg_sign_in_dao.go @@ -6,4 +6,6 @@ type EggSignInDao interface { //TODO:: You can add specific method definitions here EggSignInGetOne(startAt, endAt string, uid int64) (bool, *model.EggSignIn, error) EggSignInFindByParams(params map[string]interface{}) ([]*model.EggSignIn, error) + EggSignINGetOneByTimeAndUid(startAt, endAt string, uid int64, isCompleted int) (bool, *model.EggSignIn, error) + EggSignInFindByTimeAndParams(startAt, endAt string, isCompleted int, params map[string]interface{}) ([]*model.EggSignIn, error) } diff --git a/src/implement/egg_sign_in_implement.go b/src/implement/egg_sign_in_implement.go index 1454667..47600db 100644 --- a/src/implement/egg_sign_in_implement.go +++ b/src/implement/egg_sign_in_implement.go @@ -36,7 +36,7 @@ func (e EggSignInDb) EggSignInFindByParams(params map[string]interface{}) ([]*mo 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) + return nil, zhios_order_relate_logx.Error(err) } } else { var query = fmt.Sprintf("%s =?", params["key"]) @@ -47,3 +47,43 @@ func (e EggSignInDb) EggSignInFindByParams(params map[string]interface{}) ([]*mo } return m, nil } + +func (e EggSignInDb) EggSignINGetOneByTimeAndUid(startAt, endAt string, uid int64, isCompleted int) (bool, *model.EggSignIn, error) { + var eggSignIn model.EggSignIn + session := e.Db.Where("uid = ?", uid).And("is_completed = ?", isCompleted) + if startAt != "" { + session = session.And("start_time > ?", startAt) + } + if endAt != "" { + session = session.And("end_time < ?", endAt) + } + has, err := session.Get(&eggSignIn) + if err != nil { + return false, nil, err + } + return has, &eggSignIn, nil +} + +func (e EggSignInDb) EggSignInFindByTimeAndParams(startAt, endAt string, isCompleted int, params map[string]interface{}) ([]*model.EggSignIn, error) { + var m []*model.EggSignIn + session := e.Db.Where("is_completed > ?", isCompleted) + if startAt != "" { + session = session.And("start_time > ?", startAt) + } + if endAt != "" { + session = session.And("end_time < ?", endAt) + } + if reflect.TypeOf(params["value"]).Kind() == reflect.Slice { + //指定In查询 + session = session.In(zhios_order_relate_utils.AnyToString(params["key"]), params["value"]) + } else { + var query = fmt.Sprintf("%s =?", params["key"]) + session = session.Where(query, params["value"]) + } + + err := session.Find(m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return m, nil +}