|
|
@@ -0,0 +1,42 @@ |
|
|
|
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" |
|
|
|
"strings" |
|
|
|
"xorm.io/xorm" |
|
|
|
) |
|
|
|
|
|
|
|
func NewJpushNoticeDb(engine *xorm.Engine) dao.JpushNoticeDao { |
|
|
|
return &JpushNoticeDb{Db: engine} |
|
|
|
} |
|
|
|
|
|
|
|
type JpushNoticeDb struct { |
|
|
|
Db *xorm.Engine |
|
|
|
} |
|
|
|
|
|
|
|
func (j JpushNoticeDb) GetJpushNotice(id string) (m *model.JpushNotice, err error) { |
|
|
|
m = new(model.JpushNotice) |
|
|
|
has, err := j.Db.Where("id=?", id).Get(m) |
|
|
|
if err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
if has == false { |
|
|
|
return nil, nil |
|
|
|
} |
|
|
|
return m, nil |
|
|
|
} |
|
|
|
func (j JpushNoticeDb) FindJpushNotice(page, limit, types string) (*[]model.JpushNotice, error) { |
|
|
|
var m []model.JpushNotice |
|
|
|
sess := j.Db.Where("1=1") |
|
|
|
start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) |
|
|
|
if types != "" { |
|
|
|
sess.In("type", strings.Split(types, ",")) |
|
|
|
} |
|
|
|
if err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).Find(&m); err != nil { |
|
|
|
return nil, zhios_order_relate_logx.Error(err) |
|
|
|
} |
|
|
|
return &m, nil |
|
|
|
} |