正在显示
6 个修改的文件
包含
84 行增加
和
22 行删除
@@ -5,6 +5,7 @@ import ( | @@ -5,6 +5,7 @@ import ( | ||
5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" | 5 | "gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/log" |
6 | "opp/controllers" | 6 | "opp/controllers" |
7 | "opp/protocol" | 7 | "opp/protocol" |
8 | + "opp/services/chance" | ||
8 | "opp/services/user" | 9 | "opp/services/user" |
9 | ) | 10 | ) |
10 | 11 | ||
@@ -198,5 +199,5 @@ func (this *UserController) Permission() { | @@ -198,5 +199,5 @@ func (this *UserController) Permission() { | ||
198 | return | 199 | return |
199 | } | 200 | } |
200 | header := controllers.GetRequestHeader(this.Ctx) | 201 | header := controllers.GetRequestHeader(this.Ctx) |
201 | - msg = protocol.NewReturnResponse(user.Permission(header, request)) | 202 | + msg = protocol.NewReturnResponse(chance.Permission(header, request)) |
202 | } | 203 | } |
@@ -130,6 +130,15 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error) | @@ -130,6 +130,15 @@ func GetAuditFlowProcessList(chanceId int64) (v []*AuditFlowProcess, err error) | ||
130 | return nil, err | 130 | return nil, err |
131 | } | 131 | } |
132 | 132 | ||
133 | +func GetAuditFlowProcessListByAuditUser(chanceId int64, auditUserId int64) (v []*AuditFlowProcess, err error) { | ||
134 | + o := orm.NewOrm() | ||
135 | + sql := "select id,review_status from audit_flow_process where chance_id=? and enable_status=1 and uid=?" | ||
136 | + if _, err = o.Raw(sql, chanceId, auditUserId).QueryRows(&v); err == nil { | ||
137 | + return v, nil | ||
138 | + } | ||
139 | + return nil, err | ||
140 | +} | ||
141 | + | ||
133 | //删除机会时关闭所有审核信息 | 142 | //删除机会时关闭所有审核信息 |
134 | func CloseAuditFlowProcess(orm orm.Ormer, chanceId int64) (err error) { | 143 | func CloseAuditFlowProcess(orm orm.Ormer, chanceId int64) (err error) { |
135 | sql := "update audit_flow_process set enable_status =0,is_active=0,update_at=now() where chance_id=?" | 144 | sql := "update audit_flow_process set enable_status =0,is_active=0,update_at=now() where chance_id=?" |
@@ -106,10 +106,14 @@ type TypeTotalItem struct { | @@ -106,10 +106,14 @@ type TypeTotalItem struct { | ||
106 | 106 | ||
107 | /*Permission 用户权限*/ | 107 | /*Permission 用户权限*/ |
108 | type PermissionRequest struct { | 108 | type PermissionRequest struct { |
109 | + ChanceId int64 `json:"chanceId"` | ||
109 | } | 110 | } |
110 | type PermissionResponse struct { | 111 | type PermissionResponse struct { |
111 | - EditSorce int `json:"editSorce"` //修改评分 1:允许 0:不允许 | 112 | + Check int `json:"-"` |
113 | + DepartmentIds []int64 `json:"-"` //指定部门编号 | ||
114 | + | ||
115 | + EditScore int `json:"editScore"` //修改评分 1:允许 0:不允许 | ||
112 | EditPublicStatus int `json:"editPublicStatus"` //修改公开状态 1:允许 0:不允许 | 116 | EditPublicStatus int `json:"editPublicStatus"` //修改公开状态 1:允许 0:不允许 |
113 | - CloseChance int `json:"closeChance"` //关闭机会 1:允许 0:不允许 | 117 | + CloseChance int `json:"-"` //关闭机会 1:允许 0:不允许 |
114 | EditChance int `json:"editChance"` //编辑机会 1:允许 0:不允许 | 118 | EditChance int `json:"editChance"` //编辑机会 1:允许 0:不允许 |
115 | } | 119 | } |
@@ -141,14 +141,17 @@ type OptionOpportunity struct { | @@ -141,14 +141,17 @@ type OptionOpportunity struct { | ||
141 | EditPublicStatus int `json:"edit_public_status"` | 141 | EditPublicStatus int `json:"edit_public_status"` |
142 | CloseChance int `json:"close_chance"` | 142 | CloseChance int `json:"close_chance"` |
143 | EditChance int `json:"edit_chance"` | 143 | EditChance int `json:"edit_chance"` |
144 | + | ||
145 | + DepartmentIds []int | ||
144 | } | 146 | } |
145 | 147 | ||
146 | /* | 148 | /* |
147 | 机会管理高级设置中的 check | 149 | 机会管理高级设置中的 check |
148 | -1:禁止查看所有机会:禁止查看所有机会(除自己提交过的机会及可执行审核操作的机会) | ||
149 | -2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 | ||
150 | -3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 | ||
151 | -4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 | 150 | +1:禁止查看所有机会:禁止查看所有机会(除自己提交过的机会及可执行审核操作的机会)->禁止查看所有机会:禁止查看所有机会(除自己提交过的机会及可执行审核操作的机会); |
151 | +2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 -> 仅查看自己部门和公开机会:查看对自己所在部门公开的机会+公司公开的机会; | ||
152 | +3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 -> 特定部门的公开机会:选定部门提交的公司公开、部门公开的机会;>只选择部门 | ||
153 | +4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 -> 查看所有公开机会:查看所有部门的公开机会及部门公开机会; | ||
154 | +5. -> 特定部门的待审核机会:选定部门提交的待审核机会。>只选择部门(这条这期可以先不做) | ||
152 | */ | 155 | */ |
153 | const ( | 156 | const ( |
154 | OpportunityCheckLv1 int = 1 | 157 | OpportunityCheckLv1 int = 1 |
@@ -1833,3 +1833,63 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete | @@ -1833,3 +1833,63 @@ func ChanceDelete(header *protocol.RequestHeader, request *protocol.ChanceDelete | ||
1833 | orm.Commit() | 1833 | orm.Commit() |
1834 | return | 1834 | return |
1835 | } | 1835 | } |
1836 | + | ||
1837 | +//用户机会权限 | ||
1838 | +func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequest) (rsp *protocol.PermissionResponse, err error) { | ||
1839 | + var ( | ||
1840 | + op *agg.OptionOpportunity | ||
1841 | + chance *models.Chance | ||
1842 | + auditProcess []*models.AuditFlowProcess | ||
1843 | + isApproving bool //是否审核中 | ||
1844 | + ) | ||
1845 | + rsp = &protocol.PermissionResponse{} | ||
1846 | + if op, err = agg.GetUserPermission(header.UserId); err == nil { | ||
1847 | + rsp.EditChance = op.EditChance | ||
1848 | + rsp.EditPublicStatus = op.EditPublicStatus | ||
1849 | + rsp.EditScore = op.EditSorce | ||
1850 | + rsp.Check = op.Check | ||
1851 | + } | ||
1852 | + for i := range op.CheckOption.Departments { | ||
1853 | + rsp.DepartmentIds = append(rsp.DepartmentIds, op.CheckOption.Departments[i].Id) | ||
1854 | + } | ||
1855 | + //判断机会权限 | ||
1856 | + if request.ChanceId > 0 { | ||
1857 | + if chance, err = models.GetChanceById(request.ChanceId); err != nil { | ||
1858 | + err = protocol.NewErrWithMessage(5101) | ||
1859 | + return | ||
1860 | + } | ||
1861 | + //本人 | ||
1862 | + if chance.UserId == header.UserId { | ||
1863 | + //审核通过 或者 已经被人审核过 就不能编辑了 | ||
1864 | + if len(chance.ApproveData) > 0 || chance.ReviewStatus == protocol.ReviewStatusPass { | ||
1865 | + rsp.EditChance = 0 | ||
1866 | + } | ||
1867 | + return | ||
1868 | + } | ||
1869 | + | ||
1870 | + //他人 | ||
1871 | + if auditProcess, err = models.GetAuditFlowProcessListByAuditUser(request.ChanceId, header.UserId); err != nil { | ||
1872 | + if err == orm.ErrNoRows { | ||
1873 | + if chance.ReviewStatus != protocol.ReviewStatusPass { | ||
1874 | + rsp.EditChance = 0 | ||
1875 | + } | ||
1876 | + err = nil | ||
1877 | + return | ||
1878 | + } | ||
1879 | + } | ||
1880 | + for i := range auditProcess { | ||
1881 | + if auditProcess[i].ReviewStatus == protocol.ReviewStatusAuditging { | ||
1882 | + isApproving = true | ||
1883 | + log.Debug(fmt.Sprintf("用户:%v 审核中 编辑权限:true", header.UserId)) | ||
1884 | + break | ||
1885 | + } | ||
1886 | + } | ||
1887 | + if isApproving { | ||
1888 | + rsp.EditChance = 1 | ||
1889 | + } else if chance.ReviewStatus == protocol.ReviewStatusAuditging && len(auditProcess) > 0 { | ||
1890 | + rsp.EditChance = 0 | ||
1891 | + log.Debug(fmt.Sprintf("用户:%v 审核过,并且当前机会在审核中 编辑权限:false", header.UserId)) | ||
1892 | + } | ||
1893 | + } | ||
1894 | + return | ||
1895 | +} |
@@ -447,18 +447,3 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis | @@ -447,18 +447,3 @@ func UserStatistics(header *protocol.RequestHeader, request *protocol.UserStatis | ||
447 | //log.Debug(buf.String()) | 447 | //log.Debug(buf.String()) |
448 | return | 448 | return |
449 | } | 449 | } |
450 | - | ||
451 | -//用户权限 | ||
452 | -func Permission(header *protocol.RequestHeader, request *protocol.PermissionRequest) (rsp *protocol.PermissionResponse, err error) { | ||
453 | - var ( | ||
454 | - op *agg.OptionOpportunity | ||
455 | - ) | ||
456 | - rsp = &protocol.PermissionResponse{} | ||
457 | - if op, err = agg.GetUserPermission(header.UserId); err == nil { | ||
458 | - rsp.EditChance = op.EditChance | ||
459 | - //rsp.CloseChance = op.CloseChance | ||
460 | - rsp.EditPublicStatus = op.EditPublicStatus | ||
461 | - rsp.EditSorce = op.EditSorce | ||
462 | - } | ||
463 | - return | ||
464 | -} |
-
请 注册 或 登录 后发表评论