作者 yangfu

权限修改

... ... @@ -112,7 +112,7 @@ func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSi
sql := `select a.*,b.images,speechs,videos
from (
select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance
where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) and status==1
where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) and status=1
) a left JOIN chance_data b on a.id =b.chance_id
order by update_at desc
limit ?
... ... @@ -120,7 +120,7 @@ limit ?
//update_at
sqlCount := fmt.Sprintf(`select count(0) from (
select id,user_id,create_at,source_content from chance
where user_id=? and company_id=? and review_status in (%v)
where user_id=? and company_id=? and review_status in (%v) and status=1
) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ","))
if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
return
... ...
... ... @@ -14,18 +14,28 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
checkMap map[int]int
specialDIds []int64
userDIds []int64
company *models.Company
)
if op, e := GetUserPermission(uid); e == nil {
for i := range op.CheckOption.Departments {
specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
}
check = op.Check
checkMap = op.CheckMap
if company, err = models.GetCompanyById(cid); err != nil {
log.Error(err)
return
}
if len(specialDIds) == 0 {
specialDIds = append(specialDIds, 0)
//公司管理员有所有权限
if company.AdminId == uid {
check = 4
} else {
if op, e := GetUserPermission(uid); e == nil {
for i := range op.CheckOption.Departments {
specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
}
check = op.Check
checkMap = op.CheckMap
}
if len(specialDIds) == 0 {
specialDIds = append(specialDIds, 0)
}
}
log.Debug(fmt.Sprintf("user:%v check:%v", uid, check))
log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, company.AdminId == uid))
switch check {
case OpportunityCheckLv1:
return models.GetChancePoolMyself(uid, cid, chanceTypeId, lastId, pageSize, v)
... ... @@ -59,21 +69,31 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er
checkMap map[int]int
specialDIds []int64
userDIds []int64
company *models.Company
)
if op, e := GetUserPermission(uid); e == nil {
for i := range op.CheckOption.Departments {
specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
}
checkMap = op.CheckMap
check = op.Check
} else {
if company, err = models.GetCompanyById(cid); err != nil {
log.Error(err)
return
}
if len(specialDIds) == 0 {
specialDIds = append(specialDIds, 0)
//公司管理员有所有权限
if company.AdminId == uid {
check = 4
} else {
if op, e := GetUserPermission(uid); e == nil {
for i := range op.CheckOption.Departments {
specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
}
checkMap = op.CheckMap
check = op.Check
} else {
log.Error(err)
return
}
if len(specialDIds) == 0 {
specialDIds = append(specialDIds, 0)
}
}
log.Debug(fmt.Sprintf("user:%v check:%v", uid, check))
log.Debug(fmt.Sprintf("user:%v check:%v is_admin:%v", uid, check, company.AdminId == uid))
for i := range items {
if items[i].ChanceStatus != 0 {
continue
... ...
... ... @@ -1944,6 +1944,7 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ
}
//公司管理员有所有权限
if company.AdminId == header.UserId {
rsp.Check = 4
allPermission()
return
}
... ...