mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
【feature】添加组织数据读取权限
This commit is contained in:
@@ -1,90 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/system/api"
|
||||
"pandax/apps/system/api/vo"
|
||||
"pandax/apps/system/entity"
|
||||
"pandax/apps/system/services"
|
||||
)
|
||||
|
||||
func InitDeptRouter(container *restful.Container) {
|
||||
s := &api.DeptApi{
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/dept").Produces(restful.MIME_JSON)
|
||||
tags := []string{"dept"}
|
||||
|
||||
ws.Route(ws.GET("/roleDeptTreeSelect/{roleId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色部门树").Handle(s.GetDeptTreeRoleSelect)
|
||||
}).
|
||||
Doc("获取角色部门树").
|
||||
Param(ws.PathParameter("roleId", "角色Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(vo.DeptTreeVo{}).
|
||||
Returns(200, "OK", vo.DeptTreeVo{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/deptTree").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取所有部门树").Handle(s.GetDeptTree)
|
||||
}).
|
||||
Doc("获取所有部门树").
|
||||
Param(ws.QueryParameter("deptName", "deptName").DataType("string")).
|
||||
Param(ws.QueryParameter("status", "status").DataType("string")).
|
||||
Param(ws.QueryParameter("deptId", "deptId").DataType("int")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysDept{}).
|
||||
Returns(200, "OK", []entity.SysDept{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取部门列表").Handle(s.GetDeptList)
|
||||
}).
|
||||
Doc("获取部门列表").
|
||||
Param(ws.QueryParameter("deptName", "deptName").DataType("string")).
|
||||
Param(ws.QueryParameter("status", "status").DataType("string")).
|
||||
Param(ws.QueryParameter("deptId", "deptId").DataType("int")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysDept{}).
|
||||
Returns(200, "OK", []entity.SysDept{}))
|
||||
|
||||
ws.Route(ws.GET("/{deptId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取部门信息").Handle(s.GetDept)
|
||||
}).
|
||||
Doc("获取部门信息").
|
||||
Param(ws.PathParameter("deptId", "部门Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysDept{}). // on the response
|
||||
Returns(200, "OK", entity.SysDept{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加部门信息").Handle(s.InsertDept)
|
||||
}).
|
||||
Doc("添加部门信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDept{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改部门信息").Handle(s.UpdateDept)
|
||||
}).
|
||||
Doc("修改部门信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysDept{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{deptId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除部门信息").Handle(s.DeleteDept)
|
||||
}).
|
||||
Doc("删除部门信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("deptId", "多id 1,2,3").DataType("int")))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
}
|
||||
@@ -12,10 +12,10 @@ import (
|
||||
|
||||
func InitMenuRouter(container *restful.Container) {
|
||||
s := &api.MenuApi{
|
||||
MenuApp: services.SysMenuModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
MenuApp: services.SysMenuModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
OrganizationApp: services.SysOrganizationModelDao,
|
||||
}
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/menu").Produces(restful.MIME_JSON)
|
||||
|
||||
@@ -12,8 +12,8 @@ import (
|
||||
|
||||
func InitNoticeRouter(container *restful.Container) {
|
||||
s := &api.NoticeApi{
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
NoticeApp: services.SysNoticeModelDao,
|
||||
OrganizationApp: services.SysOrganizationModelDao,
|
||||
NoticeApp: services.SysNoticeModelDao,
|
||||
}
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/notice").Produces(restful.MIME_JSON)
|
||||
|
||||
90
apps/system/router/organization.go
Normal file
90
apps/system/router/organization.go
Normal file
@@ -0,0 +1,90 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/PandaXGO/PandaKit/restfulx"
|
||||
restfulspec "github.com/emicklei/go-restful-openapi/v2"
|
||||
"github.com/emicklei/go-restful/v3"
|
||||
"pandax/apps/system/api"
|
||||
"pandax/apps/system/api/vo"
|
||||
"pandax/apps/system/entity"
|
||||
"pandax/apps/system/services"
|
||||
)
|
||||
|
||||
func InitOrganizationRouter(container *restful.Container) {
|
||||
s := &api.OrganizationApi{
|
||||
OrganizationApp: services.SysOrganizationModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
}
|
||||
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/organization").Produces(restful.MIME_JSON)
|
||||
tags := []string{"organization"}
|
||||
|
||||
ws.Route(ws.GET("/roleOrganizationTreeSelect/{roleId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取角色组织树").Handle(s.GetOrganizationTreeRoleSelect)
|
||||
}).
|
||||
Doc("获取角色组织树").
|
||||
Param(ws.PathParameter("roleId", "角色Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(vo.OrganizationTreeVo{}).
|
||||
Returns(200, "OK", vo.OrganizationTreeVo{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/organizationTree").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取所有组织树").Handle(s.GetOrganizationTree)
|
||||
}).
|
||||
Doc("获取所有组织树").
|
||||
Param(ws.QueryParameter("organizationName", "organizationName").DataType("string")).
|
||||
Param(ws.QueryParameter("status", "status").DataType("string")).
|
||||
Param(ws.QueryParameter("organizationId", "organizationId").DataType("int")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysOrganization{}).
|
||||
Returns(200, "OK", []entity.SysOrganization{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.GET("/list").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取组织列表").Handle(s.GetOrganizationList)
|
||||
}).
|
||||
Doc("获取组织列表").
|
||||
Param(ws.QueryParameter("organizationName", "organizationName").DataType("string")).
|
||||
Param(ws.QueryParameter("status", "status").DataType("string")).
|
||||
Param(ws.QueryParameter("organizationId", "organizationId").DataType("int")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes([]entity.SysOrganization{}).
|
||||
Returns(200, "OK", []entity.SysOrganization{}))
|
||||
|
||||
ws.Route(ws.GET("/{organizationId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("获取组织信息").Handle(s.GetOrganization)
|
||||
}).
|
||||
Doc("获取组织信息").
|
||||
Param(ws.PathParameter("organizationId", "组织Id").DataType("int").DefaultValue("1")).
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Writes(entity.SysOrganization{}). // on the response
|
||||
Returns(200, "OK", entity.SysOrganization{}).
|
||||
Returns(404, "Not Found", nil))
|
||||
|
||||
ws.Route(ws.POST("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("添加组织信息").Handle(s.InsertOrganization)
|
||||
}).
|
||||
Doc("添加组织信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysOrganization{}))
|
||||
|
||||
ws.Route(ws.PUT("").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改组织信息").Handle(s.UpdateOrganization)
|
||||
}).
|
||||
Doc("修改组织信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysOrganization{}))
|
||||
|
||||
ws.Route(ws.DELETE("/{organizationId}").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("删除组织信息").Handle(s.DeleteOrganization)
|
||||
}).
|
||||
Doc("删除组织信息").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Param(ws.PathParameter("organizationId", "多id 1,2,3").DataType("int")))
|
||||
|
||||
container.Add(ws)
|
||||
|
||||
}
|
||||
@@ -12,10 +12,11 @@ import (
|
||||
|
||||
func InitRoleRouter(container *restful.Container) {
|
||||
s := &api.RoleApi{
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
RoleDeptApp: services.SysRoleDeptModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
OrganizationApp: services.SysOrganizationModelDao,
|
||||
RoleOrganizationApp: services.SysRoleOrganizationModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
}
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/role").Produces(restful.MIME_JSON)
|
||||
@@ -66,9 +67,9 @@ func InitRoleRouter(container *restful.Container) {
|
||||
Reads(entity.SysRole{}))
|
||||
|
||||
ws.Route(ws.PUT("/dataScope").To(func(request *restful.Request, response *restful.Response) {
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改角色部门权限").Handle(s.UpdateRoleDataScope)
|
||||
restfulx.NewReqCtx(request, response).WithLog("修改角色组织权限").Handle(s.UpdateRoleDataScope)
|
||||
}).
|
||||
Doc("修改角色部门权限").
|
||||
Doc("修改角色组织权限").
|
||||
Metadata(restfulspec.KeyOpenAPITags, tags).
|
||||
Reads(entity.SysRole{}))
|
||||
|
||||
|
||||
@@ -16,13 +16,13 @@ import (
|
||||
|
||||
func InitUserRouter(container *restful.Container) {
|
||||
s := &api.UserApi{
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
MenuApp: services.SysMenuModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
LogLogin: logServices.LogLoginModelDao,
|
||||
DeptApp: services.SysDeptModelDao,
|
||||
PostApp: services.SysPostModelDao,
|
||||
RoleApp: services.SysRoleModelDao,
|
||||
MenuApp: services.SysMenuModelDao,
|
||||
RoleMenuApp: services.SysRoleMenuModelDao,
|
||||
UserApp: services.SysUserModelDao,
|
||||
LogLogin: logServices.LogLoginModelDao,
|
||||
OrganizationApp: services.SysOrganizationModelDao,
|
||||
PostApp: services.SysPostModelDao,
|
||||
}
|
||||
ws := new(restful.WebService)
|
||||
ws.Path("/system/user").Produces(restful.MIME_JSON)
|
||||
|
||||
Reference in New Issue
Block a user