report_mapping_cygx.go 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. package cygx
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  4. "time"
  5. )
  6. // 查研观向报告匹配类型
  7. type CygxReportMappingCygx struct {
  8. Id int `orm:"column(id);pk" description:"id"`
  9. ChartPermissionId int `description:"行业ID"`
  10. ChartPermissionName string `description:"行业名称"`
  11. MatchTypeName string `description:"分类名称"`
  12. ReportType int `description:"报告类型,2产业报告,1行业报告"`
  13. Sort int `description:"排序"`
  14. IsCustom int `description:"是否属于自定义的匹配类型 ,1是,0否"`
  15. IsSummary int `description:"是否是纪要库,1是,0否"`
  16. IsReport int `description:"是否是报告,1是,0否"`
  17. PermissionType int `description:"1主观,2客观"`
  18. CreateTime time.Time `description:"创建时间"`
  19. ModifyTime time.Time `description:"更新时间"`
  20. }
  21. type CygxCygxReportMappingCygxResp struct {
  22. List []*CygxReportMappingCygx
  23. }
  24. // 报告归类入参
  25. type CygxReportMappingCygxAdd struct {
  26. ReportType int `description:"报告类型,2产业报告,1行业报告"`
  27. ChartPermissionId int `description:"行业ID"`
  28. ChartPermissionName string `description:"行业名称"`
  29. MatchTypeName string `description:"分类名称"`
  30. }
  31. // 列表
  32. func GetCygxReportMappingCygxList(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxReportMappingCygx, err error) {
  33. o := orm.NewOrm()
  34. sql := `SELECT * FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
  35. if condition != "" {
  36. sql += condition
  37. }
  38. if pageSize > 0 {
  39. sql += ` LIMIT ?,? `
  40. _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
  41. } else {
  42. _, err = o.Raw(sql, pars).QueryRows(&items)
  43. }
  44. return
  45. }
  46. // 获取数量
  47. func GetCygxReportMappingCygxCount(condition string, pars []interface{}) (count int, err error) {
  48. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
  49. if condition != "" {
  50. sqlCount += condition
  51. }
  52. o := orm.NewOrm()
  53. err = o.Raw(sqlCount, pars).QueryRow(&count)
  54. return
  55. }
  56. // 添加
  57. func AddCygxReportMappingCygx(itemCygx *CygxReportMappingCygx, itemCelue *CygxReportMappingCelue) (itemCygxId int64, err error) {
  58. o := orm.NewOrm()
  59. to, err := o.Begin()
  60. if err != nil {
  61. return
  62. }
  63. defer func() {
  64. if err != nil {
  65. _ = to.Rollback()
  66. } else {
  67. _ = to.Commit()
  68. }
  69. }()
  70. itemCygxId, err = to.Insert(itemCygx)
  71. if err != nil {
  72. return
  73. }
  74. _, err = to.Insert(itemCelue)
  75. if err != nil {
  76. return
  77. }
  78. item := new(CygxReportMappingGroup)
  79. item.IdCygx = int(itemCygxId)
  80. item.CategoryIdCelue = itemCelue.CategoryId
  81. item.ModifyTime = time.Now()
  82. item.CreateTime = time.Now()
  83. _, err = to.Insert(item)
  84. return
  85. }
  86. // 通过ID获取详情
  87. func GetCygxReportMappingCygxDetail(Id int) (item *CygxReportMappingCygx, err error) {
  88. o := orm.NewOrm()
  89. sql := `SELECT * FROM cygx_report_mapping_cygx WHERE id=? `
  90. err = o.Raw(sql, Id).QueryRow(&item)
  91. return
  92. }
  93. // 通过ID获取详情
  94. func GetCygxReportMappingCygxDetailByName(name string) (item *CygxReportMappingCygx, err error) {
  95. o := orm.NewOrm()
  96. sql := `SELECT * FROM cygx_report_mapping_cygx WHERE match_type_name=? LIMIT 1 `
  97. err = o.Raw(sql, name).QueryRow(&item)
  98. return
  99. }