business_database.go 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. package model
  2. //请求token
  3. type QueryToken struct{
  4. CertKey string `json:"certKey"`
  5. }
  6. //响应
  7. type ResponseToken struct{
  8. AccessToken string `json:"accessToken"`
  9. RefreshToken string `json:"refreshToken"`
  10. ExpiresAt int64 `json:"expiresAt"`
  11. }
  12. //数据库连接
  13. type DbConnInfo struct{
  14. Type string `validate:"required" json:"type"`
  15. Connection string `validate:"required" json:"connection"`
  16. DbName string `validate:"required" json:"dbName"`
  17. Mode string `validate:"required" json:"mode"` //连接模式:test:表示测试数据库是否连通,测试完成后自动断开,add表示添加数据库到管理队列。(add之前请先确保数据库已经添加到redis的database hash里面)
  18. Id int `validate:"-" json:"id"`
  19. }
  20. //动态创建数据库表
  21. /*
  22. 动态创建数据表
  23. dbid 数据库id(前面接口的那个id)
  24. connection 链接字符串
  25. dbName 数据库名称
  26. type 数据库类型
  27. tableName 表名
  28. columns 列字段数组,定义如下
  29. columnName 列名
  30. dataType 数据类型,固定传varchar
  31. dataLength 数据长度
  32. isPk 是否主键,1,0
  33. isRequired 是否必填, 1,0
  34. isIncrement 是否子增长
  35. */
  36. type ColnInfo struct {
  37. ColName string `json:"colName"`
  38. DataType string `json:"dataType"`
  39. DataLength int `json:"dataLength"`
  40. IsPk int `json:"isPk"` //是否是主键
  41. IsRequired int `json:"isRequired"`
  42. IsIncrement int `json:"isIncrement"`
  43. }
  44. type DatabaseCreateRequest struct {
  45. Id int `json:"id"`
  46. Connection string `json:"connection"`
  47. DbName string `json:"dbName"`
  48. DbType string `json:"dbType"`
  49. TbName string `json:"tbName"`
  50. Columns []ColnInfo `json:"columns"`
  51. }
  52. //动态插入数据
  53. type ColnData struct {
  54. ColName string `json:"colName"`
  55. ColVal string `json:"colVal"`
  56. }
  57. type ColnItem struct {
  58. List []string `json:"list"`
  59. }
  60. type ColnDataInsert struct{
  61. Id int `json:"id"`
  62. TbName string `json:"tbName"`
  63. Rows []ColnItem `json:"rows"`
  64. ColNameArray []string `json:"colNameArray"`
  65. }
  66. //动态添加或删除索引
  67. type TbIndex struct{
  68. Id int `json:"id"`
  69. TbName string `json:"tbName"`
  70. IndexArray []string `json:"indexArray"`
  71. }
  72. //查询数据库
  73. type SortCond struct{
  74. ColName string `json:"colName"`
  75. IsDesc int `json:"isDesc"` //1-降序 0-升序
  76. }
  77. type QueryCond struct{
  78. ColName string `json:"colName"`
  79. ColVal string `json:"colVal"`
  80. Cond int `json:"cond"`//0-等于 1-大于 2-小于
  81. }
  82. type QueryColn struct{
  83. }
  84. type DbQuery struct {
  85. Id int `validate:"required" json:"id"`
  86. PageNo int `validate:"required" json:"pageNo"`
  87. PageSize int `validate:"required" json:"pageSize"`
  88. TbName string `validate:"required" json:"tbName"`
  89. Query []QueryCond `json:"query"`
  90. Sort SortCond `json:"sort"`
  91. QueryColn []string `json:"cols"`
  92. }
  93. //输出表数据
  94. type TbDelete struct{
  95. Id int `json:"id"`
  96. TbName string `json:"tbName"`
  97. }