作者 yangfu

权限修改

@@ -112,7 +112,7 @@ func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSi @@ -112,7 +112,7 @@ func GetChanceMyChance(uid, cid int64, reviewStatus []int8, lastId int64, pageSi
112 sql := `select a.*,b.images,speechs,videos 112 sql := `select a.*,b.images,speechs,videos
113 from ( 113 from (
114 select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance 114 select id,user_id,create_at,update_at,approve_time chance_approve_time,source_content,approve_data,review_status,enable_status,status from chance
115 -where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) and status==1 115 +where user_id=? and company_id=? and review_status in (?) and (?=0 or id<?) and status=1
116 ) a left JOIN chance_data b on a.id =b.chance_id 116 ) a left JOIN chance_data b on a.id =b.chance_id
117 order by update_at desc 117 order by update_at desc
118 limit ? 118 limit ?
@@ -120,7 +120,7 @@ limit ? @@ -120,7 +120,7 @@ limit ?
120 //update_at 120 //update_at
121 sqlCount := fmt.Sprintf(`select count(0) from ( 121 sqlCount := fmt.Sprintf(`select count(0) from (
122 select id,user_id,create_at,source_content from chance 122 select id,user_id,create_at,source_content from chance
123 -where user_id=? and company_id=? and review_status in (%v) 123 +where user_id=? and company_id=? and review_status in (%v) and status=1
124 ) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ",")) 124 ) a left JOIN chance_data b on a.id =b.chance_id`, utils.JoinInt8s(reviewStatus, ","))
125 if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil { 125 if err = utils.ExecuteQueryOne(&total, sqlCount, uid, cid); err != nil {
126 return 126 return
@@ -14,18 +14,28 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, @@ -14,18 +14,28 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
14 checkMap map[int]int 14 checkMap map[int]int
15 specialDIds []int64 15 specialDIds []int64
16 userDIds []int64 16 userDIds []int64
  17 + company *models.Company
17 ) 18 )
18 - if op, e := GetUserPermission(uid); e == nil {  
19 - for i := range op.CheckOption.Departments {  
20 - specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)  
21 - }  
22 - check = op.Check  
23 - checkMap = op.CheckMap 19 + if company, err = models.GetCompanyById(cid); err != nil {
  20 + log.Error(err)
  21 + return
24 } 22 }
25 - if len(specialDIds) == 0 {  
26 - specialDIds = append(specialDIds, 0) 23 + //公司管理员有所有权限
  24 + if company.AdminId == uid {
  25 + check = 4
  26 + } else {
  27 + if op, e := GetUserPermission(uid); e == nil {
  28 + for i := range op.CheckOption.Departments {
  29 + specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
  30 + }
  31 + check = op.Check
  32 + checkMap = op.CheckMap
  33 + }
  34 + if len(specialDIds) == 0 {
  35 + specialDIds = append(specialDIds, 0)
  36 + }
27 } 37 }
28 - log.Debug(fmt.Sprintf("user:%v check:%v", uid, check)) 38 + log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, company.AdminId == uid))
29 switch check { 39 switch check {
30 case OpportunityCheckLv1: 40 case OpportunityCheckLv1:
31 return models.GetChancePoolMyself(uid, cid, chanceTypeId, lastId, pageSize, v) 41 return models.GetChancePoolMyself(uid, cid, chanceTypeId, lastId, pageSize, v)
@@ -59,21 +69,31 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er @@ -59,21 +69,31 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er
59 checkMap map[int]int 69 checkMap map[int]int
60 specialDIds []int64 70 specialDIds []int64
61 userDIds []int64 71 userDIds []int64
  72 + company *models.Company
62 ) 73 )
63 - if op, e := GetUserPermission(uid); e == nil {  
64 - for i := range op.CheckOption.Departments {  
65 - specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)  
66 - }  
67 - checkMap = op.CheckMap  
68 - check = op.Check  
69 - } else { 74 + if company, err = models.GetCompanyById(cid); err != nil {
70 log.Error(err) 75 log.Error(err)
71 return 76 return
72 } 77 }
73 - if len(specialDIds) == 0 {  
74 - specialDIds = append(specialDIds, 0) 78 + //公司管理员有所有权限
  79 + if company.AdminId == uid {
  80 + check = 4
  81 + } else {
  82 + if op, e := GetUserPermission(uid); e == nil {
  83 + for i := range op.CheckOption.Departments {
  84 + specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
  85 + }
  86 + checkMap = op.CheckMap
  87 + check = op.Check
  88 + } else {
  89 + log.Error(err)
  90 + return
  91 + }
  92 + if len(specialDIds) == 0 {
  93 + specialDIds = append(specialDIds, 0)
  94 + }
75 } 95 }
76 - log.Debug(fmt.Sprintf("user:%v check:%v", uid, check)) 96 + log.Debug(fmt.Sprintf("user:%v check:%v is_admin:%v", uid, check, company.AdminId == uid))
77 for i := range items { 97 for i := range items {
78 if items[i].ChanceStatus != 0 { 98 if items[i].ChanceStatus != 0 {
79 continue 99 continue
@@ -1944,6 +1944,7 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ @@ -1944,6 +1944,7 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ
1944 } 1944 }
1945 //公司管理员有所有权限 1945 //公司管理员有所有权限
1946 if company.AdminId == header.UserId { 1946 if company.AdminId == header.UserId {
  1947 + rsp.Check = 4
1947 allPermission() 1948 allPermission()
1948 return 1949 return
1949 } 1950 }