sandbox.go 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package sandbox
  2. import (
  3. "github.com/beego/beego/v2/client/orm"
  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. return
  49. }
  50. func GetSandboxListCountByCondition(condition string, pars []interface{}) (count int, err error) {
  51. o := orm.NewOrmUsingDB("data")
  52. sql := ` SELECT COUNT(1) AS count FROM sandbox WHERE 1=1 `
  53. if condition != "" {
  54. sql += condition
  55. }
  56. err = o.Raw(sql, pars).QueryRow(&count)
  57. return
  58. }
  59. // ContentDataStruct 沙盘内容结构体
  60. type ContentDataStruct struct {
  61. Cells []struct {
  62. Data *NodeData `json:"data,omitempty"`
  63. } `json:"cells"`
  64. }
  65. type NodeData struct {
  66. LinkData []*LinkData `json:"linkData"`
  67. LinkFold bool `json:"linkFold"`
  68. }
  69. type LinkData struct {
  70. RId string `json:"RId"`
  71. Id int `json:"Id"`
  72. Name string `json:"Name"`
  73. Type int `json:"Type"`
  74. Editing bool `json:"editing"`
  75. DatabaseType int `json:"databaseType"`
  76. DetailParams DetailParams `json:"detailParams"`
  77. }
  78. type DetailParams struct {
  79. Code string `json:"code"`
  80. Id int `json:"id"`
  81. ClassifyId int `json:"classifyId"`
  82. }