123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "github.com/rdlucklib/rdluck_tools/paging"
- "hongze/hongze_web_mfyx/utils"
- "time"
- )
- type CygxYanxuanSpecialMessage struct {
- MessageId int `orm:"column(message_id);pk"`
- UserId int `comment:"用户ID"`
- Mobile string `comment:"手机号"`
- Email string `comment:"邮箱"`
- CompanyId int `comment:"公司ID"`
- CompanyName string `comment:"公司名称"`
- RealName string `comment:"用户实际名称"`
- SellerName string `comment:"所属销售"`
- RegisterPlatform int `comment:"来源 1小程序,2:网页,5买方研选小程序,6:买方研选网页版"`
- YanxuanSpecialId int `comment:"cygx_yanxuan_special 表主键ID"`
- Content string `comment:"留言内容"`
- PublicTime time.Time `comment:"公开时间"`
- Status int `comment:"消息状态,0未公开、1:已公开"`
- TopTime int `comment:"置顶时间"`
- LikeCount int `comment:"点赞数量"`
- ParentId int `comment:"父级ID"`
- YanxuanSpecialUserId int `comment:"研选专栏作者对应的用户ID"`
- SourceTitle string `comment:"标题"`
- CreateTime time.Time `comment:"创建时间"`
- ModifyTime time.Time `comment:"修改时间"`
- }
- type AddCygxYanxuanSpecialMessageReq struct {
- YanxuanSpecialId int `comment:"cygx_yanxuan_special 表主键ID"`
- Content string `comment:"留言内容"`
- ParentId int `comment:"父级ID"`
- }
- type DeleteCygxYanxuanSpecialMessageReq struct {
- MessageId int `comment:"留言消息ID"`
- }
- type PubliceCygxYanxuanSpecialMessageReq struct {
- MessageIds []int `comment:"留言消息ID"`
- DoType int `comment:"0取消置顶,1置顶"`
- }
- type TopCygxYanxuanSpecialMessageReq struct {
- MessageId int `comment:"留言消息ID"`
- DoType int `comment:"0取消置顶,1置顶"`
- }
- // 新增
- func AddCygxYanxuanSpecialMessage(item *CygxYanxuanSpecialMessage) (newId int64, err error) {
- o := orm.NewOrm()
- newId, err = o.Insert(item)
- return
- }
- // 删除(软删除)
- func DeleteCygxYanxuanSpecialMessage(messageId int) (err error) {
- o := orm.NewOrm()
- //sql := `DELETE FROM cygx_yanxuan_special_message WHERE message_id = ? `
- sql := `UPDATE cygx_yanxuan_special_message SET status = -1 WHERE message_id = ? `
- _, err = o.Raw(sql, messageId).Exec()
- return
- }
- // 更新置顶时间
- func UpdateCygxYanxuanSpecialMessageTopTime(topTime, messageId int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_message SET top_time = ? WHERE message_id = ? `
- _, err = o.Raw(sql, topTime, messageId).Exec()
- return
- }
- // 更新是否公开
- func UpdateCygxYanxuanSpecialMessageStatus(status int, publicTime string, messageIds []int) (err error) {
- o := orm.NewOrm()
- sql := ``
- sql = `UPDATE cygx_yanxuan_special_message SET top_time = 0 , status = ? ,public_time = ? WHERE message_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `) OR ( parent_id IN (` + utils.GetOrmInReplace(len(messageIds)) + `) AND status != -1 ) `
- _, err = o.Raw(sql, status, publicTime, messageIds, messageIds).Exec()
- return
- }
- func GetCygxYanxuanSpecialMessageList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxYanxuanSpecialMessage, err error) {
- o := orm.NewOrm()
- sql := `SELECT *
- FROM
- cygx_yanxuan_special_message
- WHERE 1 = 1 ` + condition
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- return
- }
- // 根据id获取详情
- func GetCygxYanxuanSpecialMessagerDetailById(messageId int) (item *CygxYanxuanSpecialMessage, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM cygx_yanxuan_special_message WHERE message_id = ? `
- err = o.Raw(sql, messageId).QueryRow(&item)
- return
- }
- // 获取置顶留言数量数量
- func GetCygxYanxuanSpecialMessagerCountTop(yanxuanSpecialId int) (count int, err error) {
- o := orm.NewOrm()
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_message WHERE top_time > 0 AND yanxuan_special_id = ? `
- err = o.Raw(sqlCount, yanxuanSpecialId).QueryRow(&count)
- return
- }
- // 获取数量
- func GetCygxYanxuanSpecialMessagerCount(condition string, pars []interface{}) (count int, err error) {
- o := orm.NewOrm()
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_message WHERE 1= 1 ` + condition
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 获取留言公开数量
- func GetCygxYanxuanSpecialMessagerPublicCount(yanxuanSpecialId int) (count int, err error) {
- o := orm.NewOrm()
- sqlCount := ` SELECT COUNT(1) AS count FROM cygx_yanxuan_special_message WHERE status = 1 AND yanxuan_special_id = ? `
- err = o.Raw(sqlCount, yanxuanSpecialId).QueryRow(&count)
- return
- }
- type CygxYanxuanSpecialMessageManageResp struct {
- MessageId int `comment:"留言消息ID"`
- RealName string `comment:"用户实际名称"`
- Headimgurl string `comment:"用户头像"`
- YanxuanSpecialId int `comment:"研选专栏文章ID"`
- Content string `comment:"留言内容"`
- Status int `comment:"消息状态,0未公开、1:已公开"`
- TopTime int `comment:"置顶时间(大于零置顶,等于零未置顶)"`
- HaveOtherTop bool `comment:"是否有其它的置顶"`
- SourceTitle string `comment:"专栏标题"`
- CreateTime string `comment:"创建时间"`
- LikeCount int `comment:"点赞数量"`
- IsLikeCount bool `comment:"是否点赞"`
- IsMySelf bool `comment:"是否属于本人留言"`
- CheckIds []int `comment:"空数组前端渲染使用"`
- ChildList []*CygxYanxuanSpecialMessageManageChildResp // 留言子集
- }
- type CygxYanxuanSpecialMessageManageChildResp struct {
- UserId int `comment:"用户ID"`
- MessageId int `comment:"留言消息ID"`
- Content string `comment:"留言内容"`
- Headimgurl string `comment:"用户头像"`
- LikeCount int `comment:"点赞数量"`
- IsLikeCount bool `comment:"是否点赞"`
- CreateTime string `comment:"创建时间"`
- }
- type YanxuanSpecialMessageManageRespListResp struct {
- PublicMessageTotal int `comment:"公开留言数量"`
- Paging *paging.PagingItem `description:"分页数据"`
- List []*CygxYanxuanSpecialMessageManageResp
- }
|