mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 23:24:03 +00:00
Rename getRoles, getRole to find, findOne
This commit is contained in:
parent
4a71a9c93c
commit
567816591a
@ -21,10 +21,10 @@ module.exports = {
|
||||
ctx.send({ ok: true });
|
||||
},
|
||||
|
||||
async getRole(ctx) {
|
||||
async findOne(ctx) {
|
||||
const { id } = ctx.params;
|
||||
|
||||
const role = await getService('role').getRole(id);
|
||||
const role = await getService('role').findOne(id);
|
||||
|
||||
if (!role) {
|
||||
return ctx.notFound();
|
||||
@ -33,8 +33,8 @@ module.exports = {
|
||||
ctx.send({ role });
|
||||
},
|
||||
|
||||
async getRoles(ctx) {
|
||||
const roles = await getService('role').getRoles();
|
||||
async find(ctx) {
|
||||
const roles = await getService('role').find();
|
||||
|
||||
ctx.send({ roles });
|
||||
},
|
||||
|
||||
@ -37,7 +37,7 @@ module.exports = {
|
||||
.store({ type: 'plugin', name: 'users-permissions', key: 'advanced' })
|
||||
.get();
|
||||
|
||||
const roles = await getService('role').getRoles();
|
||||
const roles = await getService('role').find();
|
||||
|
||||
ctx.send({ settings, roles });
|
||||
},
|
||||
|
||||
@ -4,7 +4,7 @@ module.exports = [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/roles/:id',
|
||||
handler: 'role.getRole',
|
||||
handler: 'role.findOne',
|
||||
config: {
|
||||
policies: [
|
||||
{
|
||||
@ -19,7 +19,7 @@ module.exports = [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/roles',
|
||||
handler: 'role.getRoles',
|
||||
handler: 'role.find',
|
||||
config: {
|
||||
policies: [
|
||||
{
|
||||
|
||||
@ -4,12 +4,12 @@ module.exports = [
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/roles/:id',
|
||||
handler: 'role.getRole',
|
||||
handler: 'role.findOne',
|
||||
},
|
||||
{
|
||||
method: 'GET',
|
||||
path: '/roles',
|
||||
handler: 'role.getRoles',
|
||||
handler: 'role.find',
|
||||
},
|
||||
{
|
||||
method: 'POST',
|
||||
|
||||
@ -41,7 +41,7 @@ module.exports = ({ strapi }) => ({
|
||||
await Promise.all(createPromises);
|
||||
},
|
||||
|
||||
async getRole(roleID) {
|
||||
async findOne(roleID) {
|
||||
const role = await strapi
|
||||
.query('plugin::users-permissions.role')
|
||||
.findOne({ where: { id: roleID }, populate: ['permissions'] });
|
||||
@ -68,7 +68,7 @@ module.exports = ({ strapi }) => ({
|
||||
};
|
||||
},
|
||||
|
||||
async getRoles() {
|
||||
async find() {
|
||||
const roles = await strapi.query('plugin::users-permissions.role').findMany({ sort: ['name'] });
|
||||
|
||||
for (const role of roles) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user