sys_autocode_history.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. package system
  2. import (
  3. "strconv"
  4. "strings"
  5. "server/global"
  6. "server/model/common/request"
  7. )
  8. // SysAutoCodeHistory 自动迁移代码记录,用于回滚,重放使用
  9. type SysAutoCodeHistory struct {
  10. global.GVA_MODEL
  11. Package string `json:"package"`
  12. BusinessDB string `json:"businessDB"`
  13. TableName string `json:"tableName"`
  14. MenuID uint `json:"menuID"`
  15. RequestMeta string `gorm:"type:text" json:"requestMeta,omitempty"` // 前端传入的结构化信息
  16. AutoCodePath string `gorm:"type:text" json:"autoCodePath,omitempty"` // 其他meta信息 path;path
  17. InjectionMeta string `gorm:"type:text" json:"injectionMeta,omitempty"` // 注入的内容 RouterPath@functionName@RouterString;
  18. StructName string `json:"structName"`
  19. StructCNName string `json:"structCNName"`
  20. ApiIDs string `json:"apiIDs,omitempty"` // api表注册内容
  21. Flag int `json:"flag"` // 表示对应状态 0 代表创建, 1 代表回滚 ...
  22. }
  23. // ToRequestIds ApiIDs 转换 request.IdsReq
  24. // Author [SliverHorn](https://github.com/SliverHorn)
  25. func (m *SysAutoCodeHistory) ToRequestIds() request.IdsReq {
  26. if m.ApiIDs == "" {
  27. return request.IdsReq{}
  28. }
  29. slice := strings.Split(m.ApiIDs, ";")
  30. ids := make([]int, 0, len(slice))
  31. length := len(slice)
  32. for i := 0; i < length; i++ {
  33. id, _ := strconv.ParseInt(slice[i], 10, 32)
  34. ids = append(ids, int(id))
  35. }
  36. return request.IdsReq{Ids: ids}
  37. }