sandbox.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package sandbox
  2. import (
  3. "eta_gn/eta_task/global"
  4. "time"
  5. )
  6. // Sandbox 沙盘推演主表
  7. //type Sandbox struct {
  8. // SandboxId int `orm:"column(sandbox_id);pk" description:"沙盘id"`
  9. // Name string `description:"沙盘名称"`
  10. // ChartPermissionId int `description:"品种id"`
  11. // ChartPermissionName string `description:"品种名称"`
  12. // CurrVersion int `description:"当前版本"`
  13. // Code string `description:"沙盘code"`
  14. // Content string `description:"沙盘数据"`
  15. // PicUrl string `description:"沙盘图片地址"`
  16. // OpUserId int `description:"最近一次编辑操作的用户id"`
  17. // OpUserName string `description:"最近一次编辑的用户名称(冗余字段,避免查表)"`
  18. // IsDelete int8 `description:"是否删除,0:未删除,1:已删除"`
  19. // ModifyTime time.Time `description:"修改时间"`
  20. // CreateTime time.Time `description:"创建时间"`
  21. // SandboxClassifyId int `description:"分类id"`
  22. // Sort int `description:"排序"`
  23. //}
  24. type Sandbox struct {
  25. SandboxId int `orm:"column(sandbox_id);pk" description:"沙盘id"`
  26. Name string `description:"沙盘名称"`
  27. Code string `description:"沙盘code"`
  28. Content string `description:"沙盘数据"`
  29. MindmapData string `description:"思维导图数据"`
  30. PicUrl string `description:"沙盘图片地址"`
  31. SysUserId int `description:"作者id"`
  32. SysUserName string `description:"作者名称"`
  33. IsDelete int8 `description:"是否删除,0:未删除,1:已删除"`
  34. ModifyTime time.Time `description:"修改时间"`
  35. CreateTime time.Time `description:"创建时间"`
  36. SandboxClassifyId int `description:"分类id"`
  37. Sort int `description:"排序"`
  38. Style int `description:"风格"`
  39. }
  40. func GetSandboxListByCondition(condition string, pars []interface{}, startSize, pageSize int) (item []*Sandbox, err error) {
  41. //o := orm.NewOrmUsingDB("data")
  42. //sql := ` SELECT * FROM sandbox WHERE 1=1 `
  43. //if condition != "" {
  44. // sql += condition
  45. //}
  46. //sql += " ORDER BY create_time DESC LIMIT ?,? "
  47. //_, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&item)
  48. sql := ` SELECT * FROM sandbox WHERE 1=1 `
  49. if condition != "" {
  50. sql += condition
  51. }
  52. sql += " ORDER BY create_time DESC LIMIT ?,? "
  53. err = global.DmSQL["data"].Raw(sql, pars, startSize, pageSize).Find(&item).Error
  54. return
  55. }
  56. func GetSandboxListCountByCondition(condition string, pars []interface{}) (count int, err error) {
  57. //o := orm.NewOrmUsingDB("data")
  58. //sql := ` SELECT COUNT(1) AS count FROM sandbox WHERE 1=1 `
  59. //if condition != "" {
  60. // sql += condition
  61. //}
  62. //err = o.Raw(sql, pars).QueryRow(&count)
  63. sql := ` SELECT COUNT(1) AS count FROM sandbox WHERE 1=1 `
  64. if condition != "" {
  65. sql += condition
  66. }
  67. err = global.DmSQL["data"].Raw(sql, pars).Scan(&count).Error
  68. return
  69. }
  70. // ContentDataStruct 沙盘内容结构体
  71. type ContentDataStruct struct {
  72. Cells []struct {
  73. Data *NodeData `json:"data,omitempty"`
  74. } `json:"cells"`
  75. }
  76. type NodeData struct {
  77. LinkData []*LinkData `json:"linkData"`
  78. LinkFold bool `json:"linkFold"`
  79. }
  80. type LinkData struct {
  81. RId string `json:"RId"`
  82. Id int `json:"Id"`
  83. Name string `json:"Name"`
  84. Type int `json:"Type"`
  85. Editing bool `json:"editing"`
  86. DatabaseType int `json:"databaseType"`
  87. DetailParams DetailParams `json:"detailParams"`
  88. }
  89. type DetailParams struct {
  90. Code string `json:"code"`
  91. Id int `json:"id"`
  92. ClassifyId int `json:"classifyId"`
  93. }