const API = require("../../../lib/API")
const AccessControl = require("../../../lib/AccessControl")
const { BaseStdResponse } = require("../../../BaseStdResponse")

class GetResourceRules extends API {
    constructor() {
        super()
        this.setPath("/Admin/Permission/Resources")
        this.setMethod("GET")
        this.setPermissionCode("action.user.permissionManage")
    }

    async onRequest(req, res) {
        const rules = await AccessControl.getResourceRules()
        return res.json({
            ...BaseStdResponse.OK,
            data: rules
        })
    }
}

module.exports.GetResourceRules = GetResourceRules
