正在显示
6 个修改的文件
包含
164 行增加
和
1 行删除
@@ -142,3 +142,29 @@ func (c *AuditController) AllowForbidAudit() { | @@ -142,3 +142,29 @@ func (c *AuditController) AllowForbidAudit() { | ||
142 | msg = protocol.NewReturnResponse(nil, err) | 142 | msg = protocol.NewReturnResponse(nil, err) |
143 | return | 143 | return |
144 | } | 144 | } |
145 | + | ||
146 | +//GetChanceReviseLog | ||
147 | +//@router /v1/audit/revise/info | ||
148 | +func (c *AuditController) GetChanceReviseLog() { | ||
149 | + var msg *protocol.ResponseMessage | ||
150 | + defer func() { | ||
151 | + c.ResposeJson(msg) | ||
152 | + }() | ||
153 | + type Parameter struct { | ||
154 | + FlowLogId int64 `json:"flow_log_id"` | ||
155 | + ChanceId string `json:"chance_id"` | ||
156 | + } | ||
157 | + var param Parameter | ||
158 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
159 | + log.Error("json 解析失败", err) | ||
160 | + msg = protocol.BadRequestParam("1") | ||
161 | + return | ||
162 | + } | ||
163 | + chanceId, _ := strconv.ParseInt(param.ChanceId, 10, 64) | ||
164 | + companyId := c.GetCompanyId() | ||
165 | + rspData, err := serveaudit.GetChanceReviseLog(param.FlowLogId, chanceId, companyId) | ||
166 | + msg = protocol.NewReturnResponse(rspData, err) | ||
167 | + return | ||
168 | +} | ||
169 | + | ||
170 | +// GetChanceReviseLog |
@@ -183,3 +183,21 @@ func (c *CommonController) SelectorRoleUser() { | @@ -183,3 +183,21 @@ func (c *CommonController) SelectorRoleUser() { | ||
183 | msg = protocol.NewReturnResponse(list, err) | 183 | msg = protocol.NewReturnResponse(list, err) |
184 | return | 184 | return |
185 | } | 185 | } |
186 | + | ||
187 | +//SelectorChanceType 获取机会类型列表 | ||
188 | +func (c *CommonController) SelectorChanceType() { | ||
189 | + var msg *protocol.ResponseMessage | ||
190 | + defer func() { | ||
191 | + c.ResposeJson(msg) | ||
192 | + }() | ||
193 | + | ||
194 | + companyid := c.GetCompanyId() | ||
195 | + templatelist := servecommon.SelectGetTemplateList(companyid) | ||
196 | + chanceTypeList := servecommon.SeleteGetChanceTypeList(companyid) | ||
197 | + data := map[string]interface{}{ | ||
198 | + "template": templatelist, | ||
199 | + "chance_type": chanceTypeList, | ||
200 | + } | ||
201 | + msg = protocol.NewReturnResponse(data, nil) | ||
202 | + return | ||
203 | +} |
models/chance_revise_log.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/astaxie/beego/orm" | ||
8 | +) | ||
9 | + | ||
10 | +type ChanceReviseLog struct { | ||
11 | + Id int64 `orm:"column(id);pk" description:"id 主键"` | ||
12 | + ChanceId int64 `orm:"column(chance_id)" description:"机会编号"` | ||
13 | + UserCompanyId int64 `orm:"column(user_company_id);null" description:"用户编号 编辑机会的人"` | ||
14 | + Data string `orm:"column(data);null" description:"机会数据"` | ||
15 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"` | ||
16 | + AuditFlowLogId int64 `orm:"column(audit_flow_log_id);null" description:"表audit_flow_log.id "` | ||
17 | +} | ||
18 | + | ||
19 | +func (t *ChanceReviseLog) TableName() string { | ||
20 | + return "chance_revise_log" | ||
21 | +} | ||
22 | + | ||
23 | +func init() { | ||
24 | + orm.RegisterModel(new(ChanceReviseLog)) | ||
25 | +} | ||
26 | + | ||
27 | +type ReviseContentsItem struct { | ||
28 | + Content string `json:"content"` | ||
29 | +} | ||
30 | + | ||
31 | +type ChanceReviseLogData struct { | ||
32 | + ReviseContents []ReviseContentsItem `json:"reviseContents"` | ||
33 | + Speechs []ChanceDataSpeechs `json:"speechs"` | ||
34 | + Pictures []ChanceDataImage `json:"pictures"` | ||
35 | + Videos []ChanceDataVideos `json:"videos"` | ||
36 | +} | ||
37 | + | ||
38 | +// GetChanceReviseLogById retrieves ChanceReviseLog by Id. Returns error if | ||
39 | +// Id doesn't exist | ||
40 | +func GetChanceReviseLogById(id int64) (v *ChanceReviseLog, err error) { | ||
41 | + o := orm.NewOrm() | ||
42 | + v = &ChanceReviseLog{Id: id} | ||
43 | + if err = o.Read(v); err == nil { | ||
44 | + return v, nil | ||
45 | + } | ||
46 | + return nil, err | ||
47 | +} | ||
48 | + | ||
49 | +func GetChanceReviseLogData(flowLogId int64) (*ChanceReviseLog, *ChanceReviseLogData, error) { | ||
50 | + o := orm.NewOrm() | ||
51 | + var ( | ||
52 | + err error | ||
53 | + ) | ||
54 | + reviseLog := &ChanceReviseLog{} | ||
55 | + err = o.QueryTable(&ChanceReviseLog{}). | ||
56 | + Filter("audit_flow_log_id", flowLogId). | ||
57 | + One(reviseLog) | ||
58 | + if err != nil { | ||
59 | + return nil, nil, err | ||
60 | + } | ||
61 | + reviseLogData := &ChanceReviseLogData{ | ||
62 | + ReviseContents: make([]ReviseContentsItem, 0), | ||
63 | + Speechs: make([]ChanceDataSpeechs, 0), | ||
64 | + Pictures: make([]ChanceDataImage, 0), | ||
65 | + Videos: make([]ChanceDataVideos, 0), | ||
66 | + } | ||
67 | + json.Unmarshal([]byte(reviseLog.Data), reviseLogData) | ||
68 | + return reviseLog, reviseLogData, err | ||
69 | +} |
@@ -275,4 +275,5 @@ type ChanceFlowLog struct { | @@ -275,4 +275,5 @@ type ChanceFlowLog struct { | ||
275 | CreateAt string `json:"create_at" orm:"column(create_at)"` | 275 | CreateAt string `json:"create_at" orm:"column(create_at)"` |
276 | Content string `json:"content" orm:"column(content)"` | 276 | Content string `json:"content" orm:"column(content)"` |
277 | NickName string `json:"nick_name" orm:"column(nick_name)"` | 277 | NickName string `json:"nick_name" orm:"column(nick_name)"` |
278 | + Code int `json:"code" orm:"column(code)"` | ||
278 | } | 279 | } |
@@ -75,6 +75,7 @@ func init() { | @@ -75,6 +75,7 @@ func init() { | ||
75 | beego.NSRouter("/user_and_department", &controllers.CommonController{}, "post:SelectorUserAndDepart"), | 75 | beego.NSRouter("/user_and_department", &controllers.CommonController{}, "post:SelectorUserAndDepart"), |
76 | beego.NSRouter("/default_image", &controllers.CommonController{}, "post:DefaultImage"), | 76 | beego.NSRouter("/default_image", &controllers.CommonController{}, "post:DefaultImage"), |
77 | beego.NSRouter("/role/user", &controllers.CommonController{}, "post:SelectorRoleUser"), | 77 | beego.NSRouter("/role/user", &controllers.CommonController{}, "post:SelectorRoleUser"), |
78 | + beego.NSRouter("/chance_type", &controllers.CommonController{}, "post:SelectorChanceType"), | ||
78 | ), | 79 | ), |
79 | beego.NSNamespace("/template", | 80 | beego.NSNamespace("/template", |
80 | beego.NSRouter("/add", &controllers.TemplateController{}, "post:TemplateAdd"), | 81 | beego.NSRouter("/add", &controllers.TemplateController{}, "post:TemplateAdd"), |
@@ -102,6 +103,7 @@ func init() { | @@ -102,6 +103,7 @@ func init() { | ||
102 | beego.NSRouter("/list/before", &controllers.AuditController{}, "post:AuditListBefore"), | 103 | beego.NSRouter("/list/before", &controllers.AuditController{}, "post:AuditListBefore"), |
103 | beego.NSRouter("/info", &controllers.AuditController{}, "post:AuditInfo"), | 104 | beego.NSRouter("/info", &controllers.AuditController{}, "post:AuditInfo"), |
104 | beego.NSRouter("/allow_forbid", &controllers.AuditController{}, "post:AllowForbidAudit"), | 105 | beego.NSRouter("/allow_forbid", &controllers.AuditController{}, "post:AllowForbidAudit"), |
106 | + beego.NSRouter("/revise/info", &controllers.AuditController{}, "post:GetChanceReviseLog"), | ||
105 | ), | 107 | ), |
106 | beego.NSNamespace("/rank", | 108 | beego.NSNamespace("/rank", |
107 | beego.NSRouter("/type/list", &controllers.RankController{}, "post:GetRankType"), | 109 | beego.NSRouter("/type/list", &controllers.RankController{}, "post:GetRankType"), |
@@ -425,7 +425,7 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { | @@ -425,7 +425,7 @@ func getAuditFlowLog(chanceid int64) ([]protocol.ChanceFlowLog, error) { | ||
425 | flowLogs = make([]protocol.ChanceFlowLog, 0) | 425 | flowLogs = make([]protocol.ChanceFlowLog, 0) |
426 | err error | 426 | err error |
427 | ) | 427 | ) |
428 | - const datasql string = `SELECT a.chance_id,a.content,a.create_at,c.nick_name | 428 | + const datasql string = `SELECT a.chance_id,a.content,a.create_at,c.nick_name,a.code |
429 | FROM audit_flow_log AS a | 429 | FROM audit_flow_log AS a |
430 | LEFT JOIN user_company AS b ON a.approve_user_id=b.id | 430 | LEFT JOIN user_company AS b ON a.approve_user_id=b.id |
431 | LEFT JOIN user AS c ON b.user_id = c.id | 431 | LEFT JOIN user AS c ON b.user_id = c.id |
@@ -525,3 +525,50 @@ func GetPermissionInAuditPage(userid int64, companyid int64) serverabc.OptionOpp | @@ -525,3 +525,50 @@ func GetPermissionInAuditPage(userid int64, companyid int64) serverabc.OptionOpp | ||
525 | } | 525 | } |
526 | return option | 526 | return option |
527 | } | 527 | } |
528 | + | ||
529 | +type ChanceReviseLogInfo struct { | ||
530 | + UserName string `json:"user_name"` | ||
531 | + UserComapnyId int64 `json:"user_company_id"` | ||
532 | + CreateTime string `json:"create_time"` | ||
533 | + models.ChanceReviseLogData | ||
534 | +} | ||
535 | + | ||
536 | +//GetChanceReviseLog 获取对机会的操作记录,补充机会的详情 | ||
537 | +func GetChanceReviseLog(flowLogId int64, chanceId int64, companyId int64) (*ChanceReviseLogInfo, error) { | ||
538 | + var ( | ||
539 | + reviseLog *models.ChanceReviseLog | ||
540 | + reviseLogData *models.ChanceReviseLogData | ||
541 | + usercompanyData *models.UserCompany | ||
542 | + chanceData *models.Chance | ||
543 | + err error | ||
544 | + ) | ||
545 | + chanceData, err = models.GetChanceById(chanceId) | ||
546 | + if err != nil { | ||
547 | + log.Error("获取机会数据chance失败:%s", err) | ||
548 | + return nil, protocol.NewErrWithMessage("1") | ||
549 | + } | ||
550 | + if chanceData.CompanyId != companyId { | ||
551 | + log.Error("机会的公司不匹配") | ||
552 | + } | ||
553 | + reviseLog, reviseLogData, err = models.GetChanceReviseLogData(flowLogId) | ||
554 | + if err != nil { | ||
555 | + log.Error("获取chance_revise_log失败,err:%s", err) | ||
556 | + return nil, protocol.NewErrWithMessage("1") | ||
557 | + } | ||
558 | + if reviseLog.ChanceId != chanceId { | ||
559 | + log.Error("日志与机会不匹配") | ||
560 | + return nil, protocol.NewErrWithMessage("1") | ||
561 | + } | ||
562 | + rspData := &ChanceReviseLogInfo{ | ||
563 | + UserComapnyId: reviseLog.UserCompanyId, | ||
564 | + CreateTime: reviseLog.CreateAt.Format("2006-01-02 15:04:05"), | ||
565 | + ChanceReviseLogData: *reviseLogData, | ||
566 | + } | ||
567 | + usercompanyData, err = models.GetUserCompanyById(reviseLog.UserCompanyId) | ||
568 | + if err != nil { | ||
569 | + log.Error("获取用户数据user_company失败;%s", err) | ||
570 | + } else { | ||
571 | + rspData.UserName = usercompanyData.NickName | ||
572 | + } | ||
573 | + return rspData, nil | ||
574 | +} |
-
请 注册 或 登录 后发表评论