Merge remote-tracking branch 'origin/dev' into test
正在显示
31 个修改的文件
包含
1095 行增加
和
254 行删除
@@ -28,16 +28,20 @@ | @@ -28,16 +28,20 @@ | ||
28 | |功能|完成状态|时间|接口路径 | 28 | |功能|完成状态|时间|接口路径 |
29 | |---|---|----|----| | 29 | |---|---|----|----| |
30 | |我的机会-我提交的| | |/v1/chance/mySubmitChance| | 30 | |我的机会-我提交的| | |/v1/chance/mySubmitChance| |
31 | -|机会详情| | |v1/chance/detail| | ||
32 | -|机会更新| | | | | ||
33 | -|机会删除| | |/v1/chance/delete| | ||
34 | -|我的机会-我的审核| | | | | ||
35 | -|机会审核| | | /v1/chance/approve| | ||
36 | -|机会修改评分| | |/v1/chance/changeScore| | ||
37 | -|机会修改公开状态| | |/v1/chance/changePublish| | ||
38 | -|计算发现分| | |/v1/chance/calculateScore| | ||
39 | -|用户机会权限| | | | | ||
40 | -|机会池| | | | | 31 | +|我的机会-我的审核| | |/v1/chance/myApproveChance| |
32 | +|机会-详情| | |v1/chance/detail| | ||
33 | +|机会-更新| | | | | ||
34 | +|机会-删除| | |/v1/chance/delete| | ||
35 | +|机会-审核| | | /v1/chance/approve| | ||
36 | +|机会-修改评分| | |/v1/chance/changeScore| | ||
37 | +|机会-修改公开状态| | |/v1/chance/changePublish| | ||
38 | +|机会-计算发现分| | |/v1/chance/calculateScore| | ||
39 | +|配置-用户机会权限| | | | | ||
40 | +|配置-评分| | |v1/config/score| | ||
41 | +|消息-机会审核消息| | | | | ||
42 | +|机会池| | |/v1/chance/chancePool| | ||
43 | +|我的机会-我的收藏| | |/v1/chance/| | ||
44 | +|我的机会-我的点赞| | |/v1/chance/| | ||
41 | |消息-点赞| | |v1/message/msgInteractive| | 45 | |消息-点赞| | |v1/message/msgInteractive| |
42 | |消息-评论| | |v1/message/msgInteractive| | 46 | |消息-评论| | |v1/message/msgInteractive| |
43 | |机会评论列表| | |/v1/chance/comments| | 47 | |机会评论列表| | |/v1/chance/comments| |
@@ -49,12 +53,5 @@ | @@ -49,12 +53,5 @@ | ||
49 | |我的评论|完成|2019.11.21|/v1/chance/iComments| | 53 | |我的评论|完成|2019.11.21|/v1/chance/iComments| |
50 | |我来评论|完成|2019.11.21|/v1/chance/iComment| | 54 | |我来评论|完成|2019.11.21|/v1/chance/iComment| |
51 | |机会审核消息| | |v1/message/msgInteractive| | 55 | |机会审核消息| | |v1/message/msgInteractive| |
52 | -|我提交的机会| | | v1/chance/chances| | ||
53 | -|我审核的机会| | | v1/chance/chances| | ||
54 | -|机会详情| | | | | ||
55 | -|待抓住机会列表| | |v1/chance/chances| | ||
56 | -|配置-评分| | |v1/config/score| | ||
57 | -|机会审核| | |v1/chance/audit| | ||
58 | -|机会修改评分| | |v1/chance/editScore| | ||
59 | -|机会修改公开状态| | |v1/chance/editStatus| | 56 | + |
60 | 57 |
@@ -40,4 +40,4 @@ user_center_app_secret ="cykbjnfqgctn" | @@ -40,4 +40,4 @@ user_center_app_secret ="cykbjnfqgctn" | ||
40 | h5_host = "http://mmm-web-open-test.fjmaimaimai.com" | 40 | h5_host = "http://mmm-web-open-test.fjmaimaimai.com" |
41 | 41 | ||
42 | #审核中心 | 42 | #审核中心 |
43 | -suplus_host ="http://suplus-approve-dev.fjmaimaimai.com" | ||
43 | +suplus_approve_host ="http://suplus-approve-dev.fjmaimaimai.com" |
@@ -40,4 +40,4 @@ user_center_app_secret ="cykbjnfqgctn" | @@ -40,4 +40,4 @@ user_center_app_secret ="cykbjnfqgctn" | ||
40 | h5_host = "http://mmm-web-open-test.fjmaimaimai.com" | 40 | h5_host = "http://mmm-web-open-test.fjmaimaimai.com" |
41 | 41 | ||
42 | #审核中心 | 42 | #审核中心 |
43 | -suplus_host ="http://suplus-approve-test.fjmaimaimai.com" | ||
43 | +suplus_approve_host ="http://suplus-approve-test.fjmaimaimai.com" |
@@ -81,6 +81,14 @@ func (this *BaseController) Resp(msg *protocol.ResponseMessage) { | @@ -81,6 +81,14 @@ func (this *BaseController) Resp(msg *protocol.ResponseMessage) { | ||
81 | this.ServeJSON() | 81 | this.ServeJSON() |
82 | } | 82 | } |
83 | 83 | ||
84 | +func (this *BaseController) RespH5(msg *protocol.ResponseMessage) { | ||
85 | + if msg.Errno != 0 { | ||
86 | + msg.Errno = -1 | ||
87 | + } | ||
88 | + this.Data["json"] = msg | ||
89 | + this.ServeJSON() | ||
90 | +} | ||
91 | + | ||
84 | //获取请求头信息 | 92 | //获取请求头信息 |
85 | func GetRequestHeader(ctx *context.Context) *protocol.RequestHeader { | 93 | func GetRequestHeader(ctx *context.Context) *protocol.RequestHeader { |
86 | h := &protocol.RequestHeader{} | 94 | h := &protocol.RequestHeader{} |
@@ -17,7 +17,7 @@ type H5Controller struct { | @@ -17,7 +17,7 @@ type H5Controller struct { | ||
17 | func (this *H5Controller) Announcement() { | 17 | func (this *H5Controller) Announcement() { |
18 | var msg *protocol.ResponseMessage | 18 | var msg *protocol.ResponseMessage |
19 | defer func() { | 19 | defer func() { |
20 | - this.Resp(msg) | 20 | + this.RespH5(msg) |
21 | }() | 21 | }() |
22 | var request *protocol.AnnouncementRequest | 22 | var request *protocol.AnnouncementRequest |
23 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 23 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
@@ -38,7 +38,7 @@ func (this *H5Controller) Announcement() { | @@ -38,7 +38,7 @@ func (this *H5Controller) Announcement() { | ||
38 | func (this *H5Controller) AnnouncementSubmit() { | 38 | func (this *H5Controller) AnnouncementSubmit() { |
39 | var msg *protocol.ResponseMessage | 39 | var msg *protocol.ResponseMessage |
40 | defer func() { | 40 | defer func() { |
41 | - this.Resp(msg) | 41 | + this.RespH5(msg) |
42 | }() | 42 | }() |
43 | var request *protocol.AnnouncementSubmitRequest | 43 | var request *protocol.AnnouncementSubmitRequest |
44 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 44 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
@@ -59,7 +59,7 @@ func (this *H5Controller) AnnouncementSubmit() { | @@ -59,7 +59,7 @@ func (this *H5Controller) AnnouncementSubmit() { | ||
59 | func (this *H5Controller) ChanceExample() { | 59 | func (this *H5Controller) ChanceExample() { |
60 | var msg *protocol.ResponseMessage | 60 | var msg *protocol.ResponseMessage |
61 | defer func() { | 61 | defer func() { |
62 | - this.Resp(msg) | 62 | + this.RespH5(msg) |
63 | }() | 63 | }() |
64 | var request *protocol.ChanceExampleRequest | 64 | var request *protocol.ChanceExampleRequest |
65 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { | 65 | if err := json.Unmarshal(this.ByteBody, &request); err != nil { |
@@ -185,6 +185,27 @@ func (this *ChanceController) ChanceType() { | @@ -185,6 +185,27 @@ func (this *ChanceController) ChanceType() { | ||
185 | msg = protocol.NewReturnResponse(chance.ChanceType(header, request)) | 185 | msg = protocol.NewReturnResponse(chance.ChanceType(header, request)) |
186 | } | 186 | } |
187 | 187 | ||
188 | +//Permission 机会权限 | ||
189 | +//@router /permission [post] | ||
190 | +func (this *ChanceController) Permission() { | ||
191 | + var msg *protocol.ResponseMessage | ||
192 | + defer func() { | ||
193 | + this.Resp(msg) | ||
194 | + }() | ||
195 | + var request *protocol.ChancePermissionRequest | ||
196 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
197 | + log.Error(err) | ||
198 | + msg = protocol.BadRequestParam(1) | ||
199 | + return | ||
200 | + } | ||
201 | + if b, m := this.Valid(request); !b { | ||
202 | + msg = m | ||
203 | + return | ||
204 | + } | ||
205 | + header := controllers.GetRequestHeader(this.Ctx) | ||
206 | + msg = protocol.NewReturnResponse(chance.ChancePermission(header, request)) | ||
207 | +} | ||
208 | + | ||
188 | //Templates | 209 | //Templates |
189 | //@router /templates [post] | 210 | //@router /templates [post] |
190 | func (this *ChanceController) Templates() { | 211 | func (this *ChanceController) Templates() { |
@@ -231,7 +252,7 @@ func (this *ChanceController) ChanceSubmit() { | @@ -231,7 +252,7 @@ func (this *ChanceController) ChanceSubmit() { | ||
231 | msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request)) | 252 | msg = protocol.NewReturnResponse(chance.ChanceSubmit(header, request)) |
232 | } | 253 | } |
233 | 254 | ||
234 | -//ChanceStatistics | 255 | +//ChanceStatistics 机会统计 |
235 | //@router /statistics [post] | 256 | //@router /statistics [post] |
236 | func (this *ChanceController) ChanceStatistics() { | 257 | func (this *ChanceController) ChanceStatistics() { |
237 | var msg *protocol.ResponseMessage | 258 | var msg *protocol.ResponseMessage |
@@ -273,6 +294,27 @@ func (this *ChanceController) MySubmitChance() { | @@ -273,6 +294,27 @@ func (this *ChanceController) MySubmitChance() { | ||
273 | msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request)) | 294 | msg = protocol.NewReturnResponse(chance.MySubmitChance(header, request)) |
274 | } | 295 | } |
275 | 296 | ||
297 | +//ChancePool 机会池 | ||
298 | +//@router /chancePool [post] | ||
299 | +func (this *ChanceController) ChancePool() { | ||
300 | + var msg *protocol.ResponseMessage | ||
301 | + defer func() { | ||
302 | + this.Resp(msg) | ||
303 | + }() | ||
304 | + var request *protocol.ChancePoolRequest | ||
305 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
306 | + log.Error(err) | ||
307 | + msg = protocol.BadRequestParam(1) | ||
308 | + return | ||
309 | + } | ||
310 | + if b, m := this.Valid(request); !b { | ||
311 | + msg = m | ||
312 | + return | ||
313 | + } | ||
314 | + header := controllers.GetRequestHeader(this.Ctx) | ||
315 | + msg = protocol.NewReturnResponse(chance.ChancePool(header, request)) | ||
316 | +} | ||
317 | + | ||
276 | //ChanceDetail 机会详情 | 318 | //ChanceDetail 机会详情 |
277 | //@router /chanceDetail [post] | 319 | //@router /chanceDetail [post] |
278 | func (this *ChanceController) ChanceDetail() { | 320 | func (this *ChanceController) ChanceDetail() { |
controllers/v1/config.go
0 → 100644
1 | +package v1 | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "opp/controllers" | ||
6 | + "opp/protocol" | ||
7 | + "opp/services/config" | ||
8 | + | ||
9 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
10 | +) | ||
11 | + | ||
12 | +//BulletinController 公告 | ||
13 | +type ConfigController struct { | ||
14 | + controllers.BaseController | ||
15 | +} | ||
16 | + | ||
17 | +//GetConfigScore | ||
18 | +//@router /score/get [post] | ||
19 | +func (this *ConfigController) GetConfigScore() { | ||
20 | + var msg *protocol.ResponseMessage | ||
21 | + defer func() { | ||
22 | + this.Resp(msg) | ||
23 | + }() | ||
24 | + var request *protocol.GetConfigScoreRequest | ||
25 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
26 | + log.Error(err) | ||
27 | + msg = protocol.BadRequestParam(1) | ||
28 | + return | ||
29 | + } | ||
30 | + if b, m := this.Valid(request); !b { | ||
31 | + msg = m | ||
32 | + return | ||
33 | + } | ||
34 | + header := controllers.GetRequestHeader(this.Ctx) | ||
35 | + msg = protocol.NewReturnResponse(config.GetConfigScore(header, request)) | ||
36 | +} |
@@ -158,3 +158,24 @@ func (this *MessageController) MsgCompanyNotice() { | @@ -158,3 +158,24 @@ func (this *MessageController) MsgCompanyNotice() { | ||
158 | header := controllers.GetRequestHeader(this.Ctx) | 158 | header := controllers.GetRequestHeader(this.Ctx) |
159 | msg = protocol.NewReturnResponse(message.MsgCompanyNotice(header, request)) | 159 | msg = protocol.NewReturnResponse(message.MsgCompanyNotice(header, request)) |
160 | } | 160 | } |
161 | + | ||
162 | +//MsgChanceApprove 机会审核消息 | ||
163 | +//@router /msgChanceApprove [post] | ||
164 | +func (this *MessageController) MsgChanceApprove() { | ||
165 | + var msg *protocol.ResponseMessage | ||
166 | + defer func() { | ||
167 | + this.Resp(msg) | ||
168 | + }() | ||
169 | + var request *protocol.MsgChanceApproveRequest | ||
170 | + if err := json.Unmarshal(this.ByteBody, &request); err != nil { | ||
171 | + log.Error(err) | ||
172 | + msg = protocol.BadRequestParam(1) | ||
173 | + return | ||
174 | + } | ||
175 | + if b, m := this.Valid(request); !b { | ||
176 | + msg = m | ||
177 | + return | ||
178 | + } | ||
179 | + header := controllers.GetRequestHeader(this.Ctx) | ||
180 | + msg = protocol.NewReturnResponse(message.MsgChanceApprove(header, request)) | ||
181 | +} |
@@ -150,7 +150,7 @@ func ExecuteQueryOneWithOrmer(o orm.Ormer, result interface{}, sqlstr string, pa | @@ -150,7 +150,7 @@ func ExecuteQueryOneWithOrmer(o orm.Ormer, result interface{}, sqlstr string, pa | ||
150 | 150 | ||
151 | //ExecuteQuerySql 执行原生sql查询多条记录 | 151 | //ExecuteQuerySql 执行原生sql查询多条记录 |
152 | func ExecuteQueryAll(result interface{}, sqlstr string, param ...interface{}) error { | 152 | func ExecuteQueryAll(result interface{}, sqlstr string, param ...interface{}) error { |
153 | - PrintLogSql(sqlstr, param...) | 153 | + //PrintLogSql(sqlstr, param...) |
154 | var err error | 154 | var err error |
155 | o := orm.NewOrm() | 155 | o := orm.NewOrm() |
156 | err = ExecuteQueryAllWithOrmer(o, result, sqlstr, param) | 156 | err = ExecuteQueryAllWithOrmer(o, result, sqlstr, param) |
1 | package utils | 1 | package utils |
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | + "encoding/json" | ||
4 | "errors" | 5 | "errors" |
5 | "fmt" | 6 | "fmt" |
7 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
6 | "reflect" | 8 | "reflect" |
7 | "strings" | 9 | "strings" |
8 | ) | 10 | ) |
@@ -74,3 +76,12 @@ func IsNil(i interface{}) bool { | @@ -74,3 +76,12 @@ func IsNil(i interface{}) bool { | ||
74 | } | 76 | } |
75 | return false | 77 | return false |
76 | } | 78 | } |
79 | + | ||
80 | +func JsonUnmarshal(jsonData string, v interface{}) { | ||
81 | + if len(jsonData) == 0 { | ||
82 | + return | ||
83 | + } | ||
84 | + if e := json.Unmarshal([]byte(jsonData), v); e != nil { | ||
85 | + log.Error("json.unmarshal error data:", jsonData, e) | ||
86 | + } | ||
87 | +} |
@@ -30,6 +30,8 @@ type AuditFlowProcess struct { | @@ -30,6 +30,8 @@ type AuditFlowProcess struct { | ||
30 | UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"` | 30 | UserName string `orm:"column(user_name);size(50)" description:"用户名-冗余"` |
31 | RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"` | 31 | RoleName string `orm:"column(role_name);size(50)" description:"角色名-冗余"` |
32 | RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"` | 32 | RoleId int `orm:"column(role_id);size(50)" description:"角色id-冗余"` |
33 | + ApproveMessage string `orm:"column(approve_message);size(50)" description:"审核消息-冗余"` | ||
34 | + TemplateId int `orm:"column(template_id);size(50)" description:"模板编号-冗余"` | ||
33 | } | 35 | } |
34 | 36 | ||
35 | func (t *AuditFlowProcess) TableName() string { | 37 | func (t *AuditFlowProcess) TableName() string { |
@@ -103,18 +103,18 @@ func DeleteChance(id int64) (err error) { | @@ -103,18 +103,18 @@ func DeleteChance(id int64) (err error) { | ||
103 | func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { | 103 | func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { |
104 | sql := `select a.*,b.images,speechs,videos | 104 | sql := `select a.*,b.images,speechs,videos |
105 | from ( | 105 | from ( |
106 | -select id,user_id,create_at,source_content from chance | 106 | +select id,user_id,create_at,source_content,approve_data,review_status from chance |
107 | where user_id=? and company_id=? and review_status in (?) and (?=0 or id>?) | 107 | where user_id=? and company_id=? and review_status in (?) and (?=0 or id>?) |
108 | order by create_at desc | 108 | order by create_at desc |
109 | limit ? | 109 | limit ? |
110 | ) a left JOIN chance_data b on a.id =b.chance_id` | 110 | ) a left JOIN chance_data b on a.id =b.chance_id` |
111 | 111 | ||
112 | - sqlCount := `select count(0) from ( | 112 | + sqlCount := fmt.Sprintf(`select count(0) from ( |
113 | select id,user_id,create_at,source_content from chance | 113 | select id,user_id,create_at,source_content from chance |
114 | -where user_id=? and company_id=? and review_status in (?) | 114 | +where user_id=? and company_id=? and review_status in (%v) |
115 | order by create_at desc | 115 | order by create_at desc |
116 | -) a left JOIN chance_data b on a.id =b.chance_id` | ||
117 | - if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid, utils.JoinInt8s(reviewStatus, ",")); err != nil { | 116 | +) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ",")) |
117 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil { | ||
118 | return | 118 | return |
119 | } | 119 | } |
120 | if v != nil { | 120 | if v != nil { |
@@ -126,22 +126,48 @@ order by create_at desc | @@ -126,22 +126,48 @@ order by create_at desc | ||
126 | } | 126 | } |
127 | 127 | ||
128 | func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { | 128 | func GetChanceMyApproveChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSize int, v interface{}) (total int, err error) { |
129 | - sql := `select a.*,b.images,b.speechs,b.videos from ( | ||
130 | -select a.*,b.user_id,b.source_content,b.enable_status from ( | ||
131 | -select id,approve_time,approve_data,uid,chance_id | ||
132 | -from audit_flow_process where uid=? and enable_status =1 and review_status in (?) and (?=0 or id>?) | 129 | + sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from ( |
130 | +select a.*,b.user_id,b.source_content,b.enable_status,b.review_status from ( | ||
131 | +select id,approve_time,approve_data,uid,chance_id,approve_message,create_at process_create_time | ||
132 | +from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) and (?=0 or id>?) | ||
133 | )a left outer join chance b on a.chance_id = b.id | 133 | )a left outer join chance b on a.chance_id = b.id |
134 | )a left outer join chance_data b on a.chance_id =b.chance_id | 134 | )a left outer join chance_data b on a.chance_id =b.chance_id |
135 | -order by a.approve_time desc | ||
136 | -LIMIT ?` | 135 | +order by process_create_time desc |
136 | +LIMIT ?`, utils.JoinInt8s(reviewStatus, ",")) | ||
137 | + | ||
138 | + sqlCount := fmt.Sprintf(`select count(0) | ||
139 | +from audit_flow_process where uid=? and enable_status =1 and review_status in (%v) `, utils.JoinInt8s(reviewStatus, ",")) | ||
140 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid); err != nil { | ||
141 | + return | ||
142 | + } | ||
143 | + if v != nil { | ||
144 | + if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, pageSize); err != nil { | ||
145 | + return | ||
146 | + } | ||
147 | + } | ||
148 | + return | ||
149 | +} | ||
137 | 150 | ||
138 | - sqlCount := `select count(0) | ||
139 | -from audit_flow_process where uid=? and enable_status =1 and review_status in (?) ` | ||
140 | - if err = utils.ExecuteQueryOne(&total, sqlCount, uid, utils.JoinInt8s(reviewStatus, ",")); err != nil { | 151 | +func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) { |
152 | + sql := `select a.*,b.images,speechs,videos | ||
153 | +from ( | ||
154 | +select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance | ||
155 | +where user_id=? and company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id>?) and enable_status=1 | ||
156 | +order by create_at desc | ||
157 | +limit ? | ||
158 | +) a left JOIN chance_data b on a.id =b.chance_id` | ||
159 | + //if public==protocol.pu | ||
160 | + | ||
161 | + sqlCount := fmt.Sprintf(`select count(0) from ( | ||
162 | +select id from chance | ||
163 | +where user_id=? and company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 | ||
164 | +order by create_at desc | ||
165 | +) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId) | ||
166 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil { | ||
141 | return | 167 | return |
142 | } | 168 | } |
143 | if v != nil { | 169 | if v != nil { |
144 | - if err = utils.ExecuteQueryAll(v, sql, uid, utils.JoinInt8s(reviewStatus, ","), lastId, lastId, pageSize); err != nil { | 170 | + if err = utils.ExecuteQueryAll(v, sql, uid, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil { |
145 | return | 171 | return |
146 | } | 172 | } |
147 | } | 173 | } |
models/sys_config.go
0 → 100644
1 | +package models | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/astaxie/beego/orm" | ||
8 | +) | ||
9 | + | ||
10 | +type SysConfig struct { | ||
11 | + Id int `orm:"column(id);auto" description:"唯一编号"` | ||
12 | + Key string `orm:"column(key);size(50);null" description:"自定义键值 score:评分模式配置"` | ||
13 | + Content string `orm:"column(content);size(1000);null" description:"配置内容 json"` | ||
14 | + CreateAt time.Time `orm:"column(create_at);type(timestamp);null"` | ||
15 | + UpdateAt time.Time `orm:"column(update_at);type(timestamp);null"` | ||
16 | + CompanyId int `orm:"column(company_id);null" description:"公司编号"` | ||
17 | +} | ||
18 | + | ||
19 | +func (t *SysConfig) TableName() string { | ||
20 | + return "sys_config" | ||
21 | +} | ||
22 | + | ||
23 | +func init() { | ||
24 | + orm.RegisterModel(new(SysConfig)) | ||
25 | +} | ||
26 | + | ||
27 | +var ( | ||
28 | + KeyScore = "score" | ||
29 | +) | ||
30 | + | ||
31 | +// AddSysConfig insert a new SysConfig into database and returns | ||
32 | +// last inserted Id on success. | ||
33 | +func AddSysConfig(m *SysConfig) (id int64, err error) { | ||
34 | + o := orm.NewOrm() | ||
35 | + id, err = o.Insert(m) | ||
36 | + return | ||
37 | +} | ||
38 | + | ||
39 | +// GetSysConfigById retrieves SysConfig by Id. Returns error if | ||
40 | +// Id doesn't exist | ||
41 | +func GetSysConfigById(id int) (v *SysConfig, err error) { | ||
42 | + o := orm.NewOrm() | ||
43 | + v = &SysConfig{Id: id} | ||
44 | + if err = o.Read(v); err == nil { | ||
45 | + return v, nil | ||
46 | + } | ||
47 | + return nil, err | ||
48 | +} | ||
49 | + | ||
50 | +// UpdateSysConfig updates SysConfig by Id and returns error if | ||
51 | +// the record to be updated doesn't exist | ||
52 | +func UpdateSysConfigById(m *SysConfig) (err error) { | ||
53 | + o := orm.NewOrm() | ||
54 | + v := SysConfig{Id: m.Id} | ||
55 | + // ascertain id exists in the database | ||
56 | + if err = o.Read(&v); err == nil { | ||
57 | + var num int64 | ||
58 | + if num, err = o.Update(m); err == nil { | ||
59 | + fmt.Println("Number of records updated in database:", num) | ||
60 | + } | ||
61 | + } | ||
62 | + return | ||
63 | +} | ||
64 | + | ||
65 | +// DeleteSysConfig deletes SysConfig by Id and returns error if | ||
66 | +// the record to be deleted doesn't exist | ||
67 | +func DeleteSysConfig(id int) (err error) { | ||
68 | + o := orm.NewOrm() | ||
69 | + v := SysConfig{Id: id} | ||
70 | + // ascertain id exists in the database | ||
71 | + if err = o.Read(&v); err == nil { | ||
72 | + var num int64 | ||
73 | + if num, err = o.Delete(&SysConfig{Id: id}); err == nil { | ||
74 | + fmt.Println("Number of records deleted in database:", num) | ||
75 | + } | ||
76 | + } | ||
77 | + return | ||
78 | +} | ||
79 | + | ||
80 | +func GetSysConfigByCompanyId(cid int, key string) (v *SysConfig, err error) { | ||
81 | + o := orm.NewOrm() | ||
82 | + sql := "select * from sys_config where `key`=? and company_id=?" | ||
83 | + if err = o.Raw(sql, key, cid).QueryRow(&v); err == nil { | ||
84 | + return v, nil | ||
85 | + } | ||
86 | + return nil, err | ||
87 | +} |
@@ -173,3 +173,27 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag | @@ -173,3 +173,27 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag | ||
173 | } | 173 | } |
174 | return | 174 | return |
175 | } | 175 | } |
176 | + | ||
177 | +//获取机会消息 | ||
178 | +func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) { | ||
179 | + sql := `select a.*,b.images,b.speechs,b.videos from ( | ||
180 | +select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data from ( | ||
181 | +select id,company_id,receive_user_id,message,source_id,is_read | ||
182 | +from user_msg where receive_user_id=? and source_type=1 and (?=0 or id>?) and msg_type=? | ||
183 | +)a left outer join chance b on a.source_id = b.id | ||
184 | +)a left outer join chance_data b on a.source_id =b.chance_id | ||
185 | +order by a.create_at desc | ||
186 | +LIMIT ?` | ||
187 | + | ||
188 | + sqlCount := `select count(0) | ||
189 | +from user_msg where receive_user_id=? and source_type=1 and msg_type=? ` | ||
190 | + if err = utils.ExecuteQueryOne(&total, sqlCount, uid, msgType); err != nil { | ||
191 | + return | ||
192 | + } | ||
193 | + if v != nil { | ||
194 | + if err = utils.ExecuteQueryAll(v, sql, uid, lastId, lastId, msgType, pageSize); err != nil { | ||
195 | + return | ||
196 | + } | ||
197 | + } | ||
198 | + return | ||
199 | +} |
@@ -39,6 +39,7 @@ const ( | @@ -39,6 +39,7 @@ const ( | ||
39 | ReviewStatusReturn = 2 //退回 | 39 | ReviewStatusReturn = 2 //退回 |
40 | ReviewStatusPass = 3 //通过 | 40 | ReviewStatusPass = 3 //通过 |
41 | ReviewStatusSubmit = 4 //提交 | 41 | ReviewStatusSubmit = 4 //提交 |
42 | + ReviewStatusAuditg = 5 //审批中 | ||
42 | ) | 43 | ) |
43 | 44 | ||
44 | //公开状态 | 45 | //公开状态 |
@@ -48,7 +49,12 @@ const ( | @@ -48,7 +49,12 @@ const ( | ||
48 | PublicToCompany = 2 //公司公开 | 49 | PublicToCompany = 2 //公司公开 |
49 | ) | 50 | ) |
50 | 51 | ||
51 | -/*Favorite */ | 52 | +const ( |
53 | + ChanceStatusDelete = 1 //删除 | ||
54 | + ChanceStatusClose = 2 //关闭 | ||
55 | +) | ||
56 | + | ||
57 | +/*Favorite 我的收藏/点赞*/ | ||
52 | type FavoriteRequest struct { | 58 | type FavoriteRequest struct { |
53 | ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞 | 59 | ObjectType int `json:"object_type" valid:"Required"` //收藏 点赞 |
54 | ChanceType int `json:"chance_type" valid:"Required"` | 60 | ChanceType int `json:"chance_type" valid:"Required"` |
@@ -61,29 +67,7 @@ type FavoriteResponse struct { | @@ -61,29 +67,7 @@ type FavoriteResponse struct { | ||
61 | Lists []*ChanceFavorite `json:"lists"` | 67 | Lists []*ChanceFavorite `json:"lists"` |
62 | } | 68 | } |
63 | 69 | ||
64 | -type ChanceFavorite struct { | ||
65 | - Id int64 `json:"id"` | ||
66 | - Favorite interface{} `json:"favorite"` | ||
67 | -} | ||
68 | - | ||
69 | -type ChanceDetail struct { | ||
70 | - Id int64 `json:"id"` | ||
71 | - Provider *BaseUserInfo `json:"provider"` | ||
72 | - IsCollect bool `json:"is_collect"` | ||
73 | - IsZan bool `json:"is_zan"` | ||
74 | - Content string `json:"content"` | ||
75 | - ChanceType int `json:"chance_type"` | ||
76 | - | ||
77 | - //图片 | ||
78 | - //视频 | ||
79 | - //语音 | ||
80 | - | ||
81 | - ViewTotal int `json:"view_total"` | ||
82 | - CommentTotal int `json:"comment_total"` | ||
83 | - ZanTotal int `json:"zan_total"` | ||
84 | -} | ||
85 | - | ||
86 | -/*SympathyAction */ | 70 | +/*SympathyAction 点赞,收藏*/ |
87 | type SympathyActionRequest struct { | 71 | type SympathyActionRequest struct { |
88 | MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏 | 72 | MarkType int `json:"mark_type" valid:"Required"` // 1.赞 2.收藏 |
89 | SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论 | 73 | SourceType int `json:"source_type" valid:"Required"` //protocol.SourceType //机会 评论 |
@@ -108,27 +92,7 @@ type TemplatesResponse struct { | @@ -108,27 +92,7 @@ type TemplatesResponse struct { | ||
108 | Templates []*Template `json:"list"` | 92 | Templates []*Template `json:"list"` |
109 | } | 93 | } |
110 | 94 | ||
111 | -//模板 | ||
112 | -type Template struct { | ||
113 | - Id int64 `json:"id"` | ||
114 | - Name string `json:"name"` | ||
115 | - Doc string `json:"doc"` | ||
116 | - Icon string `json:"icon"` | ||
117 | - FormList []*Form `json:"formList"` | ||
118 | - Link string `json:"link"` //示例 | ||
119 | -} | ||
120 | - | ||
121 | -//表单 | ||
122 | -type Form struct { | ||
123 | - Id int `json:"id"` | ||
124 | - Label string `json:"label"` | ||
125 | - InputType string `json:"inputType"` | ||
126 | - SectionType int8 `json:"sectionType"` | ||
127 | - Value string `json:"value"` | ||
128 | - Required int8 `json:"required"` | ||
129 | -} | ||
130 | - | ||
131 | -/*ChanceExample*/ | 95 | +/*ChanceExample 机会示例*/ |
132 | type ChanceExampleRequest struct { | 96 | type ChanceExampleRequest struct { |
133 | TemplateId int `json:"templateId" valid:"Required"` | 97 | TemplateId int `json:"templateId" valid:"Required"` |
134 | } | 98 | } |
@@ -136,6 +100,7 @@ type ChanceExampleResponse struct { | @@ -136,6 +100,7 @@ type ChanceExampleResponse struct { | ||
136 | Content string `json:"content"` | 100 | Content string `json:"content"` |
137 | } | 101 | } |
138 | 102 | ||
103 | +/*提交机会*/ | ||
139 | type ChanceSubmitRequest struct { | 104 | type ChanceSubmitRequest struct { |
140 | Id int64 `json:"id"` // = 0添加 >0 编辑 | 105 | Id int64 `json:"id"` // = 0添加 >0 编辑 |
141 | AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"` | 106 | AuditTemplateId int64 `json:"auditTemplateId" valid:"Required"` |
@@ -146,29 +111,9 @@ type ChanceSubmitRequest struct { | @@ -146,29 +111,9 @@ type ChanceSubmitRequest struct { | ||
146 | Videos []Video `json:"videos"` | 111 | Videos []Video `json:"videos"` |
147 | RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"` | 112 | RelatedDepartment int64 `json:"relatedDepartments" valid:"Required"` |
148 | } | 113 | } |
149 | - | ||
150 | type ChanceSubmitResponse struct { | 114 | type ChanceSubmitResponse struct { |
151 | } | 115 | } |
152 | 116 | ||
153 | -type Speech struct { | ||
154 | - Path string `json:"path"` | ||
155 | - Duration int `json:"duration"` | ||
156 | -} | ||
157 | -type Picture struct { | ||
158 | - Path string `json:"path"` | ||
159 | - W int `json:"w"` | ||
160 | - H int `json:"h"` | ||
161 | -} | ||
162 | -type Video struct { | ||
163 | - Path string `json:"path"` | ||
164 | - Cover Cover `json:"cover"` //封面 | ||
165 | - Duration int `json:"duration"` | ||
166 | -} | ||
167 | - | ||
168 | -type AuditConfig struct { | ||
169 | - NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】 | ||
170 | -} | ||
171 | - | ||
172 | /*ChanceStatistics 首页-机会池统计*/ | 117 | /*ChanceStatistics 首页-机会池统计*/ |
173 | type ChanceStatisticsRequest struct { | 118 | type ChanceStatisticsRequest struct { |
174 | } | 119 | } |
@@ -177,12 +122,6 @@ type ChanceStatisticsResponse struct { | @@ -177,12 +122,6 @@ type ChanceStatisticsResponse struct { | ||
177 | List []ChanceTotalItem `json:"list"` | 122 | List []ChanceTotalItem `json:"list"` |
178 | } | 123 | } |
179 | 124 | ||
180 | -type ChanceTotalItem struct { | ||
181 | - Id int `json:"id"` //类型 | ||
182 | - Name string `json:"name"` //总数 | ||
183 | - Total int `json:"total"` | ||
184 | -} | ||
185 | - | ||
186 | /*MyChance 我的机会*/ | 125 | /*MyChance 我的机会*/ |
187 | type MySubmitChanceRequest struct { | 126 | type MySubmitChanceRequest struct { |
188 | LastId int64 `json:"lastId"` | 127 | LastId int64 `json:"lastId"` |
@@ -190,33 +129,29 @@ type MySubmitChanceRequest struct { | @@ -190,33 +129,29 @@ type MySubmitChanceRequest struct { | ||
190 | ReviewStatus int8 `json:"reviewStatus"` //审核状态 | 129 | ReviewStatus int8 `json:"reviewStatus"` //审核状态 |
191 | } | 130 | } |
192 | type MySubmitChanceResponse struct { | 131 | type MySubmitChanceResponse struct { |
193 | - List []ChanceItem `json:"list"` | ||
194 | - Total int `json:"total"` | 132 | + List []CommonListItem `json:"list"` |
133 | + Total int `json:"total"` | ||
195 | } | 134 | } |
196 | 135 | ||
197 | -/*MyApproveChance 我审核的机会*/ | ||
198 | -type MyApproveChanceRequest struct { | 136 | +/*ChancePool 机会池*/ |
137 | +type ChancePoolRequest struct { | ||
199 | LastId int64 `json:"lastId"` | 138 | LastId int64 `json:"lastId"` |
200 | PageSize int `json:"pageSize" valid:"Required"` | 139 | PageSize int `json:"pageSize" valid:"Required"` |
201 | - ReviewStatus int8 `json:"reviewStatus"` //审核状态 | 140 | + ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会 |
202 | } | 141 | } |
203 | -type MyApproveChanceResponse struct { | 142 | +type ChancePoolResponse struct { |
204 | List []CommonListItem `json:"list"` | 143 | List []CommonListItem `json:"list"` |
205 | Total int `json:"total"` | 144 | Total int `json:"total"` |
206 | } | 145 | } |
207 | 146 | ||
208 | -//机会列表 通用项 | ||
209 | -type CommonListItem struct { | ||
210 | - Chance ChanceItem `json:"chance,omitempty"` //机会详情 | ||
211 | - ChanceData ChanceData `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数) | ||
212 | - Approve Approve `json:"approve,omitempty"` //审核人 审核信息(时间) | ||
213 | - ApproveData ApproveData `json:"ApproveData"` //审核数据(公开状态 评分) | ||
214 | - Message interface{} `json:"message,omitempty"` | ||
215 | - Comment interface{} `json:"comment,omitempty"` | ||
216 | - ChanceStatus int `json:"chanceStatus,omitempty"` //1.删除 2.关闭 | 147 | +/*Permission 机会权限*/ |
148 | +type ChancePermissionRequest struct { | ||
217 | } | 149 | } |
218 | - | ||
219 | -type ChanceData struct { | 150 | +type ChancePermissionResponse struct { |
151 | + EditScore int `json:"editScore"` | ||
152 | + EditChance int `json:"editChance"` | ||
153 | + EditPublic int `json:"editPublic"` | ||
154 | + CloseChance int `json:"closeChance"` | ||
220 | } | 155 | } |
221 | 156 | ||
222 | //我的机会列表 | 157 | //我的机会列表 |
@@ -228,31 +163,59 @@ type ChanceItemOrm struct { | @@ -228,31 +163,59 @@ type ChanceItemOrm struct { | ||
228 | Images string `orm:"column(images)"` | 163 | Images string `orm:"column(images)"` |
229 | Voices string `orm:"column(speechs)"` | 164 | Voices string `orm:"column(speechs)"` |
230 | Videos string `orm:"column(videos)"` | 165 | Videos string `orm:"column(videos)"` |
166 | + ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | ||
167 | + | ||
168 | + ApproveData string `json:"approveData"` //审核数据 | ||
231 | } | 169 | } |
232 | -type ChanceItem struct { | ||
233 | - Id int64 `json:"id"` | ||
234 | - CreateTime int64 `json:"createTime"` | ||
235 | - Provider *BaseUserInfo `json:"provider"` | ||
236 | - FormList []*Form `json:"formList" valid:"Required"` | ||
237 | - Speechs []Speech `json:"speechs"` | ||
238 | - Pictures []Picture `json:"pictures"` | ||
239 | - Videos []Video `json:"videos"` | 170 | + |
171 | +/*MyApproveChance 我审核的机会*/ | ||
172 | +type MyApproveChanceRequest struct { | ||
173 | + LastId int64 `json:"lastId"` | ||
174 | + PageSize int `json:"pageSize" valid:"Required"` | ||
175 | + ReviewStatus int8 `json:"reviewStatus"` //审核状态 | ||
176 | +} | ||
177 | +type MyApproveChanceResponse struct { | ||
178 | + List []CommonListItem `json:"list"` | ||
179 | + Total int `json:"total"` | ||
240 | } | 180 | } |
241 | 181 | ||
242 | //我的审核机会列表 | 182 | //我的审核机会列表 |
243 | type ChanceApproveItemOrm struct { | 183 | type ChanceApproveItemOrm struct { |
244 | ChanceUserId int64 `orm:"column(chance_user_id)"` | 184 | ChanceUserId int64 `orm:"column(chance_user_id)"` |
245 | SourceContent string `orm:"column(source_content)"` | 185 | SourceContent string `orm:"column(source_content)"` |
246 | - ChanceEnableStatus string `orm:"column(enable_status)"` | 186 | + ChanceEnableStatus int `orm:"column(enable_status)"` |
247 | Images string `orm:"column(images)"` | 187 | Images string `orm:"column(images)"` |
248 | Voices string `orm:"column(speechs)"` | 188 | Voices string `orm:"column(speechs)"` |
249 | Videos string `orm:"column(videos)"` | 189 | Videos string `orm:"column(videos)"` |
190 | + ReviewStatus int `orm:"column(review_status)"` | ||
191 | + | ||
192 | + Id int64 `orm:"column(id)"` //审核id | ||
193 | + ApproveTime time.Time `orm:"column(approve_time)"` | ||
194 | + ApproveData string `orm:"column(approve_data)"` | ||
195 | + ApproveMessage string `orm:"column(approve_message)"` | ||
196 | + ApproveUserId int64 `orm:"column(uid)"` | ||
197 | + ProcessCreateTime time.Time `orm:"column(process_create_time)"` | ||
198 | + ChanceId int64 `orm:"column(chance_id)"` // 机会id | ||
199 | +} | ||
200 | + | ||
201 | +//机会池列表 | ||
202 | +type ChancePoolItemOrm struct { | ||
203 | + Id int64 `orm:"column(id)"` | ||
204 | + Uid int64 `orm:"column(user_id)"` | ||
205 | + CreateTime time.Time `orm:"column(create_at)"` | ||
206 | + SourceContent string `orm:"column(source_content)"` | ||
207 | + Images string `orm:"column(images)"` | ||
208 | + Voices string `orm:"column(speechs)"` | ||
209 | + Videos string `orm:"column(videos)"` | ||
210 | + ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | ||
211 | + | ||
212 | + //ApproveData string `json:"approveData"` //审核数据 | ||
250 | 213 | ||
251 | - Id int64 `orm:"column(id)"` //审核id | ||
252 | - ApproveTime time.Time `orm:"column(approve_time)"` | ||
253 | - ApproveData string `orm:"column(approve_data)"` | ||
254 | - ApproveUserId int64 `orm:"column(uid)"` | ||
255 | - ChanceId int64 `orm:"column(chance_id)"` // 机会id | 214 | + TemplateId int `orm:"column(audit_template_id)"` |
215 | + ChanceTypeId int `orm:"column(chance_type_id)"` | ||
216 | + CommentTotal int `orm:"column(comment_total)"` | ||
217 | + ZanTotal int `orm:"column(zan_total)"` | ||
218 | + ViewTotal int `orm:"column(view_total)"` | ||
256 | } | 219 | } |
257 | 220 | ||
258 | /*ChanceDetail 机会详情*/ | 221 | /*ChanceDetail 机会详情*/ |
@@ -260,17 +223,20 @@ type ChanceDetailRequest struct { | @@ -260,17 +223,20 @@ type ChanceDetailRequest struct { | ||
260 | Id int64 `json:"id"` //机会编号 | 223 | Id int64 `json:"id"` //机会编号 |
261 | } | 224 | } |
262 | type ChanceDetailResponse struct { | 225 | type ChanceDetailResponse struct { |
263 | - ChanceDetail ChanceItem `json:"chanceDetail"` | ||
264 | - ApproveData *ApproveData `json:"publicData"` | 226 | + ChanceDetail ChanceItem `json:"chance"` |
227 | + ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData | ||
228 | + ApproveData *ApproveData `json:"approveData"` | ||
265 | ApproveProcess []*ProcessItem `json:"approveProcess"` | 229 | ApproveProcess []*ProcessItem `json:"approveProcess"` |
266 | ApproveAccess *ApproveAccess `json:"approveAccess"` // | 230 | ApproveAccess *ApproveAccess `json:"approveAccess"` // |
231 | + ChanceType NameItem `json:"chanceType"` //机会类型 | ||
232 | + ChanceTemplate NameItem `json:"template"` //机会模板 | ||
233 | + ReviewStatus int `json:"review_status"` //审核状态 1:待审核 2:被退回 3:已通过 | ||
267 | } | 234 | } |
268 | 235 | ||
269 | -/*ChanceDelete 机会删除*/ | ||
270 | -type ChanceDeleteRequest struct { | ||
271 | - Id int64 `json:"id"` //机会编号 | ||
272 | -} | ||
273 | -type ChanceDeleteResponse struct { | 236 | +type ChanceType struct { |
237 | + Id int `json:"id"` | ||
238 | + Name string `json:"name"` | ||
239 | + Template | ||
274 | } | 240 | } |
275 | 241 | ||
276 | /*ChanceChangePublish 修改公开状态*/ | 242 | /*ChanceChangePublish 修改公开状态*/ |
@@ -296,3 +262,121 @@ type ChanceCalculateScoreRequest struct { | @@ -296,3 +262,121 @@ type ChanceCalculateScoreRequest struct { | ||
296 | type ChanceCalculateScoreResponse struct { | 262 | type ChanceCalculateScoreResponse struct { |
297 | DiscoveryScore float64 `json:"discoveryScore"` //发现分 | 263 | DiscoveryScore float64 `json:"discoveryScore"` //发现分 |
298 | } | 264 | } |
265 | + | ||
266 | +/*ChanceDelete 机会删除*/ | ||
267 | +type ChanceDeleteRequest struct { | ||
268 | + Id int64 `json:"id"` //机会编号 | ||
269 | +} | ||
270 | +type ChanceDeleteResponse struct { | ||
271 | +} | ||
272 | + | ||
273 | +type ChanceFavorite struct { | ||
274 | + Id int64 `json:"id"` | ||
275 | + Favorite interface{} `json:"favorite"` | ||
276 | +} | ||
277 | + | ||
278 | +//机会详情 | ||
279 | +type ChanceDetail struct { | ||
280 | + Id int64 `json:"id"` | ||
281 | + Provider *BaseUserInfo `json:"provider"` | ||
282 | + IsCollect bool `json:"is_collect"` | ||
283 | + IsZan bool `json:"is_zan"` | ||
284 | + Content string `json:"content"` | ||
285 | + ChanceType int `json:"chance_type"` | ||
286 | + | ||
287 | + //图片 | ||
288 | + //视频 | ||
289 | + //语音 | ||
290 | + | ||
291 | + ViewTotal int `json:"view_total"` | ||
292 | + CommentTotal int `json:"comment_total"` | ||
293 | + ZanTotal int `json:"zan_total"` | ||
294 | +} | ||
295 | + | ||
296 | +//模板 | ||
297 | +type Template struct { | ||
298 | + Id int64 `json:"id"` | ||
299 | + Name string `json:"name"` | ||
300 | + Doc string `json:"doc"` | ||
301 | + Icon string `json:"icon"` | ||
302 | + FormList []*Form `json:"formList"` | ||
303 | + Link string `json:"link"` //示例 | ||
304 | +} | ||
305 | + | ||
306 | +//表单 | ||
307 | +type Form struct { | ||
308 | + Id int `json:"id"` | ||
309 | + Label string `json:"label"` | ||
310 | + InputType string `json:"inputType"` | ||
311 | + SectionType int8 `json:"sectionType"` | ||
312 | + Value string `json:"value"` | ||
313 | + Required int8 `json:"required"` | ||
314 | +} | ||
315 | + | ||
316 | +//语音 | ||
317 | +type Speech struct { | ||
318 | + Path string `json:"path"` | ||
319 | + Duration int `json:"duration"` | ||
320 | +} | ||
321 | + | ||
322 | +//图片 | ||
323 | +type Picture struct { | ||
324 | + Path string `json:"path"` | ||
325 | + W int `json:"w"` | ||
326 | + H int `json:"h"` | ||
327 | +} | ||
328 | + | ||
329 | +//视频 | ||
330 | +type Video struct { | ||
331 | + Path string `json:"path"` | ||
332 | + Cover Cover `json:"cover"` //封面 | ||
333 | + Duration int `json:"duration"` | ||
334 | +} | ||
335 | + | ||
336 | +//审批配置 | ||
337 | +type AuditConfig struct { | ||
338 | + NoApprover int8 `json:"no_approver"` //审核人空时:【1:自动通过】【2:转交给管理员】 | ||
339 | +} | ||
340 | + | ||
341 | +//机会池 - 统计 | ||
342 | +type ChanceTotalItem struct { | ||
343 | + Id int `json:"id"` //类型 | ||
344 | + Name string `json:"name"` //总数 | ||
345 | + Total int `json:"total"` | ||
346 | +} | ||
347 | + | ||
348 | +//机会列表 通用项 | ||
349 | +type CommonListItem struct { | ||
350 | + Chance ChanceItem `json:"chance,omitempty"` //机会详情 | ||
351 | + ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData | ||
352 | + Approve interface{} `json:"approve,omitempty"` //审核人 审核信息(时间) Approve | ||
353 | + ApproveData interface{} `json:"approveData,omitempty"` //审核数据(公开状态 评分) ApproveData | ||
354 | + Message interface{} `json:"message,omitempty"` //消息 | ||
355 | + Comment interface{} `json:"comment,omitempty"` //评论 | ||
356 | + ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭 | ||
357 | + ReviewStatus int `json:"reviewStatus"` //审核状态 | ||
358 | + | ||
359 | + //我审核的-通过 | ||
360 | + Score interface{} `json:"score,omitempty"` | ||
361 | + | ||
362 | + //模板 | ||
363 | + ChanceType interface{} `json:"chanceType,omitempty"` //机会类型 | ||
364 | + ChanceTemplate interface{} `json:"template,omitempty"` //机会模板 | ||
365 | +} | ||
366 | +type ChanceItem struct { | ||
367 | + Id int64 `json:"id"` | ||
368 | + CreateTime int64 `json:"createTime"` | ||
369 | + Provider *BaseUserInfo `json:"provider"` | ||
370 | + FormList []*Form `json:"formList" valid:"Required"` | ||
371 | + Speechs []Speech `json:"speechs"` | ||
372 | + Pictures []Picture `json:"pictures"` | ||
373 | + Videos []Video `json:"videos"` | ||
374 | +} | ||
375 | +type ChanceData struct { | ||
376 | + ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数 | ||
377 | + CommentTotal int `json:"commentTotal"` //评论总数 | ||
378 | + PageViewTotal int `json:"pageView"` //评论总数 | ||
379 | + | ||
380 | + IsThumbsUp bool `json:"thumbsup"` //是否点赞 1 点赞, 0 没有点赞 | ||
381 | + IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否 | ||
382 | +} |
@@ -37,6 +37,27 @@ type ChanceApproveProcessResponse struct { | @@ -37,6 +37,27 @@ type ChanceApproveProcessResponse struct { | ||
37 | ApproveAccess *ApproveAccess `json:"approveOperate"` | 37 | ApproveAccess *ApproveAccess `json:"approveOperate"` |
38 | } | 38 | } |
39 | 39 | ||
40 | +//审批数据 | ||
41 | +type Approve struct { | ||
42 | + //Provider *BaseUserInfo `json:"provider"` | ||
43 | + ProcessId int64 `json:"processId"` | ||
44 | + CreateTime int64 `json:"createTime"` | ||
45 | + ApproveTime int64 `json:"approveTime"` | ||
46 | +} | ||
47 | + | ||
48 | +//审核操作权限 | ||
49 | +type ApproveAccess struct { | ||
50 | + ProcessId int64 `json:"processId"` | ||
51 | + AllowApprove int `json:"allowApprove"` | ||
52 | + AllowReject int `json:"allowReject"` | ||
53 | +} | ||
54 | + | ||
55 | +//审核数据 审核通过 | ||
56 | +type ApproveData struct { | ||
57 | + PublicData PublicData `json:"publicData"` // 公开数据 | ||
58 | + Score Score `json:"score"` | ||
59 | +} | ||
60 | + | ||
40 | //进程项 | 61 | //进程项 |
41 | type ProcessItem struct { | 62 | type ProcessItem struct { |
42 | Id int64 `json:"id"` | 63 | Id int64 `json:"id"` |
@@ -45,39 +66,15 @@ type ProcessItem struct { | @@ -45,39 +66,15 @@ type ProcessItem struct { | ||
45 | ApproveType int `json:"approveType"` //审批类型 1 业务区域负责人 2 指定成员 3 角色 | 66 | ApproveType int `json:"approveType"` //审批类型 1 业务区域负责人 2 指定成员 3 角色 |
46 | ApproveTime int64 `json:"approveTime"` //审核时间 | 67 | ApproveTime int64 `json:"approveTime"` //审核时间 |
47 | //Role Role `json:"role"` //角色 | 68 | //Role Role `json:"role"` //角色 |
48 | - Uid int64 `json:"uid"` | ||
49 | - Name string `json:"name"` | ||
50 | - RoleName string `json:"roleName"` | ||
51 | - Role int `json:"-"` | ||
52 | - ApproveData ApproveData `json:"ApproveData"` //审核数据 | 69 | + Uid int64 `json:"uid"` |
70 | + Name string `json:"name"` | ||
71 | + RoleName string `json:"roleName"` | ||
72 | + Role int `json:"-"` | ||
73 | + ApproveData *ApproveData `json:"approveData"` //审核数据 | ||
53 | //ApproveUser UserItem `json:"approveUser"` //审核人 //状态不是审核中 | 74 | //ApproveUser UserItem `json:"approveUser"` //审核人 //状态不是审核中 |
54 | ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色 | 75 | ApproveUsers []UserItem `json:"approveUsers"` //审核人员 //1 会签 2 或签 //审核中 1.部门长 2.角色 |
55 | } | 76 | } |
56 | 77 | ||
57 | -//用户项 | ||
58 | -type UserItem struct { | ||
59 | - Uid int64 `json:"uid"` | ||
60 | - Name string `json:"name"` | ||
61 | -} | ||
62 | - | ||
63 | -//角色项 | ||
64 | -type Role struct { | ||
65 | - Id int `json:"id"` | ||
66 | - Name string `json:"name"` | ||
67 | -} | ||
68 | - | ||
69 | -type Approve struct { | ||
70 | - Provider BaseUserInfo `json:"provider"` | ||
71 | - ProcessId int64 `json:"processId"` | ||
72 | - ApproveTime int64 `json:"approveTime"` | ||
73 | -} | ||
74 | - | ||
75 | -//审核数据 审核通过 | ||
76 | -type ApproveData struct { | ||
77 | - PublicData PublicData `json:"publicData"` // 公开数据 | ||
78 | - Score Score `json:"score"` | ||
79 | -} | ||
80 | - | ||
81 | //公开数据 | 78 | //公开数据 |
82 | type PublicData struct { | 79 | type PublicData struct { |
83 | PublishStatus int `json:"publishStatus"` //公开状态 0未公开、1部门公开、2公司公开 | 80 | PublishStatus int `json:"publishStatus"` //公开状态 0未公开、1部门公开、2公司公开 |
@@ -98,10 +95,3 @@ type Score struct { | @@ -98,10 +95,3 @@ type Score struct { | ||
98 | ValueScore float64 `json:"valueScore"` //价值分 | 95 | ValueScore float64 `json:"valueScore"` //价值分 |
99 | DiscoveryScore float64 `json:"discoveryScore"` //发现分 | 96 | DiscoveryScore float64 `json:"discoveryScore"` //发现分 |
100 | } | 97 | } |
101 | - | ||
102 | -//审核操作权限 | ||
103 | -type ApproveAccess struct { | ||
104 | - ProcessId int64 `json:"processId"` | ||
105 | - AllowApprove int `json:"allowApprove"` | ||
106 | - AllowReject int `json:"allowReject"` | ||
107 | -} |
protocol/config.go
0 → 100644
1 | +package protocol | ||
2 | + | ||
3 | +/*GetConfigScore */ | ||
4 | +type GetConfigScoreRequest struct { | ||
5 | +} | ||
6 | +type GetConfigScoreResponse struct { | ||
7 | + ScoreConfig | ||
8 | +} | ||
9 | + | ||
10 | +type ScoreConfig struct { | ||
11 | + DiscoveryScore *DiscoveryScore `json:"discoveryScore"` | ||
12 | + SumScore *SumScore `json:"-"` //sumScore | ||
13 | + BasicScore *ScoreRange `json:"basicScore"` | ||
14 | + ExtraScore *ScoreRange `json:"extraScore"` | ||
15 | + ValueScore *ScoreRange `json:"valueScore"` | ||
16 | +} | ||
17 | + | ||
18 | +//发现评分计算规则 | ||
19 | +type DiscoveryScore struct { | ||
20 | + BasicFactor float64 `json:"basicFactor"` //基础分系数 | ||
21 | + ExtraFactor float64 `json:"extraFactor"` //附加分系数 | ||
22 | + ValueFactor float64 `json:"valueFactor"` //价值分系数 | ||
23 | +} | ||
24 | + | ||
25 | +//总分计算规则 | ||
26 | +type SumScore struct { | ||
27 | + DiscoveryFactor float64 `json:"discoveryFactor"` //发现分系数 | ||
28 | + CatchFactor float64 `json:"catchFactor"` //抓住分系数 | ||
29 | +} | ||
30 | +type ScoreRange struct { | ||
31 | + Min float64 `json:"min"` //最小分 | ||
32 | + Max float64 `json:"max"` //最大分 | ||
33 | + Step float64 `json:"step"` //步长 | ||
34 | +} |
@@ -95,13 +95,6 @@ func NewReturnResponse(data interface{}, eRR error) *ResponseMessage { | @@ -95,13 +95,6 @@ func NewReturnResponse(data interface{}, eRR error) *ResponseMessage { | ||
95 | msg.Data = data | 95 | msg.Data = data |
96 | return msg | 96 | return msg |
97 | } | 97 | } |
98 | - //if x,ok :=eRR.(*ErrWithMessage);ok{ | ||
99 | - // if x.ErrorCode.Errno==0{ | ||
100 | - // msg = x.ParseToMessage() | ||
101 | - // msg.Data = data | ||
102 | - // } | ||
103 | - // return msg | ||
104 | - //} | ||
105 | // fmt.Println("日志:" + eRR.Error()) | 98 | // fmt.Println("日志:" + eRR.Error()) |
106 | if x, ok := eRR.(CustomErrParse); ok { | 99 | if x, ok := eRR.(CustomErrParse); ok { |
107 | msg = x.ParseToMessage() | 100 | msg = x.ParseToMessage() |
@@ -36,3 +36,37 @@ const ( | @@ -36,3 +36,37 @@ const ( | ||
36 | MyAuditChancePass //我审核的机会-已通过 | 36 | MyAuditChancePass //我审核的机会-已通过 |
37 | MyAuditChanceReturn //我审核的机会-已退回 | 37 | MyAuditChanceReturn //我审核的机会-已退回 |
38 | ) | 38 | ) |
39 | + | ||
40 | +var MapStaticName map[int64]string | ||
41 | + | ||
42 | +func init() { | ||
43 | + MapStaticName = make(map[int64]string) | ||
44 | + MapStaticName[CollectStatic] = "收藏" | ||
45 | + MapStaticName[ZanStatic] = "点赞" | ||
46 | + MapStaticName[CommentStatic] = "评论" | ||
47 | + MapStaticName[MyCommitChance] = "我提交的机会" | ||
48 | + MapStaticName[MyCommitChanceWait] = "我提交的机会-待审批" | ||
49 | + MapStaticName[MyCommitChanceReturn] = "我提交的机会-退回" | ||
50 | + MapStaticName[MyCommitChancePass] = "我提交的机会-已通过" | ||
51 | + MapStaticName[MyAuditChance] = "我审核的机会" | ||
52 | + MapStaticName[MyAuditChanceWait] = "我审核的机会-待我审批" | ||
53 | + MapStaticName[MyAuditChancePass] = "我审核的机会-已通过" | ||
54 | + MapStaticName[MyAuditChanceReturn] = "我审核的机会-已退回" | ||
55 | +} | ||
56 | + | ||
57 | +//用户项 | ||
58 | +type UserItem struct { | ||
59 | + Uid int64 `json:"uid"` | ||
60 | + Name string `json:"name"` | ||
61 | +} | ||
62 | + | ||
63 | +//角色项 | ||
64 | +type Role struct { | ||
65 | + Id int `json:"id"` | ||
66 | + Name string `json:"name"` | ||
67 | +} | ||
68 | + | ||
69 | +type NameItem struct { | ||
70 | + Id int `json:"id"` | ||
71 | + Name string `json:"name"` | ||
72 | +} |
@@ -2,6 +2,7 @@ package protocol | @@ -2,6 +2,7 @@ package protocol | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "encoding/json" | 4 | "encoding/json" |
5 | + "time" | ||
5 | ) | 6 | ) |
6 | 7 | ||
7 | var errmessge ErrorMap = map[int]string{ | 8 | var errmessge ErrorMap = map[int]string{ |
@@ -47,10 +48,19 @@ var errmessge ErrorMap = map[int]string{ | @@ -47,10 +48,19 @@ var errmessge ErrorMap = map[int]string{ | ||
47 | } | 48 | } |
48 | 49 | ||
49 | const ( | 50 | const ( |
50 | - MsgTypeBulletin = 1 //公告 | ||
51 | - MsgTypeCommend = 2 //表彰 | ||
52 | - MsgTypeInteraction = 4 //互动消息 | ||
53 | - MsgTypeAudit = 8 //机会审核 | 51 | + MsgTypeBulletin = 1 //公告 |
52 | + MsgTypeCommend = 2 //表彰 | ||
53 | + MsgTypeInteraction = 4 //互动消息 | ||
54 | + MsgTypeAudit = 8 //机会审核 | ||
55 | + MsgTypeAuditBy = 16 //机会被审核消息 | ||
56 | + MsgTypeComment = 32 //评论 | ||
57 | + MsgTypeThumbUp = 64 //点赞 | ||
58 | +) | ||
59 | + | ||
60 | +var ( | ||
61 | + MessageApproving = "提交了一条%v机会消息,需要您审核" | ||
62 | + MessageApproveSuccess = "审核通过你提交的%v机会" | ||
63 | + MessageApproveReject = "退回您了提交的%v机会" | ||
54 | ) | 64 | ) |
55 | 65 | ||
56 | /*MessageCenter */ | 66 | /*MessageCenter */ |
@@ -186,6 +196,36 @@ type MsgCompanyNoticeResponse struct { | @@ -186,6 +196,36 @@ type MsgCompanyNoticeResponse struct { | ||
186 | Total int `json:"total"` | 196 | Total int `json:"total"` |
187 | } | 197 | } |
188 | 198 | ||
199 | +/*MsgChanceApprove 机会审核消息*/ | ||
200 | +type MsgChanceApproveRequest struct { | ||
201 | + LastId int64 `json:"lastId"` | ||
202 | + PageSize int `json:"pageSize" valid:"Required"` | ||
203 | +} | ||
204 | +type MsgChanceApproveResponse struct { | ||
205 | + List []CommonListItem `json:"list"` | ||
206 | + Total int `json:"total"` | ||
207 | +} | ||
208 | + | ||
209 | +//我的审核机会列表 | ||
210 | +type MsgChanceApproveItemOrm struct { | ||
211 | + ChanceUserId int64 `orm:"column(chance_user_id)"` | ||
212 | + SourceContent string `orm:"column(source_content)"` | ||
213 | + ChanceEnableStatus int `orm:"column(enable_status)"` | ||
214 | + Images string `orm:"column(images)"` | ||
215 | + Voices string `orm:"column(speechs)"` | ||
216 | + Videos string `orm:"column(videos)"` | ||
217 | + ReviewStatus int `orm:"column(review_status)"` | ||
218 | + ApproveData string `orm:"column(approve_data)"` //审核数据 | ||
219 | + | ||
220 | + Id int64 `orm:"column(id)"` //消息id | ||
221 | + ReceiveUserId int64 `orm:"column(receive_user_id)"` | ||
222 | + CreateTime time.Time `orm:"column(create_at)"` | ||
223 | + Message string `orm:"column(message)"` | ||
224 | + IsRead int64 `orm:"column(isRead)"` | ||
225 | + ChanceId int64 `orm:"column(source_id)"` // 机会id | ||
226 | + //EnableStatus int `orm:"column(enable_status)"` | ||
227 | +} | ||
228 | + | ||
189 | /*Announcement H5公告详情*/ | 229 | /*Announcement H5公告详情*/ |
190 | type AnnouncementRequest struct { | 230 | type AnnouncementRequest struct { |
191 | Id int `json:"id" valid:"Required"` | 231 | Id int `json:"id" valid:"Required"` |
@@ -54,6 +54,15 @@ type UserInfoResponse struct { | @@ -54,6 +54,15 @@ type UserInfoResponse struct { | ||
54 | User User `json:"user"` | 54 | User User `json:"user"` |
55 | } | 55 | } |
56 | 56 | ||
57 | +//用户统计信息 | ||
58 | +/*UserStatistics */ | ||
59 | +type UserStatisticsRequest struct { | ||
60 | + TypeTotal int64 `json:"typeTotal" valid:"Required"` | ||
61 | +} | ||
62 | +type UserStatisticsResponse struct { | ||
63 | + Totals []TypeTotalItem `json:"totals"` | ||
64 | +} | ||
65 | + | ||
57 | type User struct { | 66 | type User struct { |
58 | UserId int64 `json:"uid"` | 67 | UserId int64 `json:"uid"` |
59 | Name string `json:"uname"` | 68 | Name string `json:"uname"` |
@@ -89,14 +98,6 @@ type Job struct { | @@ -89,14 +98,6 @@ type Job struct { | ||
89 | Level int `json:"level"` | 98 | Level int `json:"level"` |
90 | } | 99 | } |
91 | 100 | ||
92 | -//用户统计信息 | ||
93 | -/*UserStatistics */ | ||
94 | -type UserStatisticsRequest struct { | ||
95 | - TypeTotal int64 `json:"typeTotal" valid:"Required"` | ||
96 | -} | ||
97 | -type UserStatisticsResponse struct { | ||
98 | - Totals []TypeTotalItem `json:"totals"` | ||
99 | -} | ||
100 | type TypeTotalItem struct { | 101 | type TypeTotalItem struct { |
101 | Type int64 `json:"type"` //类型 | 102 | Type int64 `json:"type"` //类型 |
102 | Total int `json:"total"` //总数 | 103 | Total int `json:"total"` //总数 |
@@ -81,6 +81,14 @@ func init() { | @@ -81,6 +81,14 @@ func init() { | ||
81 | 81 | ||
82 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 82 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
83 | beego.ControllerComments{ | 83 | beego.ControllerComments{ |
84 | + Method: "ChancePool", | ||
85 | + Router: `/chancePool`, | ||
86 | + AllowHTTPMethods: []string{"post"}, | ||
87 | + MethodParams: param.Make(), | ||
88 | + Params: nil}) | ||
89 | + | ||
90 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
91 | + beego.ControllerComments{ | ||
84 | Method: "ChanceType", | 92 | Method: "ChanceType", |
85 | Router: `/chanceType`, | 93 | Router: `/chanceType`, |
86 | AllowHTTPMethods: []string{"post"}, | 94 | AllowHTTPMethods: []string{"post"}, |
@@ -177,6 +185,14 @@ func init() { | @@ -177,6 +185,14 @@ func init() { | ||
177 | 185 | ||
178 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | 186 | beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], |
179 | beego.ControllerComments{ | 187 | beego.ControllerComments{ |
188 | + Method: "Permission", | ||
189 | + Router: `/permission`, | ||
190 | + AllowHTTPMethods: []string{"post"}, | ||
191 | + MethodParams: param.Make(), | ||
192 | + Params: nil}) | ||
193 | + | ||
194 | + beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ChanceController"], | ||
195 | + beego.ControllerComments{ | ||
180 | Method: "ChanceStatistics", | 196 | Method: "ChanceStatistics", |
181 | Router: `/statistics`, | 197 | Router: `/statistics`, |
182 | AllowHTTPMethods: []string{"post"}, | 198 | AllowHTTPMethods: []string{"post"}, |
@@ -215,6 +231,14 @@ func init() { | @@ -215,6 +231,14 @@ func init() { | ||
215 | MethodParams: param.Make(), | 231 | MethodParams: param.Make(), |
216 | Params: nil}) | 232 | Params: nil}) |
217 | 233 | ||
234 | + beego.GlobalControllerRouter["opp/controllers/v1:ConfigController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:ConfigController"], | ||
235 | + beego.ControllerComments{ | ||
236 | + Method: "GetConfigScore", | ||
237 | + Router: `/score/get`, | ||
238 | + AllowHTTPMethods: []string{"post"}, | ||
239 | + MethodParams: param.Make(), | ||
240 | + Params: nil}) | ||
241 | + | ||
218 | beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"], | 242 | beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:DepartmentController"], |
219 | beego.ControllerComments{ | 243 | beego.ControllerComments{ |
220 | Method: "Departments", | 244 | Method: "Departments", |
@@ -265,6 +289,14 @@ func init() { | @@ -265,6 +289,14 @@ func init() { | ||
265 | 289 | ||
266 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | 290 | beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], |
267 | beego.ControllerComments{ | 291 | beego.ControllerComments{ |
292 | + Method: "MsgChanceApprove", | ||
293 | + Router: `/msgChanceApprove`, | ||
294 | + AllowHTTPMethods: []string{"post"}, | ||
295 | + MethodParams: param.Make(), | ||
296 | + Params: nil}) | ||
297 | + | ||
298 | + beego.GlobalControllerRouter["opp/controllers/v1:MessageController"] = append(beego.GlobalControllerRouter["opp/controllers/v1:MessageController"], | ||
299 | + beego.ControllerComments{ | ||
268 | Method: "MsgCompanyNotice", | 300 | Method: "MsgCompanyNotice", |
269 | Router: `/msgCompanyNotice`, | 301 | Router: `/msgCompanyNotice`, |
270 | AllowHTTPMethods: []string{"post"}, | 302 | AllowHTTPMethods: []string{"post"}, |
@@ -22,6 +22,7 @@ func init() { | @@ -22,6 +22,7 @@ func init() { | ||
22 | beego.NSNamespace("chance", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ChanceController{})), | 22 | beego.NSNamespace("chance", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ChanceController{})), |
23 | beego.NSNamespace("message", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.MessageController{})), | 23 | beego.NSNamespace("message", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.MessageController{})), |
24 | beego.NSNamespace("department", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.DepartmentController{})), | 24 | beego.NSNamespace("department", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.DepartmentController{})), |
25 | + beego.NSNamespace("config", beego.NSBefore(controllers.FilterComm), beego.NSInclude(&v1.ConfigController{})), | ||
25 | ) | 26 | ) |
26 | beego.AddNamespace(nsV1) | 27 | beego.AddNamespace(nsV1) |
27 | 28 |
@@ -3,6 +3,7 @@ package agg | @@ -3,6 +3,7 @@ package agg | ||
3 | import ( | 3 | import ( |
4 | "bytes" | 4 | "bytes" |
5 | "fmt" | 5 | "fmt" |
6 | + "github.com/astaxie/beego/orm" | ||
6 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 7 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
7 | "opp/internal/utils" | 8 | "opp/internal/utils" |
8 | "opp/models" | 9 | "opp/models" |
@@ -177,6 +178,20 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e | @@ -177,6 +178,20 @@ func GetChance(chanceId int64, companyId int64) (v *protocol.ChanceDetail, err e | ||
177 | return | 178 | return |
178 | } | 179 | } |
179 | 180 | ||
181 | +//获取机会标记数据 点赞 / 收藏 | ||
182 | +func GetChanceMarkData(userId, companyId int64, sourceId int64) (flag int, err error) { | ||
183 | + var ( | ||
184 | + v *models.ChanceFavorite | ||
185 | + ) | ||
186 | + if v, err = models.GetChanceFavorite(userId, companyId, sourceId, protocol.SourceTypeChance); err != nil { | ||
187 | + if err == orm.ErrNoRows { | ||
188 | + return 0, nil | ||
189 | + } | ||
190 | + return | ||
191 | + } | ||
192 | + return v.MarkFlag, nil | ||
193 | +} | ||
194 | + | ||
180 | //构建统计sql语句 | 195 | //构建统计sql语句 |
181 | func GetIncrementSql(table string, column string, incre int, id int64) *utils.SqlData { | 196 | func GetIncrementSql(table string, column string, incre int, id int64) *utils.SqlData { |
182 | var sql *bytes.Buffer | 197 | var sql *bytes.Buffer |
@@ -187,3 +202,17 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq | @@ -187,3 +202,17 @@ func GetIncrementSql(table string, column string, incre int, id int64) *utils.Sq | ||
187 | Sql: sql.String(), | 202 | Sql: sql.String(), |
188 | } | 203 | } |
189 | } | 204 | } |
205 | + | ||
206 | +//清楚未填写的表单数据 | ||
207 | +func ClearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) { | ||
208 | + if len(inputFormList) == 0 { | ||
209 | + return | ||
210 | + } | ||
211 | + for i := range inputFormList { | ||
212 | + item := inputFormList[i] | ||
213 | + if len(item.Value) > 0 { | ||
214 | + FormList = append(FormList, item) | ||
215 | + } | ||
216 | + } | ||
217 | + return | ||
218 | +} |
@@ -84,6 +84,56 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan | @@ -84,6 +84,56 @@ func SendApproveMsgByFormat(receiverId int64, name string, companyId int64, chan | ||
84 | return | 84 | return |
85 | } | 85 | } |
86 | 86 | ||
87 | +//发送被审核消息 | ||
88 | +func SendApprovedMsg(receiverId int64, name string, companyId int64, chanceId int64, chanceTypeId int, reviewStatus int, msgType int) (err error) { | ||
89 | + var ( | ||
90 | + chanceType *models.ChanceType | ||
91 | + format string | ||
92 | + ) | ||
93 | + switch reviewStatus { | ||
94 | + case protocol.ReviewStatusAuditging: | ||
95 | + format = MessageApproving | ||
96 | + break | ||
97 | + case protocol.ReviewStatusReturn: | ||
98 | + format = MessageApproveReject | ||
99 | + break | ||
100 | + case protocol.ReviewStatusPass: | ||
101 | + format = MessageApproveSuccess | ||
102 | + break | ||
103 | + default: | ||
104 | + format = MessageApproving | ||
105 | + break | ||
106 | + } | ||
107 | + if chanceType, err = models.GetChanceTypeById(chanceTypeId); err != nil { | ||
108 | + return | ||
109 | + } | ||
110 | + format = fmt.Sprintf(format, chanceType.Name) | ||
111 | + return SendMsg(receiverId, name, companyId, chanceId, protocol.SourceTypeChance, format, msgType) | ||
112 | +} | ||
113 | + | ||
114 | +//发送消息 | ||
115 | +func SendMsg(receiverId int64, name string, companyId int64, sourceId int64, sourceType int, message string, msgType int) (err error) { | ||
116 | + var ( | ||
117 | + userMsg *models.UserMsg | ||
118 | + ) | ||
119 | + userMsg = &models.UserMsg{ | ||
120 | + Id: idgen.Next(), | ||
121 | + CompanyId: companyId, | ||
122 | + ReceiveUserId: receiverId, | ||
123 | + MsgType: msgType, | ||
124 | + Message: message, | ||
125 | + SourceId: sourceId, | ||
126 | + SourceType: sourceType, | ||
127 | + IsPublic: 0, | ||
128 | + CreateAt: time.Now(), | ||
129 | + } | ||
130 | + if _, err = models.AddUserMsg(userMsg); err != nil { | ||
131 | + return | ||
132 | + } | ||
133 | + logMsg(userMsg, name) | ||
134 | + return | ||
135 | +} | ||
136 | + | ||
87 | //打印消息日志 | 137 | //打印消息日志 |
88 | func logMsg(msg *models.UserMsg, name string) { | 138 | func logMsg(msg *models.UserMsg, name string) { |
89 | log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v", | 139 | log.Info(fmt.Sprintf("发送消息 消息类型:%v Receiver:%v(%v) Message:%v SourceId:%v SourceType:%v", |
@@ -20,3 +20,16 @@ func MyChanceStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total | @@ -20,3 +20,16 @@ func MyChanceStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total | ||
20 | } | 20 | } |
21 | return | 21 | return |
22 | } | 22 | } |
23 | + | ||
24 | +func MyApproveStatic(header *protocol.RequestHeader, reviewStatus ...int8) (total int, err error) { | ||
25 | + var () | ||
26 | + if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, reviewStatus, 0, 0, nil); err != nil { | ||
27 | + if err == orm.ErrNoRows { | ||
28 | + err = nil | ||
29 | + return | ||
30 | + } | ||
31 | + log.Error(err) | ||
32 | + return | ||
33 | + } | ||
34 | + return | ||
35 | +} |
@@ -43,7 +43,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces | @@ -43,7 +43,7 @@ func (s SuplusApprove) NewApproveInstance(header *protocol.RequestHeader, proces | ||
43 | relativeId int64 | 43 | relativeId int64 |
44 | userCompany *models.UserCompany | 44 | userCompany *models.UserCompany |
45 | ) | 45 | ) |
46 | - if userCompany, err = models.GetUserCompanyByUserId(header.UserId, header.CompanyId); err != nil { | 46 | + if userCompany, err = models.GetUserCompanyByUserId(header.Uid, header.CompanyId); err != nil { |
47 | log.Error(err) | 47 | log.Error(err) |
48 | return | 48 | return |
49 | } | 49 | } |
@@ -291,6 +291,11 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -291,6 +291,11 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
291 | err = protocol.NewErrWithMessage(5101) | 291 | err = protocol.NewErrWithMessage(5101) |
292 | return | 292 | return |
293 | } | 293 | } |
294 | + if chance.EnableStatus == 0 { | ||
295 | + log.Error(fmt.Sprintf("chance_id:%v enable_status:%v", chance.Id, chance.EnableStatus)) | ||
296 | + err = protocol.NewErrWithMessage(5101) | ||
297 | + return | ||
298 | + } | ||
294 | if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil { | 299 | if process, err = models.GetAuditFlowProcessBy(request.ProcessId, header.UserId); err != nil { |
295 | log.Error(request.ProcessId, header.UserId, err) | 300 | log.Error(request.ProcessId, header.UserId, err) |
296 | err = protocol.NewErrWithMessage(5202) | 301 | err = protocol.NewErrWithMessage(5202) |
@@ -501,14 +506,23 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) | @@ -501,14 +506,23 @@ func ChanceApproveProcess(header *protocol.RequestHeader, chance *models.Chance) | ||
501 | } | 506 | } |
502 | } | 507 | } |
503 | } | 508 | } |
509 | + //兼容审批流 待审核1->审批中5 | ||
510 | + //chanceProcessItemReviewStatus:=func(item *protocol.ProcessItem ) *protocol.ProcessItem { | ||
511 | + // if item.ReviewStatus==protocol.ReviewStatusAuditging{ | ||
512 | + // item.ReviewStatus= protocol.ReviewStatusAuditg | ||
513 | + // } | ||
514 | + // return item | ||
515 | + //} | ||
504 | for i := range processList { | 516 | for i := range processList { |
505 | p := processList[i] | 517 | p := processList[i] |
506 | item := newProcessItem(p) | 518 | item := newProcessItem(p) |
507 | checkApprovePermission(p) | 519 | checkApprovePermission(p) |
508 | //机会已经审核通过的直接添加到审核人列表 | 520 | //机会已经审核通过的直接添加到审核人列表 |
509 | if chance.ReviewStatus == protocol.ReviewStatusPass { | 521 | if chance.ReviewStatus == protocol.ReviewStatusPass { |
510 | - if e := json.Unmarshal([]byte(p.ApproveData), &item.ApproveData); e != nil { | ||
511 | - log.Error(e) | 522 | + if len(p.ApproveData) > 0 { |
523 | + if e := json.Unmarshal([]byte(p.ApproveData), &item.ApproveData); e != nil { | ||
524 | + log.Error("data", p.ApproveData, e) | ||
525 | + } | ||
512 | } | 526 | } |
513 | rsp.ApproveProcess = append(rsp.ApproveProcess, item) | 527 | rsp.ApproveProcess = append(rsp.ApproveProcess, item) |
514 | continue | 528 | continue |
@@ -236,12 +236,17 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -236,12 +236,17 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
236 | auditConfig *protocol.AuditConfig | 236 | auditConfig *protocol.AuditConfig |
237 | auditFlows []*models.AuditFlowProcess | 237 | auditFlows []*models.AuditFlowProcess |
238 | suplusApprove SuplusApprove | 238 | suplusApprove SuplusApprove |
239 | + chanceType *models.ChanceType | ||
239 | ) | 240 | ) |
240 | //1.模板是否存在 | 241 | //1.模板是否存在 |
241 | if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil { | 242 | if template, err = models.GetAuditTemplateById(request.AuditTemplateId); err != nil { |
242 | log.Error("模板不存在:", request.AuditTemplateId, err) | 243 | log.Error("模板不存在:", request.AuditTemplateId, err) |
243 | return | 244 | return |
244 | } | 245 | } |
246 | + if chanceType, err = models.GetChanceTypeById(template.ChanceTypeId); err != nil { | ||
247 | + log.Error("一级分类不存在:", request.AuditTemplateId, err) | ||
248 | + return | ||
249 | + } | ||
245 | auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} | 250 | auditConfig = &protocol.AuditConfig{NoApprover: template.NoApprover} |
246 | orm := orm.NewOrm() | 251 | orm := orm.NewOrm() |
247 | orm.Begin() | 252 | orm.Begin() |
@@ -284,6 +289,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -284,6 +289,8 @@ func ChanceSubmit(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
284 | return | 289 | return |
285 | } | 290 | } |
286 | for i := 0; i < len(auditFlows); i++ { | 291 | for i := 0; i < len(auditFlows); i++ { |
292 | + auditFlows[i].ApproveMessage = fmt.Sprintf(protocol.MessageApproving, chanceType.Name) | ||
293 | + //auditFlows[i].TemplateId = int(template.Id) | ||
287 | if _, err = orm.Insert(auditFlows[i]); err != nil { | 294 | if _, err = orm.Insert(auditFlows[i]); err != nil { |
288 | log.Error(err) | 295 | log.Error(err) |
289 | orm.Rollback() | 296 | orm.Rollback() |
@@ -379,6 +386,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit | @@ -379,6 +386,7 @@ func ChanceUpdate(header *protocol.RequestHeader, request *protocol.ChanceSubmit | ||
379 | //6.更新文件 | 386 | //6.更新文件 |
380 | { | 387 | { |
381 | if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { | 388 | if chanceData, err = models.GetChanceDataByChanceId(chance.Id); err == nil { |
389 | + | ||
382 | if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{ | 390 | if err = utils.UpdateTableByMapWithOrmer(orm, chanceData, map[string]interface{}{ |
383 | "Speechs": common.AssertJson(request.Speechs), | 391 | "Speechs": common.AssertJson(request.Speechs), |
384 | "Images": common.AssertJson(request.Pictures), | 392 | "Images": common.AssertJson(request.Pictures), |
@@ -520,6 +528,19 @@ func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.Chan | @@ -520,6 +528,19 @@ func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.Chan | ||
520 | return | 528 | return |
521 | } | 529 | } |
522 | 530 | ||
531 | +//机会权限 | ||
532 | +func ChancePermission(header *protocol.RequestHeader, request *protocol.ChancePermissionRequest) (rsp *protocol.ChancePermissionResponse, err error) { | ||
533 | + var () | ||
534 | + rsp = &protocol.ChancePermissionResponse{} | ||
535 | + { | ||
536 | + rsp.EditChance = 1 | ||
537 | + rsp.EditScore = 1 | ||
538 | + rsp.EditPublic = 1 | ||
539 | + rsp.CloseChance = 1 | ||
540 | + } | ||
541 | + return | ||
542 | +} | ||
543 | + | ||
523 | //生成审批流-提交记录 | 544 | //生成审批流-提交记录 |
524 | func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) { | 545 | func GenAuditFlowProcess_Submit(header *protocol.RequestHeader, chanceId int64, templateId int64) (v *models.AuditFlowProcess) { |
525 | v = &models.AuditFlowProcess{ | 546 | v = &models.AuditFlowProcess{ |
@@ -660,6 +681,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | @@ -660,6 +681,7 @@ func GenAuditFlowProcess(header *protocol.RequestHeader, chanceId int64, templat | ||
660 | RoleName: roleName, | 681 | RoleName: roleName, |
661 | UserName: approver.NickName, | 682 | UserName: approver.NickName, |
662 | ReviewStatus: protocol.ReviewStatusAuditging, | 683 | ReviewStatus: protocol.ReviewStatusAuditging, |
684 | + TemplateId: int(templateId), | ||
663 | } | 685 | } |
664 | if config.Level == 1 { | 686 | if config.Level == 1 { |
665 | item.IsActive = 1 | 687 | item.IsActive = 1 |
@@ -777,29 +799,38 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | @@ -777,29 +799,38 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | ||
777 | 799 | ||
778 | for i := 0; i < len(myChances); i++ { | 800 | for i := 0; i < len(myChances); i++ { |
779 | chance := myChances[i] | 801 | chance := myChances[i] |
780 | - item := protocol.ChanceItem{ | ||
781 | - Id: chance.Id, | ||
782 | - Provider: provider, | ||
783 | - CreateTime: chance.CreateTime.Unix() * 1000, | 802 | + commItem := protocol.CommonListItem{} |
803 | + { | ||
804 | + item := protocol.ChanceItem{ | ||
805 | + Id: chance.Id, | ||
806 | + Provider: provider, | ||
807 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
808 | + } | ||
809 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
810 | + item.FormList = clearEmptyForm(item.FormList) | ||
811 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
812 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
813 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
814 | + commItem.Chance = item | ||
784 | } | 815 | } |
785 | - jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
786 | - jsonUnmarshal(chance.Images, &item.Pictures) | ||
787 | - jsonUnmarshal(chance.Voices, &item.Speechs) | ||
788 | - jsonUnmarshal(chance.Videos, &item.Videos) | ||
789 | - rsp.List = append(rsp.List, item) | 816 | + commItem.ReviewStatus = chance.ReviewStatus |
817 | + if request.ReviewStatus == protocol.ReviewStatusPass { | ||
818 | + jsonUnmarshal(chance.ApproveData, &commItem.ApproveData) | ||
819 | + } | ||
820 | + rsp.List = append(rsp.List, commItem) | ||
790 | } | 821 | } |
791 | return | 822 | return |
792 | } | 823 | } |
793 | 824 | ||
794 | -//我审核的机会 | ||
795 | -func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) { | 825 | +//机会池 |
826 | +func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequest) (rsp *protocol.ChancePoolResponse, err error) { | ||
796 | var ( | 827 | var ( |
797 | - myChances []protocol.ChanceApproveItemOrm | 828 | + myChances []protocol.ChancePoolItemOrm |
798 | total int | 829 | total int |
799 | provider *protocol.BaseUserInfo | 830 | provider *protocol.BaseUserInfo |
831 | + flag int | ||
800 | ) | 832 | ) |
801 | - rsp = &protocol.MyApproveChanceResponse{} | ||
802 | - if total, err = models.GetChanceMyChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { | 833 | + if total, err = models.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.LastId, request.PageSize, &myChances); err != nil { |
803 | if err == orm.ErrNoRows { | 834 | if err == orm.ErrNoRows { |
804 | err = nil | 835 | err = nil |
805 | return | 836 | return |
@@ -811,26 +842,127 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | @@ -811,26 +842,127 @@ func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApprove | ||
811 | log.Error(err) | 842 | log.Error(err) |
812 | return | 843 | return |
813 | } | 844 | } |
814 | - rsp = &protocol.MyApproveChanceResponse{Total: total} | 845 | + rsp = &protocol.ChancePoolResponse{Total: total} |
846 | + | ||
815 | for i := 0; i < len(myChances); i++ { | 847 | for i := 0; i < len(myChances); i++ { |
816 | chance := myChances[i] | 848 | chance := myChances[i] |
817 | commItem := protocol.CommonListItem{} | 849 | commItem := protocol.CommonListItem{} |
818 | - item := protocol.ChanceItem{ | ||
819 | - Id: chance.Id, | ||
820 | - Provider: provider, | ||
821 | - //CreateTime: chance.CreateTime.Unix() * 1000, | 850 | + { |
851 | + item := protocol.ChanceItem{ | ||
852 | + Id: chance.Id, | ||
853 | + Provider: provider, | ||
854 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
855 | + } | ||
856 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
857 | + item.FormList = clearEmptyForm(item.FormList) | ||
858 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
859 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
860 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
861 | + commItem.Chance = item | ||
862 | + } | ||
863 | + commItem.ReviewStatus = chance.ReviewStatus | ||
864 | + { | ||
865 | + var chanceData = protocol.ChanceData{ | ||
866 | + ThumbsUpTotal: chance.ZanTotal, | ||
867 | + CommentTotal: chance.CommentTotal, | ||
868 | + PageViewTotal: chance.ViewTotal, | ||
869 | + } | ||
870 | + if flag, err = agg.GetChanceMarkData(header.UserId, header.CompanyId, chance.Id); err != nil { | ||
871 | + log.Error(err) | ||
872 | + continue | ||
873 | + } | ||
874 | + chanceData.IsThumbsUp = (flag & protocol.MarkFlagZan) == protocol.MarkFlagZan | ||
875 | + chanceData.IsCollect = (flag & protocol.MarkFlagCollect) == protocol.MarkFlagCollect | ||
876 | + commItem.ChanceData = chanceData | ||
822 | } | 877 | } |
823 | - jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
824 | - jsonUnmarshal(chance.Images, &item.Pictures) | ||
825 | - jsonUnmarshal(chance.Voices, &item.Speechs) | ||
826 | - jsonUnmarshal(chance.Videos, &item.Videos) | ||
827 | 878 | ||
828 | { | 879 | { |
829 | - commItem.Chance = item | 880 | + //做一次查询 查回所有的模板数据 |
881 | + if template, e := models.GetAuditTemplateById(int64(chance.TemplateId)); e == nil { | ||
882 | + commItem.ChanceTemplate = protocol.NameItem{ | ||
883 | + Id: int(template.Id), | ||
884 | + Name: template.Name, | ||
885 | + } | ||
886 | + } | ||
887 | + if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil { | ||
888 | + commItem.ChanceType = protocol.NameItem{ | ||
889 | + Id: int(chanceType.Id), | ||
890 | + Name: chanceType.Name, | ||
891 | + } | ||
892 | + } | ||
830 | } | 893 | } |
831 | rsp.List = append(rsp.List, commItem) | 894 | rsp.List = append(rsp.List, commItem) |
832 | } | 895 | } |
896 | + return | ||
897 | +} | ||
833 | 898 | ||
899 | +//我审核的机会 | ||
900 | +func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) { | ||
901 | + var ( | ||
902 | + myChances []protocol.ChanceApproveItemOrm | ||
903 | + total int | ||
904 | + provider *protocol.BaseUserInfo | ||
905 | + ) | ||
906 | + rsp = &protocol.MyApproveChanceResponse{} | ||
907 | + if total, err = models.GetChanceMyApproveChance(header.UserId, header.CompanyId, []int8{request.ReviewStatus}, request.LastId, request.PageSize, &myChances); err != nil { | ||
908 | + if err == orm.ErrNoRows { | ||
909 | + err = nil | ||
910 | + return | ||
911 | + } | ||
912 | + log.Error(err) | ||
913 | + return | ||
914 | + } | ||
915 | + rsp = &protocol.MyApproveChanceResponse{Total: total} | ||
916 | + for i := 0; i < len(myChances); i++ { | ||
917 | + chance := myChances[i] | ||
918 | + commItem := protocol.CommonListItem{} | ||
919 | + commItem.ReviewStatus = chance.ReviewStatus | ||
920 | + if len(chance.SourceContent) == 0 { //机会删除 | ||
921 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
922 | + } else if chance.ChanceEnableStatus == 0 { //机会关闭 | ||
923 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
924 | + } else { | ||
925 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
926 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
927 | + log.Error(err) | ||
928 | + //return | ||
929 | + } else { | ||
930 | + item := protocol.ChanceItem{ | ||
931 | + Id: chance.ChanceId, | ||
932 | + Provider: provider, | ||
933 | + //CreateTime: chance.CreateTime.Unix() * 1000, | ||
934 | + } | ||
935 | + jsonUnmarshal(chance.SourceContent, &item.FormList) | ||
936 | + item.FormList = clearEmptyForm(item.FormList) | ||
937 | + jsonUnmarshal(chance.Images, &item.Pictures) | ||
938 | + jsonUnmarshal(chance.Voices, &item.Speechs) | ||
939 | + jsonUnmarshal(chance.Videos, &item.Videos) | ||
940 | + commItem.Chance = item | ||
941 | + } | ||
942 | + } | ||
943 | + approve := protocol.Approve{ | ||
944 | + ProcessId: chance.Id, | ||
945 | + //Provider:provider, | ||
946 | + CreateTime: chance.ProcessCreateTime.Unix() * 1000, | ||
947 | + } | ||
948 | + //审核过的才有审核时间 | ||
949 | + if request.ReviewStatus != protocol.ReviewStatusAuditging { | ||
950 | + approve.ApproveTime = chance.ApproveTime.Unix() * 1000 | ||
951 | + } | ||
952 | + commItem.Approve = approve | ||
953 | + //审核完有审核数据 | ||
954 | + if request.ReviewStatus == protocol.ReviewStatusAuditging { | ||
955 | + commItem.Message = chance.ApproveMessage | ||
956 | + } | ||
957 | + if request.ReviewStatus == protocol.ReviewStatusPass { | ||
958 | + var approveData *protocol.ApproveData | ||
959 | + jsonUnmarshal(chance.ApproveData, &approveData) | ||
960 | + if approveData != nil { | ||
961 | + commItem.Score = approveData.Score | ||
962 | + } | ||
963 | + } | ||
964 | + rsp.List = append(rsp.List, commItem) | ||
965 | + } | ||
834 | return | 966 | return |
835 | } | 967 | } |
836 | 968 | ||
@@ -843,6 +975,20 @@ func jsonUnmarshal(jsonData string, v interface{}) { | @@ -843,6 +975,20 @@ func jsonUnmarshal(jsonData string, v interface{}) { | ||
843 | } | 975 | } |
844 | } | 976 | } |
845 | 977 | ||
978 | +//清楚未填写的表单数据 | ||
979 | +func clearEmptyForm(inputFormList []*protocol.Form) (FormList []*protocol.Form) { | ||
980 | + if len(inputFormList) == 0 { | ||
981 | + return | ||
982 | + } | ||
983 | + for i := range inputFormList { | ||
984 | + item := inputFormList[i] | ||
985 | + if len(item.Value) > 0 { | ||
986 | + FormList = append(FormList, item) | ||
987 | + } | ||
988 | + } | ||
989 | + return | ||
990 | +} | ||
991 | + | ||
846 | //机会详情 | 992 | //机会详情 |
847 | func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetailRequest) (rsp *protocol.ChanceDetailResponse, err error) { | 993 | func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetailRequest) (rsp *protocol.ChanceDetailResponse, err error) { |
848 | var ( | 994 | var ( |
@@ -850,6 +996,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -850,6 +996,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
850 | chanceData *models.ChanceData | 996 | chanceData *models.ChanceData |
851 | provider *protocol.BaseUserInfo | 997 | provider *protocol.BaseUserInfo |
852 | approveProcess *protocol.ChanceApproveProcessResponse | 998 | approveProcess *protocol.ChanceApproveProcessResponse |
999 | + //chanceType *models.ChanceType | ||
1000 | + //tempalte *models.AuditTemplate | ||
853 | ) | 1001 | ) |
854 | rsp = &protocol.ChanceDetailResponse{} | 1002 | rsp = &protocol.ChanceDetailResponse{} |
855 | if chance, err = models.GetChanceById(request.Id); err != nil { | 1003 | if chance, err = models.GetChanceById(request.Id); err != nil { |
@@ -860,6 +1008,18 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -860,6 +1008,18 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
860 | log.Error(err) | 1008 | log.Error(err) |
861 | return | 1009 | return |
862 | } | 1010 | } |
1011 | + if template, e := models.GetAuditTemplateById(chance.AuditTemplateId); e == nil { | ||
1012 | + rsp.ChanceTemplate = protocol.NameItem{ | ||
1013 | + Id: int(template.Id), | ||
1014 | + Name: template.Name, | ||
1015 | + } | ||
1016 | + } | ||
1017 | + if chanceType, e := models.GetChanceTypeById(chance.ChanceTypeId); e == nil { | ||
1018 | + rsp.ChanceType = protocol.NameItem{ | ||
1019 | + Id: int(chanceType.Id), | ||
1020 | + Name: chanceType.Name, | ||
1021 | + } | ||
1022 | + } | ||
863 | if chance.EnableStatus == 0 { | 1023 | if chance.EnableStatus == 0 { |
864 | err = protocol.NewErrWithMessage(5101) | 1024 | err = protocol.NewErrWithMessage(5101) |
865 | return | 1025 | return |
@@ -883,6 +1043,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -883,6 +1043,7 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
883 | } | 1043 | } |
884 | jsonUnmarshal(chance.ApproveData, &rsp.ApproveData) | 1044 | jsonUnmarshal(chance.ApproveData, &rsp.ApproveData) |
885 | rsp.ChanceDetail = item | 1045 | rsp.ChanceDetail = item |
1046 | + rsp.ReviewStatus = int(chance.ReviewStatus) | ||
886 | if approveProcess, err = ChanceApproveProcess(header, chance); err != nil { | 1047 | if approveProcess, err = ChanceApproveProcess(header, chance); err != nil { |
887 | log.Error(err) | 1048 | log.Error(err) |
888 | return | 1049 | return |
services/config/config.go
0 → 100644
1 | +package config | ||
2 | + | ||
3 | +import ( | ||
4 | + "encoding/json" | ||
5 | + "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | ||
6 | + "opp/models" | ||
7 | + "opp/protocol" | ||
8 | +) | ||
9 | + | ||
10 | +func GetConfigScore(header *protocol.RequestHeader, request *protocol.GetConfigScoreRequest) (rsp *protocol.GetConfigScoreResponse, err error) { | ||
11 | + var ( | ||
12 | + scoreConfig *models.SysConfig | ||
13 | + ) | ||
14 | + rsp = &protocol.GetConfigScoreResponse{} | ||
15 | + if scoreConfig, err = models.GetSysConfigByCompanyId(int(header.CompanyId), models.KeyScore); err != nil { | ||
16 | + log.Error(err.Error()) | ||
17 | + return | ||
18 | + } | ||
19 | + if err = json.Unmarshal([]byte(scoreConfig.Content), &rsp); err != nil { | ||
20 | + log.Error(err.Error()) | ||
21 | + return | ||
22 | + } | ||
23 | + return | ||
24 | +} |
@@ -10,6 +10,7 @@ import ( | @@ -10,6 +10,7 @@ import ( | ||
10 | "opp/internal/utils" | 10 | "opp/internal/utils" |
11 | "opp/models" | 11 | "opp/models" |
12 | "opp/protocol" | 12 | "opp/protocol" |
13 | + "opp/services/agg" | ||
13 | "time" | 14 | "time" |
14 | ) | 15 | ) |
15 | 16 | ||
@@ -182,15 +183,73 @@ func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompa | @@ -182,15 +183,73 @@ func MsgCompanyNotice(header *protocol.RequestHeader, request *protocol.MsgCompa | ||
182 | return | 183 | return |
183 | } | 184 | } |
184 | 185 | ||
186 | +//消息中心-机会审核消息 | ||
187 | +func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanceApproveRequest) (rsp *protocol.MsgChanceApproveResponse, err error) { | ||
188 | + var ( | ||
189 | + myChances []protocol.MsgChanceApproveItemOrm | ||
190 | + total int | ||
191 | + provider *protocol.BaseUserInfo | ||
192 | + ) | ||
193 | + if total, err = models.GetChanceMsg(header.UserId, request.LastId, request.PageSize, protocol.MsgTypeAudit, &myChances); err != nil { | ||
194 | + if err == orm.ErrNoRows { | ||
195 | + err = nil | ||
196 | + return | ||
197 | + } | ||
198 | + log.Error(err) | ||
199 | + return | ||
200 | + } | ||
201 | + rsp = &protocol.MsgChanceApproveResponse{Total: total} | ||
202 | + for i := 0; i < len(myChances); i++ { | ||
203 | + chance := myChances[i] | ||
204 | + commItem := protocol.CommonListItem{} | ||
205 | + commItem.ReviewStatus = chance.ReviewStatus | ||
206 | + if len(chance.SourceContent) == 0 { //机会删除 | ||
207 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
208 | + } else if chance.ChanceEnableStatus == 0 { //机会关闭 | ||
209 | + commItem.ChanceStatus = protocol.ChanceStatusClose | ||
210 | + } else { | ||
211 | + if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil { | ||
212 | + commItem.ChanceStatus = protocol.ChanceStatusDelete | ||
213 | + log.Error(err) | ||
214 | + continue | ||
215 | + } else { | ||
216 | + item := protocol.ChanceItem{ | ||
217 | + Id: chance.ChanceId, | ||
218 | + Provider: provider, | ||
219 | + CreateTime: chance.CreateTime.Unix() * 1000, | ||
220 | + } | ||
221 | + utils.JsonUnmarshal(chance.SourceContent, &item.FormList) | ||
222 | + item.FormList = agg.ClearEmptyForm(item.FormList) | ||
223 | + utils.JsonUnmarshal(chance.Images, &item.Pictures) | ||
224 | + utils.JsonUnmarshal(chance.Voices, &item.Speechs) | ||
225 | + utils.JsonUnmarshal(chance.Videos, &item.Videos) | ||
226 | + commItem.Chance = item | ||
227 | + } | ||
228 | + } | ||
229 | + | ||
230 | + if chance.ReviewStatus == protocol.ReviewStatusPass { | ||
231 | + var approveData *protocol.ApproveData | ||
232 | + utils.JsonUnmarshal(chance.ApproveData, &approveData) | ||
233 | + if approveData != nil { | ||
234 | + commItem.Score = approveData.Score | ||
235 | + } | ||
236 | + } | ||
237 | + //审核完有审核数据 | ||
238 | + commItem.Message = chance.Message | ||
239 | + rsp.List = append(rsp.List, commItem) | ||
240 | + } | ||
241 | + return | ||
242 | +} | ||
243 | + | ||
185 | //H5公告详情 | 244 | //H5公告详情 |
186 | func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) { | 245 | func H5Announcement(header *protocol.RequestHeader, request *protocol.AnnouncementRequest) (rsp *protocol.AnnouncementResponse, err error) { |
187 | var ( | 246 | var ( |
188 | - bulletin *models.Bulletin | ||
189 | - question *models.BulletinQuestion | ||
190 | - userMsg *models.UserMsg | ||
191 | - bulletinAnswer *models.BulletinQuestionAnswer | ||
192 | - setRead bool = false | ||
193 | - answer *protocol.Answer | 247 | + bulletin *models.Bulletin |
248 | + question *models.BulletinQuestion | ||
249 | + userMsg *models.UserMsg | ||
250 | + //bulletinAnswer *models.BulletinQuestionAnswer | ||
251 | + setRead bool = false | ||
252 | + answer *protocol.Answer | ||
194 | ) | 253 | ) |
195 | if bulletin, err = models.GetBulletinById(request.Id); err != nil { | 254 | if bulletin, err = models.GetBulletinById(request.Id); err != nil { |
196 | log.Error(err.Error()) | 255 | log.Error(err.Error()) |
@@ -227,10 +286,11 @@ func H5Announcement(header *protocol.RequestHeader, request *protocol.Announceme | @@ -227,10 +286,11 @@ func H5Announcement(header *protocol.RequestHeader, request *protocol.Announceme | ||
227 | } | 286 | } |
228 | 287 | ||
229 | //获取回答详情数据 | 288 | //获取回答详情数据 |
230 | - if bulletinAnswer, err = models.GetBulletinQuestionAnswerBy(request.Id, int64(request.Uid)); err == nil { | 289 | + if bulletinAnswer, e := models.GetBulletinQuestionAnswerBy(request.Id, int64(request.Uid)); e == nil { |
231 | if len(bulletinAnswer.Answer) != 0 { | 290 | if len(bulletinAnswer.Answer) != 0 { |
232 | if err = json.Unmarshal([]byte(bulletinAnswer.Answer), &answer); err != nil { | 291 | if err = json.Unmarshal([]byte(bulletinAnswer.Answer), &answer); err != nil { |
233 | - log.Error(err) | 292 | + log.Error(e) |
293 | + return | ||
234 | } else { | 294 | } else { |
235 | rsp.Announcement.EditContent = answer.EditContent | 295 | rsp.Announcement.EditContent = answer.EditContent |
236 | rsp.Announcement.VoteResults = answer.VoteResults | 296 | rsp.Announcement.VoteResults = answer.VoteResults |
@@ -368,40 +368,67 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis | @@ -368,40 +368,67 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis | ||
368 | total int | 368 | total int |
369 | ) | 369 | ) |
370 | rsp = &protocol.UserStatisticsResponse{} | 370 | rsp = &protocol.UserStatisticsResponse{} |
371 | - isMark := func(v int64) bool { | ||
372 | - if flag != v { | ||
373 | - return false | ||
374 | - } | ||
375 | - return (request.TypeTotal & v) > 0 | ||
376 | - } | ||
377 | - for flag = 1; flag < (1 << 20); flag = flag << 1 { | 371 | + //buf :=bytes.NewBuffer(nil) |
372 | + //buf.WriteString(fmt.Sprintf("用户中心-统计信息 user:%v type_total:%v \n",header.UserId,request.TypeTotal)) | ||
373 | + for flag = 1; flag <= (protocol.MyAuditChanceReturn); flag = flag << 1 { | ||
378 | total = 0 | 374 | total = 0 |
379 | - if isMark(protocol.MyCommitChance) { | 375 | + switch flag { |
376 | + case protocol.MyCommitChance: | ||
380 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil { | 377 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil { |
381 | log.Error(err) | 378 | log.Error(err) |
382 | } | 379 | } |
383 | - } | ||
384 | - if isMark(protocol.MyCommitChanceWait) { | 380 | + break |
381 | + case protocol.MyCommitChanceWait: | ||
385 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging); err != nil { | 382 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusAuditging); err != nil { |
386 | log.Error(err) | 383 | log.Error(err) |
387 | } | 384 | } |
388 | - } | ||
389 | - if isMark(protocol.MyAuditChanceReturn) { | 385 | + break |
386 | + case protocol.MyCommitChancePass: | ||
387 | + if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil { | ||
388 | + log.Error(err) | ||
389 | + } | ||
390 | + break | ||
391 | + case protocol.MyCommitChanceReturn: | ||
390 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusReturn); err != nil { | 392 | if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusReturn); err != nil { |
391 | log.Error(err) | 393 | log.Error(err) |
392 | } | 394 | } |
393 | - } | ||
394 | - if isMark(protocol.MyCommitChancePass) { | ||
395 | - if total, err = agg.MyChanceStatic(header, protocol.ReviewStatusPass); err != nil { | 395 | + break |
396 | + case protocol.MyAuditChance: | ||
397 | + if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusAuditging, protocol.ReviewStatusReturn, protocol.ReviewStatusPass); err != nil { | ||
398 | + log.Error(err) | ||
399 | + } | ||
400 | + break | ||
401 | + case protocol.MyAuditChanceWait: | ||
402 | + if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusAuditging); err != nil { | ||
403 | + log.Error(err) | ||
404 | + } | ||
405 | + break | ||
406 | + case protocol.MyAuditChancePass: | ||
407 | + if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusPass); err != nil { | ||
408 | + log.Error(err) | ||
409 | + } | ||
410 | + break | ||
411 | + case protocol.MyAuditChanceReturn: | ||
412 | + if total, err = agg.MyApproveStatic(header, protocol.ReviewStatusReturn); err != nil { | ||
396 | log.Error(err) | 413 | log.Error(err) |
397 | } | 414 | } |
415 | + break | ||
416 | + | ||
398 | } | 417 | } |
399 | if flag&request.TypeTotal > 0 { | 418 | if flag&request.TypeTotal > 0 { |
400 | rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{ | 419 | rsp.Totals = append(rsp.Totals, protocol.TypeTotalItem{ |
401 | Type: flag, | 420 | Type: flag, |
402 | Total: total, | 421 | Total: total, |
403 | }) | 422 | }) |
423 | + log.Debug(fmt.Sprintf("用户中心-统计信息 user:%v name:%v type:%v total:%v ", header.UserId, protocol.MapStaticName[flag], flag, total)) | ||
424 | + //buf.WriteString(fmt.Sprintf("user:%v name:%v type:%v total:%v ",header.UserId,protocol.MapStaticName[flag],flag,total)) | ||
425 | + //if err!=nil{ | ||
426 | + // buf.WriteString("err:%v \n") | ||
427 | + //}else{ | ||
428 | + // buf.WriteString("\n") | ||
429 | + //} | ||
404 | } | 430 | } |
405 | } | 431 | } |
432 | + //log.Debug(buf.String()) | ||
406 | return | 433 | return |
407 | } | 434 | } |
-
请 注册 或 登录 后发表评论