瀏覽代碼

极光推送

master
huangjiajun 15 小時之前
父節點
當前提交
537beca9fa
共有 6 個檔案被更改,包括 136 行新增0 行删除
  1. +8
    -0
      src/dao/jpush_notice_dao.go
  2. +8
    -0
      src/dao/jpush_record_dao.go
  3. +42
    -0
      src/implement/jpush_notice_implement.go
  4. +41
    -0
      src/implement/jpush_record_implement.go
  5. +16
    -0
      src/model/jpush_notice.go
  6. +21
    -0
      src/model/jpush_record.go

+ 8
- 0
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)
}

+ 8
- 0
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)
}

+ 42
- 0
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
}

+ 41
- 0
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
}

+ 16
- 0
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)"`
}

+ 21
- 0
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"`
}

Loading…
取消
儲存