sys_autocode_history.go 1.3 KB

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