|
|
@@ -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 |
|
|
|
} |