Przeglądaj źródła

add add friend

master
shenjiachi 3 dni temu
rodzic
commit
771252f025
2 zmienionych plików z 43 dodań i 1 usunięć
  1. +2
    -0
      src/dao/egg_sign_in_dao.go
  2. +41
    -1
      src/implement/egg_sign_in_implement.go

+ 2
- 0
src/dao/egg_sign_in_dao.go Wyświetl plik

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

+ 41
- 1
src/implement/egg_sign_in_implement.go Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz