advisory_admin_fllow_chart.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package advisory
  2. import (
  3. "fmt"
  4. "github.com/beego/beego/v2/client/orm"
  5. "time"
  6. )
  7. type PublishChart struct {
  8. ChartIds string `description:"分类id,多个用英文逗号隔开"`
  9. }
  10. type PublishReq struct {
  11. ReportIds string `description:"报告id,多个用英文逗号隔开"`
  12. }
  13. type AdvisoryAdminFllowChart struct {
  14. Id int `orm:"column(advisory_fllow_id);pk"`
  15. //AdvisoryFllowId int `description:"主键id"`
  16. AdvisoryAdminUserId int `description:"用户id"`
  17. ChartPermissionId string `description:"分类id"`
  18. CreatedTime time.Time `description:"创建时间"`
  19. LastUpdatedTime time.Time `description:"修改时间"`
  20. }
  21. type AdvisoryAdminFllowChartList struct {
  22. List []*AdvisoryAdminFllowChart
  23. }
  24. //检查用户是否关注过分类
  25. func ChckeAdminUserIsFllow(Uid int) (isFllow bool) {
  26. fllowInfo, _ := GetUserFllowInfo(Uid)
  27. if fllowInfo.AdvisoryAdminUserId > 0 {
  28. return false
  29. } else {
  30. return true
  31. }
  32. }
  33. func GetUserFllowInfo(Uid int) (items *AdvisoryAdminFllowChart, err error) {
  34. o := orm.NewOrm()
  35. //o.Using("rddp")
  36. sql := `SELECT * FROM advisory_admin_fllow_chart WHERE advisory_admin_user_id=? LIMIT 1`
  37. err = o.Raw(sql, Uid).QueryRow(&items)
  38. return
  39. }
  40. //添加用户关注
  41. func AddAdminUserFllow(item *AdvisoryAdminFllowChart) (err error) {
  42. o := orm.NewOrm()
  43. _, err = o.Insert(item)
  44. return
  45. }
  46. func GetUserFllowListByIds(Ids string) (items []*AdvisoryAdminFllowChartList, err error) {
  47. o := orm.NewOrm()
  48. sql := `SELECT * FROM chart_permission WHERE chart_permission_id IN (` + Ids + `)`
  49. fmt.Println(sql)
  50. err = o.Raw(sql).QueryRow(&items)
  51. return
  52. }
  53. //修改选择的分类
  54. func UpdateAdminUserFllow(item *AdvisoryAdminFllowChart) (err error) {
  55. o := orm.NewOrm()
  56. sql := " UPDATE advisory_admin_fllow_chart SET chart_permission_id = ? WHERE advisory_admin_user_id = ? "
  57. o.Raw(sql, item.ChartPermissionId, item.AdvisoryAdminUserId).Exec()
  58. return
  59. }