|
|
@@ -6,12 +6,13 @@ import (
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
|
|
|
+ "dashoo.cn/backend/api/business/organize"
|
|
|
"dashoo.cn/backend/api/business/role"
|
|
|
|
|
|
. "dashoo.cn/backend/api/controllers"
|
|
|
"dashoo.cn/business2/district"
|
|
|
"dashoo.cn/business2/module"
|
|
|
- "dashoo.cn/business2/organize"
|
|
|
+ commonorgnize "dashoo.cn/business2/organize"
|
|
|
"dashoo.cn/business2/permission"
|
|
|
"dashoo.cn/business2/userRole"
|
|
|
"dashoo.cn/utils"
|
|
|
@@ -32,8 +33,8 @@ type RolePerAjaxModel struct {
|
|
|
Selecteoperation []permission.Base_Permissionstrtree
|
|
|
}
|
|
|
type OrganizeAjaxModel struct {
|
|
|
- Organize []organize.Base_Organizetree
|
|
|
- SelectedOrganize []organize.Base_Organizetree
|
|
|
+ Organize []commonorgnize.Base_Organizetree
|
|
|
+ SelectedOrganize []commonorgnize.Base_Organizetree
|
|
|
}
|
|
|
type DistrictAjaxModel struct {
|
|
|
District []district.Base_Districttree
|
|
|
@@ -56,10 +57,10 @@ func (this *RoleController) RoleList() {
|
|
|
svrUser := userRole.GetUserService(utils.DBE)
|
|
|
rids := svrUser.GetUserRoleIds(this.User.Id)
|
|
|
permisvc := permission.GetPermissionService(utils.DBE)
|
|
|
- if permisvc.IsAdmin(this.User.Id) == false{
|
|
|
+ if permisvc.IsAdmin(this.User.Id) == false {
|
|
|
var roleofrole string
|
|
|
- for i:=0; i<len(rids); i++ {
|
|
|
- roleofrole += permisvc.GetManRoleForRole(rids[i])+ ","
|
|
|
+ for i := 0; i < len(rids); i++ {
|
|
|
+ roleofrole += permisvc.GetManRoleForRole(rids[i]) + ","
|
|
|
}
|
|
|
roleofrole = strings.Trim(roleofrole, ",")
|
|
|
where = where + " and Id in (" + roleofrole + ")"
|
|
|
@@ -76,7 +77,7 @@ func (this *RoleController) RoleList() {
|
|
|
// @Description 获取角色列表
|
|
|
// @Success 200 {object} controllers.Request
|
|
|
// @router /getAdminPermi [get]
|
|
|
-func (this *RoleController) GetAdminPermision(){
|
|
|
+func (this *RoleController) GetAdminPermision() {
|
|
|
var datainfo ErrorDataInfo
|
|
|
//判断超级管理员和有查看所有数据权限的用户
|
|
|
svcPerm := permission.GetPermissionService(utils.DBE)
|
|
|
@@ -86,13 +87,43 @@ func (this *RoleController) GetAdminPermision(){
|
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
|
return
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
datainfo.Code = 0
|
|
|
this.Data["json"] = &datainfo
|
|
|
this.ServeJSON()
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+// @Title 部门表
|
|
|
+// @Description
|
|
|
+// @Success 200 {object} business.device.DeviceChannels
|
|
|
+// @router /orgalllist [get]
|
|
|
+func (this *RoleController) OrgAllList() {
|
|
|
+ svc := organize.GetOrganizeService(utils.DBE)
|
|
|
+
|
|
|
+ var user userRole.Base_User
|
|
|
+ svc.GetEntityById(this.User.Id, &user)
|
|
|
+ ids := ""
|
|
|
+ //判断超级管理员和有查看所有数据权限的用户
|
|
|
+ svcPerm := permission.GetPermissionService(utils.DBE)
|
|
|
+ isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
|
|
|
+ if svcPerm.IsAdmin(this.User.Id) || isauth {
|
|
|
+ ids = svc.GetAllChildById("100000000")
|
|
|
+ } else {
|
|
|
+ unitId := svc.GetMyUnitDepartmentId(this.User.DepartmentId)
|
|
|
+ ids = svc.GetAllChildById(unitId)
|
|
|
+ }
|
|
|
+ where := " and Id in ( " + ids + " )"
|
|
|
+
|
|
|
+ list := make([]organize.Base_Organize, 0)
|
|
|
+ svc.GetEntities(&list, where)
|
|
|
+ var datainfo DataInfo
|
|
|
+ datainfo.Items = list
|
|
|
+ this.Data["json"] = &datainfo
|
|
|
+ this.ServeJSON()
|
|
|
+}
|
|
|
+
|
|
|
// @Title 根据部门获取人员
|
|
|
// @Description 根据部门获取人员
|
|
|
// @router /getauditerbydept/:deptId [get]
|
|
|
@@ -107,10 +138,10 @@ func (this *RoleController) GetAuditerByDept() {
|
|
|
svcPerm := permission.GetPermissionService(utils.DBE)
|
|
|
isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
|
|
|
if !svcPerm.IsAdmin(this.User.Id) && !isauth {
|
|
|
- depids := organsvc.GetChildByTopId(Id)
|
|
|
+ depids := organsvc.GetAllChildById(Id)
|
|
|
where += " and DepartmentId in (" + depids + ")"
|
|
|
- }else {
|
|
|
- depids := organsvc.GetChildByTopId("0")
|
|
|
+ } else {
|
|
|
+ depids := organsvc.GetAllChildById("100000000")
|
|
|
where += " and DepartmentId in (" + depids + ")"
|
|
|
}
|
|
|
where += " and IsCompanyUser = 0"
|
|
|
@@ -155,7 +186,7 @@ func (this *RoleController) RoleAllList() {
|
|
|
func (this *RoleController) GetManRole() {
|
|
|
userid := this.Ctx.Input.Param(":id")
|
|
|
svc := permission.GetPermissionService(utils.DBE)
|
|
|
- roleofrole := svc.GetManRoleForRole("rid_"+userid)
|
|
|
+ roleofrole := svc.GetManRoleForRole("rid_" + userid)
|
|
|
roleid := strings.Split(roleofrole, ",")
|
|
|
this.Data["json"] = &roleid
|
|
|
this.ServeJSON()
|
|
|
@@ -516,7 +547,7 @@ func (this *RoleController) GetUsersForRole() {
|
|
|
svcPerm := permission.GetPermissionService(utils.DBE)
|
|
|
isauth := svcPerm.IsAuthorized(this.User.Id, "oil_supplier.marketAccess.AllRecord")
|
|
|
if !svcPerm.IsAdmin(this.User.Id) && !isauth {
|
|
|
- where += " and Unit = '" + this.User.Uint+"'"
|
|
|
+ where += " and Unit = '" + this.User.Uint + "'"
|
|
|
}
|
|
|
total, users := svc.GetUserListForRole(page.CurrentPage, page.Size, roleid, "Id", where)
|
|
|
|
|
|
@@ -565,9 +596,13 @@ func (this *RoleController) UserRoleAddUser() {
|
|
|
func (this *RoleController) UserDelete() {
|
|
|
inputstr := this.Ctx.Input.Param(":id")
|
|
|
serial := strings.Split(inputstr, "_")
|
|
|
- id := serial[0]
|
|
|
+ userids := strings.Split(serial[0], ",")
|
|
|
roleid := serial[1]
|
|
|
- utils.RBAC.DeleteRoleForUserInDomain("uid_"+id, "rid_"+roleid, utils.DOMAIN)
|
|
|
+ for i := 0; i < len(userids); i++ {
|
|
|
+ if userids[i] != "0" && userids[i] != "" {
|
|
|
+ utils.RBAC.DeleteRoleForUserInDomain("uid_"+userids[i], "rid_"+roleid, utils.DOMAIN)
|
|
|
+ }
|
|
|
+ }
|
|
|
var errinfo ErrorInfo
|
|
|
var err error = nil
|
|
|
if err == nil {
|