/api/index.js中:
/** *将四个请求接口函数统一暴露 */ import * as trademark from './product/tradeMark' import * as attr from './product/attr' import * as sku from './product/sku' import * as spu from './product/spu' //引入权限相关接口文件 //里面方法是单个暴露的引入方式 import * as user from './acl/user' // 里面方法统一暴露的引入方式 import role from './acl/role' import permission from './acl/permission' // 对外暴露 export default { trademark, attr, sku, spu, user, role, permission } api/acl/user.js
/** *Created by lining on 2022/4/2 * 与用户请求相关API */ import request from '@/utils/request' const api_name = '/admin/acl/user' //每个接口方法单独暴露 //登录 export function login({username, password}) { return request({ url: '/admin/acl/index/login', method: 'POST', data: {username, password} }); } // 根据token获取用户信息 export function getInfo() { return request({ url: '/admin/acl/index/info', method: 'GET' }); } // 退出登录 export function logout() { return request({ url: '/admin/acl/index/logout', method: 'GET' }); } // 获取当前用户的菜单权限列表 export function getMenu() { return request({ url: '/admin/acl/index/menu' }); } // 获取后台用户分页列表(带搜索) export function getPageList(page, limit, searchObj) { return request({ url: `${api_name}/${page}/${limit}`, method: 'GET', params: searchObj }); } // 根据ID获取某个后台用户 export function getById(id) { return request({ url: `${api_name}/get/${id}`, method: 'GET', }); }
api/acl/role.js
/** *Created by lining on 2022/4/2 * 角色管理相关API请求函数 */ import request from '@/utils/request' const api_name = '/admin/acl/role' // 所有方法统一暴露 export default { /* * 获取角色分页列表(带搜索) * */ getPageList(page,limit,searchObj){ return request({ url:`${api_name}/${page}/${limit}`, method:'GET', params:searchObj }); }, /* * 获取某一个角色 * */ getById(id){ return request({ url: `${api_name}/get/${id}`, method: 'get' }); }, /* * 保存一个新角色 * */ save(role){ return request({ url: `${api_name}/save`, method: 'post', data: role }) }, // 更新一个角色 updateById(role){ return request({ url: `${api_name}/update`, method: 'put', data: role }); }, // 获取一个角色的所有权限列表 getAssign(roleId){ return request({ url: `${api_name}/toAssign/${roleId}`, method: 'get' }); }, //删除某一个角色 removeById(id){ return request({ url: `${api_name}/remove/${id}`, method: 'delete' }); }, //批量删除多个角色 removeRole(ids){ return request({ url: `${api_name}/batchRemove`, method: 'delete', data: ids }); } }
api/acl/permission.js
/** *Created by lining on 2022/4/3 * 权限管理相关的Api请求函数 */ import request from '@/utils/request' const api_name = '/admin/acl/permission' //所有方法统一暴露 export default { // 获取权限(菜单/功能)列表 getPermissionList() { return request({ url: `${api_name}`, method: 'get' }); }, // 删除一个权限项 removePermission(id) { return request({ url: `${api_name}/remove/${id}`, method: "delete" }); }, // 保存一个权限项 addPermission(permission) { return request({ url: `${api_name}/save`, method: "post", data: permission }); }, // 更新一个权限项 updatePermission(permission) { return request({ url: `${api_name}/update`, method: "put", data: permission }); }, // 查看某个角色的权限列表 toAssign(roleId) { return request({ url: `${api_name}/toAssign/${roleId}`, method: 'get' }); }, // 给某一个角色授权 doAssign(roleId, permissionId) { return request({ url: `${api_name}/doAssign`, method: 'POST', params: { roleId, permissionId } }) } }