report_mapping_cygx.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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.NewOrmUsingDB("hz_cygx")
  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 GetCygxReportMappingCygxByCon(condition string, pars []interface{}) (items []*CygxReportMappingCygx, err error) {
  48. o := orm.NewOrmUsingDB("hz_cygx")
  49. sql := `SELECT * FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
  50. if condition != "" {
  51. sql += condition
  52. }
  53. _, err = o.Raw(sql, pars).QueryRows(&items)
  54. return
  55. }
  56. // 获取数量
  57. func GetCygxReportMappingCygxCount(condition string, pars []interface{}) (count int, err error) {
  58. sqlCount := ` SELECT COUNT(1) AS count FROM cygx_report_mapping_cygx as art WHERE 1= 1 `
  59. if condition != "" {
  60. sqlCount += condition
  61. }
  62. o := orm.NewOrmUsingDB("hz_cygx")
  63. err = o.Raw(sqlCount, pars).QueryRow(&count)
  64. return
  65. }
  66. // 添加
  67. func AddCygxReportMappingCygx(itemCygx *CygxReportMappingCygx, itemCelue *CygxReportMappingCelue) (itemCygxId int64, err error) {
  68. o := orm.NewOrmUsingDB("hz_cygx")
  69. to, err := o.Begin()
  70. if err != nil {
  71. return
  72. }
  73. defer func() {
  74. if err != nil {
  75. _ = to.Rollback()
  76. } else {
  77. _ = to.Commit()
  78. }
  79. }()
  80. itemCygxId, err = to.Insert(itemCygx)
  81. if err != nil {
  82. return
  83. }
  84. _, err = to.Insert(itemCelue)
  85. if err != nil {
  86. return
  87. }
  88. item := new(CygxReportMappingGroup)
  89. item.IdCygx = int(itemCygxId)
  90. item.CategoryIdCelue = itemCelue.CategoryId
  91. item.ModifyTime = time.Now()
  92. item.CreateTime = time.Now()
  93. _, err = to.Insert(item)
  94. return
  95. }
  96. // 通过ID获取详情
  97. func GetCygxReportMappingCygxDetail(Id int) (item *CygxReportMappingCygx, err error) {
  98. o := orm.NewOrmUsingDB("hz_cygx")
  99. sql := `SELECT * FROM cygx_report_mapping_cygx WHERE id=? `
  100. err = o.Raw(sql, Id).QueryRow(&item)
  101. return
  102. }
  103. // 通过ID获取详情
  104. func GetCygxReportMappingCygxDetailByName(name string) (item *CygxReportMappingCygx, err error) {
  105. o := orm.NewOrmUsingDB("hz_cygx")
  106. sql := `SELECT * FROM cygx_report_mapping_cygx WHERE match_type_name=? LIMIT 1 `
  107. err = o.Raw(sql, name).QueryRow(&item)
  108. return
  109. }
  110. // 通过ID获取详情
  111. func GetCygxReportMappingCygxDetailByNameAndChartPermissionId(name string, chartPermissionId int) (item *CygxReportMappingCygx, err error) {
  112. o := orm.NewOrmUsingDB("hz_cygx")
  113. sql := `SELECT * FROM cygx_report_mapping_cygx WHERE match_type_name=? AND chart_permission_id = ? LIMIT 1 `
  114. err = o.Raw(sql, name, chartPermissionId).QueryRow(&item)
  115. return
  116. }