rs_calendar_meeting_label_group.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. package roadshow
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "hongze/hz_crm_api/utils"
  5. "time"
  6. )
  7. type RsCalendarMeetingLabelGroup struct {
  8. LabelId int `orm:"column(label_id);pk" description:"主键ID"`
  9. RsCalendarId int `description:"路演ID"`
  10. CreateTime time.Time `description:"创建时间"`
  11. ModifyTime time.Time `description:"修改时间"`
  12. AdminId int `description:"管理员ID"`
  13. AdminName string `description:"管理员姓名"`
  14. TagType int `description:"标签类型,1产业,2标的,3行业权限"`
  15. TagId int `description:"标签ID"`
  16. }
  17. // 新增
  18. func AddRsCalendarMeetingLabelGroup(item *RsCalendarMeetingLabelGroup) (err error) {
  19. o := orm.NewOrm()
  20. _, err = o.Insert(item)
  21. return
  22. }
  23. // AddRsCalendarMeetingLabelGroupMulti 批量添加
  24. func AddRsCalendarMeetingLabelGroupMulti(items []*RsCalendarMeetingLabelGroup, rsCalendarId int) (err error) {
  25. o, err := orm.NewOrm().Begin()
  26. if err != nil {
  27. return
  28. }
  29. defer func() {
  30. if err == nil {
  31. o.Commit()
  32. } else {
  33. o.Rollback()
  34. }
  35. }()
  36. //删除历史记录
  37. sql := " DELETE FROM rs_calendar_meeting_label_group WHERE rs_calendar_id = ? "
  38. _, err = o.Raw(sql, rsCalendarId).Exec()
  39. if err != nil {
  40. return
  41. }
  42. if len(items) > 0 {
  43. _, err = o.InsertMulti(len(items), items)
  44. if err != nil {
  45. return
  46. }
  47. }
  48. //批量插入
  49. return
  50. }
  51. // 获取数量
  52. func GetRsCalendarMeetingLabelGroupByRsCalendarId(rsCalendarId int) (count int, err error) {
  53. o := orm.NewOrm()
  54. sqlCount := ` SELECT COUNT(1) AS count FROM rs_calendar_meeting_label_group WHERE rs_calendar_id = ?`
  55. err = o.Raw(sqlCount, rsCalendarId).QueryRow(&count)
  56. return
  57. }
  58. // 获取详情
  59. func GetRsCalendarMeetingLabelGroupDetailByRsCalendarId(rsCalendarId int) (item *RsCalendarMeetingLabelGroup, err error) {
  60. o := orm.NewOrm()
  61. sql := ` SELECT * FROM rs_calendar_meeting_label_group WHERE rs_calendar_id = ? `
  62. err = o.Raw(sql, rsCalendarId).QueryRow(&item)
  63. return
  64. }
  65. // 根据多个路演ID获取研信息
  66. func GetRsCalendarMeetingLabelGroupListByRsCalendarId(rsCalendarId int) (item []*RsCalendarMeetingLabelGroup, err error) {
  67. o := orm.NewOrm()
  68. sql := `SELECT * FROM rs_calendar_meeting_label_group WHERE rs_calendar_id = ? `
  69. _, err = o.Raw(sql, rsCalendarId).QueryRows(&item)
  70. return
  71. }
  72. // 根据多个路演ID获取研信息
  73. func GetRsCalendarMeetingLabelGroupDetailByRsCalendarIds(rsCalendarIds []int) (item []*RsCalendarMeetingLabelGroup, err error) {
  74. if len(rsCalendarIds) == 0 {
  75. return
  76. }
  77. o := orm.NewOrm()
  78. sql := `SELECT * FROM rs_calendar_meeting_label_group WHERE rs_calendar_id IN (` + utils.GetOrmInReplace(len(rsCalendarIds)) + `) `
  79. _, err = o.Raw(sql, rsCalendarIds).QueryRows(&item)
  80. return
  81. }
  82. // 修改
  83. func UpdateProductInterior(item *RsCalendarMeetingLabelGroup) (err error) {
  84. o := orm.NewOrm()
  85. updateParams := make(map[string]interface{})
  86. updateParams["AdminId"] = item.AdminId
  87. updateParams["AdminName"] = item.AdminName
  88. updateParams["TagType"] = item.TagType
  89. updateParams["TagId"] = item.TagId
  90. updateParams["ModifyTime"] = item.ModifyTime
  91. ptrStructOrTableName := "rs_calendar_meeting_label_group"
  92. whereParam := map[string]interface{}{"rs_calendar_id": item.RsCalendarId}
  93. qs := o.QueryTable(ptrStructOrTableName)
  94. for expr, exprV := range whereParam {
  95. qs = qs.Filter(expr, exprV)
  96. }
  97. _, err = qs.Update(updateParams)
  98. return
  99. }
  100. // 根据类型、id 获取对应的分组信息
  101. func GetRsCalendarMeetingLabelGroupDetailByTag(tagType, tagId int) (item []*RsCalendarMeetingLabelGroup, err error) {
  102. o := orm.NewOrm()
  103. sql := `SELECT * FROM rs_calendar_meeting_label_group WHERE tag_type = ? AND tag_id = ? `
  104. _, err = o.Raw(sql, tagType, tagId).QueryRows(&item)
  105. return
  106. }
  107. // 根据类型、id 获取对应的分组信息
  108. func GetRsCalendarMeetingLabelGroupDetailByTagIds(tagType int, tagIds []int) (item []*RsCalendarMeetingLabelGroup, err error) {
  109. lenArr := len(tagIds)
  110. if lenArr == 0 {
  111. return
  112. }
  113. o := orm.NewOrm()
  114. sql := `SELECT * FROM rs_calendar_meeting_label_group WHERE tag_type = ? AND tag_id IN (` + utils.GetOrmInReplace(lenArr) + `) `
  115. _, err = o.Raw(sql, tagType, tagIds).QueryRows(&item)
  116. return
  117. }