import request from '/@/utils/request';

/**
 * @method getroleList 获取全部角色
 * @method getMenuTree 获取菜单树
 * @method setMenu 添加菜单
 * @method putMenu 修改惨淡
 * @method selectroleOne 查询单条数据
 * @method grantrole 授权
 */
export function roleApi() {
    return {
        getroleList: (params?: object) => {
            return request({
                url: 'system/role/v1',
                method: 'get',
                params,
            });
        },
        selectroleOne: (params: Number) => {
            return request({
                url: 'system/role/v1/' + params,
                method: 'get',
            });
        },
        grantrole: (data: any) => {
            return request({
                url: 'system/role/v1/grant',
                method: 'put',
                data
            });
        },
        removerole: (data: number) => {
            return request({
                url: 'system/role/v1/' + data,
                method: 'delete'
            });
        },
        setrule: (data?: object) => {
            return request({
                url: 'system/role/v1',
                method: 'post',
                data,
            });
        },
        putrole: (data?: object) => {
            return request({
                url: 'system/role/v1',
                method: 'puts',
                data,
            });
        },

    };
}


/**
 * @method getlogList 获取全部数据
 * @method selectlogOne 获取单条数据
 * @method selecttype 查询条件
 */
export function logApi() {
    return {
        getlogList: (params?: object) => {
            return request({
                url: 'system/log/v1',
                method: 'get',
                params,
            });
        },
        selectlogOne: (params: Number) => {
            return request({
                url: 'system/log/v1/' + params,
                method: 'get',
            });
        },
        selecttype: (params?: object) => {
            return request({
                url: 'system/dictItem/v1/type/sys_log_type',
                method: 'get',
                params
            });
        },
    };
}

/**
 * @method getuserList 获取全部用户
 * @method selectuserOne 获取单条用户
 * @method selectTree 获取组织机构菜单树
 * @method setUser 添加用户
 * @method putUser 修改用户
 * @method delUser 删除用户
 * @method getEnableRoles 获取用户角色
 */
export function userApi() {
    return {
        getuserList: (params?: object) => {
            return request({
                url: 'system/user/v1',
                method: 'get',
                params,
            });
        },
        selectuserOne: (params: Number) => {
            return request({
                url: 'system/user/v1/' + params,
                method: 'get',
            });
        },
        selectTree: (params?: object) => {
            return request({
                url: 'system/org/v1/selectTree',
                method: 'get',
                params
            });
        },
        getEnableRoles: (params?: any) => {
            return request({
                url: '/system/role/v1/getEnableRoles',
                method: 'get',
                params
            });
        },
        setUser: (data?: object) => {
            return request({
                url: 'system/user/v1',
                method: 'posts',
                data,
            });
        },
        putUser: (data?: object) => {
            return request({
                url: 'system/user/v1',
                method: 'put',
                data,
            });
        },
        delUser: (data?: object) => {
            return request({
                url: 'system/user/v1/' + data,
                method: 'delete',
            });
        },

    };
}
