...
|
...
|
@@ -158,8 +158,8 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% |
|
|
|
|
|
func GetChanceCollect(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
|
|
|
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,b.publish_status,b.status from (
|
|
|
select id collect_id,source_id,update_at collect_time,chance_id from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1
|
|
|
select a.*,b.user_id chance_user_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,b.publish_status,b.status from (
|
|
|
select id collect_id,source_id,update_at,collect_time,chance_id from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1
|
|
|
and source_type=1
|
|
|
and (mark_flag&2)>0
|
|
|
)a left outer join chance b on a.source_id = b.id
|
...
|
...
|
@@ -181,13 +181,13 @@ limit ?`) |
|
|
|
|
|
func GetChanceThumbUp(uid int64, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
sql := fmt.Sprintf(`select a.*,b.images,b.speechs,b.videos from (
|
|
|
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,b.publish_status,b.status from (
|
|
|
select id collect_id,source_id,update_at collect_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1
|
|
|
select a.*,b.user_id chance_user_id,b.id chance_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,b.publish_status,b.status from (
|
|
|
select id collect_id,source_id,update_at,zan_time from chance_favorite where (0=? or id<?) and user_id =? and enable_status=1
|
|
|
and source_type=1
|
|
|
and (mark_flag&1)>0
|
|
|
)a left outer join chance b on a.source_id = b.id
|
|
|
)a left outer join chance_data b on a.source_id =b.chance_id
|
|
|
order by collect_time desc
|
|
|
order by zan_time desc
|
|
|
limit ?`)
|
|
|
|
|
|
sqlCount := `select count(0) from chance_favorite where user_id =? and enable_status=1 and (mark_flag&1)>0 and source_type=1`
|
...
|
...
|
@@ -216,7 +216,7 @@ func GetChanceComment(uid int64, lastId int64, pageSize int, v interface{}) (tot |
|
|
sql := fmt.Sprintf(`select a.*,b.content commented_content,b.create_at commented_time,b.user_id commented_user_id
|
|
|
from (
|
|
|
select a.*,b.images,b.speechs,b.videos from (
|
|
|
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data,b.publish_status from (
|
|
|
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.approve_data,b.publish_status,b.status from (
|
|
|
select id,content,view_total,zan_total,comment_total,source_type,source_id,create_at comment_time from comment
|
|
|
where user_id =? and (?=0 or id<?)
|
|
|
)a left outer join chance b on a.source_id = b.id and source_type=1
|
...
|
...
|
@@ -244,7 +244,7 @@ func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize i |
|
|
sql := `select a.*,b.images,speechs,videos
|
|
|
from (
|
|
|
select id,user_id,create_at,source_content,review_status,audit_template_id,chance_type_id,comment_total,zan_total,view_total from chance
|
|
|
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1
|
|
|
where company_id=? and review_status=3 and (?=0 or chance_type_id =?) and (?=0 or id<?) and enable_status=1 and status=1
|
|
|
order by create_at desc
|
|
|
limit ?
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id`
|
...
|
...
|
@@ -252,7 +252,7 @@ limit ? |
|
|
|
|
|
sqlCount := fmt.Sprintf(`select count(0) from (
|
|
|
select id from chance
|
|
|
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1
|
|
|
where company_id=? and review_status=3 and (%v=0 or chance_type_id =%v) and enable_status=1 and status=1
|
|
|
order by create_at desc
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id`, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount, cid); err != nil {
|
...
|
...
|
@@ -273,26 +273,26 @@ func GetChancePoolSpecialDepartment(uid, cid int64, chanceTypeId int, lastId int |
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
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,status from chance
|
|
|
where company_id = %v and publish_status = 2
|
|
|
UNION
|
|
|
|
|
|
##指定部门-机会提交的部门
|
|
|
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
|
|
|
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,status from chance
|
|
|
where department_id in (%v)
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
...
|
...
|
@@ -301,26 +301,26 @@ limit %v |
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
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,status from chance
|
|
|
where company_id = %v and publish_status = 2
|
|
|
UNION
|
|
|
|
|
|
##指定部门-机会提交的部门
|
|
|
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
|
|
|
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,status from chance
|
|
|
where department_id in (%v)
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
...
|
...
|
@@ -340,32 +340,32 @@ func GetChancePoolDepartment(uid, cid int64, chanceTypeId int, lastId int64, pag |
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
|
|
##指定部门-机会公开的部门
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
)a inner join chance b on a.chance_id = b.id
|
|
|
UNION
|
|
|
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
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,status from chance
|
|
|
where company_id = %v and publish_status = 2
|
|
|
UNION
|
|
|
|
|
|
##指定部门-机会提交的部门
|
|
|
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
|
|
|
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,status from chance
|
|
|
where department_id in (%v)
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
...
|
...
|
@@ -374,32 +374,32 @@ limit %v |
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
|
|
##指定部门-机会公开的部门
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
)a inner join chance b on a.chance_id = b.id
|
|
|
UNION
|
|
|
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
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,status from chance
|
|
|
where company_id = %v and publish_status = 2
|
|
|
UNION
|
|
|
|
|
|
##指定部门-机会提交的部门
|
|
|
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
|
|
|
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,status from chance
|
|
|
where department_id in (%v)
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1
|
|
|
`, utils.JoinInt64s(userDepartmetIds, ","), cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
...
|
...
|
@@ -418,27 +418,27 @@ func GetChancePoolPublicCompany(uid, cid int64, chanceTypeId int, lastId int64, |
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
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,status from chance
|
|
|
where company_id = %v and publish_status = 2
|
|
|
|
|
|
UNION
|
|
|
##指定部门-机会公开的部门
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
)a inner join chance b on a.chance_id = b.id
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
...
|
...
|
@@ -447,27 +447,27 @@ limit %v |
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
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,status from chance
|
|
|
where company_id = %v and publish_status = 2
|
|
|
|
|
|
UNION
|
|
|
##指定部门-机会公开的部门
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
)a inner join chance b on a.chance_id = b.id
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
...
|
...
|
@@ -486,16 +486,16 @@ func GetChancePoolMyself(uid, cid int64, chanceTypeId int, lastId int64, pageSiz |
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1 and status=1
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
...
|
...
|
@@ -504,16 +504,16 @@ limit %v |
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
|
|
##本人
|
|
|
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
|
|
|
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,status from chance
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
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,status from (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1 and status=1
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
...
|
...
|
@@ -582,120 +582,6 @@ select * from ( |
|
|
return
|
|
|
}
|
|
|
|
|
|
//type2 对我所在部门公开的机会 公司公开的机会
|
|
|
func ValidtChancePublicCompany(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}, departmentIds []int64) (total int, err error) {
|
|
|
sql := fmt.Sprintf(`
|
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
where company_id = %v and publish_status = 2
|
|
|
|
|
|
UNION
|
|
|
##指定部门-机会公开的部门
|
|
|
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 (
|
|
|
select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
)a inner join chance b on a.chance_id = b.id
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
|
|
##公司公开的机会
|
|
|
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
|
|
|
where company_id = %v and publish_status = 2
|
|
|
|
|
|
UNION
|
|
|
##指定部门-机会公开的部门
|
|
|
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 (
|
|
|
select DISTINCT chance_id from chance_department where department_id in (%v)
|
|
|
)a inner join chance b on a.chance_id = b.id
|
|
|
UNION
|
|
|
|
|
|
##本人
|
|
|
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
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
`, cid, utils.JoinInt64s(departmentIds, ","), uid, uid, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
|
|
if v != nil {
|
|
|
if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//type1 禁止查看所有机会
|
|
|
func ValidChanceMyself(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
sql := fmt.Sprintf(`
|
|
|
select a.*,b.images,speechs,videos from (
|
|
|
select * from (
|
|
|
##本人
|
|
|
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
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and (0=%v or id<%v) and a.enable_status=1
|
|
|
order by create_at desc
|
|
|
limit %v
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize)
|
|
|
|
|
|
sqlCount := fmt.Sprintf(`
|
|
|
select count(0) from (
|
|
|
##本人
|
|
|
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
|
|
|
where user_id = %v
|
|
|
UNION
|
|
|
|
|
|
##我审核
|
|
|
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 (
|
|
|
select DISTINCT chance_id from audit_flow_process where uid =%v
|
|
|
) a inner join chance b on a.chance_id = b.id
|
|
|
|
|
|
) a where review_status=3 and (0=%v or chance_type_id =%v) and a.enable_status=1
|
|
|
`, uid, uid, chanceTypeId, chanceTypeId)
|
|
|
if err = utils.ExecuteQueryOne(&total, sqlCount); err != nil {
|
|
|
return
|
|
|
}
|
|
|
if v != nil {
|
|
|
if err = utils.ExecuteQueryAll(v, sql); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//是否存在按发布机会部门编号查询
|
|
|
func ExitsChanceByDeparmentIds(chanceId int64, departmentIds []int64) (v *Chance, err error) {
|
|
|
sql := fmt.Sprintf(`select id from chance where id=%v and department_id in (%v)`,
|
...
|
...
|
|