这俩个功能有没有具体一点实现思路和案例呀 给我来一个啊 被困扰好几天了 思路那些啥都没有 我快麻了
1条回答 默认 最新
关注 1、身份鉴别具体指的是什么意思?
2、你说的访问权限是指进入到系统的权限还是说接口的功能权限或者数据权限?
3、系统的访问权限:
当用户登录以后,设置一个token将token与userId的映射关系存入到reids中,并且将token返回给前端,要求前端在请求接口时在header中带上token,后端就在拦截器中解析header获取token,再到redis中进行查询,如果存在则表示已经登录了有访问的权限。
4、功能权限:可以为每个请求接口定义一个code,将code分配给用户或角色,在拦截器中验证当前请求的接口对应的code是否已经分配给了当人员或者角色
5、数据权限:将数据权限分为:个人、部门、公司,并且每个业务数据表中都需要创建人、创建部门、创建公司这三个冗余字段,我们通过一个张记录,当前人员或角色应该有的数据权限属于那种,在请求sql前,获取数据权限类型,然后拼接达到sql中,比如:SELECT * FROM sys_user a LEFT JOIN sys_organization b ON a.dept_id = b.id <where> a.del_flag = 1 AND a.status = 1 <if test="id != null "> AND a.id = #{id,jdbcType=BIGINT} </if> <if test="name != null and name != ''"> AND a.`name` like concat(concat('%',#{name,jdbcType=VARCHAR}),'%') </if> <if test="deptId != null "> AND a.dept_id = #{deptId,jdbcType=BIGINT} </if> <if test="status != null "> AND a.`status` = #{status,jdbcType=INTEGER} </if> <if test="dataScope!=null"> <choose> <when test="dataScope==2"> and a.dept_id IN <foreach collection="deptIds" item="id" open="(" close=")" separator=","> #{id} </foreach> </when> <when test="dataScope==3"> and (find_in_set(#{defaultCompanyId},b.ancestors) or b.id = #{defaultCompanyId}) </when> <when test="dataScope==4"> and a.company_id = #{defaultCompanyId} </when> <when test="dataScope==5"> and (find_in_set(#{defaultDeptId},b.ancestors) or b.id = #{defaultDeptId}) </when> <when test="dataScope==6"> and b.id = #{defaultDeptId} </when> <when test="dataScope==7"> and a.id = #{userId} </when> </choose> </if> </where>
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报 编辑记录
悬赏问题
- ¥30 Unity接入微信SDK 无法开启摄像头
- ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
- ¥20 cad图纸,chx-3六轴码垛机器人
- ¥15 移动摄像头专网需要解vlan
- ¥20 access多表提取相同字段数据并合并
- ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
- ¥20 Java-Oj-桌布的计算
- ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
- ¥20 有人知道这种图怎么画吗?
- ¥15 pyqt6如何引用qrc文件加载里面的的资源