角色列表

This commit is contained in:
guosl 2024-07-30 14:38:46 +08:00
parent b4956ea2be
commit c3eb1b9f77
2 changed files with 4 additions and 2 deletions

View File

@ -81,12 +81,13 @@ func (o *roleService) Role(ctx context.Context, info *roleModel.GetReq) (role ro
func (o *roleService) Search(ctx context.Context, info *roleModel.Query) ([]roleModel.Role, error) {
dbQuery := repo.Query{}
copier.Copy(&dbQuery, info)
dbRoles, err := o.roleRepo.Search(ctx, dbQuery)
if err != nil {
return nil, err
}
roles := make([]roleModel.Role, len(dbRoles))
roles := make([]roleModel.Role, 0, len(dbRoles))
for _, role := range dbRoles {
roles = append(roles, convertDTM(role))
}

View File

@ -33,7 +33,7 @@ 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.DELETE("/delete", ginUtil.WrapNoRsp(server.DelRole))
api.GET("/get", ginUtil.Wrap(server.Role))
api.GET("/search", ginUtil.Wrap(server.Search))
}
@ -56,6 +56,7 @@ func (u *RoleServer) Role(ctx context.Context, info *roleModel.GetReq) (roleMode
}
func (u *RoleServer) Search(ctx context.Context, info *roleModel.Query) ([]roleModel.Role, error) {
info.Default()
return u.roleService.Search(ctx, info)
}