97 lines
2.7 KiB
Go
97 lines
2.7 KiB
Go
package role
|
|
|
|
import (
|
|
"context"
|
|
|
|
roleModel "busniess-user-center/internal/models/role"
|
|
userModel "busniess-user-center/internal/models/user"
|
|
roleService "busniess-user-center/internal/service/role"
|
|
ginUtil "busniess-user-center/pkg/utils/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/samber/do"
|
|
"go.uber.org/zap"
|
|
)
|
|
|
|
func init() {
|
|
do.Provide(nil, NewRoleServer)
|
|
}
|
|
|
|
type RoleServer struct {
|
|
roleService roleService.RoleService
|
|
logger *zap.SugaredLogger
|
|
}
|
|
|
|
func NewRoleServer(i *do.Injector) (*RoleServer, error) {
|
|
return &RoleServer{
|
|
roleService: do.MustInvoke[roleService.RoleService](i),
|
|
logger: do.MustInvoke[*zap.SugaredLogger](i),
|
|
}, nil
|
|
}
|
|
|
|
func RegisterRoute(api *gin.RouterGroup) {
|
|
server := do.MustInvoke[*RoleServer](nil)
|
|
api.POST("/create", ginUtil.WrapNoRsp(server.Create))
|
|
api.POST("/save", ginUtil.WrapNoRsp(server.Save))
|
|
api.POST("/delete", ginUtil.WrapNoRsp(server.DelRole))
|
|
api.GET("/get", ginUtil.Wrap(server.Role))
|
|
api.GET("/search", ginUtil.Wrap(server.Search))
|
|
}
|
|
|
|
func (u *RoleServer) Create(ctx context.Context, req *roleModel.CreateReq) (err error) {
|
|
// 转换dto
|
|
return u.roleService.Create(ctx, req)
|
|
}
|
|
|
|
func (u *RoleServer) Save(ctx context.Context, info *roleModel.SaveReq) error {
|
|
return u.roleService.Save(ctx, info)
|
|
}
|
|
|
|
func (u *RoleServer) DelRole(ctx context.Context, info *roleModel.DelReq) error {
|
|
return u.roleService.Delete(ctx, info)
|
|
}
|
|
|
|
func (u *RoleServer) Role(ctx context.Context, info *roleModel.GetReq) (roleModel.Role, error) {
|
|
return u.roleService.Role(ctx, info)
|
|
}
|
|
|
|
func (u *RoleServer) Search(ctx context.Context, info *roleModel.Query) ([]roleModel.Role, error) {
|
|
return u.roleService.Search(ctx, info)
|
|
}
|
|
|
|
func (u *RoleServer) AddUsers(ctx context.Context, info *roleModel.AddUsersReq) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *RoleServer) RemoveUsers(ctx context.Context, info *roleModel.RemoveUsersReq) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *RoleServer) AddOrgs(ctx context.Context, info *roleModel.AddOrgsReq) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *RoleServer) RemoveOrgs(ctx context.Context, info *roleModel.RemoveOrgsReq) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *RoleServer) RoleUsers(ctx context.Context, info *roleModel.RoleUsersReq) ([]userModel.User, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (u *RoleServer) RoleOrgs(ctx context.Context, info *roleModel.RoleOrgsReq) ([]roleModel.OrgRoleAuthor, error) {
|
|
return nil, nil
|
|
}
|
|
|
|
func (u *RoleServer) AuthorRoleMenu(ctx context.Context, info *roleModel.AuthorRoleMenuReq) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *RoleServer) RemoveRoleMenu(ctx context.Context, info *roleModel.RemoveReleMenuReq) error {
|
|
return nil
|
|
}
|
|
|
|
func (u *RoleServer) RoleMenuAuthorList(ctx context.Context, info *roleModel.AddOrgsReq) ([]roleModel.RoleMenu, error) {
|
|
return nil, nil
|
|
}
|