...
|
...
|
@@ -1833,3 +1833,63 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete |
|
|
orm.Commit()
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//用户机会权限
|
|
|
func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequest) (rsp *protocol.PermissionResponse, err error) {
|
|
|
var (
|
|
|
op *agg.OptionOpportunity
|
|
|
chance *models.Chance
|
|
|
auditProcess []*models.AuditFlowProcess
|
|
|
isApproving bool //是否审核中
|
|
|
)
|
|
|
rsp = &protocol.PermissionResponse{}
|
|
|
if op, err = agg.GetUserPermission(header.UserId); err == nil {
|
|
|
rsp.EditChance = op.EditChance
|
|
|
rsp.EditPublicStatus = op.EditPublicStatus
|
|
|
rsp.EditScore = op.EditSorce
|
|
|
rsp.Check = op.Check
|
|
|
}
|
|
|
for i := range op.CheckOption.Departments {
|
|
|
rsp.DepartmentIds = append(rsp.DepartmentIds, op.CheckOption.Departments[i].Id)
|
|
|
}
|
|
|
//判断机会权限
|
|
|
if request.ChanceId > 0 {
|
|
|
if chance, err = models.GetChanceById(request.ChanceId); err != nil {
|
|
|
err = protocol.NewErrWithMessage(5101)
|
|
|
return
|
|
|
}
|
|
|
//本人
|
|
|
if chance.UserId == header.UserId {
|
|
|
//审核通过 或者 已经被人审核过 就不能编辑了
|
|
|
if len(chance.ApproveData) > 0 || chance.ReviewStatus == protocol.ReviewStatusPass {
|
|
|
rsp.EditChance = 0
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
|
|
|
//他人
|
|
|
if auditProcess, err = models.GetAuditFlowProcessListByAuditUser(request.ChanceId, header.UserId); err != nil {
|
|
|
if err == orm.ErrNoRows {
|
|
|
if chance.ReviewStatus != protocol.ReviewStatusPass {
|
|
|
rsp.EditChance = 0
|
|
|
}
|
|
|
err = nil
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
for i := range auditProcess {
|
|
|
if auditProcess[i].ReviewStatus == protocol.ReviewStatusAuditging {
|
|
|
isApproving = true
|
|
|
log.Debug(fmt.Sprintf("用户:%v 审核中 编辑权限:true", header.UserId))
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
if isApproving {
|
|
|
rsp.EditChance = 1
|
|
|
} else if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(auditProcess) > 0 {
|
|
|
rsp.EditChance = 0
|
|
|
log.Debug(fmt.Sprintf("用户:%v 审核过,并且当前机会在审核中 编辑权限:false", header.UserId))
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
} |
...
|
...
|
|