From 7ef2c42532e53ac89d76418dff96c6f2e6730554 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Mon, 25 Nov 2024 15:31:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E7=9F=AD=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/aliyun_sms_notice_dao.go | 9 ++++ src/dao/aliyun_sms_record_dao.go | 9 ++++ src/implement/aliyun_sms_notice_implement.go | 55 ++++++++++++++++++++ src/implement/aliyun_sms_record_implement.go | 54 +++++++++++++++++++ src/model/aliyun_sms_notice.go | 16 ++++++ src/model/aliyun_sms_record.go | 23 ++++++++ 6 files changed, 166 insertions(+) create mode 100644 src/dao/aliyun_sms_notice_dao.go create mode 100644 src/dao/aliyun_sms_record_dao.go create mode 100644 src/implement/aliyun_sms_notice_implement.go create mode 100644 src/implement/aliyun_sms_record_implement.go create mode 100644 src/model/aliyun_sms_notice.go create mode 100644 src/model/aliyun_sms_record.go diff --git a/src/dao/aliyun_sms_notice_dao.go b/src/dao/aliyun_sms_notice_dao.go new file mode 100644 index 0000000..1e88066 --- /dev/null +++ b/src/dao/aliyun_sms_notice_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type AliyunSmsNoticeDao interface { + GetAliyunSmsNotice(id string) (m *model.AliyunSmsNotice, err error) + FindAliyunSmsNotice(page, limit, types string) (*[]model.AliyunSmsNotice, error) + FindAliyunSmsNoticeAndTotal(page, limit, types string) (*[]model.AliyunSmsNotice, int64, error) +} diff --git a/src/dao/aliyun_sms_record_dao.go b/src/dao/aliyun_sms_record_dao.go new file mode 100644 index 0000000..41a56fa --- /dev/null +++ b/src/dao/aliyun_sms_record_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type AliyunSmsRecordDao interface { + GetAliyunSmsRecord(id string) (m *model.AliyunSmsRecord, err error) + FindAliyunSmsRecord(page, limit, title string) (*[]model.AliyunSmsRecord, error) + FindAliyunSmsRecordAndTotal(page, limit, title string) (*[]model.AliyunSmsRecord, int64, error) +} diff --git a/src/implement/aliyun_sms_notice_implement.go b/src/implement/aliyun_sms_notice_implement.go new file mode 100644 index 0000000..e7a6f57 --- /dev/null +++ b/src/implement/aliyun_sms_notice_implement.go @@ -0,0 +1,55 @@ +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 NewAliyunSmsNoticeDb(engine *xorm.Engine) dao.AliyunSmsNoticeDao { + return &AliyunSmsNoticeDb{Db: engine} +} + +type AliyunSmsNoticeDb struct { + Db *xorm.Engine +} + +func (j AliyunSmsNoticeDb) GetAliyunSmsNotice(id string) (m *model.AliyunSmsNotice, err error) { + m = new(model.AliyunSmsNotice) + 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 AliyunSmsNoticeDb) FindAliyunSmsNotice(page, limit, types string) (*[]model.AliyunSmsNotice, error) { + var m []model.AliyunSmsNotice + 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 +} +func (j AliyunSmsNoticeDb) FindAliyunSmsNoticeAndTotal(page, limit, types string) (*[]model.AliyunSmsNotice, int64, error) { + var m []model.AliyunSmsNotice + 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, ",")) + } + count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).Desc("id").FindAndCount(&m) + if err != nil { + return nil, count, zhios_order_relate_logx.Error(err) + } + return &m, count, nil +} diff --git a/src/implement/aliyun_sms_record_implement.go b/src/implement/aliyun_sms_record_implement.go new file mode 100644 index 0000000..1442a08 --- /dev/null +++ b/src/implement/aliyun_sms_record_implement.go @@ -0,0 +1,54 @@ +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 NewAliyunSmsRecordDb(engine *xorm.Engine) dao.AliyunSmsRecordDao { + return &AliyunSmsRecordDb{Db: engine} +} + +type AliyunSmsRecordDb struct { + Db *xorm.Engine +} + +func (j AliyunSmsRecordDb) GetAliyunSmsRecord(id string) (m *model.AliyunSmsRecord, err error) { + m = new(model.AliyunSmsRecord) + 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 AliyunSmsRecordDb) FindAliyunSmsRecord(page, limit, title string) (*[]model.AliyunSmsRecord, error) { + var m []model.AliyunSmsRecord + 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 +} +func (j AliyunSmsRecordDb) FindAliyunSmsRecordAndTotal(page, limit, title string) (*[]model.AliyunSmsRecord, int64, error) { + var m []model.AliyunSmsRecord + 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+"%") + } + count, err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).Desc("id").FindAndCount(&m) + if err != nil { + return nil, count, zhios_order_relate_logx.Error(err) + } + return &m, count, nil +} diff --git a/src/model/aliyun_sms_notice.go b/src/model/aliyun_sms_notice.go new file mode 100644 index 0000000..96189e4 --- /dev/null +++ b/src/model/aliyun_sms_notice.go @@ -0,0 +1,16 @@ +package model + +import ( + "time" +) + +type AliyunSmsNotice 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/aliyun_sms_record.go b/src/model/aliyun_sms_record.go new file mode 100644 index 0000000..c828733 --- /dev/null +++ b/src/model/aliyun_sms_record.go @@ -0,0 +1,23 @@ +package model + +import ( + "time" +) + +type AliyunSmsRecord 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"` + Phone string `json:"phone" 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)"` + State int `json:"state" 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"` +}