@@ -19,4 +19,5 @@ type UserDao interface { | |||||
GetUser(id int64) (m *model.User, err error) | GetUser(id int64) (m *model.User, err error) | ||||
UserCount() (int64, error) | UserCount() (int64, error) | ||||
UserFindNotInByParamsByPage(page int, limit int, params map[string]interface{}) ([]model.User, int64, error) | UserFindNotInByParamsByPage(page int, limit int, params map[string]interface{}) ([]model.User, int64, error) | ||||
UserExistByParams(params map[string]interface{}) (bool, error) | |||||
} | } |
@@ -14,7 +14,7 @@ type UserLevelDao interface { | |||||
UserLevelAllByAsc() ([]*model.UserLevel, error) | UserLevelAllByAsc() ([]*model.UserLevel, error) | ||||
// UserLevelAllByAscByPage 获取所有开启等级升序分页返回 | // UserLevelAllByAscByPage 获取所有开启等级升序分页返回 | ||||
UserLevelAllByAscByPage(page, limit int) ([]*model.UserLevel, int64, error) | 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) | UserLevelDeleteBySession(session *xorm.Session, id interface{}) (int64, error) | ||||
UserLevelInsert(userLevel *model.UserLevel) (int, error) | |||||
UserLevelInsertBySession(session *xorm.Session, userLevel *model.UserLevel) (int, error) | |||||
} | } |
@@ -1,11 +1,15 @@ | |||||
package dao | 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 { | type UserLevelTaskDao interface { | ||||
//TODO:: You can add specific method definitions here | //TODO:: You can add specific method definitions here | ||||
UserLevelTaskFindByParams(params map[string]interface{}) ([]model.UserLevelTask, error) | UserLevelTaskFindByParams(params map[string]interface{}) ([]model.UserLevelTask, error) | ||||
UserLevelTaskInsert(userLevelTask *model.UserLevelTask) (int, error) | UserLevelTaskInsert(userLevelTask *model.UserLevelTask) (int, error) | ||||
UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, forceColumns ...string) (int64, 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) | |||||
} | } |
@@ -83,10 +83,10 @@ func (e EggSignInDb) EggSignINGetOneByTimeAndUid(startAt, endAt string, uid int6 | |||||
var eggSignIn model.EggSignIn | var eggSignIn model.EggSignIn | ||||
session := e.Db.Where("uid = ?", uid).And("is_completed = ?", isCompleted) | session := e.Db.Where("uid = ?", uid).And("is_completed = ?", isCompleted) | ||||
if startAt != "" { | if startAt != "" { | ||||
session = session.And("start_time > ?", startAt) | |||||
session = session.And("start_time < ?", startAt) | |||||
} | } | ||||
if endAt != "" { | if endAt != "" { | ||||
session = session.And("end_time < ?", endAt) | |||||
session = session.And("end_time > ?", endAt) | |||||
} | } | ||||
has, err := session.Get(&eggSignIn) | has, err := session.Get(&eggSignIn) | ||||
if err != nil { | if err != nil { | ||||
@@ -176,3 +176,13 @@ func (u UserDb) UserFindNotInByParamsByPage(page int, limit int, params map[stri | |||||
} | } | ||||
return m, total, nil | 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 | |||||
} |
@@ -59,15 +59,15 @@ func (u UserLevelDb) UserLevelAllByAscByPage(page, limit int) ([]*model.UserLeve | |||||
return m, total, nil | 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 ( | var ( | ||||
affected int64 | affected int64 | ||||
err error | err error | ||||
) | ) | ||||
if forceColumns != nil { | 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 { | } else { | ||||
affected, err = u.Db.Where("id=?", id).Update(userLevel) | |||||
affected, err = session.Where("id=?", id).Update(userLevel) | |||||
} | } | ||||
if err != nil { | if err != nil { | ||||
return 0, zhios_order_relate_logx.Error(err.Error()) | 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 | 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 { | if err != nil { | ||||
return 0, zhios_order_relate_logx.Error(err) | return 0, zhios_order_relate_logx.Error(err) | ||||
} | } | ||||
@@ -49,10 +49,19 @@ func (u UserLevelTaskDb) UserLevelTaskUpdate(userLevelTask *model.UserLevelTask, | |||||
return affected, nil | 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 { | if err != nil { | ||||
return 0, err | |||||
return 0, zhios_order_relate_logx.Error(err.Error()) | |||||
} | } | ||||
return affected, nil | return affected, nil | ||||
} | } |