作者 yangfu

点赞列表修改

... ... @@ -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)`,
... ...
... ... @@ -21,6 +21,8 @@ type ChanceFavorite struct {
CreateAt time.Time `orm:"column(create_at);type(timestamp);null" description:"创建时间"`
UpdateAt time.Time `orm:"column(update_at);type(timestamp);null" description:"删除时间"`
ChanceId int64 `orm:"column(chance_id)" description:"机会编号"`
CollectTime time.Time `orm:"column(collect_time);type(timestamp);null" description:"收藏时间"`
ZanTime time.Time `orm:"column(zan_time);type(timestamp);null" description:"点赞时间"`
}
func (t *ChanceFavorite) TableName() string {
... ... @@ -127,8 +129,12 @@ func ExitsChanceFavorite(userId, companyId int64, sourceId int64, markFlag int)
//更新机会点赞/收藏状态
func UpdateChanceFavorite(userId, companyId int64, sourceId int64, markFlag int) (err error) {
o := orm.NewOrm()
sql := `update chance_favorite set mark_flag = mark_flag ^ ? ,update_at=now()
sql := `update chance_favorite set mark_flag = mark_flag ^ ? ,update_at=now(),zan_time=now()
where user_id =? and company_id =? and source_id=? ` //
if markFlag == 2 {
sql = `update chance_favorite set mark_flag = mark_flag ^ ? ,update_at=now(),collect_time=now()
where user_id =? and company_id =? and source_id=? `
}
if _, err = o.Raw(sql, markFlag, userId, companyId, sourceId).Exec(); err == nil {
return
}
... ...
... ... @@ -182,7 +182,7 @@ func GetUserMsgsBulletin(userId, companyId int64, msgType int, lastId int64, pag
//获取机会消息
func GetChanceMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
sql := `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 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.status from (
select id,company_id,receive_user_id,message,source_id,is_read,chance_id,create_at msg_time,data,sender_user_id
from user_msg where receive_user_id=? and source_type=1 and (?=0 or id<?) and msg_type=?
)a left outer join chance b on a.source_id = b.id
... ... @@ -207,7 +207,7 @@ from user_msg where receive_user_id=? and source_type=1 and msg_type=? `
func GetChanceCommentMsg(uid, lastId int64, pageSize int, msgType int, v interface{}) (total int, err error) {
sql := `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 from (
select a.*,b.source_content,b.enable_status,b.user_id chance_user_id,b.create_at,b.review_status,b.status from (
select id,message content,source_type,source_id,is_read,create_at comment_time,chance_id,receive_user_id,sender_user_id from user_msg
where receive_user_id =? and (?=0 or id<?) and msg_type=? and sender_user_id<>0
)a left outer join chance b on a.source_id = b.id and source_type=1
... ...
... ... @@ -285,75 +285,32 @@ type ChancePoolItemOrm struct {
//机会池收藏列表项
type ChanceCollectItemOrm struct {
ChanceId int64 `orm:"column(id)"`
ChanceUserId int64 `orm:"column(user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
PublishStatus int `orm:"column(publish_status)"` //公开状态
Status int `orm:"column(status)"`
CommChanceItemOrm
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CollectId int64 `orm:"column(collect_id)"` //收藏id
CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
//chance_id
//ChanceId int64 `orm:"column(id)"`
UpdateTime time.Time `orm:"column(update_at)"` //收藏时间
}
//机会池收藏列表项
type ChanceThumbUpItemOrm struct {
ChanceId int64 `orm:"column(id)"`
ChanceUserId int64 `orm:"column(user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
PublishStatus int `orm:"column(publish_status)"` //公开状态
Status int `orm:"column(status)"` //公开状态
CommChanceItemOrm
//ApproveData string `json:"approveData"` //审核数据
TemplateId int `orm:"column(audit_template_id)"`
ChanceTypeId int `orm:"column(chance_type_id)"`
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CollectId int64 `orm:"column(collect_id)"` //收藏id
CollectTime time.Time `orm:"column(collect_time)"` //收藏时间
CollectId int64 `orm:"column(collect_id)"` //收藏id
ZanTime time.Time `orm:"column(zan_time)"` //收藏时间
UpdateTime time.Time `orm:"column(update_at)"` //收藏时间
}
//我的评论
type ChanceCommentItemOrm struct {
ChanceId int64 `orm:"column(chance_id)"`
Uid int64 `orm:"column(chance_user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
PublishStatus int `orm:"column(publish_status)"` //公开状态
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
CommChanceItemOrm
CommentId int64 `orm:"column(id)"`
CommentContent string `orm:"column(content)"`
... ... @@ -372,6 +329,24 @@ type ChanceCommentItemOrm struct {
SenderUserId int64 `orm:"column(sender_user_id)"`
}
//通用 机会orm对象
type CommChanceItemOrm struct {
ChanceId int64 `orm:"column(chance_id)"`
ChanceUserId int64 `orm:"column(chance_user_id)"`
CreateTime time.Time `orm:"column(create_at)"`
SourceContent string `orm:"column(source_content)"`
ChanceEnableStatus int `orm:"column(enable_status)"`
ReviewStatus int `orm:"column(review_status)"` //审核状态 1:待审核 2:被退回 3:已通过
Images string `orm:"column(images)"`
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
PublishStatus int `orm:"column(publish_status)"` //公开状态
Status int `orm:"column(status)"` //开启状态
CommentTotal int `orm:"column(comment_total)"`
ZanTotal int `orm:"column(zan_total)"`
ViewTotal int `orm:"column(view_total)"`
}
/*ChanceDetail 机会详情*/
type ChanceDetailRequest struct {
Id int64 `json:"id"` //机会编号
... ... @@ -538,6 +513,7 @@ type CommonListItem struct {
SourceType int `json:"sourceType,omitempty"` //类型 1:机会 2:评论
ChanceStatus int `json:"chanceStatus"` //0:正常 1.删除 2.关闭
Status int `json:"-"` //1:开启 2:关闭
ReviewStatus int `json:"reviewStatus"` //审核状态
ChanceId int64 `json:"chanceId"` //机会编号
... ... @@ -572,17 +548,17 @@ type MsgCommonListItem struct {
ChanceId int64 `json:"chanceId"` //机会编号
}
type ChanceItem struct {
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
CreateTimeCopy int64 `json:"createTimeCopy"`
UpdateTime int64 `json:"updateTime"`
ApproveTime int64 `json:"approveTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
PublicStatus int `json:"-"` //publicStatus
Id int64 `json:"id"`
CreateTime int64 `json:"createTime"`
//CreateTimeCopy int64 `json:"createTimeCopy"`
UpdateTime int64 `json:"updateTime"`
ApproveTime int64 `json:"approveTime"`
Provider *BaseUserInfo `json:"provider"`
FormList []*Form `json:"formList" valid:"Required"`
Speechs []Speech `json:"speechs"`
Pictures []Picture `json:"pictures"`
Videos []Video `json:"videos"`
PublicStatus int `json:"-"` //publicStatus
}
type ChanceData struct {
ThumbsUpTotal int `json:"thumbsupTotal"` //点赞总数
... ...
... ... @@ -266,6 +266,7 @@ type MsgChanceApproveItemOrm struct {
Voices string `orm:"column(speechs)"`
Videos string `orm:"column(videos)"`
ReviewStatus int `orm:"column(review_status)"`
Status int `orm:"column(status)"`
ApproveData string `orm:"column(approve_data)"` //审核数据
Id int64 `orm:"column(id)"` //消息id
... ...
... ... @@ -98,6 +98,10 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er
if items[i].ChanceStatus != 0 {
continue
}
if items[i].Status == models.ChanceStatusClose {
items[i].ChanceStatus = protocol.ChanceStatusClose
log.Debug(fmt.Sprintf("chance_id:%v 关闭原因:%v %v", items[i].ChanceId, "后台关闭", items[i].Status))
}
if items[i].ChanceId == 0 {
items[i].ChanceStatus = protocol.ChanceStatusClose
log.Debug(fmt.Sprintf("chance_id:%v 关闭原因:%v", items[i].ChanceId, "机会编号0"))
... ...
... ... @@ -148,6 +148,8 @@ func SympathyAction(header *protocol.RequestHeader, request *protocol.SympathyAc
UpdateAt: time.Now(),
EnableStatus: 1,
ChanceId: request.ChanceId,
CollectTime: time.Now(),
ZanTime: time.Now(),
}
if _, err = models.AddChanceFavorite(chanceFavoirte); err != nil {
log.Error(err)
... ... @@ -1519,9 +1521,9 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect
//return
} else {
item := protocol.ChanceItem{
Id: chance.ChanceId,
Provider: provider,
//CreateTime: chance.CreateTime.Unix() * 1000,
Id: chance.ChanceId,
Provider: provider,
CreateTime: chance.CreateTime.Unix() * 1000,
PublicStatus: chance.PublishStatus,
}
jsonUnmarshal(chance.SourceContent, &item.FormList)
... ... @@ -1549,11 +1551,16 @@ func MyCollectChance(header *protocol.RequestHeader, request *protocol.MyCollect
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
}
{
//收藏数据
commItem.CollectData = protocol.CollectData{
collect := protocol.CollectData{
Id: chance.CollectId,
CollectTime: chance.CollectTime.Unix() * 1000,
}
if collect.CollectTime <= 0 && chance.UpdateTime.Unix() > 0 {
collect.CollectTime = chance.UpdateTime.Unix() * 1000
}
//收藏数据
commItem.CollectData = collect
//commItem.ChanceId = chance.ChanceId
}
rsp.List = append(rsp.List, commItem)
... ... @@ -1625,11 +1632,15 @@ func MyThumbUpChance(header *protocol.RequestHeader, request *protocol.MyThumbUp
commItem.ChanceType = getChanceType(chance.ChanceTypeId)
}
{
//收藏数据
commItem.ThumbUpData = protocol.ThumbUpData{
thumb := protocol.ThumbUpData{
Id: chance.CollectId,
ThumbUpTime: chance.CollectTime.Unix() * 1000,
ThumbUpTime: chance.ZanTime.Unix() * 1000,
}
if thumb.ThumbUpTime <= 0 && chance.UpdateTime.Unix() > 0 {
thumb.ThumbUpTime = chance.UpdateTime.Unix() * 1000
}
//收藏数据
commItem.ThumbUpData = thumb
}
rsp.List = append(rsp.List, commItem)
}
... ... @@ -1664,7 +1675,10 @@ func MyComment(header *protocol.RequestHeader, request *protocol.MyCommentReques
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
if chance.Status == models.ChanceStatusClose { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
err = nil
log.Error(err)
... ...
... ... @@ -265,7 +265,9 @@ func MsgChanceApprove(header *protocol.RequestHeader, request *protocol.MsgChanc
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if chance.Status == models.ChanceStatusClose {
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
... ... @@ -328,6 +330,9 @@ func MsgChanceSubmit(header *protocol.RequestHeader, request *protocol.MsgChance
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if chance.Status == models.ChanceStatusClose {
commItem.ChanceStatus = protocol.ChanceStatusClose
}
approveUserId := chance.ChanceUserId
if chance.SenderUserId != 0 {
approveUserId = chance.SenderUserId
... ... @@ -399,8 +404,12 @@ func MsgChanceComment(header *protocol.RequestHeader, request *protocol.MsgChanc
commItem.ChanceStatus = protocol.ChanceStatusDelete
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
} else {
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
}
if chance.Status == models.ChanceStatusClose {
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if chance.ChanceUserId > 0 {
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
... ... @@ -478,8 +487,10 @@ func MsgChanceThumbUp(header *protocol.RequestHeader, request *protocol.MsgChanc
} else if chance.ChanceEnableStatus == 0 { //机会关闭
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if provider, err = agg.GetUserBaseInfo(chance.Uid, header.CompanyId); err != nil {
if chance.Status == models.ChanceStatusClose {
commItem.ChanceStatus = protocol.ChanceStatusClose
}
if provider, err = agg.GetUserBaseInfo(chance.ChanceUserId, header.CompanyId); err != nil {
commItem.ChanceStatus = protocol.ChanceStatusDelete
log.Error(err)
//return
... ...