* @description: 获取用户按钮权限 * @author: 白雾茫茫丶
(session: SessionTypes)
| 181 | * @author: 白雾茫茫丶 |
| 182 | */ |
| 183 | async getPermissions(session: SessionTypes): Promise<Response<string[]>> { |
| 184 | // 获取当前用户 id |
| 185 | const { currentUserInfo } = session; |
| 186 | if (currentUserInfo?.user_id) { |
| 187 | const { user_id } = currentUserInfo; |
| 188 | // 查询权限菜单 |
| 189 | const sqlData = await this.menuModel.findAll({ |
| 190 | attributes: ['permission'], |
| 191 | where: { |
| 192 | menu_id: { |
| 193 | [Op.in]: this.sequelize.literal(`(select menu_id from xmw_permission |
| 194 | where FIND_IN_SET(role_id,(select role_id from xmw_user where user_id='${user_id}')))`), |
| 195 | }, |
| 196 | }, |
| 197 | }); |
| 198 | // 获取按钮权限集合 |
| 199 | const permissions = sqlData.map((s) => s.permission); |
| 200 | return responseMessage(permissions); |
| 201 | } |
| 202 | return responseMessage({}, '登录信息已失效!', 401); |
| 203 | } |
| 204 | |
| 205 | /** |
| 206 | * @description: 获取用户权限菜单 |
nothing calls this directly
no test coverage detected