params.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. package net
  2. import (
  3. "go-common/app/admin/main/aegis/model/common"
  4. xtime "go-common/library/time"
  5. )
  6. const (
  7. //StateAvailable .
  8. StateAvailable = "available"
  9. //StateDisable .
  10. StateDisable = "disable"
  11. )
  12. // ListNetParam .
  13. type ListNetParam struct {
  14. BusinessID int64 `json:"business_id" form:"business_id" validte:"omitempty,gt=0"`
  15. ID []int64 `json:"id" form:"id,split" validate:"omitempty,dive,gt=0"`
  16. State string `json:"state" form:"state"`
  17. Sort string `json:"sort" form:"sort" default:"desc"`
  18. Pn int64 `json:"pn" form:"pn" default:"1" validate:"gt=0"`
  19. Ps int64 `json:"ps" form:"ps" default:"30" validate:"gt=0"`
  20. }
  21. // ListNetItem .
  22. type ListNetItem struct {
  23. ID int64 `json:"id"`
  24. BusinessID int64 `json:"business_id"`
  25. ChName string `json:"ch_name"`
  26. Description string `json:"description"`
  27. StartFlowID int64 `json:"start_flow_id"`
  28. PID int64 `json:"pid" gorm:"column:pid"`
  29. UID int64 `json:"uid" gorm:"column:uid"`
  30. DisableTime xtime.Time `json:"disable_time"`
  31. Ctime common.FormatTime `json:"ctime"`
  32. Mtime common.FormatTime `json:"mtime"`
  33. BusinessName string `json:"business_name"`
  34. Username string `json:"username"`
  35. }
  36. // ListNetRes .
  37. type ListNetRes struct {
  38. Result []*ListNetItem `json:"result"`
  39. Pager Pager `json:"pager"`
  40. }
  41. // NetEditParam .
  42. type NetEditParam struct {
  43. ID int64 `form:"id" validate:"required,gt=0"`
  44. ChName string `form:"ch_name" validate:"required,max=32"`
  45. Description string `form:"description" validate:"max=60"`
  46. }
  47. // ListTokenParam .
  48. type ListTokenParam struct {
  49. NetID int64 `json:"net_id" form:"net_id" validate:"required,gt=0"`
  50. Name string `json:"name" form:"name" validate:"omitempty,max=10"`
  51. ID []int64 `json:"id" form:"id,split" validate:"omitempty,dive,gt=0"`
  52. Sort string `json:"sort" form:"sort" default:"desc"`
  53. Pn int64 `json:"pn" form:"pn" default:"1" validate:"gt=0"`
  54. Ps int64 `json:"ps" form:"ps" default:"30" validate:"gt=0"`
  55. Assign bool `json:"assign" form:"assign"`
  56. }
  57. // GroupTokenParam .
  58. type GroupTokenParam struct {
  59. BusinessID int64 `json:"business_id" form:"business_id" validate:"omitempty,gt=0"`
  60. NetID int64 `json:"net_id" form:"net_id" validate:"omitempty,gt=0"`
  61. GroupName string `json:"group_name" form:"group_name" validate:"omitempty,max=10"`
  62. }
  63. // ListTokenItem .
  64. type ListTokenItem struct {
  65. ID int64 `json:"id"`
  66. NetID int64 `json:"net_id"`
  67. ChName string `json:"ch_name"`
  68. Name string `json:"name"`
  69. Compare int8 `json:"compare"`
  70. Value string `json:"value"`
  71. Type int8 `json:"type"`
  72. UID int64 `json:"uid" gorm:"column:uid"`
  73. Ctime common.FormatTime `json:"ctime"`
  74. Mtime common.FormatTime `json:"mtime"`
  75. Username string `json:"username"`
  76. }
  77. // ListTokenRes .
  78. type ListTokenRes struct {
  79. Result []*ListTokenItem `json:"result"`
  80. Pager Pager `json:"pager"`
  81. }
  82. // ListNetElementParam .
  83. type ListNetElementParam struct {
  84. NetID int64 `json:"net_id" form:"net_id" validate:"required,gt=0"`
  85. Name string `json:"name" form:"name" validate:"omitempty,max=10"`
  86. ID []int64 `json:"id" form:"id,split" validate:"omitempty,dive,gt=0"`
  87. State string `json:"state" form:"state"`
  88. Sort string `json:"sort" form:"sort" default:"desc"`
  89. Pn int64 `json:"pn" form:"pn" default:"1" validate:"gt=0"`
  90. Ps int64 `json:"ps" form:"ps" default:"30" validate:"gt=0"`
  91. }
  92. // ListFlowItem .
  93. type ListFlowItem struct {
  94. ID int64 `json:"id"`
  95. NetID int64 `json:"net_id"`
  96. Name string `json:"name"`
  97. ChName string `json:"ch_name"`
  98. Description string `json:"description"`
  99. UID int64 `json:"uid" gorm:"column:uid"`
  100. DisableTime xtime.Time `json:"disable_time"`
  101. Ctime common.FormatTime `json:"ctime"`
  102. Mtime common.FormatTime `json:"mtime"`
  103. Username string `json:"username"`
  104. Tokens []string `json:"tokens"`
  105. IsStart bool `json:"is_start"`
  106. }
  107. // ListFlowRes .
  108. type ListFlowRes struct {
  109. Result []*ListFlowItem `json:"result"`
  110. Pager Pager `json:"pager"`
  111. }
  112. // ListTransitionItem .
  113. type ListTransitionItem struct {
  114. ID int64 `json:"id"`
  115. NetID int64 `json:"net_id"`
  116. Trigger int8 `json:"trigger"`
  117. Limit int64 `json:"limit"`
  118. Name string `json:"name"`
  119. ChName string `json:"ch_name"`
  120. Description string `json:"description"`
  121. UID int64 `json:"uid" gorm:"column:uid"`
  122. DisableTime xtime.Time `json:"disable_time"`
  123. Ctime common.FormatTime `json:"ctime"`
  124. Mtime common.FormatTime `json:"mtime"`
  125. Username string `json:"username"`
  126. Tokens []string `json:"tokens"`
  127. }
  128. // ListTransitionRes .
  129. type ListTransitionRes struct {
  130. Result []*ListTransitionItem `json:"result"`
  131. Pager Pager `json:"pager"`
  132. }
  133. // ListDirectionParam .
  134. type ListDirectionParam struct {
  135. NetID int64 `json:"net_id" form:"net_id" validate:"required,gt=0"`
  136. FlowID int64 `json:"flow_id" form:"flow_id" validate:"omitempty,gt=0"`
  137. TransitionID int64 `json:"transition_id" form:"transition_id" validate:"omitempty,gt=0"`
  138. Direction int8 `json:"direction" form:"direction"`
  139. ID []int64 `json:"id" form:"id,split" validate:"omitempty,dive,gt=0"`
  140. State string `json:"state" form:"state"`
  141. Sort string `json:"sort" form:"sort" default:"desc"`
  142. Pn int64 `json:"pn" form:"pn" default:"1" validate:"gt=0"`
  143. Ps int64 `json:"ps" form:"ps" default:"30" validate:"gt=0"`
  144. }
  145. // ListDirectionItem .
  146. type ListDirectionItem struct {
  147. ID int64 `json:"id"`
  148. NetID int64 `json:"net_id"`
  149. FlowID int64 `json:"flow_id"`
  150. TransitionID int64 `json:"transition_id"`
  151. Direction int8 `json:"direction"`
  152. Order int8 `json:"order"`
  153. Guard string `json:"guard"`
  154. Output string `json:"output"`
  155. UID int64 `json:"uid" gorm:"column:uid"`
  156. DisableTime xtime.Time `json:"disable_time"`
  157. Ctime common.FormatTime `json:"ctime"`
  158. Mtime common.FormatTime `json:"mtime"`
  159. FlowName string `json:"flow_name"`
  160. TransitionName string `json:"transition_name"`
  161. UserName string `json:"user_name"`
  162. NetName string `json:"net_name"`
  163. }
  164. // ListDirectionRes .
  165. type ListDirectionRes struct {
  166. Result []*ListDirectionItem `json:"result"`
  167. Pager Pager `json:"pager"`
  168. }
  169. // SwitchParam .
  170. type SwitchParam struct {
  171. ID int64 `json:"id" form:"id" validate:"required,gt=0"`
  172. Disable bool `json:"disable" form:"disable"`
  173. }
  174. // FlowEditParam .
  175. type FlowEditParam struct {
  176. NetID int64 `form:"net_id" validate:"omitempty,gt=0"`
  177. ID int64 `form:"id" validate:"omitempty,gt=0"`
  178. Name string `form:"name" validate:"required,max=32"`
  179. ChName string `form:"ch_name" validate:"required,max=16"`
  180. Description string `form:"description" validate:"max=60"`
  181. IsStart bool `form:"is_start" default:"false"`
  182. TokenIDList []int64 `form:"token_id_list,split" validate:"omitempty,dive,gt=0"`
  183. }
  184. // TokenBindParam .
  185. type TokenBindParam struct {
  186. ID int64 `json:"id,omitemtpy"`
  187. ChName string `json:"ch_name,omitempty"`
  188. TokenID string `json:"token_id"`
  189. Type int8 `json:"type"`
  190. }
  191. // TransitionEditParam .
  192. type TransitionEditParam struct {
  193. NetID int64 `json:"net_id" validate:"omitempty,gt=0"`
  194. ID int64 `json:"id" validate:"omitempty,gt=0"`
  195. Trigger int8 `json:"trigger" validate:"omitempty,min=1,max=1"`
  196. Limit int64 `json:"limit"`
  197. Name string `json:"name" validate:"required,max=32"`
  198. ChName string `json:"ch_name" validate:"required,max=16"`
  199. Description string `json:"description" validate:"max=60"`
  200. TokenList []*TokenBindParam `json:"token_list" validate:"required,gt=0" `
  201. }
  202. // DirEditParam .
  203. type DirEditParam struct {
  204. ID int64 `form:"id" validate:"omitempty,gt=0"`
  205. NetID int64 `form:"net_id" validate:"omitempty,gt=0"`
  206. FlowID int64 `form:"flow_id" validate:"required,gt=0"`
  207. TransitionID int64 `form:"transition_id" validate:"required,gt=0"`
  208. Direction int8 `form:"direction" validate:"required,min=1,max=2"`
  209. Order int8 `form:"order" validate:"min=0,max=0"`
  210. Output string
  211. Guard string
  212. }
  213. // Pager .
  214. type Pager struct {
  215. Num int64 `json:"num"`
  216. Size int64 `json:"size"`
  217. Total int64 `json:"total"`
  218. }
  219. // ShowFlowResult .
  220. type ShowFlowResult struct {
  221. Flow *Flow `json:"flow"`
  222. Tokens []*TokenBind `json:"tokens"`
  223. IsStart bool `json:"is_start"`
  224. }
  225. // ShowTransitionResult .
  226. type ShowTransitionResult struct {
  227. Transition *Transition `json:"transition"`
  228. Tokens []*TokenBind `json:"tokens"`
  229. }
  230. // ShowDirectionResult .
  231. type ShowDirectionResult struct {
  232. Direction *Direction `json:"direction"`
  233. FlowName string `json:"flow_name"`
  234. TransitionName string `json:"transition_name"`
  235. }
  236. // TokenPackage .
  237. type TokenPackage struct {
  238. Values map[string]interface{} `json:"values"`
  239. TokenIDList []int64 `json:"token_id_list"`
  240. ChName string `json:"ch_name"`
  241. HitAudit bool `json:"hit_audit"`
  242. }
  243. // TriggerResult .
  244. type TriggerResult struct {
  245. RID int64 `json:"rid"`
  246. NetID int64 `json:"net_id"`
  247. SubmitToken *TokenPackage `json:"submit_token"`
  248. ResultToken *TokenPackage `json:"result_token"`
  249. NewFlowID int64 `json:"new_flow_id"`
  250. OldFlowID string `json:"old_flow_id"` //可能有多个旧节点
  251. TransitionID []int64 `json:"transition_id"`
  252. From string `json:"from"`
  253. }
  254. // TranOperation .
  255. type TranOperation struct {
  256. BindIDList string `json:"bind_id_list"`
  257. ChName string `json:"ch_name"`
  258. }
  259. // TranOperationArr .
  260. type TranOperationArr []*TranOperation
  261. func (a TranOperationArr) Len() int {
  262. return len(a)
  263. }
  264. func (a TranOperationArr) Less(i, j int) bool {
  265. return a[i].BindIDList < a[j].BindIDList
  266. }
  267. func (a TranOperationArr) Swap(i, j int) {
  268. a[i], a[j] = a[j], a[i]
  269. }
  270. // TransitionInfo .
  271. type TransitionInfo struct {
  272. RID int64 `json:"rid"`
  273. FlowID int64 `json:"flow_id"`
  274. Operations []*TranOperation `json:"operations"`
  275. }
  276. // JumpFlowResult .
  277. type JumpFlowResult struct {
  278. RID int64 `json:"rid"`
  279. NetID int64 `json:"net_id"`
  280. SubmitToken *TokenPackage `json:"submit_token"`
  281. ResultToken *TokenPackage `json:"result_token"`
  282. NewFlowID int64 `json:"new_flow_id"`
  283. OldFlowID string `json:"old_flow_id"`
  284. }
  285. // SimpleInfo .
  286. type SimpleInfo struct {
  287. ID int64 `json:"id"`
  288. ChName string `json:"ch_name"`
  289. }
  290. // JumpInfo .
  291. type JumpInfo struct {
  292. Flows []*SimpleInfo `json:"flows"`
  293. Operations []*TranOperation `json:"operations"`
  294. }