...
|
...
|
@@ -149,33 +149,6 @@ from audit_flow_process where uid=? and enable_status =1 and review_status in (% |
|
|
return
|
|
|
}
|
|
|
|
|
|
func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
|
|
|
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
|
|
|
order by create_at desc
|
|
|
limit ?
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id`
|
|
|
//if public==protocol.pu
|
|
|
|
|
|
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
|
|
|
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 {
|
|
|
return
|
|
|
}
|
|
|
if v != nil {
|
|
|
if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
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 from (
|
...
|
...
|
@@ -257,3 +230,202 @@ where user_id =?` |
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//type4 查看所有机会
|
|
|
func GetChancePoolAll(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, v interface{}) (total int, err error) {
|
|
|
|
|
|
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
|
|
|
order by create_at desc
|
|
|
limit ?
|
|
|
) a left JOIN chance_data b on a.id =b.chance_id`
|
|
|
//if public==protocol.pu
|
|
|
|
|
|
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
|
|
|
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 {
|
|
|
return
|
|
|
}
|
|
|
if v != nil {
|
|
|
if err = utils.ExecuteQueryAll(v, sql, cid, chanceTypeId, chanceTypeId, lastId, lastId, pageSize); err != nil {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//type3 特定部门机会
|
|
|
func GetChancePoolSpecialDepartment(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 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
|
|
|
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
|
|
|
`, 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 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
|
|
|
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
|
|
|
`, 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
|
|
|
}
|
|
|
|
|
|
//type2 对我所在部门公开的机会 公司公开的机会
|
|
|
func GetChancePoolPublicCompany(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 GetChancePoolMyself(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
|
|
|
} |
...
|
...
|
|