chance_revise_log.go
2.8 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package models
import (
"encoding/json"
"time"
"github.com/astaxie/beego/orm"
)
type ChanceReviseLog struct {
Id int64 `orm:"column(id);pk" description:"id 主键"`
ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
UserCompanyId int64 `orm:"column(user_company_id);null" description:"用户编号 编辑机会的人"`
Data string `orm:"column(data);null" description:"机会数据"`
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
AuditFlowLogId int64 `orm:"column(audit_flow_log_id);null" description:"表audit_flow_log.id "`
}
func (t *ChanceReviseLog) TableName() string {
return "chance_revise_log"
}
func init() {
orm.RegisterModel(new(ChanceReviseLog))
}
type ReviseContentsItemData struct {
Type string `json:"type"`
Value string `json:"value"`
Path string `json:"path"`
Cover struct {
Path string `json:"path"`
} `json:"cover"`
Duration int `json:"duration"`
}
type ReviseContentsItem struct {
Content string `json:"content"`
Data []ReviseContentsItemData `json:"data,omitempty"`
InputType string `json:"inputType"`
Lable string `json:"lable"`
RemoveAllPhotoVideo bool `json:"removeAllPhotoVideo"`
}
type ChanceReviseLogData struct {
ReviseContents []ReviseContentsItem `json:"reviseContents"`
Speechs []ChanceDataSpeechs `json:"speechs"`
Pictures []ChanceDataImage `json:"pictures"`
Videos []ChanceDataVideos `json:"videos"`
RemoveAllPhotoVideo bool `json:"removeAllPhotoVideo"`
RemoveAllSpeech bool `json:"removeAllSpeech"`
}
// GetChanceReviseLogById retrieves ChanceReviseLog by Id. Returns error if
// Id doesn't exist
func GetChanceReviseLogById(id int64) (v *ChanceReviseLog, err error) {
o := orm.NewOrm()
v = &ChanceReviseLog{Id: id}
if err = o.Read(v); err == nil {
return v, nil
}
return nil, err
}
func GetChanceReviseLogData(flowLogId int64) (*ChanceReviseLog, *ChanceReviseLogData, error) {
o := orm.NewOrm()
var (
err error
)
reviseLog := &ChanceReviseLog{}
err = o.QueryTable(&ChanceReviseLog{}).
Filter("audit_flow_log_id", flowLogId).
One(reviseLog)
if err != nil {
return nil, nil, err
}
reviseLogData := &ChanceReviseLogData{
ReviseContents: make([]ReviseContentsItem, 0),
Speechs: make([]ChanceDataSpeechs, 0),
Pictures: make([]ChanceDataImage, 0),
Videos: make([]ChanceDataVideos, 0),
}
json.Unmarshal([]byte(reviseLog.Data), reviseLogData)
for i := range reviseLogData.ReviseContents {
if reviseLogData.ReviseContents[i].InputType == "" {
reviseLogData.ReviseContents[i].InputType = InputTypeText
}
}
return reviseLog, reviseLogData, err
}