正在显示
7 个修改的文件
包含
127 行增加
和
69 行删除
@@ -34,3 +34,14 @@ func GetRoleMenuByRole(roleid int64) ([]RoleMenu, error) { | @@ -34,3 +34,14 @@ func GetRoleMenuByRole(roleid int64) ([]RoleMenu, error) { | ||
34 | } | 34 | } |
35 | return list, err | 35 | return list, err |
36 | } | 36 | } |
37 | + | ||
38 | +func GetRoleMenuByCode(roleId int64, code string) (*RoleMenu, error) { | ||
39 | + // data := []RoleMenu{} | ||
40 | + // o := orm.NewOrm() | ||
41 | + // _, err := o.QueryTable(&Role{}). | ||
42 | + // Filter("role_id", roleId). | ||
43 | + // Filter("code", code). | ||
44 | + // All(&data) | ||
45 | + | ||
46 | + return nil, nil | ||
47 | +} |
@@ -44,8 +44,8 @@ var errmessge ErrorMap = map[string]string{ | @@ -44,8 +44,8 @@ var errmessge ErrorMap = map[string]string{ | ||
44 | "10037": "用户的部门必填", | 44 | "10037": "用户的部门必填", |
45 | "10038": "用户的角色必填", | 45 | "10038": "用户的角色必填", |
46 | "10039": "用户已存在", | 46 | "10039": "用户已存在", |
47 | - "10071": "不能删除主管", | ||
48 | - "10072": "不能禁用主管", | 47 | + "10071": "不能删除主管理员", |
48 | + "10072": "不能禁用主管理员", | ||
49 | //部门相关 | 49 | //部门相关 |
50 | "10041": "无效的主管设置", | 50 | "10041": "无效的主管设置", |
51 | "10042": "上级部门不能选择当前部门及其子部门", | 51 | "10042": "上级部门不能选择当前部门及其子部门", |
@@ -21,12 +21,6 @@ type RequestRoleEdit struct { | @@ -21,12 +21,6 @@ type RequestRoleEdit struct { | ||
21 | RequestRoleAdd | 21 | RequestRoleAdd |
22 | } | 22 | } |
23 | 23 | ||
24 | -//RequestRoleOne 获取一个角色数据 | ||
25 | -// type RequestRoleOne struct { | ||
26 | -// CompanyID int `json:"company_id"` | ||
27 | -// RoleID int `json:"role_id"` | ||
28 | -// } | ||
29 | - | ||
30 | //ResponseRoleInfo 响应数据 | 24 | //ResponseRoleInfo 响应数据 |
31 | type ResponseRoleInfo struct { | 25 | type ResponseRoleInfo struct { |
32 | ID int64 `json:"id"` | 26 | ID int64 `json:"id"` |
@@ -81,5 +75,5 @@ type ResponseRoleMenus struct { | @@ -81,5 +75,5 @@ type ResponseRoleMenus struct { | ||
81 | MenuId []int64 `json:"menu_ids"` | 75 | MenuId []int64 `json:"menu_ids"` |
82 | } | 76 | } |
83 | 77 | ||
84 | -type ResponseRolePermission struct { | ||
85 | -} | 78 | +// type ResponseRolePermission struct { |
79 | +// } |
@@ -158,3 +158,32 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error { | @@ -158,3 +158,32 @@ func RoleMenuEdit(companyid int64, roleId int64, menuids []int64) error { | ||
158 | o.Commit() | 158 | o.Commit() |
159 | return nil | 159 | return nil |
160 | } | 160 | } |
161 | + | ||
162 | +//机会管理高级设置 | ||
163 | +func UpdateSetOpportunity() error { | ||
164 | + return nil | ||
165 | +} | ||
166 | + | ||
167 | +//机会管理高级设置 | ||
168 | +func GetSetOpportunity(roleid int64, companyid int64) (*OptionOpportunity, error) { | ||
169 | + setting := &OptionOpportunity{ | ||
170 | + CheckOption: CheckOpp{ | ||
171 | + Departments: []CheckDeparment{}, | ||
172 | + }, | ||
173 | + } | ||
174 | + var ( | ||
175 | + //code = M_SYSTEM_OPPORTUNITY | ||
176 | + roleInfo *models.Role | ||
177 | + err error | ||
178 | + ) | ||
179 | + roleInfo, err = models.GetRoleById(roleid) | ||
180 | + if err != nil { | ||
181 | + log.Error("获取角色数据失败:%s", err) | ||
182 | + return setting, protocol.NewErrWithMessage("1") | ||
183 | + } | ||
184 | + if roleInfo.CompanyId != companyid { | ||
185 | + log.Error("角色公司不匹配") | ||
186 | + return setting, protocol.NewErrWithMessage("1") | ||
187 | + } | ||
188 | + return setting, nil | ||
189 | +} |
1 | package rbac | 1 | package rbac |
2 | 2 | ||
3 | -import "encoding/json" | ||
4 | - | ||
5 | type UserObject struct { | 3 | type UserObject struct { |
6 | UserId int64 `json:"user_id"` | 4 | UserId int64 `json:"user_id"` |
7 | CompanyId int64 `json:"company_id"` | 5 | CompanyId int64 `json:"company_id"` |
@@ -39,20 +37,20 @@ func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool { | @@ -39,20 +37,20 @@ func (p *PermissionOptionBase) GetValidFunc(k string) func(UserObject) bool { | ||
39 | return nil | 37 | return nil |
40 | } | 38 | } |
41 | 39 | ||
42 | -//StringUnmarshal PermissionOptionBase 接口实现 | ||
43 | -func (p *PermissionOptionBase) StringUnmarshal(s string) error { | ||
44 | - err := json.Unmarshal([]byte(s), p) | ||
45 | - return err | ||
46 | -} | ||
47 | - | ||
48 | -//ObjectMarshal PermissionOptionBase 接口实现 | ||
49 | -func (p *PermissionOptionBase) ObjectMarshal() string { | ||
50 | - bt, err := json.Marshal(p) | ||
51 | - if err != nil { | ||
52 | - return "" | ||
53 | - } | ||
54 | - return string(bt) | ||
55 | -} | 40 | +// //StringUnmarshal PermissionOptionBase 接口实现 |
41 | +// func (p *PermissionOptionBase) StringUnmarshal(s string) error { | ||
42 | +// err := json.Unmarshal([]byte(s), p) | ||
43 | +// return err | ||
44 | +// } | ||
45 | + | ||
46 | +// //ObjectMarshal PermissionOptionBase 接口实现 | ||
47 | +// func (p *PermissionOptionBase) ObjectMarshal() string { | ||
48 | +// bt, err := json.Marshal(p) | ||
49 | +// if err != nil { | ||
50 | +// return "" | ||
51 | +// } | ||
52 | +// return string(bt) | ||
53 | +// } | ||
56 | 54 | ||
57 | /* | 55 | /* |
58 | 机会管理模块 | 56 | 机会管理模块 |
@@ -60,17 +58,19 @@ CheckOpp | @@ -60,17 +58,19 @@ CheckOpp | ||
60 | CheckDeparment | 58 | CheckDeparment |
61 | OptionOpportunity | 59 | OptionOpportunity |
62 | */ | 60 | */ |
63 | -//CheckOpp 特殊的查看条件设定 | ||
64 | -type CheckOpp struct { | ||
65 | - Departments []CheckDeparment `json:"departments"` | ||
66 | -} | ||
67 | 61 | ||
68 | //CheckDeparment 特殊的查看条件设定中关于部门的设定 | 62 | //CheckDeparment 特殊的查看条件设定中关于部门的设定 |
69 | type CheckDeparment struct { | 63 | type CheckDeparment struct { |
70 | - Id int64 `json:"id"` | ||
71 | - Wait int `json:"wail"` | ||
72 | - OpenAll int `json:"open_all"` | ||
73 | - OpenDepart int `json:"open_depart"` | 64 | + Id int64 `json:"id"` |
65 | + Name string `json:"name,omitempty"` | ||
66 | + Wait int `json:"wail"` | ||
67 | + OpenAll int `json:"open_all"` | ||
68 | + OpenDepart int `json:"open_depart"` | ||
69 | +} | ||
70 | + | ||
71 | +//CheckOpp 特殊的查看条件设定 | ||
72 | +type CheckOpp struct { | ||
73 | + Departments []CheckDeparment `json:"departments"` | ||
74 | } | 74 | } |
75 | 75 | ||
76 | //OptionOpportunity 机会管理 高级权限设置 | 76 | //OptionOpportunity 机会管理 高级权限设置 |
@@ -82,25 +82,36 @@ type OptionOpportunity struct { | @@ -82,25 +82,36 @@ type OptionOpportunity struct { | ||
82 | CloseChance int `json:"close_chance"` | 82 | CloseChance int `json:"close_chance"` |
83 | } | 83 | } |
84 | 84 | ||
85 | +/* | ||
86 | +机会管理高级设置中的 check | ||
87 | +1:禁止查看所有机会:禁止查看所有机会(除自己提交过的机会及可执行审核操作的机会) | ||
88 | +2:仅查看自己部门和公开机会:查看对自己部门公开的机会+公司公开的机会 | ||
89 | +3:特定部门的机会:自由配置选定部门的待审核、公司公开、部门公开的机会+查看对自己部门公开的机会 | ||
90 | +4:查看所有机会:查看所有部门的待审核机会、公开机会及部门公开机会 | ||
91 | +*/ | ||
92 | +const ( | ||
93 | + OpportunityCheckLv1 int = 1 | ||
94 | + OpportunityCheckLv2 int = 2 | ||
95 | + OpportunityCheckLv3 int = 3 | ||
96 | + OpportunityCheckLv4 int = 4 | ||
97 | +) | ||
98 | + | ||
85 | var ( | 99 | var ( |
86 | _ PermissionOptionObject = &OptionOpportunity{} | 100 | _ PermissionOptionObject = &OptionOpportunity{} |
87 | ) | 101 | ) |
88 | 102 | ||
89 | func NewOptionOpportunity() PermissionOptionObject { | 103 | func NewOptionOpportunity() PermissionOptionObject { |
90 | - return &OptionOpportunity{} | ||
91 | -} | ||
92 | - | ||
93 | -func (p *OptionOpportunity) ValidDefault(obj UserObject) bool { | ||
94 | - if p.Check == 1 { | ||
95 | - return true | 104 | + return &OptionOpportunity{ |
105 | + CheckOption: CheckOpp{ | ||
106 | + Departments: []CheckDeparment{}, | ||
107 | + }, | ||
96 | } | 108 | } |
97 | - return false | ||
98 | } | 109 | } |
99 | 110 | ||
100 | //GetValidFunc PermissionOptionBase 接口实现 | 111 | //GetValidFunc PermissionOptionBase 接口实现 |
101 | func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool { | 112 | func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool { |
102 | m := map[string]func(UserObject) bool{ | 113 | m := map[string]func(UserObject) bool{ |
103 | - "default": p.ValidDefault, | 114 | + "check": p.ValidCheck, |
104 | } | 115 | } |
105 | if _, ok := m[k]; ok { | 116 | if _, ok := m[k]; ok { |
106 | return m[k] | 117 | return m[k] |
@@ -108,17 +119,37 @@ func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool { | @@ -108,17 +119,37 @@ func (p *OptionOpportunity) GetValidFunc(k string) func(UserObject) bool { | ||
108 | return nil | 119 | return nil |
109 | } | 120 | } |
110 | 121 | ||
111 | -//StringUnmarshal PermissionOptionBase 接口实现 | ||
112 | -func (p *OptionOpportunity) StringUnmarshal(s string) error { | ||
113 | - err := json.Unmarshal([]byte(s), p) | ||
114 | - return err | 122 | +func (p *OptionOpportunity) ValidCheck(obj UserObject) bool { |
123 | + if p.Check > 0 { | ||
124 | + return true | ||
125 | + } | ||
126 | + return false | ||
115 | } | 127 | } |
116 | 128 | ||
117 | -//ObjectMarshal PermissionOptionBase 接口实现 | ||
118 | -func (p *OptionOpportunity) ObjectMarshal() string { | ||
119 | - bt, err := json.Marshal(p) | ||
120 | - if err != nil { | ||
121 | - return "" | 129 | +func (p *OptionOpportunity) ValidEditSorce(obj UserObject) bool { |
130 | + if p.EditSorce > 0 { | ||
131 | + return true | ||
132 | + } | ||
133 | + return false | ||
134 | +} | ||
135 | +func (p *OptionOpportunity) ValidEditPublicStatus(obj UserObject) bool { | ||
136 | + if p.EditPublicStatus > 0 { | ||
137 | + return true | ||
122 | } | 138 | } |
123 | - return string(bt) | 139 | + return false |
124 | } | 140 | } |
141 | + | ||
142 | +// //StringUnmarshal PermissionOptionBase 接口实现 | ||
143 | +// func (p *OptionOpportunity) StringUnmarshal(s string) error { | ||
144 | +// err := json.Unmarshal([]byte(s), p) | ||
145 | +// return err | ||
146 | +// } | ||
147 | + | ||
148 | +// //ObjectMarshal PermissionOptionBase 接口实现 | ||
149 | +// func (p *OptionOpportunity) ObjectMarshal() string { | ||
150 | +// bt, err := json.Marshal(p) | ||
151 | +// if err != nil { | ||
152 | +// return "" | ||
153 | +// } | ||
154 | +// return string(bt) | ||
155 | +// } |
@@ -26,8 +26,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { | @@ -26,8 +26,7 @@ func RequestUCenterLogin(account, password string) (*ResponseLogin, error) { | ||
26 | log.Error("解析统一用户中心响应失败 err:%s", err) | 26 | log.Error("解析统一用户中心响应失败 err:%s", err) |
27 | return nil, protocol.NewErrWithMessage("1") | 27 | return nil, protocol.NewErrWithMessage("1") |
28 | } | 28 | } |
29 | - if !(uclientReturn.Code == ResponseCode0 && | ||
30 | - uclientReturn.Msg == ResponseMsgOk) { | 29 | + if !(uclientReturn.Code == ResponseCode0) { |
31 | return nil, protocol.NewErrWithMessage("10052") | 30 | return nil, protocol.NewErrWithMessage("10052") |
32 | } | 31 | } |
33 | return uclientReturn, nil | 32 | return uclientReturn, nil |
@@ -58,8 +57,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo | @@ -58,8 +57,7 @@ func RequestUCenterAddUser(phone string, nickname string, avatar string) (*Respo | ||
58 | log.Error("解析统一用户中心响应失败 err:%s", err) | 57 | log.Error("解析统一用户中心响应失败 err:%s", err) |
59 | return nil, protocol.NewErrWithMessage("1") | 58 | return nil, protocol.NewErrWithMessage("1") |
60 | } | 59 | } |
61 | - if !(ucenterReturn.Code == ResponseCode0 && | ||
62 | - ucenterReturn.Msg == ResponseMsgOk) { | 60 | + if !(ucenterReturn.Code == ResponseCode0) { |
63 | return nil, protocol.NewErrWithMessage("10052") | 61 | return nil, protocol.NewErrWithMessage("10052") |
64 | } | 62 | } |
65 | return ucenterReturn, nil | 63 | return ucenterReturn, nil |
@@ -85,8 +83,7 @@ func RequestUCenterSmsCode(phone string) error { | @@ -85,8 +83,7 @@ func RequestUCenterSmsCode(phone string) error { | ||
85 | log.Error("解析统一用户中心响应失败 err:%s", err) | 83 | log.Error("解析统一用户中心响应失败 err:%s", err) |
86 | return protocol.NewErrWithMessage("1") | 84 | return protocol.NewErrWithMessage("1") |
87 | } | 85 | } |
88 | - if !(ucenterReturn.Code == ResponseCode0 && | ||
89 | - ucenterReturn.Msg == ResponseMsgOk) { | 86 | + if !(ucenterReturn.Code == ResponseCode0) { |
90 | return protocol.NewErrWithMessage("10052") | 87 | return protocol.NewErrWithMessage("10052") |
91 | } | 88 | } |
92 | return nil | 89 | return nil |
@@ -105,17 +102,16 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er | @@ -105,17 +102,16 @@ func RequestUCenterLoginSms(phone string, captcha string) (*ResponseLoginSms, er | ||
105 | log.Error("统一用户中心请求失败 err:%s", err) | 102 | log.Error("统一用户中心请求失败 err:%s", err) |
106 | return nil, protocol.NewErrWithMessage("1") | 103 | return nil, protocol.NewErrWithMessage("1") |
107 | } | 104 | } |
108 | - var ucenterReturn *ResponseLoginSms | ||
109 | - err = json.Unmarshal(btBody, ucenterReturn) | 105 | + var ucenterReturn ResponseLoginSms |
106 | + err = json.Unmarshal(btBody, &ucenterReturn) | ||
110 | if err != nil { | 107 | if err != nil { |
111 | log.Error("解析统一用户中心响应失败 err:%s", err) | 108 | log.Error("解析统一用户中心响应失败 err:%s", err) |
112 | return nil, protocol.NewErrWithMessage("1") | 109 | return nil, protocol.NewErrWithMessage("1") |
113 | } | 110 | } |
114 | - if !(ucenterReturn.Code == ResponseCode0 && | ||
115 | - ucenterReturn.Msg == ResponseMsgOk) { | 111 | + if !(ucenterReturn.Code == ResponseCode0) { |
116 | return nil, protocol.NewErrWithMessage("10052") | 112 | return nil, protocol.NewErrWithMessage("10052") |
117 | } | 113 | } |
118 | - return ucenterReturn, nil | 114 | + return &ucenterReturn, nil |
119 | } | 115 | } |
120 | 116 | ||
121 | func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeCheck, error) { | 117 | func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeCheck, error) { |
@@ -135,8 +131,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC | @@ -135,8 +131,7 @@ func RequestUCenterSmsCodeCheck(phone string, captcha string) (*ResponseSmsCodeC | ||
135 | log.Error("解析统一用户中心响应失败 err:%s", err) | 131 | log.Error("解析统一用户中心响应失败 err:%s", err) |
136 | return nil, protocol.NewErrWithMessage("1") | 132 | return nil, protocol.NewErrWithMessage("1") |
137 | } | 133 | } |
138 | - if !(ucenterReturn.Code == ResponseCode0 && | ||
139 | - ucenterReturn.Msg == ResponseMsgOk) { | 134 | + if !(ucenterReturn.Code == ResponseCode0) { |
140 | return nil, protocol.NewErrWithMessage("10026") | 135 | return nil, protocol.NewErrWithMessage("10026") |
141 | } | 136 | } |
142 | return ucenterReturn, nil | 137 | return ucenterReturn, nil |
@@ -161,8 +156,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e | @@ -161,8 +156,7 @@ func RequestUCenterRestPassword(phone, newPwd, confirmPwd, certificate string) e | ||
161 | log.Error("解析统一用户中心响应失败 err:%s", err) | 156 | log.Error("解析统一用户中心响应失败 err:%s", err) |
162 | return protocol.NewErrWithMessage("1") | 157 | return protocol.NewErrWithMessage("1") |
163 | } | 158 | } |
164 | - if !(ucenterReturn.Code == ResponseCode0 && | ||
165 | - ucenterReturn.Msg == ResponseMsgOk) { | 159 | + if !(ucenterReturn.Code == ResponseCode0) { |
166 | return protocol.NewErrWithMessage("10052") | 160 | return protocol.NewErrWithMessage("10052") |
167 | } | 161 | } |
168 | 162 |
-
请 注册 或 登录 后发表评论