help_doc.go 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. package help_doc
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type HelpDoc struct {
  7. Id int `orm:"column(id);pk"`
  8. ClassifyId int // 分类id
  9. ClassifyName string // 分类名称
  10. Title string // 标题
  11. Author string // 作者
  12. CreateTime time.Time // 创建时间
  13. ModifyTime time.Time // 修改时间
  14. Status int // 1:未发布,2:已发布
  15. PublishTime time.Time // 发布时间
  16. Content string // 内容
  17. AdminId int // 创建人
  18. AdminRealName string // 创建人姓名
  19. }
  20. func EditHelpDocClassifyId(classifyId int, classifyName string) (err error) {
  21. o := orm.NewOrm()
  22. sql := `UPDATE help_doc SET classify_name=?,modify_time=NOW() WHERE classify_id=? `
  23. _, err = o.Raw(sql, classifyId, classifyName).Exec()
  24. return
  25. }
  26. type AddHelpDocReq struct {
  27. ClassifyId int `description:"一级分类id"`
  28. ClassifyName string `description:"一级分类名称"`
  29. Title string `description:"标题"`
  30. Author string `description:"作者"`
  31. Status int `description:"状态:1:未发布,2:已发布"`
  32. Content string `description:"内容"`
  33. }
  34. func AddHelpDoc(item *HelpDoc) (lastId int64, err error) {
  35. o := orm.NewOrm()
  36. lastId, err = o.Insert(item)
  37. return
  38. }
  39. type EditHelpDocReq struct {
  40. Id int64 `description:"文章id"`
  41. ClassifyId int `description:"分类id"`
  42. ClassifyName string `description:"分类名称"`
  43. Title string `description:"标题"`
  44. Abstract string `description:"摘要"`
  45. Author string `description:"作者"`
  46. Frequency string `description:"频度"`
  47. State int `description:"状态:1:未发布,2:已发布"`
  48. Content string `description:"内容"`
  49. CreateTime string `description:"创建时间"`
  50. Overview string `description:"英文概述部分"`
  51. }
  52. //func EditHelpDoc(item *HelpDoc, reportId int64) (err error) {
  53. // o := orm.NewOrmUsingDB("rddp")
  54. // sql := `UPDATE help_doc
  55. // SET
  56. // classify_id =?,
  57. // classify_name_first = ?,
  58. // classify_id_second = ?,
  59. // classify_name_second = ?,
  60. // title = ?,
  61. // abstract = ?,
  62. // author = ?,
  63. // frequency = ?,
  64. // state = ?,
  65. // content = ?,
  66. // content_sub = ?,
  67. // stage =?,
  68. // create_time = ?,
  69. // modify_time = ?,
  70. // overview = ?
  71. // WHERE id = ? `
  72. // _, err = o.Raw(sql, item.ClassifyIdFirst, item.ClassifyNameFirst, item.ClassifyIdSecond, item.ClassifyNameSecond, item.Title,
  73. // item.Abstract, item.Author, item.Frequency, item.State, item.Content, item.ContentSub, item.Stage, item.CreateTime, time.Now(), item.Overview, reportId).Exec()
  74. // return
  75. //}