...
|
...
|
@@ -42,12 +42,14 @@ func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool { |
|
|
}
|
|
|
|
|
|
func (p *PermissionOptionBase) MergeObject(jsonString string) error {
|
|
|
var obj PermissionBase
|
|
|
var obj PermissionOptionBase
|
|
|
err := json.Unmarshal([]byte(jsonString), &obj)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
// if o
|
|
|
if obj.Check > p.Check {
|
|
|
p.Check = obj.Check
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -89,11 +91,13 @@ type CheckOpp struct { |
|
|
|
|
|
//OptionOpportunity 机会管理 高级权限设置
|
|
|
type OptionOpportunity struct {
|
|
|
Check int `json:"check"`
|
|
|
CheckOption CheckOpp `json:"check_option"`
|
|
|
EditSorce int `json:"edit_sorce"`
|
|
|
EditPublicStatus int `json:"edit_public_status"`
|
|
|
CloseChance int `json:"close_chance"`
|
|
|
Check int `json:"check"`
|
|
|
CheckMap map[int]int `json:"-"`
|
|
|
CheckOption CheckOpp `json:"check_option"`
|
|
|
EditSorce int `json:"edit_sorce"`
|
|
|
EditPublicStatus int `json:"edit_public_status"`
|
|
|
CloseChance int `json:"close_chance"`
|
|
|
EditChance int `json:"edit_chance"`
|
|
|
}
|
|
|
|
|
|
/*
|
...
|
...
|
@@ -116,6 +120,7 @@ var ( |
|
|
|
|
|
func NewOptionOpportunity() PermissionOptionObject {
|
|
|
return &OptionOpportunity{
|
|
|
CheckMap: make(map[int]int),
|
|
|
CheckOption: CheckOpp{
|
|
|
Departments: []CheckDeparment{},
|
|
|
},
|
...
|
...
|
@@ -134,7 +139,56 @@ func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool { |
|
|
}
|
|
|
|
|
|
//MergeObject PermissionOptionBase 接口实现
|
|
|
func (p *OptionOpportunity) MergeObject(string) error {
|
|
|
func (p *OptionOpportunity) MergeObject(jsonString string) error {
|
|
|
var obj OptionOpportunity
|
|
|
err := json.Unmarshal([]byte(jsonString), &obj)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
if p.CheckMap == nil {
|
|
|
p.CheckMap = make(map[int]int)
|
|
|
}
|
|
|
p.CheckMap[obj.Check] = 1
|
|
|
departMap := make(map[int64]*CheckDeparment)
|
|
|
for k := range p.CheckOption.Departments {
|
|
|
i := p.CheckOption.Departments[k].Id
|
|
|
departMap[i] = &p.CheckOption.Departments[k]
|
|
|
}
|
|
|
//列表合并
|
|
|
for k := range obj.CheckOption.Departments {
|
|
|
i := obj.CheckOption.Departments[k].Id
|
|
|
if _, ok := departMap[i]; ok {
|
|
|
if obj.CheckOption.Departments[k].OpenAll > departMap[i].OpenAll {
|
|
|
departMap[i].OpenAll = obj.CheckOption.Departments[k].OpenAll
|
|
|
}
|
|
|
if obj.CheckOption.Departments[k].OpenDepart > departMap[i].OpenDepart {
|
|
|
departMap[i].OpenDepart = obj.CheckOption.Departments[k].OpenDepart
|
|
|
}
|
|
|
if obj.CheckOption.Departments[k].Wait > departMap[i].Wait {
|
|
|
departMap[i].Wait = obj.CheckOption.Departments[k].Wait
|
|
|
}
|
|
|
} else {
|
|
|
|
|
|
departMap[i] = &obj.CheckOption.Departments[k]
|
|
|
|
|
|
}
|
|
|
}
|
|
|
p.CheckOption.Departments = make([]CheckDeparment, 0)
|
|
|
for k := range departMap {
|
|
|
p.CheckOption.Departments = append(p.CheckOption.Departments, *departMap[k])
|
|
|
}
|
|
|
if obj.CloseChance > p.CloseChance {
|
|
|
p.CloseChance = obj.CloseChance
|
|
|
}
|
|
|
if obj.EditPublicStatus > p.EditPublicStatus {
|
|
|
p.EditPublicStatus = obj.EditPublicStatus
|
|
|
}
|
|
|
if obj.EditSorce > p.EditSorce {
|
|
|
p.EditSorce = obj.EditSorce
|
|
|
}
|
|
|
if obj.EditChance > p.EditChance {
|
|
|
p.EditChance = obj.EditChance
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
|