正在显示
6 个修改的文件
包含
33 行增加
和
19 行删除
@@ -430,6 +430,10 @@ func (c *CompanyController) InitCompany() { | @@ -430,6 +430,10 @@ func (c *CompanyController) InitCompany() { | ||
430 | var ( | 430 | var ( |
431 | err error | 431 | err error |
432 | ) | 432 | ) |
433 | + param.CompanyName = strings.TrimSpace(param.CompanyName) | ||
434 | + param.AdminAccount = strings.TrimSpace(param.AdminAccount) | ||
435 | + param.AdminName = strings.TrimSpace(param.AdminName) | ||
436 | + if ok := param.IsEnable(); ok { | ||
433 | if len(param.CompanyName) == 0 { | 437 | if len(param.CompanyName) == 0 { |
434 | log.Error("公司名称空") | 438 | log.Error("公司名称空") |
435 | msg = protocol.BadRequestParam("1") | 439 | msg = protocol.BadRequestParam("1") |
@@ -446,6 +450,12 @@ func (c *CompanyController) InitCompany() { | @@ -446,6 +450,12 @@ func (c *CompanyController) InitCompany() { | ||
446 | return | 450 | return |
447 | } | 451 | } |
448 | err = servecompany.InitCompanyInfo(param) | 452 | err = servecompany.InitCompanyInfo(param) |
453 | + } else if ok := param.IsForbid(); ok { | ||
454 | + err = servecompany.ForbidCompany(param.CompanyId) | ||
455 | + } else { | ||
456 | + err = protocol.NewErrWithMessage("1") | ||
457 | + } | ||
458 | + | ||
449 | msg = protocol.NewReturnResponse(nil, err) | 459 | msg = protocol.NewReturnResponse(nil, err) |
450 | return | 460 | return |
451 | } | 461 | } |
@@ -220,7 +220,8 @@ func (c *RbacController) RoleList() { | @@ -220,7 +220,8 @@ func (c *RbacController) RoleList() { | ||
220 | msg = protocol.BadRequestParam("1") | 220 | msg = protocol.BadRequestParam("1") |
221 | return | 221 | return |
222 | } | 222 | } |
223 | - rolelist, err := serverbac.GetRoleList(companyid) | 223 | + userid := c.GetUserId() |
224 | + rolelist, err := serverbac.GetRoleList(companyid, userid) | ||
224 | msg = protocol.NewReturnResponse(rolelist, err) | 225 | msg = protocol.NewReturnResponse(rolelist, err) |
225 | return | 226 | return |
226 | } | 227 | } |
@@ -139,21 +139,19 @@ type CenterCompanyInfo struct { | @@ -139,21 +139,19 @@ type CenterCompanyInfo struct { | ||
139 | Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】 | 139 | Status int8 `json:"status"` //公司的状态 【1:启用】【2:禁用】 |
140 | } | 140 | } |
141 | 141 | ||
142 | -// func (c CenterCompanyInfo) IsEnable() bool { | ||
143 | -// if c.Status == 1 { | ||
144 | -// return true | ||
145 | -// } | ||
146 | -// return false | ||
147 | -// } | ||
148 | - | ||
149 | -// func (c CenterCompanyInfo) IsForbid() bool { | ||
150 | -// if c.Status == 2 { | ||
151 | -// return true | ||
152 | -// } | ||
153 | -// return false | ||
154 | -// } | ||
155 | - | ||
156 | -// type Request | 142 | +func (c CenterCompanyInfo) IsEnable() bool { |
143 | + if c.Status == 1 { | ||
144 | + return true | ||
145 | + } | ||
146 | + return false | ||
147 | +} | ||
148 | + | ||
149 | +func (c CenterCompanyInfo) IsForbid() bool { | ||
150 | + if c.Status == 2 { | ||
151 | + return true | ||
152 | + } | ||
153 | + return false | ||
154 | +} | ||
157 | 155 | ||
158 | type ResponseCenterCompany struct { | 156 | type ResponseCenterCompany struct { |
159 | UCenterCompanyId int64 `json:"comopany_id"` //总 | 157 | UCenterCompanyId int64 `json:"comopany_id"` //总 |
@@ -645,6 +645,7 @@ func UserForbid(userCompanyids []int64, companyid int64) error { | @@ -645,6 +645,7 @@ func UserForbid(userCompanyids []int64, companyid int64) error { | ||
645 | companyInfo, err = models.GetCompanyById(companyid) | 645 | companyInfo, err = models.GetCompanyById(companyid) |
646 | if err != nil { | 646 | if err != nil { |
647 | log.Error("GetCompanyById(%d) err:%s", companyid, err) | 647 | log.Error("GetCompanyById(%d) err:%s", companyid, err) |
648 | + return protocol.NewErrWithMessage("1") | ||
648 | } | 649 | } |
649 | o := orm.NewOrm() | 650 | o := orm.NewOrm() |
650 | _, err = o.QueryTable(&models.UserCompany{}). | 651 | _, err = o.QueryTable(&models.UserCompany{}). |
@@ -659,7 +660,7 @@ func UserForbid(userCompanyids []int64, companyid int64) error { | @@ -659,7 +660,7 @@ func UserForbid(userCompanyids []int64, companyid int64) error { | ||
659 | ids []int64 | 660 | ids []int64 |
660 | ) | 661 | ) |
661 | for _, v := range updateIds { | 662 | for _, v := range updateIds { |
662 | - if v.Id == companyInfo.AdminId { | 663 | + if v.UserId == companyInfo.AdminId { |
663 | return protocol.NewErrWithMessage("10072") | 664 | return protocol.NewErrWithMessage("10072") |
664 | } | 665 | } |
665 | ids = append(ids, v.Id) | 666 | ids = append(ids, v.Id) |
@@ -10,7 +10,7 @@ import ( | @@ -10,7 +10,7 @@ import ( | ||
10 | "github.com/astaxie/beego/orm" | 10 | "github.com/astaxie/beego/orm" |
11 | ) | 11 | ) |
12 | 12 | ||
13 | -//获取全部的权限菜单 | 13 | +//GetMenuAll 获取全部的权限菜单 |
14 | func GetMenuAll() ([]protocol.PermissionItem, error) { | 14 | func GetMenuAll() ([]protocol.PermissionItem, error) { |
15 | const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code | 15 | const datasql string = `SELECT id,name,icon,parent_id,senior_status,sort,code |
16 | FROM menu WHERE enabled=1 ORDER BY sort ` | 16 | FROM menu WHERE enabled=1 ORDER BY sort ` |
@@ -179,17 +179,21 @@ func RoleGroupDelete(param protocol.RequestRoleDelete) error { | @@ -179,17 +179,21 @@ func RoleGroupDelete(param protocol.RequestRoleDelete) error { | ||
179 | return nil | 179 | return nil |
180 | } | 180 | } |
181 | 181 | ||
182 | -func GetRoleList(companyId int64) ([]protocol.RoleGroup, error) { | 182 | +//GetRoleList 获取角色列表 |
183 | +func GetRoleList(adminid int64, companyId int64) ([]protocol.RoleGroup, error) { | ||
183 | var ( | 184 | var ( |
184 | roleGroups []protocol.RoleGroup | 185 | roleGroups []protocol.RoleGroup |
185 | err error | 186 | err error |
186 | groups []protocol.RoleInfo | 187 | groups []protocol.RoleInfo |
188 | + // companyinfo *models.Company | ||
187 | ) | 189 | ) |
190 | + // models.GetCompanyById(companyId) | ||
188 | groups, err = getRoleGroupByCompany(companyId) | 191 | groups, err = getRoleGroupByCompany(companyId) |
189 | if err != nil { | 192 | if err != nil { |
190 | log.Error("getRoleGroupByCompany err:%s", err) | 193 | log.Error("getRoleGroupByCompany err:%s", err) |
191 | return roleGroups, protocol.NewErrWithMessage("1") | 194 | return roleGroups, protocol.NewErrWithMessage("1") |
192 | } | 195 | } |
196 | + | ||
193 | for k, v := range groups { | 197 | for k, v := range groups { |
194 | var roles []protocol.RoleInfo | 198 | var roles []protocol.RoleInfo |
195 | roles, err = getRoleInfoByPid(companyId, v.Id) | 199 | roles, err = getRoleInfoByPid(companyId, v.Id) |
-
请 注册 或 登录 后发表评论