|
@@ -429,3 +429,173 @@ select count(0) from ( |
|
@@ -429,3 +429,173 @@ select count(0) from ( |
429
|
}
|
429
|
}
|
430
|
return
|
430
|
return
|
431
|
}
|
431
|
}
|
|
|
432
|
+
|
|
|
433
|
+//type4 查看所有机会
|
|
|
434
|
+func ValidChanceAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
435
|
+
|
|
|
436
|
+ // sql := `select a.*,b.images,speechs,videos
|
|
|
437
|
+ //from (
|
|
|
438
|
+ //select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
|
|
|
439
|
+ //where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1
|
|
|
440
|
+ //order by create_at desc
|
|
|
441
|
+ //limit ?
|
|
|
442
|
+ //) a left JOIN chance_data b on a.id =b.chance_id`
|
|
|
443
|
+ // //if public==protocol.pu
|
|
|
444
|
+ //
|
|
|
445
|
+ // sqlCount := fmt.Sprintf(`select count(0) from (
|
|
|
446
|
+ //select id from chance
|
|
|
447
|
+ //where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
|
|
|
448
|
+ //order by create_at desc
|
|
|
449
|
+ //) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
|
|
|
450
|
+ // if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
|
|
|
451
|
+ // return
|
|
|
452
|
+ // }
|
|
|
453
|
+ // if v != nil {
|
|
|
454
|
+ // if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
|
|
|
455
|
+ // return
|
|
|
456
|
+ // }
|
|
|
457
|
+ // }
|
|
|
458
|
+ return
|
|
|
459
|
+}
|
|
|
460
|
+
|
|
|
461
|
+//type3 特定部门机会
|
|
|
462
|
+func ValidChanceSpecialDepartment(uid, chanceIds string, v interface{}) (err error) {
|
|
|
463
|
+
|
|
|
464
|
+ sql := fmt.Sprintf(`
|
|
|
465
|
+select * from (
|
|
|
466
|
+ ##指定部门-机会提交的部门
|
|
|
467
|
+ ##select chance_id from chance
|
|
|
468
|
+ ##where id in (v) and department_id in (v)
|
|
|
469
|
+ ##UNION
|
|
|
470
|
+
|
|
|
471
|
+ ##本人
|
|
|
472
|
+ ##select chance_id from chance
|
|
|
473
|
+ ##where user_id = v and id in (v)
|
|
|
474
|
+ ##UNION
|
|
|
475
|
+
|
|
|
476
|
+ ##我审核
|
|
|
477
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v and chance_id in (%v)
|
|
|
478
|
+)
|
|
|
479
|
+`, chanceIds)
|
|
|
480
|
+
|
|
|
481
|
+ if v != nil {
|
|
|
482
|
+ if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
483
|
+ return
|
|
|
484
|
+ }
|
|
|
485
|
+ }
|
|
|
486
|
+ return
|
|
|
487
|
+}
|
|
|
488
|
+
|
|
|
489
|
+//type2 对我所在部门公开的机会 公司公开的机会
|
|
|
490
|
+func ValidtChancePublicCompany(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
491
|
+ sql := fmt.Sprintf(`
|
|
|
492
|
+select a.*,b.images,speechs,videos from (
|
|
|
493
|
+select * from (
|
|
|
494
|
+ ##公司公开的机会
|
|
|
495
|
+ 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
|
|
|
496
|
+ where company_id = %v and publish_status = 2
|
|
|
497
|
+
|
|
|
498
|
+ UNION
|
|
|
499
|
+ ##指定部门-机会公开的部门
|
|
|
500
|
+ 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 (
|
|
|
501
|
+ select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
502
|
+ )a inner join chance b on a.chance_id = b.id
|
|
|
503
|
+ UNION
|
|
|
504
|
+
|
|
|
505
|
+ ##本人
|
|
|
506
|
+ 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
|
|
|
507
|
+ where user_id = %v
|
|
|
508
|
+ UNION
|
|
|
509
|
+
|
|
|
510
|
+ ##我审核
|
|
|
511
|
+ 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 (
|
|
|
512
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
513
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
514
|
+
|
|
|
515
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
516
|
+order by create_at desc
|
|
|
517
|
+limit %v
|
|
|
518
|
+) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
519
|
+`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
520
|
+
|
|
|
521
|
+ sqlCount := fmt.Sprintf(`
|
|
|
522
|
+select count(0) from (
|
|
|
523
|
+ ##公司公开的机会
|
|
|
524
|
+ 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
|
|
|
525
|
+ where company_id = %v and publish_status = 2
|
|
|
526
|
+
|
|
|
527
|
+ UNION
|
|
|
528
|
+ ##指定部门-机会公开的部门
|
|
|
529
|
+ 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 (
|
|
|
530
|
+ select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
531
|
+ )a inner join chance b on a.chance_id = b.id
|
|
|
532
|
+ UNION
|
|
|
533
|
+
|
|
|
534
|
+ ##本人
|
|
|
535
|
+ 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
|
|
|
536
|
+ where user_id = %v
|
|
|
537
|
+ UNION
|
|
|
538
|
+
|
|
|
539
|
+ ##我审核
|
|
|
540
|
+ 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 (
|
|
|
541
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
542
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
543
|
+
|
|
|
544
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
545
|
+`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
546
|
+ if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
547
|
+ return
|
|
|
548
|
+ }
|
|
|
549
|
+ if v != nil {
|
|
|
550
|
+ if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
551
|
+ return
|
|
|
552
|
+ }
|
|
|
553
|
+ }
|
|
|
554
|
+ return
|
|
|
555
|
+}
|
|
|
556
|
+
|
|
|
557
|
+//type1 禁止查看所有机会
|
|
|
558
|
+func ValidChanceMyself(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
559
|
+ sql := fmt.Sprintf(`
|
|
|
560
|
+select a.*,b.images,speechs,videos from (
|
|
|
561
|
+select * from (
|
|
|
562
|
+ ##本人
|
|
|
563
|
+ 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
|
|
|
564
|
+ where user_id = %v
|
|
|
565
|
+ UNION
|
|
|
566
|
+
|
|
|
567
|
+ ##我审核
|
|
|
568
|
+ 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 (
|
|
|
569
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
570
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
571
|
+
|
|
|
572
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
573
|
+order by create_at desc
|
|
|
574
|
+limit %v
|
|
|
575
|
+) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
576
|
+`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
577
|
+
|
|
|
578
|
+ sqlCount := fmt.Sprintf(`
|
|
|
579
|
+select count(0) from (
|
|
|
580
|
+ ##本人
|
|
|
581
|
+ 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
|
|
|
582
|
+ where user_id = %v
|
|
|
583
|
+ UNION
|
|
|
584
|
+
|
|
|
585
|
+ ##我审核
|
|
|
586
|
+ 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 (
|
|
|
587
|
+ select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
588
|
+ ) a inner join chance b on a.chance_id = b.id
|
|
|
589
|
+
|
|
|
590
|
+) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
591
|
+`, uid, uid, chanceTypeId, chanceTypeId)
|
|
|
592
|
+ if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
593
|
+ return
|
|
|
594
|
+ }
|
|
|
595
|
+ if v != nil {
|
|
|
596
|
+ if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
597
|
+ return
|
|
|
598
|
+ }
|
|
|
599
|
+ }
|
|
|
600
|
+ return
|
|
|
601
|
+} |