article_department.go 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package models
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. type CygxArticleDepartment struct {
  7. DepartmentId int `orm:"column(department_id);pk;主键ID"`
  8. CreateTime time.Time `description:"创建时间"`
  9. NickName string `description:"昵称"`
  10. Remark string `description:"备注"`
  11. Remarks string `description:"备注辅助字段"`
  12. Content string `description:"初始内容"`
  13. }
  14. type DepartmentResp struct {
  15. DepartmentId int `description:"作者ID"`
  16. CreateTime string `description:"创建时间"`
  17. NickName string `description:"昵称"`
  18. ImgUrl string `description:"头像链接"`
  19. IsFollow bool `description:"是否关注"`
  20. }
  21. type CygxArticleDepartmentId struct {
  22. DepartmentId int `description:"作者ID"`
  23. }
  24. func GetArticleDepartmentDateilById(departmentId int) (item *DepartmentResp, err error) {
  25. o := orm.NewOrm()
  26. sql := `SELECT * FROM cygx_article_department WHERE department_id = ? `
  27. err = o.Raw(sql, departmentId).QueryRow(&item)
  28. return
  29. }
  30. //数量
  31. func GetArticleDepartmentCount(condition string) (count int, err error) {
  32. o := orm.NewOrm()
  33. sql := ` SELECT COUNT(*) count
  34. FROM
  35. ( SELECT COUNT(1) FROM cygx_article_department AS d
  36. INNER JOIN cygx_article AS a ON a.department_id = d.department_id
  37. INNER JOIN cygx_industrial_article_group_management AS mg ON mg.article_id = a.article_id
  38. INNER JOIN cygx_industrial_management AS m ON m.industrial_management_id = mg.industrial_management_id WHERE 1= 1 `
  39. if condition != "" {
  40. sql += condition
  41. }
  42. sql += ` GROUP BY d.department_id ) AS num `
  43. err = o.Raw(sql).QueryRow(&count)
  44. return
  45. }
  46. type IndustrialSubjectList struct {
  47. SubjectName string `description:"标的名称"`
  48. }