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