作者 yangfu

机会池权限修改

@@ -83,6 +83,8 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int, @@ -83,6 +83,8 @@ func GetChancePool(uid, cid int64, o *models.ChancePoolOption, departmentId int,
83 return models.GetChancePoolSpecialDepartment(uid, cid, option, lastId, pageSize, v, specialDIds) 83 return models.GetChancePoolSpecialDepartment(uid, cid, option, lastId, pageSize, v, specialDIds)
84 case OpportunityCheckLv4: 84 case OpportunityCheckLv4:
85 return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v) 85 return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v)
  86 + case OpportunityCheckLv5:
  87 + return models.GetChancePoolMyself(uid, cid, option, lastId, pageSize, v)
86 default: 88 default:
87 return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v) 89 return models.GetChancePoolAll(uid, cid, option, lastId, pageSize, v)
88 } 90 }
@@ -151,13 +151,14 @@ type OptionOpportunity struct { @@ -151,13 +151,14 @@ type OptionOpportunity struct {
151 2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 -> 仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会; 151 2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 -> 仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会;
152 3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 -> 特定部门的公开机会:选定部门提交的公司公开、部门公开的机会;>只选择部门 152 3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 -> 特定部门的公开机会:选定部门提交的公司公开、部门公开的机会;>只选择部门
153 4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 -> 查看所有公开机会:查看所有部门的公开机会及部门公开机会; 153 4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 -> 查看所有公开机会:查看所有部门的公开机会及部门公开机会;
154 -5. -> 特定部门的待审核机会:选定部门提交的待审核机会。>只选择部门(这条这期可以先不做) 154 +5:特定部门的待审核机会:选定部门提交的待审核机会。>只选择部门 (只配置该权限,则机会池查看权限是 1)
155 */ 155 */
156 const ( 156 const (
157 OpportunityCheckLv1 int = 1 157 OpportunityCheckLv1 int = 1
158 OpportunityCheckLv2 int = 2 158 OpportunityCheckLv2 int = 2
159 OpportunityCheckLv3 int = 3 159 OpportunityCheckLv3 int = 3
160 OpportunityCheckLv4 int = 4 160 OpportunityCheckLv4 int = 4
  161 + OpportunityCheckLv5 int = 5
161 ) 162 )
162 163
163 var ( 164 var (
@@ -351,6 +352,15 @@ func getUserChancePermission(userCompanyid int64) (map[string]PermissionOptionOb @@ -351,6 +352,15 @@ func getUserChancePermission(userCompanyid int64) (map[string]PermissionOptionOb
351 return getPermissionMap(list) 352 return getPermissionMap(list)
352 } 353 }
353 354
  355 +//权限权重 值越大,权重越大
  356 +var PermissionWeight map[int]int = map[int]int{
  357 + OpportunityCheckLv1: 1,
  358 + OpportunityCheckLv2: 2,
  359 + OpportunityCheckLv3: 3,
  360 + OpportunityCheckLv4: 4,
  361 + OpportunityCheckLv5: 1,
  362 +}
  363 +
354 //获取机会权限map 364 //获取机会权限map
355 func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObject, error) { 365 func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObject, error) {
356 var ( 366 var (
@@ -371,7 +381,7 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje @@ -371,7 +381,7 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje
371 specialDepIds := make(map[int64]CheckDeparment) //特定部门 381 specialDepIds := make(map[int64]CheckDeparment) //特定部门
372 for i := range list { 382 for i := range list {
373 tmp := list[i] 383 tmp := list[i]
374 - if tmp.Check > obj.Check { 384 + if tmp.Check > 0 && checkPermissionWeight(obj.Check, tmp.Check) {
375 obj.Check = tmp.Check 385 obj.Check = tmp.Check
376 } 386 }
377 if _, ok := obj.CheckMap[tmp.Check]; !ok { //所有的check都加进来 387 if _, ok := obj.CheckMap[tmp.Check]; !ok { //所有的check都加进来
@@ -397,3 +407,15 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje @@ -397,3 +407,15 @@ func getPermissionMap(list []OptionOpportunity) (map[string]PermissionOptionObje
397 objMap[M_SYSTEM_OPPORTUNITY] = obj 407 objMap[M_SYSTEM_OPPORTUNITY] = obj
398 return objMap, nil 408 return objMap, nil
399 } 409 }
  410 +
  411 +//@return true:比当前权限更大 false:比当前权限小
  412 +func checkPermissionWeight(oldCheck, newCheck int) bool {
  413 + var ow, nw int
  414 + if v, ok := PermissionWeight[oldCheck]; ok {
  415 + ow = v
  416 + }
  417 + if v, ok := PermissionWeight[newCheck]; ok {
  418 + nw = v
  419 + }
  420 + return nw > ow
  421 +}