正在显示
7 个修改的文件
包含
262 行增加
和
4 行删除
@@ -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() { |
@@ -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() { |
@@ -147,3 +147,29 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% | @@ -147,3 +147,29 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% | ||
147 | } | 147 | } |
148 | return | 148 | return |
149 | } | 149 | } |
150 | + | ||
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 { | ||
167 | + return | ||
168 | + } | ||
169 | + if v != nil { | ||
170 | + if err = utils.ExecuteQueryAll(v, sql, uid, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil { | ||
171 | + return | ||
172 | + } | ||
173 | + } | ||
174 | + return | ||
175 | +} |
@@ -133,6 +133,27 @@ type MySubmitChanceResponse struct { | @@ -133,6 +133,27 @@ type MySubmitChanceResponse struct { | ||
133 | Total int `json:"total"` | 133 | Total int `json:"total"` |
134 | } | 134 | } |
135 | 135 | ||
136 | +/*ChancePool 机会池*/ | ||
137 | +type ChancePoolRequest struct { | ||
138 | + LastId int64 `json:"lastId"` | ||
139 | + PageSize int `json:"pageSize" valid:"Required"` | ||
140 | + ChanceTypeId int `json:"chanceTypeId"` //0:所有机会 编号:对应机会类型编号的机会 | ||
141 | +} | ||
142 | +type ChancePoolResponse struct { | ||
143 | + List []CommonListItem `json:"list"` | ||
144 | + Total int `json:"total"` | ||
145 | +} | ||
146 | + | ||
147 | +/*Permission 机会权限*/ | ||
148 | +type ChancePermissionRequest struct { | ||
149 | +} | ||
150 | +type ChancePermissionResponse struct { | ||
151 | + EditScore int `json:"editScore"` | ||
152 | + EditChance int `json:"editChance"` | ||
153 | + EditPublic int `json:"editPublic"` | ||
154 | + CloseChance int `json:"closeChance"` | ||
155 | +} | ||
156 | + | ||
136 | //我的机会列表 | 157 | //我的机会列表 |
137 | type ChanceItemOrm struct { | 158 | type ChanceItemOrm struct { |
138 | Id int64 `orm:"column(id)"` | 159 | Id int64 `orm:"column(id)"` |
@@ -177,6 +198,26 @@ type ChanceApproveItemOrm struct { | @@ -177,6 +198,26 @@ type ChanceApproveItemOrm struct { | ||
177 | ChanceId int64 `orm:"column(chance_id)"` // 机会id | 198 | ChanceId int64 `orm:"column(chance_id)"` // 机会id |
178 | } | 199 | } |
179 | 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"` //审核数据 | ||
213 | + | ||
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)"` | ||
219 | +} | ||
220 | + | ||
180 | /*ChanceDetail 机会详情*/ | 221 | /*ChanceDetail 机会详情*/ |
181 | type ChanceDetailRequest struct { | 222 | type ChanceDetailRequest struct { |
182 | Id int64 `json:"id"` //机会编号 | 223 | Id int64 `json:"id"` //机会编号 |
@@ -186,8 +227,16 @@ type ChanceDetailResponse struct { | @@ -186,8 +227,16 @@ type ChanceDetailResponse struct { | ||
186 | ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData | 227 | ChanceData interface{} `json:"chanceData,omitempty"` //机会数据(是否收藏/点赞 浏览数 点赞总数 评论数)ChanceData |
187 | ApproveData *ApproveData `json:"approveData"` | 228 | ApproveData *ApproveData `json:"approveData"` |
188 | ApproveProcess []*ProcessItem `json:"approveProcess"` | 229 | ApproveProcess []*ProcessItem `json:"approveProcess"` |
189 | - ApproveAccess *ApproveAccess `json:"approveAccess"` // | ||
190 | - ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过 | 230 | + ApproveAccess *ApproveAccess `json:"approveAccess"` // |
231 | + ChanceType NameItem `json:"chanceType"` //机会类型 | ||
232 | + ChanceTemplate NameItem `json:"template"` //机会模板 | ||
233 | + ReviewStatus int `json:"review_status"` //审核状态 1:待审核 2:被退回 3:已通过 | ||
234 | +} | ||
235 | + | ||
236 | +type ChanceType struct { | ||
237 | + Id int `json:"id"` | ||
238 | + Name string `json:"name"` | ||
239 | + Template | ||
191 | } | 240 | } |
192 | 241 | ||
193 | /*ChanceChangePublish 修改公开状态*/ | 242 | /*ChanceChangePublish 修改公开状态*/ |
@@ -309,6 +358,10 @@ type CommonListItem struct { | @@ -309,6 +358,10 @@ type CommonListItem struct { | ||
309 | 358 | ||
310 | //我审核的-通过 | 359 | //我审核的-通过 |
311 | Score interface{} `json:"score,omitempty"` | 360 | Score interface{} `json:"score,omitempty"` |
361 | + | ||
362 | + //模板 | ||
363 | + ChanceType interface{} `json:"chanceType,omitempty"` //机会类型 | ||
364 | + ChanceTemplate interface{} `json:"template,omitempty"` //机会模板 | ||
312 | } | 365 | } |
313 | type ChanceItem struct { | 366 | type ChanceItem struct { |
314 | Id int64 `json:"id"` | 367 | Id int64 `json:"id"` |
@@ -324,6 +377,6 @@ type ChanceData struct { | @@ -324,6 +377,6 @@ type ChanceData struct { | ||
324 | CommentTotal int `json:"commentTotal"` //评论总数 | 377 | CommentTotal int `json:"commentTotal"` //评论总数 |
325 | PageViewTotal int `json:"pageViewTotal"` //评论总数 | 378 | PageViewTotal int `json:"pageViewTotal"` //评论总数 |
326 | 379 | ||
327 | - IsThumbsUp int `json:"isThumbsUp"` //是否点赞 1 点赞, 0 没有点赞 | ||
328 | - IsCollect int `json:"isCollect"` //是否收藏 1 是 0 否 | 380 | + IsThumbsUp bool `json:"isThumbsUp"` //是否点赞 1 点赞, 0 没有点赞 |
381 | + IsCollect bool `json:"isCollect"` //是否收藏 1 是 0 否 | ||
329 | } | 382 | } |
@@ -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"}, |
@@ -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 |
@@ -528,6 +528,19 @@ func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.Chan | @@ -528,6 +528,19 @@ func ChanceCalculateScore(header *protocol.RequestHeader, request *protocol.Chan | ||
528 | return | 528 | return |
529 | } | 529 | } |
530 | 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 | + | ||
531 | //生成审批流-提交记录 | 544 | //生成审批流-提交记录 |
532 | 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) { |
533 | v = &models.AuditFlowProcess{ | 546 | v = &models.AuditFlowProcess{ |
@@ -809,6 +822,80 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | @@ -809,6 +822,80 @@ func MySubmitChance(header *protocol.RequestHeader, request *protocol.MySubmitCh | ||
809 | return | 822 | return |
810 | } | 823 | } |
811 | 824 | ||
825 | +//机会池 | ||
826 | +func ChancePool(header *protocol.RequestHeader, request *protocol.ChancePoolRequest) (rsp *protocol.ChancePoolResponse, err error) { | ||
827 | + var ( | ||
828 | + myChances []protocol.ChancePoolItemOrm | ||
829 | + total int | ||
830 | + provider *protocol.BaseUserInfo | ||
831 | + flag int | ||
832 | + ) | ||
833 | + if total, err = models.GetChancePool(header.UserId, header.CompanyId, request.ChanceTypeId, request.LastId, request.PageSize, &myChances); err != nil { | ||
834 | + if err == orm.ErrNoRows { | ||
835 | + err = nil | ||
836 | + return | ||
837 | + } | ||
838 | + log.Error(err) | ||
839 | + return | ||
840 | + } | ||
841 | + if provider, err = agg.GetUserBaseInfo(header.UserId, header.CompanyId); err != nil { | ||
842 | + log.Error(err) | ||
843 | + return | ||
844 | + } | ||
845 | + rsp = &protocol.ChancePoolResponse{Total: total} | ||
846 | + | ||
847 | + for i := 0; i < len(myChances); i++ { | ||
848 | + chance := myChances[i] | ||
849 | + commItem := protocol.CommonListItem{} | ||
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 | ||
877 | + } | ||
878 | + | ||
879 | + { | ||
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 | + } | ||
893 | + } | ||
894 | + rsp.List = append(rsp.List, commItem) | ||
895 | + } | ||
896 | + return | ||
897 | +} | ||
898 | + | ||
812 | //我审核的机会 | 899 | //我审核的机会 |
813 | func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) { | 900 | func MyApproveChance(header *protocol.RequestHeader, request *protocol.MyApproveChanceRequest) (rsp *protocol.MyApproveChanceResponse, err error) { |
814 | var ( | 901 | var ( |
@@ -909,6 +996,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -909,6 +996,8 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
909 | chanceData *models.ChanceData | 996 | chanceData *models.ChanceData |
910 | provider *protocol.BaseUserInfo | 997 | provider *protocol.BaseUserInfo |
911 | approveProcess *protocol.ChanceApproveProcessResponse | 998 | approveProcess *protocol.ChanceApproveProcessResponse |
999 | + //chanceType *models.ChanceType | ||
1000 | + //tempalte *models.AuditTemplate | ||
912 | ) | 1001 | ) |
913 | rsp = &protocol.ChanceDetailResponse{} | 1002 | rsp = &protocol.ChanceDetailResponse{} |
914 | if chance, err = models.GetChanceById(request.Id); err != nil { | 1003 | if chance, err = models.GetChanceById(request.Id); err != nil { |
@@ -919,6 +1008,18 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | @@ -919,6 +1008,18 @@ func ChanceDetail(header *protocol.RequestHeader, request *protocol.ChanceDetail | ||
919 | log.Error(err) | 1008 | log.Error(err) |
920 | return | 1009 | return |
921 | } | 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 | + } | ||
922 | if chance.EnableStatus == 0 { | 1023 | if chance.EnableStatus == 0 { |
923 | err = protocol.NewErrWithMessage(5101) | 1024 | err = protocol.NewErrWithMessage(5101) |
924 | return | 1025 | return |
-
请 注册 或 登录 后发表评论