diff --git a/src/dao/jpush_notice_dao.go b/src/dao/jpush_notice_dao.go new file mode 100644 index 0000000..1a3b7a3 --- /dev/null +++ b/src/dao/jpush_notice_dao.go @@ -0,0 +1,8 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type JpushNoticeDao interface { + GetJpushNotice(id string) (m *model.JpushNotice, err error) + FindJpushNotice(page, limit, types string) (*[]model.JpushNotice, error) +} diff --git a/src/dao/jpush_record_dao.go b/src/dao/jpush_record_dao.go new file mode 100644 index 0000000..0721136 --- /dev/null +++ b/src/dao/jpush_record_dao.go @@ -0,0 +1,8 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type JpushRecordDao interface { + GetJpushRecord(id string) (m *model.JpushRecord, err error) + FindJpushRecord(page, limit, title string) (*[]model.JpushRecord, error) +} diff --git a/src/implement/jpush_notice_implement.go b/src/implement/jpush_notice_implement.go new file mode 100644 index 0000000..5784739 --- /dev/null +++ b/src/implement/jpush_notice_implement.go @@ -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 +} diff --git a/src/implement/jpush_record_implement.go b/src/implement/jpush_record_implement.go new file mode 100644 index 0000000..182c0a9 --- /dev/null +++ b/src/implement/jpush_record_implement.go @@ -0,0 +1,41 @@ +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" +) + +func NewJpushRecordDb(engine *xorm.Engine) dao.JpushRecordDao { + return &JpushRecordDb{Db: engine} +} + +type JpushRecordDb struct { + Db *xorm.Engine +} + +func (j JpushRecordDb) GetJpushRecord(id string) (m *model.JpushRecord, err error) { + m = new(model.JpushRecord) + 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 JpushRecordDb) FindJpushRecord(page, limit, title string) (*[]model.JpushRecord, error) { + var m []model.JpushRecord + sess := j.Db.Where("1=1") + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + if title != "" { + sess.And("title like ?", "%"+title+"%") + } + 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 +} diff --git a/src/model/jpush_notice.go b/src/model/jpush_notice.go new file mode 100644 index 0000000..63088f1 --- /dev/null +++ b/src/model/jpush_notice.go @@ -0,0 +1,16 @@ +package model + +import ( + "time" +) + +type JpushNotice struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Title string `json:"title" xorm:"VARCHAR(255)"` + Content string `json:"content" xorm:"VARCHAR(255)"` + Skip string `json:"skip" xorm:"TEXT"` + CreateAt time.Time `json:"create_at" xorm:"DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"DATETIME"` + Day int `json:"day" xorm:"comment('部分通知需要时间') INT(11)"` + Type string `json:"type" xorm:"VARCHAR(255)"` +} diff --git a/src/model/jpush_record.go b/src/model/jpush_record.go new file mode 100644 index 0000000..c9cbf9c --- /dev/null +++ b/src/model/jpush_record.go @@ -0,0 +1,21 @@ +package model + +import ( + "time" +) + +type JpushRecord struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Platform string `json:"platform" xorm:"VARCHAR(255)"` + Target string `json:"target" xorm:"VARCHAR(255)"` + UserId string `json:"user_id" xorm:"TEXT"` + Level int `json:"level" xorm:"default 0 INT(11)"` + Title string `json:"title" xorm:"VARCHAR(255)"` + Content string `json:"content" xorm:"VARCHAR(255)"` + Skip string `json:"skip" xorm:"TEXT"` + SendType int `json:"send_type" xorm:"default 0 INT(1)"` + SendStartTime time.Time `json:"send_start_time" xorm:"DATETIME"` + SendEndTime time.Time `json:"send_end_time" xorm:"DATETIME"` + CreateAt time.Time `json:"create_at" xorm:"DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"DATETIME"` +}