You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.4 KiB

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