cygx_yanxuan_special.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxYanxuanSpecial struct {
  7. Id int `orm:"column(id);pk"`
  8. UserId int // 用户ID
  9. CreateTime time.Time // 创建时间
  10. ModifyTime time.Time // 修改时间
  11. PublishTime time.Time // 提审过审或驳回时间
  12. Content string // 内容
  13. Tags string // 标签
  14. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  15. ImgUrl string // 图片链接
  16. DocUrl string // 文档链接
  17. Reason string // 理由
  18. Title string // 标题
  19. Type string // 类型1:笔记,2:观点
  20. }
  21. type CygxYanxuanSpeciaResplItem struct {
  22. Id int `orm:"column(id);pk"`
  23. UserId int // 用户ID
  24. CreateTime string // 创建时间
  25. ModifyTime string // 修改时间
  26. PublishTime string // 提审过审或驳回时间
  27. Content string // 内容
  28. Tags string // 标签
  29. Status int // 1:未发布,2:审核中 3:已发布 4:驳回
  30. ImgUrl string // 图片链接
  31. DocUrl string // 文档链接
  32. SpecialName string // 专栏名称
  33. Introduction string // 介绍
  34. Label string // 标签
  35. NickName string // 昵称
  36. RealName string // 姓名
  37. Mobile string // 手机号
  38. HeadImg string // 头像
  39. BgImg string // 背景图
  40. Reason string // 理由
  41. Title string // 标题
  42. CompanyTags string
  43. IndustryTags string
  44. Type int // 类型1:笔记,2:观点
  45. ContentHasImg int //正文是否包含图片 1包含 0不包含
  46. Docs []Doc
  47. }
  48. type Doc struct {
  49. DocName string
  50. DocSuffix string
  51. DocUrl string
  52. DocIcon string
  53. }
  54. func GetYanxuanSpecialList(condition string, pars []interface{}) (items []*CygxYanxuanSpeciaResplItem, err error) {
  55. o := orm.NewOrm()
  56. sql := ``
  57. sql = `SELECT a.*,b.bg_img,b.head_img,b.introduction,b.label,b.mobile,b.nick_name,b.real_name,b.special_name
  58. FROM cygx_yanxuan_special AS a
  59. JOIN cygx_yanxuan_special_author AS b ON a.user_id = b.user_id
  60. WHERE 1=1 `
  61. if condition != "" {
  62. sql += condition
  63. }
  64. sql += `ORDER BY a.publish_time `
  65. _, err = o.Raw(sql, pars).QueryRows(&items)
  66. return
  67. }
  68. type EnableCygxYanxuanSpecialReq struct {
  69. Id int // 文章id
  70. Status int // 1通过2驳回
  71. Reason string //理由
  72. }
  73. func EnableYanxuanSpecial(id, status int, reason string) (err error) {
  74. o := orm.NewOrm()
  75. sql := ``
  76. sql = `UPDATE cygx_yanxuan_special SET status=?,reason=?,publish_time=NOW() WHERE id = ? `
  77. _, err = o.Raw(sql, status, reason, id).Exec()
  78. return
  79. }