Rename getRoles, getRole to find, findOne

This commit is contained in:
harimkims 2022-03-03 22:55:29 +09:00
parent 4a71a9c93c
commit 567816591a
5 changed files with 11 additions and 11 deletions

View File

@ -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 });
},

View File

@ -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 });
},

View File

@ -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: [
{

View File

@ -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',

View File

@ -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) {