这俩个功能有没有具体一点实现思路和案例呀 给我来一个啊 被困扰好几天了 思路那些啥都没有 我快麻了
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>