正在显示
4 个修改的文件
包含
32 行增加
和
22 行删除
@@ -115,6 +115,16 @@ func GetUserByUcid(ucid int64) (v *User, err error) { | @@ -115,6 +115,16 @@ func GetUserByUcid(ucid int64) (v *User, err error) { | ||
115 | return nil, err | 115 | return nil, err |
116 | } | 116 | } |
117 | 117 | ||
118 | +//按公司编号获取管理员编号 | ||
119 | +func GetUserByCompanyId(cid int64) (v *User, err error) { | ||
120 | + o := orm.NewOrm() | ||
121 | + sql := "select id,nick_name from `user` where id = (select admin_id from company where id=? and enable=1) and enable_status=1" | ||
122 | + if err = o.Raw(sql, cid).QueryRow(&v); err == nil { | ||
123 | + return v, nil | ||
124 | + } | ||
125 | + return nil, err | ||
126 | +} | ||
127 | + | ||
118 | func GetUserByUcidEnable(ucid int64) (v *User, err error) { | 128 | func GetUserByUcidEnable(ucid int64) (v *User, err error) { |
119 | o := orm.NewOrm() | 129 | o := orm.NewOrm() |
120 | sql := "select id,nick_name from `user` where id = (select user_id from user_company where user_company.id=? and user_company.enable=1) and enable_status=1" | 130 | sql := "select id,nick_name from `user` where id = (select user_id from user_company where user_company.id=? and user_company.enable=1) and enable_status=1" |
@@ -14,14 +14,14 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, | @@ -14,14 +14,14 @@ 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 | + user *models.User |
18 | ) | 18 | ) |
19 | - if company, err = models.GetCompanyById(cid); err != nil { | 19 | + if user, err = models.GetUserByCompanyId(cid); err != nil { |
20 | log.Error(err) | 20 | log.Error(err) |
21 | return | 21 | return |
22 | } | 22 | } |
23 | //公司管理员有所有权限 | 23 | //公司管理员有所有权限 |
24 | - if company.AdminId == uid { | 24 | + if user.Id == uid { |
25 | check = 4 | 25 | check = 4 |
26 | } else { | 26 | } else { |
27 | if op, e := GetUserPermission(uid); e == nil { | 27 | if op, e := GetUserPermission(uid); e == nil { |
@@ -35,7 +35,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, | @@ -35,7 +35,7 @@ func GetChancePool(uid, cid int64, chanceTypeId int, lastId int64, pageSize int, | ||
35 | specialDIds = append(specialDIds, 0) | 35 | specialDIds = append(specialDIds, 0) |
36 | } | 36 | } |
37 | } | 37 | } |
38 | - log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, company.AdminId == uid)) | 38 | + log.Debug(fmt.Sprintf("user:%v check:%v is_amdin:%v", uid, check, user.Id == uid)) |
39 | switch check { | 39 | switch check { |
40 | case OpportunityCheckLv1: | 40 | case OpportunityCheckLv1: |
41 | return models.GetChancePoolMyself(uid, cid, chanceTypeId, lastId, pageSize, v) | 41 | return models.GetChancePoolMyself(uid, cid, chanceTypeId, lastId, pageSize, v) |
@@ -69,14 +69,14 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er | @@ -69,14 +69,14 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er | ||
69 | checkMap map[int]int | 69 | checkMap map[int]int |
70 | specialDIds []int64 | 70 | specialDIds []int64 |
71 | userDIds []int64 | 71 | userDIds []int64 |
72 | - company *models.Company | 72 | + user *models.User |
73 | ) | 73 | ) |
74 | - if company, err = models.GetCompanyById(cid); err != nil { | 74 | + if user, err = models.GetUserByCompanyId(cid); err != nil { |
75 | log.Error(err) | 75 | log.Error(err) |
76 | return | 76 | return |
77 | } | 77 | } |
78 | //公司管理员有所有权限 | 78 | //公司管理员有所有权限 |
79 | - if company.AdminId == uid { | 79 | + if user.Id == uid { |
80 | check = 4 | 80 | check = 4 |
81 | } else { | 81 | } else { |
82 | if op, e := GetUserPermission(uid); e == nil { | 82 | if op, e := GetUserPermission(uid); e == nil { |
@@ -93,7 +93,7 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er | @@ -93,7 +93,7 @@ func ValidChancePermission(uid, cid int64, items []*protocol.CommonListItem) (er | ||
93 | specialDIds = append(specialDIds, 0) | 93 | specialDIds = append(specialDIds, 0) |
94 | } | 94 | } |
95 | } | 95 | } |
96 | - log.Debug(fmt.Sprintf("user:%v check:%v is_admin:%v", uid, check, company.AdminId == uid)) | 96 | + log.Debug(fmt.Sprintf("user:%v check:%v is_admin:%v", uid, check, user.Id == uid)) |
97 | for i := range items { | 97 | for i := range items { |
98 | if items[i].ChanceStatus != 0 { | 98 | if items[i].ChanceStatus != 0 { |
99 | continue | 99 | continue |
@@ -414,7 +414,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | @@ -414,7 +414,7 @@ func ChanceApprove(header *protocol.RequestHeader, request *protocol.ChanceAppro | ||
414 | } | 414 | } |
415 | } | 415 | } |
416 | } | 416 | } |
417 | - if err = saveApproveMsgByApproveData(orm, request.ReviewStatus, chance, request.ApproveData); err != nil { | 417 | + if err = saveApproveMsgByApproveData(header, orm, request.ReviewStatus, chance, request.ApproveData); err != nil { |
418 | orm.Rollback() | 418 | orm.Rollback() |
419 | log.Error("发送审核日志失败", err) | 419 | log.Error("发送审核日志失败", err) |
420 | return | 420 | return |
@@ -477,7 +477,7 @@ func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateR | @@ -477,7 +477,7 @@ func ProcessIntegrate(header *protocol.RequestHeader, request *ProcessIntegrateR | ||
477 | } | 477 | } |
478 | 478 | ||
479 | //发送审核日志 | 479 | //发送审核日志 |
480 | -func saveApproveMsgByApproveData(orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData) (err error) { | 480 | +func saveApproveMsgByApproveData(header *protocol.RequestHeader, orm orm.Ormer, reviewStatus int, chance *models.Chance, approveData protocol.ApproveData) (err error) { |
481 | var ( | 481 | var ( |
482 | parames = make([]interface{}, 0) | 482 | parames = make([]interface{}, 0) |
483 | code = 0 | 483 | code = 0 |
@@ -503,7 +503,7 @@ func saveApproveMsgByApproveData(orm orm.Ormer, reviewStatus int, chance *models | @@ -503,7 +503,7 @@ func saveApproveMsgByApproveData(orm orm.Ormer, reviewStatus int, chance *models | ||
503 | parames = append(parames, strings.Join(department, ",")) | 503 | parames = append(parames, strings.Join(department, ",")) |
504 | } | 504 | } |
505 | } | 505 | } |
506 | - if err = agg.SaveApproveLog(orm, code, chance.UserId, chance.Id, parames...); err != nil { | 506 | + if err = agg.SaveApproveLog(orm, code, header.UserId, chance.Id, parames...); err != nil { |
507 | log.Error(err) | 507 | log.Error(err) |
508 | return | 508 | return |
509 | } | 509 | } |
@@ -480,7 +480,7 @@ func setChanceAutoPass(header *protocol.RequestHeader, chance *models.Chance, or | @@ -480,7 +480,7 @@ func setChanceAutoPass(header *protocol.RequestHeader, chance *models.Chance, or | ||
480 | log.Error(err) | 480 | log.Error(err) |
481 | return | 481 | return |
482 | } | 482 | } |
483 | - if err = agg.SaveApproveLog(orm, 6, chance.UserId, chance.Id, approveData.Score.BasicScore, approveData.Score.ExtraScore, approveData.Score.ValueScore); err != nil { | 483 | + if err = agg.SaveApproveLog(orm, 6, header.UserId, chance.Id, approveData.Score.BasicScore, approveData.Score.ExtraScore, approveData.Score.ValueScore); err != nil { |
484 | log.Error(err) | 484 | log.Error(err) |
485 | //orm.Rollback() | 485 | //orm.Rollback() |
486 | return | 486 | return |
@@ -809,7 +809,7 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC | @@ -809,7 +809,7 @@ func ChanceChangeScore(header *protocol.RequestHeader, request *protocol.ChanceC | ||
809 | return | 809 | return |
810 | } | 810 | } |
811 | //修改评分日志 | 811 | //修改评分日志 |
812 | - if err = agg.SaveApproveLog(orm, 9, chance.UserId, chance.Id, request.Score.BasicScore, request.Score.ExtraScore, request.Score.ValueScore); err != nil { | 812 | + if err = agg.SaveApproveLog(orm, 9, header.UserId, chance.Id, request.Score.BasicScore, request.Score.ExtraScore, request.Score.ValueScore); err != nil { |
813 | log.Error(err) | 813 | log.Error(err) |
814 | return | 814 | return |
815 | } | 815 | } |
@@ -1918,7 +1918,7 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | @@ -1918,7 +1918,7 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | ||
1918 | chance *models.Chance | 1918 | chance *models.Chance |
1919 | auditProcess []*models.AuditFlowProcess | 1919 | auditProcess []*models.AuditFlowProcess |
1920 | isApproving bool //是否审核中 | 1920 | isApproving bool //是否审核中 |
1921 | - company *models.Company | 1921 | + user *models.User |
1922 | ) | 1922 | ) |
1923 | rsp = &protocol.PermissionResponse{} | 1923 | rsp = &protocol.PermissionResponse{} |
1924 | if op, err = agg.GetUserPermission(header.UserId); err == nil { | 1924 | if op, err = agg.GetUserPermission(header.UserId); err == nil { |
@@ -1940,22 +1940,22 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | @@ -1940,22 +1940,22 @@ func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequ | ||
1940 | rsp.EditPublicStatus = 1 | 1940 | rsp.EditPublicStatus = 1 |
1941 | rsp.EditScore = 1 | 1941 | rsp.EditScore = 1 |
1942 | } | 1942 | } |
1943 | - if company, err = models.GetCompanyById(header.CompanyId); err != nil { | 1943 | + //无权限 |
1944 | + noPermission := func() { | ||
1945 | + rsp.EditChance = 0 | ||
1946 | + rsp.EditPublicStatus = 0 | ||
1947 | + rsp.EditScore = 0 | ||
1948 | + } | ||
1949 | + if user, err = models.GetUserByCompanyId(header.CompanyId); err != nil { | ||
1944 | log.Error(err) | 1950 | log.Error(err) |
1945 | return | 1951 | return |
1946 | } | 1952 | } |
1947 | //公司管理员有所有权限 | 1953 | //公司管理员有所有权限 |
1948 | - if company.AdminId == header.UserId { | 1954 | + if user.Id == header.UserId { |
1949 | rsp.Check = 4 | 1955 | rsp.Check = 4 |
1950 | allPermission() | 1956 | allPermission() |
1951 | return | 1957 | return |
1952 | } | 1958 | } |
1953 | - //无权限 | ||
1954 | - noPermission := func() { | ||
1955 | - rsp.EditChance = 0 | ||
1956 | - rsp.EditPublicStatus = 0 | ||
1957 | - rsp.EditScore = 0 | ||
1958 | - } | ||
1959 | //判断机会权限 | 1959 | //判断机会权限 |
1960 | if request.ChanceId > 0 { | 1960 | if request.ChanceId > 0 { |
1961 | if chance, err = models.GetChanceById(request.ChanceId); err != nil { | 1961 | if chance, err = models.GetChanceById(request.ChanceId); err != nil { |
-
请 注册 或 登录 后发表评论