sandbox.go 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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 `gorm:"column:sandbox_id;primaryKey"` //`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. pars = append(pars, startSize, pageSize)
  54. err = global.DmSQL["data"].Raw(sql, pars...).Find(&item).Error
  55. return
  56. }
  57. func GetSandboxListCountByCondition(condition string, pars []interface{}) (count int, err error) {
  58. //o := orm.NewOrmUsingDB("data")
  59. //sql := ` SELECT COUNT(1) AS count FROM sandbox WHERE 1=1 `
  60. //if condition != "" {
  61. // sql += condition
  62. //}
  63. //err = o.Raw(sql, pars).QueryRow(&count)
  64. sql := ` SELECT COUNT(1) AS count FROM sandbox WHERE 1=1 `
  65. if condition != "" {
  66. sql += condition
  67. }
  68. err = global.DmSQL["data"].Raw(sql, pars...).Scan(&count).Error
  69. return
  70. }
  71. // ContentDataStruct 沙盘内容结构体
  72. type ContentDataStruct struct {
  73. Cells []struct {
  74. Data *NodeData `json:"data,omitempty"`
  75. } `json:"cells"`
  76. }
  77. type NodeData struct {
  78. LinkData []*LinkData `json:"linkData"`
  79. LinkFold bool `json:"linkFold"`
  80. }
  81. type LinkData struct {
  82. RId string `json:"RId"`
  83. Id int `json:"Id"`
  84. Name string `json:"Name"`
  85. Type int `json:"Type"`
  86. Editing bool `json:"editing"`
  87. DatabaseType int `json:"databaseType"`
  88. DetailParams DetailParams `json:"detailParams"`
  89. }
  90. type DetailParams struct {
  91. Code string `json:"code"`
  92. Id int `json:"id"`
  93. ClassifyId int `json:"classifyId"`
  94. }