diff --git a/src/dao/advertising_function_dao.go b/src/dao/advertising_function_dao.go index a46ea0c..21b84df 100644 --- a/src/dao/advertising_function_dao.go +++ b/src/dao/advertising_function_dao.go @@ -4,4 +4,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type AdvertisingFunctionDao interface { AdvertisingFunctionAll() (*[]model.AdvertisingFunction, error) + FindUserFeedbackFunctionAndTotal(page, limit string) (*[]model.AdvertisingFunction, int64, error) } diff --git a/src/dao/advertising_space_dao.go b/src/dao/advertising_space_dao.go index 03e2dce..6ffef0e 100644 --- a/src/dao/advertising_space_dao.go +++ b/src/dao/advertising_space_dao.go @@ -5,5 +5,5 @@ import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" type AdvertisingSpaceDao interface { AdvertisingSpaceAll() (*[]model.AdvertisingSpace, error) GetAdvertisingSpace(id string) (m *model.AdvertisingSpace, err error) - FindUserFeedbackCateAndTotal(page, limit string) (*[]model.AdvertisingSpace, int64, error) + FindUserFeedbackCateAndTotal(page, limit, name, kind string) (*[]model.AdvertisingSpace, int64, error) } diff --git a/src/implement/advertising_function_implement.go b/src/implement/advertising_function_implement.go index c343483..8d7ac72 100644 --- a/src/implement/advertising_function_implement.go +++ b/src/implement/advertising_function_implement.go @@ -3,6 +3,7 @@ package implement 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" "xorm.io/xorm" ) @@ -22,3 +23,13 @@ func (a AdvertisingFunctionDb) AdvertisingFunctionAll() (*[]model.AdvertisingFun } return &m, nil } +func (a AdvertisingFunctionDb) FindUserFeedbackFunctionAndTotal(page, limit string) (*[]model.AdvertisingFunction, int64, error) { + var m []model.AdvertisingFunction + sess := a.Db.Where("1=1") + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("id desc").FindAndCount(&m) + if err != nil { + return nil, count, zhios_order_relate_logx.Error(err) + } + return &m, count, nil +} diff --git a/src/implement/advertising_space_implement.go b/src/implement/advertising_space_implement.go index 93705d9..7b97f5a 100644 --- a/src/implement/advertising_space_implement.go +++ b/src/implement/advertising_space_implement.go @@ -34,9 +34,15 @@ func (a AdvertisingSpaceDb) GetAdvertisingSpace(id string) (m *model.Advertising } return m, nil } -func (a AdvertisingSpaceDb) FindUserFeedbackCateAndTotal(page, limit string) (*[]model.AdvertisingSpace, int64, error) { +func (a AdvertisingSpaceDb) FindUserFeedbackCateAndTotal(page, limit, name, kind string) (*[]model.AdvertisingSpace, int64, error) { var m []model.AdvertisingSpace sess := a.Db.Where("1=1") + if name != "" { + sess.And("name like ?", "%"+name+"%") + } + if kind != "" { + sess.And("kind=?", kind) + } start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("id desc").FindAndCount(&m) if err != nil {