diff --git a/src/dao/user_dao.go b/src/dao/user_dao.go index c665546..9d49083 100644 --- a/src/dao/user_dao.go +++ b/src/dao/user_dao.go @@ -19,4 +19,5 @@ type UserDao interface { GetUser(id int64) (m *model.User, err error) UserCount() (int64, error) UserFindNotInByParamsByPage(page int, limit int, params map[string]interface{}) ([]model.User, int64, error) + UserExistByParams(params map[string]interface{}) (bool, error) } diff --git a/src/dao/user_level_dao.go b/src/dao/user_level_dao.go index 9e6bab5..c592a28 100644 --- a/src/dao/user_level_dao.go +++ b/src/dao/user_level_dao.go @@ -14,7 +14,7 @@ type UserLevelDao interface { UserLevelAllByAsc() ([]*model.UserLevel, error) // UserLevelAllByAscByPage 获取所有开启等级升序分页返回 UserLevelAllByAscByPage(page, limit int) ([]*model.UserLevel, int64, error) - UserLevelUpdate(id interface{}, level *model.UserLevel, forceColumns ...string) (int64, error) + UserLevelUpdateBySession(session *xorm.Session, id interface{}, level *model.UserLevel, forceColumns ...string) (int64, error) UserLevelDeleteBySession(session *xorm.Session, id interface{}) (int64, error) - UserLevelInsert(userLevel *model.UserLevel) (int, error) + UserLevelInsertBySession(session *xorm.Session, userLevel *model.UserLevel) (int, error) } diff --git a/src/dao/user_level_task_dao.go b/src/dao/user_level_task_dao.go index 7fa4b24..9215cad 100644 --- a/src/dao/user_level_task_dao.go +++ b/src/dao/user_level_task_dao.go @@ -1,11 +1,15 @@ package dao -import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" +import ( + "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + "xorm.io/xorm" +) type UserLevelTaskDao interface { //TODO:: You can add specific method definitions here UserLevelTaskFindByParams(params map[string]interface{}) ([]model.UserLevelTask, error) UserLevelTaskInsert(userLevelTask *model.UserLevelTask) (int, error) UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, forceColumns ...string) (int64, error) - UserLevelTaskDelete(id interface{}) (int64, error) + UserLevelTaskDeleteByParamsBySession(session *xorm.Session, params map[string]interface{}) (int64, error) + UserLevelTaskBatchInsertBySession(session *xorm.Session, UserLevelTasks []model.UserLevelTask) (int64, error) } diff --git a/src/implement/egg_sign_in_implement.go b/src/implement/egg_sign_in_implement.go index f5d3177..645a55a 100644 --- a/src/implement/egg_sign_in_implement.go +++ b/src/implement/egg_sign_in_implement.go @@ -83,10 +83,10 @@ func (e EggSignInDb) EggSignINGetOneByTimeAndUid(startAt, endAt string, uid int6 var eggSignIn model.EggSignIn session := e.Db.Where("uid = ?", uid).And("is_completed = ?", isCompleted) if startAt != "" { - session = session.And("start_time > ?", startAt) + session = session.And("start_time < ?", startAt) } if endAt != "" { - session = session.And("end_time < ?", endAt) + session = session.And("end_time > ?", endAt) } has, err := session.Get(&eggSignIn) if err != nil { diff --git a/src/implement/user_implement.go b/src/implement/user_implement.go index e4df67b..f396fe4 100644 --- a/src/implement/user_implement.go +++ b/src/implement/user_implement.go @@ -176,3 +176,13 @@ func (u UserDb) UserFindNotInByParamsByPage(page int, limit int, params map[stri } return m, total, nil } + +func (u UserDb) UserExistByParams(params map[string]interface{}) (bool, error) { + var m model.User + var query = fmt.Sprintf("%s = ?", params["key"]) + has, err := u.Db.Where(query, params["value"]).Exist(&m) + if err != nil { + return has, zhios_order_relate_logx.Error(err) + } + return has, nil +} diff --git a/src/implement/user_level_implement.go b/src/implement/user_level_implement.go index be530b8..0588a52 100644 --- a/src/implement/user_level_implement.go +++ b/src/implement/user_level_implement.go @@ -59,15 +59,15 @@ func (u UserLevelDb) UserLevelAllByAscByPage(page, limit int) ([]*model.UserLeve return m, total, nil } -func (u UserLevelDb) UserLevelUpdate(id interface{}, userLevel *model.UserLevel, forceColumns ...string) (int64, error) { +func (u UserLevelDb) UserLevelUpdateBySession(session *xorm.Session, id interface{}, userLevel *model.UserLevel, forceColumns ...string) (int64, error) { var ( affected int64 err error ) if forceColumns != nil { - affected, err = u.Db.Where("id=?", id).MustCols(forceColumns...).Update(userLevel) + affected, err = session.Where("id=?", id).MustCols(forceColumns...).Update(userLevel) } else { - affected, err = u.Db.Where("id=?", id).Update(userLevel) + affected, err = session.Where("id=?", id).Update(userLevel) } if err != nil { return 0, zhios_order_relate_logx.Error(err.Error()) @@ -83,8 +83,8 @@ func (u UserLevelDb) UserLevelDeleteBySession(session *xorm.Session, id interfac return affected, nil } -func (u UserLevelDb) UserLevelInsert(userLevel *model.UserLevel) (int, error) { - _, err := u.Db.InsertOne(userLevel) +func (u UserLevelDb) UserLevelInsertBySession(session *xorm.Session, userLevel *model.UserLevel) (int, error) { + _, err := session.Insert(userLevel) if err != nil { return 0, zhios_order_relate_logx.Error(err) } diff --git a/src/implement/user_level_task_implement.go b/src/implement/user_level_task_implement.go index ec4243b..af4382b 100644 --- a/src/implement/user_level_task_implement.go +++ b/src/implement/user_level_task_implement.go @@ -49,10 +49,19 @@ func (u UserLevelTaskDb) UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, return affected, nil } -func (u UserLevelTaskDb) UserLevelTaskDelete(id interface{}) (int64, error) { - affected, err := u.Db.Where("id = ?", id).Delete(&model.UserLevelTask{}) +func (u UserLevelTaskDb) UserLevelTaskDeleteByParamsBySession(session *xorm.Session, params map[string]interface{}) (int64, error) { + var query = fmt.Sprintf("%s = ?", params["key"]) + affected, err := session.Where(query, params["value"]).Delete(&model.UserLevelTask{}) + if err != nil { + return 0, zhios_order_relate_logx.Error(err.Error()) + } + return affected, nil +} + +func (u UserLevelTaskDb) UserLevelTaskBatchInsertBySession(session *xorm.Session, UserLevelTasks []model.UserLevelTask) (int64, error) { + affected, err := session.Insert(UserLevelTasks) if err != nil { - return 0, err + return 0, zhios_order_relate_logx.Error(err.Error()) } return affected, nil }