From c64ccdff1c3ed20ced4f2d32d1e8eb34d5bac00d Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 26 Nov 2024 15:29:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dao/user_feedback_cate_dao.go | 9 +++ src/dao/user_feedback_dao.go | 5 ++ src/dao/user_feedback_record_dao.go | 7 +++ src/implement/user_feedback_cate_implement.go | 49 +++++++++++++++ src/implement/user_feedback_implement.go | 62 +++++++++++++++++++ .../user_feedback_record_implement.go | 31 ++++++++++ src/model/user_feedback.go | 13 ++++ src/model/user_feedback_cate.go | 7 +++ src/model/user_feedback_record.go | 13 ++++ 9 files changed, 196 insertions(+) create mode 100644 src/dao/user_feedback_cate_dao.go create mode 100644 src/dao/user_feedback_dao.go create mode 100644 src/dao/user_feedback_record_dao.go create mode 100644 src/implement/user_feedback_cate_implement.go create mode 100644 src/implement/user_feedback_implement.go create mode 100644 src/implement/user_feedback_record_implement.go create mode 100644 src/model/user_feedback.go create mode 100644 src/model/user_feedback_cate.go create mode 100644 src/model/user_feedback_record.go diff --git a/src/dao/user_feedback_cate_dao.go b/src/dao/user_feedback_cate_dao.go new file mode 100644 index 0000000..ffcdc1a --- /dev/null +++ b/src/dao/user_feedback_cate_dao.go @@ -0,0 +1,9 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type UserFeedbackCateDao interface { + GetUserFeedbackCate(id string) (m *model.UserFeedbackCate, err error) + FindUserFeedbackCate(page, limit string) (*[]model.UserFeedbackCate, error) + FindUserFeedbackCateAndTotal(page, limit string) (*[]model.UserFeedbackCate, int64, error) +} diff --git a/src/dao/user_feedback_dao.go b/src/dao/user_feedback_dao.go new file mode 100644 index 0000000..b341d8e --- /dev/null +++ b/src/dao/user_feedback_dao.go @@ -0,0 +1,5 @@ +package dao + +type UserFeedbackDao interface { + //TODO:: You can add specific method definitions here +} diff --git a/src/dao/user_feedback_record_dao.go b/src/dao/user_feedback_record_dao.go new file mode 100644 index 0000000..ddb19ee --- /dev/null +++ b/src/dao/user_feedback_record_dao.go @@ -0,0 +1,7 @@ +package dao + +import "code.fnuoos.com/EggPlanet/egg_models.git/src/model" + +type UserFeedbackRecordDao interface { + FindUserFeedback(page, limit, lid string) (*[]model.UserFeedbackRecord, error) +} diff --git a/src/implement/user_feedback_cate_implement.go b/src/implement/user_feedback_cate_implement.go new file mode 100644 index 0000000..ae7019d --- /dev/null +++ b/src/implement/user_feedback_cate_implement.go @@ -0,0 +1,49 @@ +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 NewUserFeedbackCateDb(engine *xorm.Engine) dao.UserFeedbackCateDao { + return &UserFeedbackCateDb{Db: engine} +} + +type UserFeedbackCateDb struct { + Db *xorm.Engine +} + +func (u UserFeedbackCateDb) GetUserFeedbackCate(id string) (m *model.UserFeedbackCate, err error) { + m = new(model.UserFeedbackCate) + has, err := u.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 (u UserFeedbackCateDb) FindUserFeedbackCate(page, limit string) (*[]model.UserFeedbackCate, error) { + var m []model.UserFeedbackCate + sess := u.Db.Where("1=1") + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("sort desc,id desc").Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +} +func (u UserFeedbackCateDb) FindUserFeedbackCateAndTotal(page, limit string) (*[]model.UserFeedbackCate, int64, error) { + var m []model.UserFeedbackCate + sess := u.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("sort desc,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/user_feedback_implement.go b/src/implement/user_feedback_implement.go new file mode 100644 index 0000000..455588f --- /dev/null +++ b/src/implement/user_feedback_implement.go @@ -0,0 +1,62 @@ +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 NewUserFeedbackDb(engine *xorm.Engine) dao.UserFeedbackDao { + return &UserFeedbackDb{Db: engine} +} + +type UserFeedbackDb struct { + Db *xorm.Engine +} + +func (u UserFeedbackDb) GetUserFeedback(id string) (m *model.UserFeedback, err error) { + m = new(model.UserFeedback) + has, err := u.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 (u UserFeedbackDb) FindUserFeedback(page, limit, uid string) (*[]model.UserFeedback, error) { + var m []model.UserFeedback + sess := u.Db.Where("1=1") + if uid != "" { + sess.And("uid=?", uid) + } + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("sort desc,id desc").Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +} +func (u UserFeedbackDb) FindUserFeedbackAndTotal(page, limit, uid, cid, content string) (*[]model.UserFeedback, int64, error) { + var m []model.UserFeedback + sess := u.Db.Where("1=1") + if uid != "" { + sess.In("uid=?", strings.Split(uid, ",")) + } + if cid != "" { + sess.And("cid=?", cid) + } + if content != "" { + sess.And("content like ?", "%"+cid+"%") + } + 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("sort desc,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/user_feedback_record_implement.go b/src/implement/user_feedback_record_implement.go new file mode 100644 index 0000000..91449f0 --- /dev/null +++ b/src/implement/user_feedback_record_implement.go @@ -0,0 +1,31 @@ +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 NewUserFeedbackRecordDb(engine *xorm.Engine) dao.UserFeedbackRecordDao { + return &UserFeedbackRecordDb{Db: engine} +} + +type UserFeedbackRecordDb struct { + Db *xorm.Engine +} + +func (u UserFeedbackRecordDb) FindUserFeedback(page, limit, lid string) (*[]model.UserFeedbackRecord, error) { + var m []model.UserFeedbackRecord + sess := u.Db.Where("1=1") + if lid != "" { + sess.And("lid=?", lid) + } + start := (zhios_order_relate_utils.StrToInt(page) - 1) * zhios_order_relate_utils.StrToInt(limit) + err := sess.Limit(zhios_order_relate_utils.StrToInt(limit), start).OrderBy("id asc").Find(&m) + if err != nil { + return nil, zhios_order_relate_logx.Error(err) + } + return &m, nil +} diff --git a/src/model/user_feedback.go b/src/model/user_feedback.go new file mode 100644 index 0000000..f0967c6 --- /dev/null +++ b/src/model/user_feedback.go @@ -0,0 +1,13 @@ +package model + +type UserFeedback struct { + Id int `json:"id" xorm:"not null pk default 0 INT(11)"` + Uid int `json:"uid" xorm:"default 0 INT(11)"` + Type string `json:"type" xorm:"default '0' VARCHAR(255)"` + Extra string `json:"extra" xorm:"comment('api请求头内容') TEXT"` + Content string `json:"content" xorm:"comment('问题内容') VARCHAR(5000)"` + Img string `json:"img" xorm:"comment('图片 [""]') VARCHAR(5000)"` + Idea string `json:"idea" xorm:"comment('建议') VARCHAR(5000)"` + Phone string `json:"phone" xorm:"VARCHAR(255)"` + State int `json:"state" xorm:"default 0 comment('0待解决 1处理中 2已解决') INT(1)"` +} diff --git a/src/model/user_feedback_cate.go b/src/model/user_feedback_cate.go new file mode 100644 index 0000000..ff200cd --- /dev/null +++ b/src/model/user_feedback_cate.go @@ -0,0 +1,7 @@ +package model + +type UserFeedbackCate struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Name string `json:"name" xorm:"VARCHAR(255)"` + Sort int `json:"sort" xorm:"default 0 INT(11)"` +} diff --git a/src/model/user_feedback_record.go b/src/model/user_feedback_record.go new file mode 100644 index 0000000..dce4519 --- /dev/null +++ b/src/model/user_feedback_record.go @@ -0,0 +1,13 @@ +package model + +import ( + "time" +) + +type UserFeedbackRecord struct { + Id int `json:"id" xorm:"not null pk autoincr INT(11)"` + Lid int `json:"lid" xorm:"comment('反馈列表id') INT(11)"` + Content string `json:"content" xorm:"VARCHAR(255)"` + Uid int `json:"uid" xorm:"default 0 INT(11)"` + CreateAt time.Time `json:"create_at" xorm:"DATETIME"` +}