my_chart.go 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017
  1. package data_manage
  2. import (
  3. "eta/eta_api/global"
  4. "eta/eta_api/utils"
  5. "fmt"
  6. "github.com/rdlucklib/rdluck_tools/paging"
  7. "time"
  8. )
  9. type ChartListResp struct {
  10. Paging *paging.PagingItem
  11. List []*ChartInfoView
  12. }
  13. func GetChartListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*ChartInfoView, err error) {
  14. o := global.DbMap[utils.DbNameIndex]
  15. sql := ` SELECT * FROM chart_info WHERE 1=1 `
  16. if condition != "" {
  17. sql += condition
  18. }
  19. //sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
  20. sql += " ORDER BY create_time DESC LIMIT ?,? "
  21. pars = append(pars, startSize, pageSize)
  22. err = o.Raw(sql, pars...).Find(&item).Error
  23. return
  24. }
  25. func GetChartListCountByCondition(condition string, pars []interface{}) (count int, err error) {
  26. o := global.DbMap[utils.DbNameIndex]
  27. sql := ` SELECT COUNT(1) AS count FROM chart_info WHERE 1=1 `
  28. if condition != "" {
  29. sql += condition
  30. }
  31. err = o.Raw(sql, pars...).Scan(&count).Error
  32. return
  33. }
  34. type MyChartClassify struct {
  35. MyChartClassifyId int `orm:"column(my_chart_classify_id);pk" gorm:"primaryKey"`
  36. MyChartClassifyName string
  37. Sort int `json:"-" description:"排序字段,值越小,排的越靠前"`
  38. AdminId int `description:"创建人id"`
  39. IsPublic int `description:"是否公共分类"`
  40. IsCompanyPublic int `description:"是否为用户公共分类"`
  41. CreateTime time.Time `json:"-"`
  42. ModifyTime time.Time `json:"-"`
  43. PublicTime time.Time `json:"-" description:"公开(分享)时间"`
  44. CompanyPublicTime time.Time `json:"-" description:"用户可见公开时间"`
  45. }
  46. func AddMyChartClassify(item *MyChartClassify) (err error) {
  47. o := global.DbMap[utils.DbNameIndex]
  48. err = o.Create(item).Error
  49. return
  50. }
  51. func GetMyChartClassifyAll(adminId int) (item []*MyChartClassify, err error) {
  52. o := global.DbMap[utils.DbNameIndex]
  53. sql := ` SELECT * FROM my_chart_classify WHERE 1=1 AND admin_id=? `
  54. sql += " ORDER BY sort asc, my_chart_classify_id asc "
  55. err = o.Raw(sql, adminId).Find(&item).Error
  56. return
  57. }
  58. func GetPublicChartClassifyAllExceptMy(adminId int) (item []*MyChartClassify, err error) {
  59. o := global.DbMap[utils.DbNameIndex]
  60. sql := ` SELECT * FROM my_chart_classify WHERE 1=1 AND is_public=1 AND admin_id !=?`
  61. sql += " ORDER BY public_time asc"
  62. err = o.Raw(sql, adminId).Find(&item).Error
  63. return
  64. }
  65. type MyChartClassifyResp struct {
  66. List []*MyChartClassifyItem
  67. Language string `description:"指标的展示语言,CN:中文,EN:英文"`
  68. }
  69. // PublicChartClassifyResp 公共分类返回数据结构体
  70. type PublicChartClassifyResp struct {
  71. List []PublicChartClassifyList
  72. Language string `description:"指标的展示语言,CN:中文,EN:英文"`
  73. }
  74. // PublicChartClassifyItem 公共分类结构体
  75. type PublicChartClassifyItem struct {
  76. MyChartClassifyId int `description:"分类id"`
  77. MyChartClassifyName string `description:"分类名称"`
  78. AdminId int `description:"创建人id"`
  79. RealName string `description:"创建人名称"`
  80. IsPublic int `description:"是否公共分类"`
  81. IsCompanyPublic int `description:"是否为客户可见"`
  82. }
  83. // PublicChartClassifyList 公共分类结构体
  84. type PublicChartClassifyList struct {
  85. MenuAdminId int `description:"目录创建人ID"`
  86. MenuName string `description:"目录名称"`
  87. Items []PublicChartClassifyItem `description:"分类数据"`
  88. }
  89. type MyChartClassifyAddReq struct {
  90. MyChartClassifyName string `description:"分类名称"`
  91. }
  92. func GetMyChartClassifyCountByCondition(condition string, pars []interface{}) (count int, err error) {
  93. o := global.DbMap[utils.DbNameIndex]
  94. sql := ` SELECT COUNT(1) AS count FROM my_chart_classify WHERE 1=1 `
  95. if condition != "" {
  96. sql += condition
  97. }
  98. err = o.Raw(sql, pars...).Scan(&count).Error
  99. return
  100. }
  101. func GetMyChartClassifyById(adminId, myChartClassifyId int) (item *MyChartClassify, err error) {
  102. o := global.DbMap[utils.DbNameIndex]
  103. sql := ` SELECT * FROM my_chart_classify WHERE admin_id=? AND my_chart_classify_id=? `
  104. err = o.Raw(sql, adminId, myChartClassifyId).Find(&item).Error
  105. return
  106. }
  107. // GetMyChartClassifyMastSort 获取MY ETA 分类中排序最大的值
  108. func GetMyChartClassifyMastSort(adminId int) (sort int, err error) {
  109. o := global.DbMap[utils.DbNameIndex]
  110. sql := ` SELECT MAX(sort) sort FROM my_chart_classify WHERE admin_id=? `
  111. err = o.Raw(sql, adminId).Scan(&sort).Error
  112. return
  113. }
  114. // GetMyChartClassifyMinSort 获取MY ETA 分类中排序最小的值
  115. func GetMyChartClassifyMinSort(adminId int) (sort int, err error) {
  116. o := global.DbMap[utils.DbNameIndex]
  117. sql := ` SELECT MIN(sort) sort FROM my_chart_classify WHERE admin_id=? `
  118. err = o.Raw(sql, adminId).Scan(&sort).Error
  119. return
  120. }
  121. type MyChartClassifyEditReq struct {
  122. MyChartClassifyId int `description:"分类ID"`
  123. MyChartClassifyName string `description:"分类名称"`
  124. }
  125. // MyChartClassifyMoveReq 移动分类请求参数
  126. type MyChartClassifyMoveReq struct {
  127. MyChartClassifyId int `description:"分类id"`
  128. PrevClassifyId int `description:"上一个兄弟节点分类id"`
  129. NextClassifyId int `description:"下一个兄弟节点分类id"`
  130. }
  131. func ModifyMyChartClassify(myChartClassifyId int, myChartClassifyName string) (err error) {
  132. o := global.DbMap[utils.DbNameIndex]
  133. sql := `UPDATE my_chart_classify SET my_chart_classify_name=?,modify_time=NOW() WHERE my_chart_classify_id=?`
  134. err = o.Exec(sql, myChartClassifyName, myChartClassifyId).Error
  135. return
  136. }
  137. type MyChartClassifyDeleteReq struct {
  138. MyChartClassifyId int `description:"分类ID"`
  139. }
  140. func DeleteMyChartClassify(myChartClassifyId int) (err error) {
  141. o := global.DbMap[utils.DbNameIndex]
  142. //o.Begin()
  143. //
  144. //defer func() {
  145. // if err != nil {
  146. // o.Rollback()
  147. // } else {
  148. // o.Commit()
  149. // }
  150. //}()
  151. sql := `DELETE FROM my_chart_classify WHERE my_chart_classify_id=?`
  152. err = o.Exec(sql, myChartClassifyId).Error
  153. if err != nil {
  154. return err
  155. }
  156. mappingList := make([]*MyChartClassifyMapping, 0)
  157. sql = `SELECT * FROM my_chart_classify_mapping WHERE my_chart_classify_id=?`
  158. err = o.Raw(sql, myChartClassifyId).Find(&mappingList).Error
  159. sql = `DELETE FROM my_chart_classify_mapping WHERE my_chart_classify_id=?`
  160. err = o.Exec(sql, myChartClassifyId).Error
  161. if err != nil {
  162. return err
  163. }
  164. for _, v := range mappingList {
  165. var count int
  166. sql = ` SELECT COUNT(1) AS count FROM my_chart_classify_mapping WHERE my_chart_id=?`
  167. err = o.Raw(sql, v.MyChartId).Scan(&count).Error
  168. if err != nil {
  169. return err
  170. }
  171. if count <= 0 {
  172. sql = `DELETE FROM my_chart WHERE my_chart_id=?`
  173. err = o.Exec(sql, v.MyChartId).Error
  174. if err != nil {
  175. return err
  176. }
  177. }
  178. }
  179. return
  180. }
  181. type MyChartAddReq struct {
  182. ChartInfoId int `description:"图表id"`
  183. MyChartClassifyId []int `description:"分类id,数组形式"`
  184. }
  185. type MyChartAddResp struct {
  186. MyChartInfoId int `description:"图表id"`
  187. MyChartClassifyId string `description:"分类id,多个用英文逗号隔开"`
  188. }
  189. type MyChart struct {
  190. MyChartId int `orm:"column(my_chart_id);pk" gorm:"primaryKey"`
  191. ChartInfoId int `description:"图表id"`
  192. Source int `description:"1:ETA图库;2:商品价格"`
  193. AdminId int `description:"用户id"`
  194. CreateTime time.Time `description:"创建时间"`
  195. ModifyTime time.Time `description:"修改时间"`
  196. }
  197. type MyChartView struct {
  198. MyChartId int `orm:"column(my_chart_id);pk" gorm:"primaryKey"`
  199. ChartInfoId int `description:"图表id"`
  200. AdminId int `description:"用户id"`
  201. CreateTime time.Time `description:"创建时间"`
  202. ModifyTime time.Time `description:"修改时间"`
  203. MyChartClassifyId string
  204. }
  205. func AddMyChart(item *MyChart) (lastId int64, err error) {
  206. o := global.DbMap[utils.DbNameIndex]
  207. err = o.Create(item).Error
  208. if err != nil {
  209. return
  210. }
  211. lastId = int64(item.MyChartId)
  212. return
  213. }
  214. type MyChartClassifyMapping struct {
  215. MyChartClassifyMappingId int `orm:"column(my_chart_classify_mapping_id);pk" gorm:"primaryKey"`
  216. AdminId int
  217. MyChartId int
  218. MyChartClassifyId int
  219. CreateTime time.Time
  220. ModifyTime time.Time
  221. Sort float64
  222. }
  223. func AddMyChartClassifyMapping(item *MyChartClassifyMapping) (lastId int64, err error) {
  224. o := global.DbMap[utils.DbNameIndex]
  225. err = o.Create(item).Error
  226. if err != nil {
  227. return
  228. }
  229. lastId = int64(item.MyChartClassifyMappingId)
  230. return
  231. }
  232. func GetMyChartClassifyMapping(adminId, myChartId, myChartClassifyId int) (item *MyChartClassifyMapping, err error) {
  233. o := global.DbMap[utils.DbNameIndex]
  234. sql := `SELECT * FROM my_chart_classify_mapping WHERE admin_id=? AND my_chart_id=? AND my_chart_classify_id=? `
  235. err = o.Raw(sql, adminId, myChartId, myChartClassifyId).Find(&item).Error
  236. return
  237. }
  238. type MyChartDeleteReq struct {
  239. MyChartId int `description:"我的图表id"`
  240. MyChartClassifyId int `description:"我的图表分类id"`
  241. }
  242. func DeleteMyChart(myChartId, myChartClassifyId int) (isDelMyChart bool, err error) {
  243. o := global.DbMap[utils.DbNameIndex]
  244. if myChartClassifyId > 0 {
  245. sql := `DELETE FROM my_chart_classify_mapping WHERE my_chart_id=? AND my_chart_classify_id=? `
  246. err = o.Exec(sql, myChartId, myChartClassifyId).Error
  247. if err != nil {
  248. return
  249. }
  250. var count int
  251. sql = ` SELECT COUNT(1) AS count FROM my_chart_classify_mapping WHERE my_chart_id=? `
  252. err = o.Raw(sql, myChartId).Scan(&count).Error
  253. if err != nil {
  254. return
  255. }
  256. if count <= 0 {
  257. sql = `DELETE FROM my_chart WHERE my_chart_id=? `
  258. err = o.Exec(sql, myChartId).Error
  259. if err != nil {
  260. return
  261. }
  262. isDelMyChart = true
  263. }
  264. } else {
  265. sql := `DELETE FROM my_chart WHERE my_chart_id=? `
  266. err = o.Exec(sql, myChartId).Error
  267. if err != nil {
  268. return
  269. }
  270. isDelMyChart = true
  271. }
  272. return
  273. }
  274. type MyChartList struct {
  275. AdminId int `description:"关联人id"`
  276. MyChartId int `description:"我的图表主键"`
  277. ChartInfoId int
  278. ChartName string `description:"来源名称"`
  279. ChartNameEn string `description:"英文图表名称"`
  280. ChartClassifyId int `description:"图表分类id"`
  281. SysUserId int
  282. SysUserRealName string
  283. UniqueCode string `description:"图表唯一编码"`
  284. CreateTime time.Time
  285. ModifyTime time.Time
  286. DateType int `description:"日期类型:1:00年至今,2:10年至今,3:15年至今,4:年初至今,5:自定义时间"`
  287. StartDate string `description:"自定义开始日期"`
  288. EndDate string `description:"自定义结束日期"`
  289. IsSetName int `description:"设置名称"`
  290. EdbInfoIds string `description:"指标id"`
  291. ChartType int `description:"生成样式:1:曲线图,2:季节性图"`
  292. Calendar string `description:"公历/农历"`
  293. SeasonStartDate string `description:"季节性图开始日期"`
  294. SeasonEndDate string `description:"季节性图开始日期"`
  295. ChartImage string `description:"图表图片"`
  296. Sort int `description:"排序字段,数字越小越排前面"`
  297. IsAdd bool `description:"true:已加入我的图库,false:未加入我的图库"`
  298. MyChartClassifyName string `description:"分类名称,多个用英文逗号分割"`
  299. MyChartClassifyId string `description:"分类id,多个用英文逗号分割"`
  300. EdbEndDate string `description:"指标最新更新日期"`
  301. IsEnChart bool `description:"是否展示英文标识"`
  302. Disabled int `description:"是否禁用,0:启用,1:禁用,默认:0"`
  303. Source int `description:"1:ETA图库;2:商品价格曲线"`
  304. IsJoinPermission int `description:"是否加入权限管控,0:不加入;1:加入;默认:0"`
  305. HaveOperaAuth bool `description:"是否有数据权限,默认:false"`
  306. SearchText string `description:"搜索结果(含高亮)"`
  307. }
  308. type MyChartListResp struct {
  309. Paging *paging.PagingItem
  310. List []*MyChartList
  311. }
  312. func GetMyChartListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*MyChartList, err error) {
  313. o := global.DbMap[utils.DbNameIndex]
  314. field := `a.my_chart_id,c.admin_id,c.sort,c.create_time as c_ctime,b.chart_info_id,b.chart_name,b.chart_name_en,b.chart_classify_id,b.sys_user_id,b.sys_user_real_name,b.unique_code,b.create_time,b.modify_time,b.date_type,b.start_date,b.end_date,b.is_set_name,b.edb_info_ids,b.chart_type,b.calendar,b.season_start_date,b.season_end_date,b.chart_image,b.edb_end_date,b.disabled,b.source,b.is_join_permission `
  315. //MyChartClassifyName string `description:"分类名称,多个用英文逗号分割"`
  316. //MyChartClassifyId string `description:"分类id,多个用英文逗号分割"`
  317. sql := ` SELECT * FROM ( SELECT ` + field + ` FROM my_chart AS a
  318. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  319. INNER JOIN my_chart_classify_mapping AS c ON a.my_chart_id=c.my_chart_id
  320. INNER JOIN my_chart_classify AS d ON c.my_chart_classify_id=d.my_chart_classify_id
  321. WHERE 1=1 `
  322. if condition != "" {
  323. sql += condition
  324. }
  325. sql += " GROUP BY a.chart_info_id) AS f ORDER BY sort ASC,c_ctime desc LIMIT ?,? "
  326. pars = append(pars, startSize, pageSize)
  327. err = o.Raw(sql, pars...).Find(&item).Error
  328. return
  329. }
  330. func GetMyChartListCountByCondition(condition string, pars []interface{}) (count int, err error) {
  331. o := global.DbMap[utils.DbNameIndex]
  332. sql := ` select a.* from my_chart AS a
  333. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  334. INNER JOIN my_chart_classify_mapping AS c ON a.my_chart_id=c.my_chart_id
  335. INNER JOIN my_chart_classify AS d ON c.my_chart_classify_id=d.my_chart_classify_id
  336. WHERE 1=1`
  337. if condition != "" {
  338. sql += condition
  339. }
  340. sql1 := ` SELECT COUNT(1) AS count FROM (` + sql + ` GROUP BY a.chart_info_id ) d`
  341. err = o.Raw(sql1, pars...).Scan(&count).Error
  342. return
  343. }
  344. func GetMyChartMaxSort(adminId, myChartClassifyId int) (count int, err error) {
  345. o := global.DbMap[utils.DbNameIndex]
  346. sql := ` SELECT COUNT(1) AS count FROM my_chart_classify_mapping WHERE 1=1 AND admin_id=? AND my_chart_classify_id=? `
  347. err = o.Raw(sql, adminId, myChartClassifyId).Scan(&count).Error
  348. return
  349. }
  350. type MoveMyChartReq struct {
  351. MyChartId int `description:"移动的,我的图表图表ID"`
  352. PrevMyChartId int `description:"移动到的位置,上一级的,我的图表ID,如果没有上一级,则传0"`
  353. NextMyChartId int `description:"移动到的位置,下一级的,我的图表ID,如果没有下一级,则传0"`
  354. MyChartClassifyId int `description:"当前分类id"`
  355. }
  356. func MyChartMove(sort float64, adminId int, myChartId, myChartClassifyId int) (err error) {
  357. o := global.DbMap[utils.DbNameIndex]
  358. sql := ` UPDATE my_chart_classify_mapping SET sort = ?,modify_time=NOW() WHERE admin_id=? AND my_chart_id=? AND my_chart_classify_id=? `
  359. err = o.Exec(sql, sort, adminId, myChartId, myChartClassifyId).Error
  360. return
  361. }
  362. // UpdateMyChartSortByClassifyId 根据分类id更新排序
  363. func UpdateMyChartSortByClassifyId(myChartClassifyId, nowSort int, prevMyChartClassifyMappingId int, updateSort string) (err error) {
  364. o := global.DbMap[utils.DbNameIndex]
  365. sql := ` update my_chart_classify_mapping set sort = ` + updateSort + ` WHERE my_chart_classify_id=? AND `
  366. if prevMyChartClassifyMappingId > 0 {
  367. sql += ` ( sort > ? or ( my_chart_classify_mapping_id < ? and sort=? )) `
  368. }
  369. err = o.Exec(sql, myChartClassifyId, nowSort, prevMyChartClassifyMappingId, nowSort).Error
  370. return
  371. }
  372. func GetMyChartMinSortByAdminId(adminId int) (item *MyChart, err error) {
  373. o := global.DbMap[utils.DbNameIndex]
  374. sql := ` SELECT * FROM my_chart WHERE admin_id=? ORDER BY sort ASC LIMIT 1`
  375. err = o.Raw(sql, adminId).Find(&item).Error
  376. return
  377. }
  378. type ChartRecommendListResp struct {
  379. List []*ChartInfoView
  380. }
  381. func GetChartClassify(chartClassifyId int) (chart_classify_id string, err error) {
  382. o := global.DbMap[utils.DbNameIndex]
  383. sql := `SELECT GROUP_CONCAT(t.chart_classify_id) AS chart_classify_id FROM (
  384. SELECT a.chart_classify_id FROM chart_classify AS a
  385. WHERE a.chart_classify_id=?
  386. UNION ALL
  387. SELECT a.chart_classify_id FROM chart_classify AS a
  388. WHERE a.parent_id=? UNION ALL
  389. SELECT
  390. chart_classify_id
  391. FROM
  392. chart_classify
  393. WHERE
  394. parent_id IN ( SELECT chart_classify_id FROM chart_classify WHERE parent_id = ? )
  395. )AS t`
  396. err = o.Raw(sql, chartClassifyId, chartClassifyId, chartClassifyId).Scan(&chart_classify_id).Error
  397. return
  398. }
  399. func GetRecommendChartListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*ChartInfoView, err error) {
  400. o := global.DbMap[utils.DbNameIndex]
  401. sql := ` SELECT b.* FROM my_chart AS a
  402. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id `
  403. if condition != "" {
  404. sql += condition
  405. }
  406. sql += " ORDER BY a.create_time DESC LIMIT ?,? "
  407. pars = append(pars, startSize, pageSize)
  408. err = o.Raw(sql, pars...).Find(&item).Error
  409. return
  410. }
  411. func GetMyChartListByAdminId(adminId int) (item []*MyChartView, err error) {
  412. o := global.DbMap[utils.DbNameIndex]
  413. //sql := ` SELECT * FROM my_chart WHERE 1=1 AND admin_id=? `
  414. //sql := ` SELECT a.*,GROUP_CONCAT(c.my_chart_classify_id SEPARATOR ',') AS my_chart_classify_id FROM my_chart AS a
  415. // LEFT JOIN my_chart_classify_mapping AS b ON a.my_chart_id=b.my_chart_id AND a.admin_id=b.admin_id
  416. // LEFT JOIN my_chart_classify AS c ON b.my_chart_classify_id=c.my_chart_classify_id AND b.admin_id=c.admin_id
  417. // WHERE 1=1 AND a.admin_id=?
  418. // GROUP BY a.chart_info_id `
  419. sql := fmt.Sprintf(` SELECT a.*, %s AS my_chart_classify_id FROM my_chart AS a
  420. LEFT JOIN my_chart_classify_mapping AS b ON a.my_chart_id=b.my_chart_id AND a.admin_id=b.admin_id
  421. LEFT JOIN my_chart_classify AS c ON b.my_chart_classify_id=c.my_chart_classify_id AND b.admin_id=c.admin_id
  422. WHERE 1=1 AND a.admin_id=?
  423. GROUP BY a.chart_info_id `, utils.GroupUnitFunc(utils.DbDriverName, "c.my_chart_classify_id", ",", ""))
  424. err = o.Raw(sql, adminId).Find(&item).Error
  425. return
  426. }
  427. func GetMyChartSearchByCondition(condition string, pars []interface{}) (item []*MyChartList, err error) {
  428. o := global.DbMap[utils.DbNameIndex]
  429. sql := ` SELECT a.my_chart_id,c.sort,b.*,GROUP_CONCAT(DISTINCT d.my_chart_classify_name) AS my_chart_classify_name,GROUP_CONCAT(DISTINCT d.my_chart_classify_id) AS my_chart_classify_id
  430. FROM my_chart AS a
  431. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  432. INNER JOIN my_chart_classify_mapping AS c ON a.my_chart_id=c.my_chart_id
  433. INNER JOIN my_chart_classify AS d ON c.my_chart_classify_id=d.my_chart_classify_id
  434. WHERE 1=1 `
  435. if condition != "" {
  436. sql += condition
  437. }
  438. sql += " GROUP BY a.chart_info_id ORDER BY c.sort DESC "
  439. err = o.Raw(sql, pars...).Find(&item).Error
  440. return
  441. }
  442. type MyChartSearchListResp struct {
  443. List []*MyChartList
  444. Paging *paging.PagingItem
  445. }
  446. type MyChartEditReq struct {
  447. MyChartId int `description:"我的图表主键"`
  448. CurrentMyChartClassifyId int `description:"当前分类ID"`
  449. MyChartClassifyId []int `description:"分类id,数组形式"`
  450. }
  451. func GetMyChartClassifyMappingCount(adminId, myChartId, myChartClassifyId int) (count int, err error) {
  452. o := global.DbMap[utils.DbNameIndex]
  453. sql := ` SELECT COUNT(1) AS count
  454. FROM my_chart_classify_mapping
  455. WHERE 1=1 AND admin_id=? AND my_chart_id=? AND my_chart_classify_id=? `
  456. err = o.Raw(sql, adminId, myChartId, myChartClassifyId).Scan(&count).Error
  457. return
  458. }
  459. func DeleteMyChartClassifyMapping(adminId, myChartId, myChartClassifyId int) (err error) {
  460. o := global.DbMap[utils.DbNameIndex]
  461. sql := ` DELETE FROM my_chart_classify_mapping
  462. WHERE admin_id=? AND my_chart_id=? AND my_chart_classify_id=? `
  463. err = o.Exec(sql, adminId, myChartId, myChartClassifyId).Error
  464. return
  465. }
  466. func GetMyChartSort(adminId, myChartClassifyId, sort int) (item *MyChartClassifyMapping, err error) {
  467. o := global.DbMap[utils.DbNameIndex]
  468. sql := ` SELECT * FROM my_chart_classify_mapping WHERE 1=1 AND admin_id=? AND my_chart_classify_id=? `
  469. if sort == 1 {
  470. sql += ` ORDER BY sort DESC,my_chart_classify_mapping_id ASC LIMIT 1 `
  471. } else {
  472. sql += ` ORDER BY sort ASC,my_chart_classify_mapping_id DESC LIMIT 1 `
  473. }
  474. err = o.Raw(sql, adminId, myChartClassifyId).Find(&item).Error
  475. return
  476. }
  477. func GetMyChartByCondition(condition string, pars []interface{}) (item []*MyChartView, err error) {
  478. o := global.DbMap[utils.DbNameIndex]
  479. //sql := ` SELECT * FROM my_chart WHERE 1=1 `
  480. sql := `SELECT a.*,GROUP_CONCAT(c.my_chart_classify_id SEPARATOR ',') AS my_chart_classify_id FROM my_chart AS a
  481. LEFT JOIN my_chart_classify_mapping AS b ON a.my_chart_id=b.my_chart_id AND a.admin_id=b.admin_id
  482. LEFT JOIN my_chart_classify AS c ON b.my_chart_classify_id=c.my_chart_classify_id AND b.admin_id=c.admin_id
  483. WHERE 1=1
  484. `
  485. if condition != "" {
  486. sql += condition
  487. }
  488. sql += ` GROUP BY a.chart_info_id `
  489. err = o.Raw(sql, pars...).Find(&item).Error
  490. return
  491. }
  492. func GetMyChartDetailByCondition(condition string, pars []interface{}) (item *MyChartView, err error) {
  493. o := global.DbMap[utils.DbNameIndex]
  494. sql := ` SELECT * FROM my_chart WHERE 1=1 `
  495. if condition != "" {
  496. sql += condition
  497. }
  498. err = o.Raw(sql, pars...).Find(&item).Error
  499. return
  500. }
  501. func MoveMyChartClassify(adminId, myChartId int, myChartClassifyId []int) (err error) {
  502. o := global.DbMap[utils.DbNameIndex]
  503. to := o.Begin()
  504. defer func() {
  505. if err != nil {
  506. _ = to.Rollback()
  507. } else {
  508. _ = to.Commit()
  509. }
  510. }()
  511. classifyIdMap := make(map[int]int)
  512. for _, v := range myChartClassifyId {
  513. classifyIdMap[v] = v
  514. }
  515. mappingList := make([]*MyChartClassifyMapping, 0)
  516. sql := `SELECT * FROM my_chart_classify_mapping WHERE admin_id=? AND my_chart_id=?`
  517. err = to.Raw(sql, adminId, myChartId).Find(&mappingList).Error
  518. if err != nil {
  519. return
  520. }
  521. for _, v := range mappingList {
  522. if _, ok := classifyIdMap[v.MyChartClassifyId]; !ok {
  523. sql := ` DELETE FROM my_chart_classify_mapping WHERE my_chart_classify_mapping_id=? `
  524. err = to.Exec(sql, v.MyChartClassifyMappingId).Error
  525. if err != nil {
  526. return
  527. }
  528. }
  529. }
  530. //sql := `DELETE FROM my_chart_classify_mapping WHERE admin_id=? AND my_chart_id=? `
  531. //err = to.Exec(sql, adminId, myChartId).Error
  532. //if err != nil {
  533. // return err
  534. //}
  535. //step := float64(65536)
  536. for _, v := range myChartClassifyId {
  537. var count int
  538. sql := ` SELECT COUNT(1) AS count FROM my_chart_classify_mapping WHERE my_chart_id=? AND my_chart_classify_id=? `
  539. err = to.Raw(sql, myChartId, v).Scan(&count).Error
  540. if err != nil {
  541. return
  542. }
  543. if count <= 0 {
  544. //total, err := GetMyChartMaxSort(adminId, v)
  545. if err != nil {
  546. return err
  547. }
  548. //sort := (float64(total) + 1) * step
  549. sort := 0
  550. sql = ` INSERT INTO my_chart_classify_mapping (
  551. admin_id,
  552. my_chart_id,
  553. my_chart_classify_id,
  554. create_time,
  555. modify_time,
  556. sort )VALUES (?,?,?,NOW(),NOW(),?) `
  557. err = to.Exec(sql, adminId, myChartId, v, sort).Error
  558. if err != nil {
  559. return err
  560. }
  561. }
  562. }
  563. return
  564. }
  565. // Update 更新分类基础信息
  566. func (myChartClassify *MyChartClassify) Update(cols []string) (err error) {
  567. o := global.DbMap[utils.DbNameIndex]
  568. err = o.Select(cols).Updates(myChartClassify).Error
  569. return
  570. }
  571. // GetFirstMyChartClassifyByAdminId 获取当前账号下,排序第一条的分类数据
  572. func GetFirstMyChartClassifyByAdminId(adminId int) (item *MyChartClassify, err error) {
  573. o := global.DbMap[utils.DbNameIndex]
  574. sql := ` SELECT * FROM my_chart_classify WHERE admin_id=? order by sort asc,my_chart_classify_id asc limit 1`
  575. err = o.Raw(sql, adminId).Find(&item).Error
  576. return
  577. }
  578. // UpdateMyChartClassifySortByClassifyId 根据分类id更新排序
  579. func UpdateMyChartClassifySortByClassifyId(adminId, classifyId, nowSort int, updateSort string) (err error) {
  580. o := global.DbMap[utils.DbNameIndex]
  581. sql := ` update my_chart_classify set sort = ` + updateSort + ` WHERE admin_id = ? and sort > ? `
  582. if classifyId > 0 {
  583. sql += ` or ( my_chart_classify_id > ` + fmt.Sprint(classifyId) + ` and sort = ` + fmt.Sprint(nowSort) + `)`
  584. }
  585. err = o.Exec(sql, adminId, nowSort).Error
  586. return
  587. }
  588. // ModifyChartClassifyPublicReq 修改我的图库分类是否可见
  589. type ModifyChartClassifyPublicReq struct {
  590. MyChartClassifyId int `description:"分类id"`
  591. IsPublic int `description:"是否所有人可见,0:仅自己可见,1:所有人可见"`
  592. }
  593. // CopyChartClassifyReq 复制我的图库分类
  594. type CopyChartClassifyReq struct {
  595. MyChartClassifyId int `description:"分类id"`
  596. }
  597. // GetPublicMyChartClassifyById 根据分类ID获取公开分类
  598. func GetPublicMyChartClassifyById(myChartClassifyId int) (item *MyChartClassify, err error) {
  599. o := global.DbMap[utils.DbNameIndex]
  600. sql := ` SELECT * FROM my_chart_classify WHERE is_public=1 AND my_chart_classify_id=? `
  601. err = o.Raw(sql, myChartClassifyId).Find(&item).Error
  602. return
  603. }
  604. // CopyPublicMyChartClassifyById 根据分类ID获取公开分类
  605. func CopyPublicMyChartClassifyById(myChartClassifyId, adminId int, newMyChartClassifyName string) (newMyChartClassify *MyChartClassify, err error) {
  606. o := global.DbMap[utils.DbNameIndex]
  607. to := o.Begin()
  608. defer func() {
  609. if err != nil {
  610. _ = to.Rollback()
  611. } else {
  612. _ = to.Commit()
  613. }
  614. }()
  615. //获取分类里面所有的图表信息
  616. fromMappingList := make([]*MyChartClassifyMapping, 0)
  617. sql := `SELECT * FROM my_chart_classify_mapping WHERE my_chart_classify_id=?`
  618. err = to.Raw(sql, myChartClassifyId).Find(&fromMappingList).Error
  619. if err != nil {
  620. return
  621. }
  622. fromMyChartSortMap := make(map[int]float64)
  623. for _, fromMapping := range fromMappingList {
  624. fromMyChartSortMap[fromMapping.MyChartId] = fromMapping.Sort
  625. }
  626. var minSort int
  627. sql = ` SELECT MIN(sort) sort FROM my_chart_classify WHERE admin_id=? `
  628. err = o.Raw(sql, adminId).Scan(&minSort).Error
  629. if err != nil {
  630. return
  631. }
  632. // 我的图表
  633. fromMyChartList := make([]*MyChart, 0)
  634. sql = `SELECT a.* FROM my_chart a join my_chart_classify_mapping b on a.my_chart_id=b.my_chart_id
  635. WHERE b.my_chart_classify_id=?`
  636. err = to.Raw(sql, myChartClassifyId).Find(&fromMyChartList).Error
  637. if err != nil {
  638. return
  639. }
  640. //新增我的图库分类
  641. newMyChartClassify = &MyChartClassify{
  642. MyChartClassifyName: newMyChartClassifyName,
  643. AdminId: adminId,
  644. CreateTime: time.Now(),
  645. ModifyTime: time.Now(),
  646. Sort: minSort - 1,
  647. }
  648. err = to.Create(newMyChartClassify).Error
  649. if err != nil {
  650. return
  651. }
  652. newMyChartClassifyId := newMyChartClassify.MyChartClassifyId
  653. newMappingList := make([]*MyChartClassifyMapping, 0)
  654. //将图表加入我的图库
  655. for _, v := range fromMyChartList {
  656. tmpMyChart := &MyChart{
  657. ChartInfoId: v.ChartInfoId,
  658. AdminId: adminId,
  659. Source: v.Source,
  660. CreateTime: time.Now(),
  661. ModifyTime: time.Now(),
  662. }
  663. tmpErr := to.Create(tmpMyChart).Error
  664. if tmpErr != nil {
  665. err = tmpErr
  666. }
  667. tmpMyChartId := tmpMyChart.MyChartId
  668. // 往自己的分类里面新增图表关系
  669. //原始图表的排序
  670. tmpSort, ok := fromMyChartSortMap[v.MyChartId]
  671. if !ok {
  672. tmpSort = 0
  673. }
  674. tmp := &MyChartClassifyMapping{
  675. AdminId: adminId,
  676. MyChartId: int(tmpMyChartId),
  677. MyChartClassifyId: int(newMyChartClassifyId),
  678. CreateTime: time.Now(),
  679. ModifyTime: time.Now(),
  680. Sort: tmpSort,
  681. }
  682. newMappingList = append(newMappingList, tmp)
  683. }
  684. if len(newMappingList) > 0 {
  685. err = to.CreateInBatches(newMappingList, utils.MultiAddNum).Error
  686. }
  687. return
  688. }
  689. // ModifyChartClassifyCompanyPublicReq 修改公共图库分类是否用户可见
  690. type ModifyChartClassifyCompanyPublicReq struct {
  691. MyChartClassifyId int `description:"分类id"`
  692. IsCompanyPublic int `description:"是否用户可见 0-否 1-是"`
  693. }
  694. // GetCompanyPublicClassifyList 获取用户可见的分类列表
  695. func GetCompanyPublicClassifyList(condition string, pars []interface{}) (item []*MyChartClassify, err error) {
  696. o := global.DbMap[utils.DbNameIndex]
  697. sql := ` SELECT * FROM my_chart_classify WHERE 1 = 1 AND is_public = 1 AND is_company_public = 1 `
  698. sql += condition
  699. sql += " ORDER BY public_time asc"
  700. err = o.Raw(sql, pars...).Find(&item).Error
  701. return
  702. }
  703. // GetMyChartClassifyList 获取我的图表关联的分类列表数据
  704. func GetMyChartClassifyList(myChartClassifyId int) (mappingList []*MyChartClassifyMapping, err error) {
  705. o := global.DbMap[utils.DbNameIndex]
  706. //o.Begin()
  707. //
  708. //defer func() {
  709. // if err != nil {
  710. // o.Rollback()
  711. // } else {
  712. // o.Commit()
  713. // }
  714. //}()
  715. sql := `SELECT * FROM my_chart_classify_mapping WHERE my_chart_id=?`
  716. err = o.Raw(sql, myChartClassifyId).Find(&mappingList).Error
  717. return
  718. }
  719. // AddMyChartToMyChartClassify 添加我的图表至我的分类
  720. func AddMyChartToMyChartClassify(adminId, myChartId int, myChartClassifyId []int) (err error) {
  721. o := global.DbMap[utils.DbNameIndex]
  722. //o.Begin()
  723. //defer func() {
  724. // if err != nil {
  725. // o.Rollback()
  726. // } else {
  727. // o.Commit()
  728. // }
  729. //}()
  730. //需要添加的分类id 集合map
  731. classifyIdMap := make(map[int]int)
  732. for _, v := range myChartClassifyId {
  733. classifyIdMap[v] = v
  734. }
  735. //查询已存在系统中的图表分类集合
  736. mappingList := make([]*MyChartClassifyMapping, 0)
  737. sql := `SELECT * FROM my_chart_classify_mapping WHERE admin_id=? AND my_chart_id=?`
  738. err = o.Raw(sql, adminId, myChartId).Find(&mappingList).Error
  739. if err != nil {
  740. return
  741. }
  742. //遍历已存在系统中的图表分类集合,如果和需要添加的分类重复了,那么移除需要添加分类集合map里面的数据
  743. for _, v := range mappingList {
  744. if _, ok := classifyIdMap[v.MyChartClassifyId]; ok {
  745. delete(classifyIdMap, v.MyChartClassifyId)
  746. }
  747. }
  748. step := float64(65536)
  749. for _, v := range myChartClassifyId {
  750. var count int
  751. sql := ` SELECT COUNT(1) AS count FROM my_chart_classify_mapping WHERE my_chart_id=? AND my_chart_classify_id=? `
  752. err = o.Raw(sql, myChartId, v).Scan(&count).Error
  753. if err != nil {
  754. return
  755. }
  756. if count <= 0 {
  757. total, err := GetMyChartMaxSort(adminId, v)
  758. if err != nil {
  759. return err
  760. }
  761. sort := (float64(total) + 1) * step
  762. sql = ` INSERT INTO my_chart_classify_mapping (
  763. admin_id,
  764. my_chart_id,
  765. my_chart_classify_id,
  766. create_time,
  767. modify_time,
  768. sort )VALUES (?,?,?,NOW(),NOW(),?) `
  769. err = o.Exec(sql, adminId, myChartId, v, sort).Error
  770. if err != nil {
  771. return err
  772. }
  773. }
  774. }
  775. return
  776. }
  777. // GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition 获取MY ETA 图表数据,根据图表id和操作员id
  778. func GetMyChartListGroupByCharyInfoIdAndAdminIdByCondition(condition string, pars []interface{}) (item []*MyChartList, err error) {
  779. o := global.DbMap[utils.DbNameIndex]
  780. sql := ` SELECT a.admin_id,a.my_chart_id,c.sort,b.*,GROUP_CONCAT(DISTINCT d.my_chart_classify_name) AS my_chart_classify_name,GROUP_CONCAT(DISTINCT d.my_chart_classify_id) AS my_chart_classify_id
  781. FROM my_chart AS a
  782. INNER JOIN chart_info AS b ON a.chart_info_id=b.chart_info_id
  783. INNER JOIN my_chart_classify_mapping AS c ON a.my_chart_id=c.my_chart_id
  784. INNER JOIN my_chart_classify AS d ON c.my_chart_classify_id=d.my_chart_classify_id
  785. WHERE 1=1 `
  786. if condition != "" {
  787. sql += condition
  788. }
  789. sql += " GROUP BY a.chart_info_id,a.admin_id ORDER BY c.sort DESC "
  790. err = o.Raw(sql, pars...).Find(&item).Error
  791. return
  792. }
  793. func GetRelationChartListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*ChartInfoView, err error) {
  794. o := global.DbMap[utils.DbNameIndex]
  795. sql := ` SELECT a.* FROM chart_info AS a
  796. WHERE 1=1 `
  797. if condition != "" {
  798. sql += condition
  799. }
  800. //sql += " ORDER BY sort ASC,chart_info_id DESC LIMIT ?,? "
  801. sql += " ORDER BY a.create_time DESC LIMIT ?,? "
  802. pars = append(pars, startSize, pageSize)
  803. err = o.Raw(sql, pars...).Find(&item).Error
  804. return
  805. }
  806. func GetRelationChartListCountByCondition(condition string, pars []interface{}) (count int, err error) {
  807. o := global.DbMap[utils.DbNameIndex]
  808. sql := ` SELECT COUNT(1) AS count FROM chart_info AS a
  809. WHERE 1=1 `
  810. if condition != "" {
  811. sql += condition
  812. }
  813. err = o.Raw(sql, pars...).Scan(&count).Error
  814. return
  815. }
  816. // GetChartInfoByIdList 根据图表id集合 获取 图表列表
  817. func GetChartInfoByIdList(chartInfoIdList []int) (items []*ChartInfo, err error) {
  818. num := len(chartInfoIdList)
  819. if num <= 0 {
  820. return
  821. }
  822. o := global.DbMap[utils.DbNameIndex]
  823. sql := ` SELECT * FROM chart_info WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `) `
  824. err = o.Raw(sql, chartInfoIdList).Find(&items).Error
  825. return
  826. }
  827. func GetChartInfoViewByIdList(chartInfoIdList []int) (items []*ChartInfoView, err error) {
  828. num := len(chartInfoIdList)
  829. if num <= 0 {
  830. return
  831. }
  832. o := global.DbMap[utils.DbNameIndex]
  833. sql := ` SELECT * FROM chart_info WHERE chart_info_id in (` + utils.GetOrmInReplace(num) + `) `
  834. err = o.Raw(sql, chartInfoIdList).Find(&items).Error
  835. return
  836. }
  837. // GetMyChartClassifyByClassifyId 主键获取分类
  838. func GetMyChartClassifyByClassifyId(classifyId int) (item *MyChartClassify, err error) {
  839. o := global.DbMap[utils.DbNameIndex]
  840. sql := ` SELECT * FROM my_chart_classify WHERE my_chart_classify_id = ? `
  841. err = o.Raw(sql, classifyId).Find(&item).Error
  842. return
  843. }
  844. // MyChartClassifyItem 我的图表分类信息
  845. type MyChartClassifyItem struct {
  846. MyChartClassifyId int `description:"分类ID"`
  847. MyChartClassifyName string `description:"分类名称"`
  848. AdminId int `description:"创建人id"`
  849. IsPublic int `description:"是否公共分类"`
  850. IsCompanyPublic int `description:"是否为用户公共分类"`
  851. ChartNum int `description:"分类下的图表数量"`
  852. }
  853. // FormatMyChartClassify2Item 格式化我的图表信息
  854. func FormatMyChartClassify2Item(origin *MyChartClassify, chartNum int) (item *MyChartClassifyItem) {
  855. if origin == nil {
  856. return
  857. }
  858. item = new(MyChartClassifyItem)
  859. item.MyChartClassifyId = origin.MyChartClassifyId
  860. item.MyChartClassifyName = origin.MyChartClassifyName
  861. item.AdminId = origin.AdminId
  862. item.IsPublic = origin.IsPublic
  863. item.IsCompanyPublic = origin.IsCompanyPublic
  864. item.ChartNum = chartNum
  865. return
  866. }
  867. // MyChartClassifyIdAndNum 我的图表-分类ID及图表数
  868. type MyChartClassifyIdAndNum struct {
  869. MyChartClassifyId int `description:"分类ID"`
  870. ChartNum int `description:"分类下的图表数量"`
  871. }
  872. // GetMyChartClassifyIdAndNum 我的图表-获取分类ID及图表数
  873. func GetMyChartClassifyIdAndNum(cond string, pars []interface{}) (items []*MyChartClassifyIdAndNum, err error) {
  874. o := global.DbMap[utils.DbNameIndex]
  875. sql := fmt.Sprintf(`SELECT
  876. a.my_chart_classify_id,
  877. COUNT(1) AS chart_num
  878. FROM
  879. my_chart_classify AS a
  880. INNER JOIN my_chart_classify_mapping AS b ON a.my_chart_classify_id = b.my_chart_classify_id
  881. INNER JOIN my_chart AS c ON b.my_chart_id = c.my_chart_id
  882. INNER JOIN chart_info AS d ON c.chart_info_id = d.chart_info_id
  883. WHERE
  884. 1 = 1 %s
  885. GROUP BY
  886. a.my_chart_classify_id`, cond)
  887. err = o.Raw(sql, pars...).Find(&items).Error
  888. return
  889. }
  890. func GetChartClassifyByIds(chartClassifyIds []string) (chart_classify_ids string, err error) {
  891. o := global.DbMap[utils.DbNameIndex]
  892. sql := `SELECT GROUP_CONCAT(DISTINCT t.chart_classify_id) AS chart_classify_ids
  893. FROM (
  894. SELECT chart_classify_id
  895. FROM chart_classify
  896. WHERE chart_classify_id IN (` + utils.GetOrmInReplace(len(chartClassifyIds)) + `)
  897. OR parent_id IN (` + utils.GetOrmInReplace(len(chartClassifyIds)) + `)
  898. OR parent_id IN (
  899. SELECT chart_classify_id
  900. FROM chart_classify
  901. WHERE parent_id IN (` + utils.GetOrmInReplace(len(chartClassifyIds)) + `)
  902. )
  903. ) AS t;`
  904. err = o.Raw(sql, chartClassifyIds, chartClassifyIds, chartClassifyIds).Scan(&chart_classify_ids).Error
  905. return
  906. }
  907. func GetChartClassifyByIdsNoSubClassify(chartClassifyIds []string) (chart_classify_ids string, err error) {
  908. o := global.DbMap[utils.DbNameIndex]
  909. sql := `SELECT GROUP_CONCAT(DISTINCT t.chart_classify_id) AS chart_classify_ids
  910. FROM (
  911. SELECT chart_classify_id
  912. FROM chart_classify
  913. WHERE chart_classify_id IN (` + utils.GetOrmInReplace(len(chartClassifyIds)) + `)
  914. ) AS t;`
  915. err = o.Raw(sql, chartClassifyIds).Scan(&chart_classify_ids).Error
  916. return
  917. }