|
@@ -149,33 +149,6 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% |
|
@@ -149,33 +149,6 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% |
149
|
return
|
149
|
return
|
150
|
}
|
150
|
}
|
151
|
|
151
|
|
152
|
-func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
153
|
-
|
|
|
154
|
- sql := `select a.*,b.images,speechs,videos
|
|
|
155
|
-from (
|
|
|
156
|
-select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
|
|
|
157
|
-where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1
|
|
|
158
|
-order by create_at desc
|
|
|
159
|
-limit ?
|
|
|
160
|
-) a left JOIN chance_data b on a.id =b.chance_id`
|
|
|
161
|
- //if public==protocol.pu
|
|
|
162
|
-
|
|
|
163
|
- sqlCount := fmt.Sprintf(`select count(0) from (
|
|
|
164
|
-select id from chance
|
|
|
165
|
-where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
|
|
|
166
|
-order by create_at desc
|
|
|
167
|
-) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
|
|
|
168
|
- if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
|
|
|
169
|
- return
|
|
|
170
|
- }
|
|
|
171
|
- if v != nil {
|
|
|
172
|
- if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
|
|
|
173
|
- return
|
|
|
174
|
- }
|
|
|
175
|
- }
|
|
|
176
|
- return
|
|
|
177
|
-}
|
|
|
178
|
-
|
|
|
179
|
func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
152
|
func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
180
|
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
|
153
|
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
|
181
|
select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from (
|
154
|
select a.*,b.user_id,b.id,b.create_at,b.source_content,b.enable_status,b.review_status,b.audit_template_id,b.chance_type_id,comment_total,zan_total,view_total from (
|
|
@@ -257,3 +230,202 @@ where user_id =?` |
|
@@ -257,3 +230,202 @@ where user_id =?` |
257
|
}
|
230
|
}
|
258
|
return
|
231
|
return
|
259
|
}
|
232
|
}
|
|
|
233
|
+
|
|
|
234
|
+//type4 查看所有机会
|
|
|
235
|
+func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
236
|
+
|
|
|
237
|
+ sql := `select a.*,b.images,speechs,videos
|
|
|
238
|
+from (
|
|
|
239
|
+select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
|
|
|
240
|
+where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1
|
|
|
241
|
+order by create_at desc
|
|
|
242
|
+limit ?
|
|
|
243
|
+) a left JOIN chance_data b on a.id =b.chance_id`
|
|
|
244
|
+ //if public==protocol.pu
|
|
|
245
|
+
|
|
|
246
|
+ sqlCount := fmt.Sprintf(`select count(0) from (
|
|
|
247
|
+select id from chance
|
|
|
248
|
+where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
|
|
|
249
|
+order by create_at desc
|
|
|
250
|
+) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
|
|
|
251
|
+ if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
|
|
|
252
|
+ return
|
|
|
253
|
+ }
|
|
|
254
|
+ if v != nil {
|
|
|
255
|
+ if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
|
|
|
256
|
+ return
|
|
|
257
|
+ }
|
|
|
258
|
+ }
|
|
|
259
|
+ return
|
|
|
260
|
+}
|
|
|
261
|
+
|
|
|
262
|
+//type3 特定部门机会
|
|
|
263
|
+func GetChancePoolSpecialDepartment(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
264
|
+
|
|
|
265
|
+ sql := fmt.Sprintf(`
|
|
|
266
|
+select a.*,b.images,speechs,videos from (
|
|
|
267
|
+select * from (
|
|
|
268
|
+ ##指定部门-机会提交的部门
|
|
|
269
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
270
|
+ where department_id in (%v)
|
|
|
271
|
+ UNION
|
|
|
272
|
+
|
|
|
273
|
+ ##本人
|
|
|
274
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
275
|
+ where user_id = %v
|
|
|
276
|
+ UNION
|
|
|
277
|
+
|
|
|
278
|
+ ##我审核
|
|
|
279
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
280
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
281
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
282
|
+
|
|
|
283
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
284
|
+order by create_at desc
|
|
|
285
|
+limit %v
|
|
|
286
|
+) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
287
|
+`, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
288
|
+
|
|
|
289
|
+ sqlCount := fmt.Sprintf(`
|
|
|
290
|
+select count(0) from (
|
|
|
291
|
+ ##指定部门-机会提交的部门
|
|
|
292
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
293
|
+ where department_id in (%v)
|
|
|
294
|
+ UNION
|
|
|
295
|
+
|
|
|
296
|
+ ##本人
|
|
|
297
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
298
|
+ where user_id = %v
|
|
|
299
|
+ UNION
|
|
|
300
|
+
|
|
|
301
|
+ ##我审核
|
|
|
302
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
303
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
304
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
305
|
+
|
|
|
306
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
307
|
+`, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
308
|
+ if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
309
|
+ return
|
|
|
310
|
+ }
|
|
|
311
|
+ if v != nil {
|
|
|
312
|
+ if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
313
|
+ return
|
|
|
314
|
+ }
|
|
|
315
|
+ }
|
|
|
316
|
+ return
|
|
|
317
|
+}
|
|
|
318
|
+
|
|
|
319
|
+//type2 对我所在部门公开的机会 公司公开的机会
|
|
|
320
|
+func GetChancePoolPublicCompany(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
321
|
+ sql := fmt.Sprintf(`
|
|
|
322
|
+select a.*,b.images,speechs,videos from (
|
|
|
323
|
+select * from (
|
|
|
324
|
+ ##公司公开的机会
|
|
|
325
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
326
|
+ where company_id = %v and publish_status = 2
|
|
|
327
|
+
|
|
|
328
|
+ UNION
|
|
|
329
|
+ ##指定部门-机会公开的部门
|
|
|
330
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
331
|
+ select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
332
|
+ )a inner join chance b on a.chance_id = b.id
|
|
|
333
|
+ UNION
|
|
|
334
|
+
|
|
|
335
|
+ ##本人
|
|
|
336
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
337
|
+ where user_id = %v
|
|
|
338
|
+ UNION
|
|
|
339
|
+
|
|
|
340
|
+ ##我审核
|
|
|
341
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
342
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
343
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
344
|
+
|
|
|
345
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
346
|
+order by create_at desc
|
|
|
347
|
+limit %v
|
|
|
348
|
+) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
349
|
+`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
350
|
+
|
|
|
351
|
+ sqlCount := fmt.Sprintf(`
|
|
|
352
|
+select count(0) from (
|
|
|
353
|
+ ##公司公开的机会
|
|
|
354
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
355
|
+ where company_id = %v and publish_status = 2
|
|
|
356
|
+
|
|
|
357
|
+ UNION
|
|
|
358
|
+ ##指定部门-机会公开的部门
|
|
|
359
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
360
|
+ select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
361
|
+ )a inner join chance b on a.chance_id = b.id
|
|
|
362
|
+ UNION
|
|
|
363
|
+
|
|
|
364
|
+ ##本人
|
|
|
365
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
366
|
+ where user_id = %v
|
|
|
367
|
+ UNION
|
|
|
368
|
+
|
|
|
369
|
+ ##我审核
|
|
|
370
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
371
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
372
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
373
|
+
|
|
|
374
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
375
|
+`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
376
|
+ if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
377
|
+ return
|
|
|
378
|
+ }
|
|
|
379
|
+ if v != nil {
|
|
|
380
|
+ if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
381
|
+ return
|
|
|
382
|
+ }
|
|
|
383
|
+ }
|
|
|
384
|
+ return
|
|
|
385
|
+}
|
|
|
386
|
+
|
|
|
387
|
+//type1 禁止查看所有机会
|
|
|
388
|
+func GetChancePoolMyself(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
389
|
+ sql := fmt.Sprintf(`
|
|
|
390
|
+select a.*,b.images,speechs,videos from (
|
|
|
391
|
+select * from (
|
|
|
392
|
+ ##本人
|
|
|
393
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
394
|
+ where user_id = %v
|
|
|
395
|
+ UNION
|
|
|
396
|
+
|
|
|
397
|
+ ##我审核
|
|
|
398
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
399
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
400
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
401
|
+
|
|
|
402
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
403
|
+order by create_at desc
|
|
|
404
|
+limit %v
|
|
|
405
|
+) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
406
|
+`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
407
|
+
|
|
|
408
|
+ sqlCount := fmt.Sprintf(`
|
|
|
409
|
+select count(0) from (
|
|
|
410
|
+ ##本人
|
|
|
411
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from chance
|
|
|
412
|
+ where user_id = %v
|
|
|
413
|
+ UNION
|
|
|
414
|
+
|
|
|
415
|
+ ##我审核
|
|
|
416
|
+ select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total,enable_status,department_id from (
|
|
|
417
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
418
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
419
|
+
|
|
|
420
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
421
|
+`, uid, uid, chanceTypeId, chanceTypeId)
|
|
|
422
|
+ if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
423
|
+ return
|
|
|
424
|
+ }
|
|
|
425
|
+ if v != nil {
|
|
|
426
|
+ if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
427
|
+ return
|
|
|
428
|
+ }
|
|
|
429
|
+ }
|
|
|
430
|
+ return
|
|
|
431
|
+} |