作者 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,7 +14,16 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, @@ -14,7 +14,16 @@ 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 )
  19 + if company, err = models.GetCompanyById(cid); err != nil {
  20 + log.Error(err)
  21 + return
  22 + }
  23 + //公司管理员有所有权限
  24 + if company.AdminId == uid {
  25 + check = 4
  26 + } else {
18 if op, e := GetUserPermission(uid); e == nil { 27 if op, e := GetUserPermission(uid); e == nil {
19 for i := range op.CheckOption.Departments { 28 for i := range op.CheckOption.Departments {
20 specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id) 29 specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
@@ -25,7 +34,8 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, @@ -25,7 +34,8 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int,
25 if len(specialDIds) == 0 { 34 if len(specialDIds) == 0 {
26 specialDIds = append(specialDIds, 0) 35 specialDIds = append(specialDIds, 0)
27 } 36 }
28 - log.Debug(fmt.Sprintf("user:%v check:%v", uid, check)) 37 + }
  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,7 +69,16 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er @@ -59,7 +69,16 @@ 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 )
  74 + if company, err = models.GetCompanyById(cid); err != nil {
  75 + log.Error(err)
  76 + return
  77 + }
  78 + //公司管理员有所有权限
  79 + if company.AdminId == uid {
  80 + check = 4
  81 + } else {
63 if op, e := GetUserPermission(uid); e == nil { 82 if op, e := GetUserPermission(uid); e == nil {
64 for i := range op.CheckOption.Departments { 83 for i := range op.CheckOption.Departments {
65 specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id) 84 specialDIds = append(specialDIds, op.CheckOption.Departments[i].Id)
@@ -73,7 +92,8 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er @@ -73,7 +92,8 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er
73 if len(specialDIds) == 0 { 92 if len(specialDIds) == 0 {
74 specialDIds = append(specialDIds, 0) 93 specialDIds = append(specialDIds, 0)
75 } 94 }
76 - log.Debug(fmt.Sprintf("user:%v check:%v", uid, check)) 95 + }
  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 }