|
@@ -1931,16 +1931,27 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
|
@@ -1931,16 +1931,27 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
1931
|
for i := range op.CheckOption.Departments {
|
1931
|
for i := range op.CheckOption.Departments {
|
1932
|
rsp.DepartmentIds = append(rsp.DepartmentIds, op.CheckOption.Departments[i].Id)
|
1932
|
rsp.DepartmentIds = append(rsp.DepartmentIds, op.CheckOption.Departments[i].Id)
|
1933
|
}
|
1933
|
}
|
|
|
1934
|
+ //所有权限
|
|
|
1935
|
+ allPermission := func() {
|
|
|
1936
|
+ rsp.EditChance = 1
|
|
|
1937
|
+ rsp.EditPublicStatus = 1
|
|
|
1938
|
+ rsp.EditScore = 1
|
|
|
1939
|
+ }
|
|
|
1940
|
+ //无权限
|
|
|
1941
|
+ noPermission := func() {
|
|
|
1942
|
+ rsp.EditChance = 0
|
|
|
1943
|
+ rsp.EditPublicStatus = 0
|
|
|
1944
|
+ rsp.EditScore = 0
|
|
|
1945
|
+ }
|
1934
|
//判断机会权限
|
1946
|
//判断机会权限
|
1935
|
if request.ChanceId > 0 {
|
1947
|
if request.ChanceId > 0 {
|
1936
|
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
|
1948
|
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
|
1937
|
err = protocol.NewErrWithMessage(5101)
|
1949
|
err = protocol.NewErrWithMessage(5101)
|
1938
|
return
|
1950
|
return
|
1939
|
}
|
1951
|
}
|
1940
|
- if chance.Status == models.ChanceStatusClose || chance.EnableStatus == 0 { //机会关闭 / 删除
|
|
|
1941
|
- rsp.EditChance = 0
|
|
|
1942
|
- rsp.EditPublicStatus = 0
|
|
|
1943
|
- rsp.EditScore = 0
|
1952
|
+ //机会关闭 / 删除
|
|
|
1953
|
+ if chance.Status == models.ChanceStatusClose || chance.EnableStatus == 0 {
|
|
|
1954
|
+ noPermission()
|
1944
|
log.Debug(fmt.Sprintf("用户:%v chance_id:%v 机会关闭/删除 无权限", header.UserId, chance.Id))
|
1955
|
log.Debug(fmt.Sprintf("用户:%v chance_id:%v 机会关闭/删除 无权限", header.UserId, chance.Id))
|
1945
|
return
|
1956
|
return
|
1946
|
}
|
1957
|
}
|
|
@@ -1948,31 +1959,29 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
|
@@ -1948,31 +1959,29 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
1948
|
if chance.UserId == header.UserId {
|
1959
|
if chance.UserId == header.UserId {
|
1949
|
//审核通过 或者 已经被人审核过 就不能编辑了
|
1960
|
//审核通过 或者 已经被人审核过 就不能编辑了
|
1950
|
if len(chance.ApproveData) > 0 && chance.ReviewStatus == protocol.ReviewStatusAuditging { //审批中 且有人审批 本人不可编辑
|
1961
|
if len(chance.ApproveData) > 0 && chance.ReviewStatus == protocol.ReviewStatusAuditging { //审批中 且有人审批 本人不可编辑
|
1951
|
- rsp.EditChance = 0
|
1962
|
+ noPermission()
|
1952
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging { //未有人审核过
|
1963
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging { //未有人审核过
|
1953
|
rsp.EditChance = 1
|
1964
|
rsp.EditChance = 1
|
1954
|
rsp.EditPublicStatus = 0
|
1965
|
rsp.EditPublicStatus = 0
|
1955
|
rsp.EditScore = 0
|
1966
|
rsp.EditScore = 0
|
1956
|
}
|
1967
|
}
|
1957
|
if chance.ReviewStatus == protocol.ReviewStatusPass {
|
1968
|
if chance.ReviewStatus == protocol.ReviewStatusPass {
|
1958
|
- rsp.EditScore = 1
|
1969
|
+ rsp.EditChance = 1
|
1959
|
}
|
1970
|
}
|
1960
|
return
|
1971
|
return
|
1961
|
- } else {
|
|
|
1962
|
- if chance.ReviewStatus == protocol.ReviewStatusReturn { //退回的机会不可编辑
|
|
|
1963
|
- rsp.EditChance = 0
|
|
|
1964
|
- rsp.EditPublicStatus = 0
|
|
|
1965
|
- rsp.EditScore = 0
|
|
|
1966
|
- }
|
|
|
1967
|
}
|
1972
|
}
|
|
|
1973
|
+ //他人
|
1968
|
if chance.UserId != header.UserId {
|
1974
|
if chance.UserId != header.UserId {
|
1969
|
- //他人
|
1975
|
+ if chance.ReviewStatus == protocol.ReviewStatusReturn { //退回的机会不可编辑
|
|
|
1976
|
+ noPermission()
|
|
|
1977
|
+ return
|
|
|
1978
|
+ }
|
|
|
1979
|
+ //是否是审核人
|
1970
|
if auditProcess, err = models.GetAuditFlowProcessListByAuditUser(request.ChanceId, header.UserId); err != nil {
|
1980
|
if auditProcess, err = models.GetAuditFlowProcessListByAuditUser(request.ChanceId, header.UserId); err != nil {
|
1971
|
if err == orm.ErrNoRows {
|
1981
|
if err == orm.ErrNoRows {
|
|
|
1982
|
+ //非审核人 并且 审核状态不是通过的,无所有权限
|
1972
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
1983
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
1973
|
- rsp.EditChance = 0
|
|
|
1974
|
- rsp.EditPublicStatus = 0
|
|
|
1975
|
- rsp.EditScore = 0
|
1984
|
+ noPermission()
|
1976
|
}
|
1985
|
}
|
1977
|
err = nil
|
1986
|
err = nil
|
1978
|
return
|
1987
|
return
|
|
@@ -1987,15 +1996,13 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
|
@@ -1987,15 +1996,13 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ |
1987
|
}
|
1996
|
}
|
1988
|
//审核进行中
|
1997
|
//审核进行中
|
1989
|
if isApproving {
|
1998
|
if isApproving {
|
1990
|
- rsp.EditChance = 1
|
1999
|
+ allPermission()
|
1991
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(auditProcess) > 0 {
|
2000
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(auditProcess) > 0 {
|
1992
|
- rsp.EditChance = 0
|
2001
|
+ noPermission()
|
1993
|
log.Debug(fmt.Sprintf("用户:%v 审核过,并且当前机会在审核中 编辑权限:false", header.UserId))
|
2002
|
log.Debug(fmt.Sprintf("用户:%v 审核过,并且当前机会在审核中 编辑权限:false", header.UserId))
|
1994
|
}
|
2003
|
}
|
1995
|
if chance.ReviewStatus == protocol.ReviewStatusPass && len(auditProcess) > 0 { //已通过的机会 并且是审批人 有所有编辑权限
|
2004
|
if chance.ReviewStatus == protocol.ReviewStatusPass && len(auditProcess) > 0 { //已通过的机会 并且是审批人 有所有编辑权限
|
1996
|
- rsp.EditChance = 1
|
|
|
1997
|
- rsp.EditPublicStatus = 1
|
|
|
1998
|
- rsp.EditScore = 1
|
2005
|
+ allPermission()
|
1999
|
}
|
2006
|
}
|
2000
|
}
|
2007
|
}
|
2001
|
}
|
2008
|
}
|