分组管理数据分离
This commit is contained in:
@@ -69,6 +69,10 @@ public class BasSheepGroupController extends BaseController
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody BasSheepGroup basSheepGroup)
|
public AjaxResult add(@RequestBody BasSheepGroup basSheepGroup)
|
||||||
{
|
{
|
||||||
|
// 👇 新增这两行赋值语句
|
||||||
|
basSheepGroup.setDeptId(getDeptId());
|
||||||
|
basSheepGroup.setUserId(getUserId());
|
||||||
|
|
||||||
return toAjax(basSheepGroupService.insertBasSheepGroup(basSheepGroup));
|
return toAjax(basSheepGroupService.insertBasSheepGroup(basSheepGroup));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,4 +42,24 @@ public class BasSheepGroup extends TreeEntity
|
|||||||
|
|
||||||
private Integer isLeaf;
|
private Integer isLeaf;
|
||||||
|
|
||||||
|
// 新增数据隔离字段
|
||||||
|
/** 用户编号 */
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 部门编号 */
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
|
public Long getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
public void setUserId(Long userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
public Long getDeptId() {
|
||||||
|
return deptId;
|
||||||
|
}
|
||||||
|
public void setDeptId(Long deptId) {
|
||||||
|
this.deptId = deptId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.zhyc.module.base.service.impl;
|
package com.zhyc.module.base.service.impl;
|
||||||
|
|
||||||
|
import com.zhyc.common.annotation.DataScope;
|
||||||
import com.zhyc.common.exception.ServiceException;
|
import com.zhyc.common.exception.ServiceException;
|
||||||
import com.zhyc.common.utils.DateUtils;
|
import com.zhyc.common.utils.DateUtils;
|
||||||
import com.zhyc.module.base.domain.BasSheepGroup;
|
import com.zhyc.module.base.domain.BasSheepGroup;
|
||||||
@@ -45,6 +46,7 @@ public class BasSheepGroupServiceImpl implements IBasSheepGroupService
|
|||||||
// {
|
// {
|
||||||
// return basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup);
|
// return basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup);
|
||||||
// }
|
// }
|
||||||
|
@DataScope(deptAlias = "g", userAlias = "g")
|
||||||
@Override
|
@Override
|
||||||
public List<BasSheepGroup> selectBasSheepGroupList(BasSheepGroup basSheepGroup) {
|
public List<BasSheepGroup> selectBasSheepGroupList(BasSheepGroup basSheepGroup) {
|
||||||
List<BasSheepGroup> groups = basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup);
|
List<BasSheepGroup> groups = basSheepGroupMapper.selectBasSheepGroupList(basSheepGroup);
|
||||||
@@ -122,6 +124,7 @@ public class BasSheepGroupServiceImpl implements IBasSheepGroupService
|
|||||||
return basSheepGroupMapper.deleteBasSheepGroupByGroupId(groupId);
|
return basSheepGroupMapper.deleteBasSheepGroupByGroupId(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DataScope(deptAlias = "g", userAlias = "g")
|
||||||
@Override
|
@Override
|
||||||
public List<BasSheepGroup> selectLeafNodes() {
|
public List<BasSheepGroup> selectLeafNodes() {
|
||||||
List<BasSheepGroup> leafNodes = basSheepGroupMapper.selectLeafNodes();
|
List<BasSheepGroup> leafNodes = basSheepGroupMapper.selectLeafNodes();
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<where>
|
<where>
|
||||||
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
|
<if test="groupName != null and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
|
||||||
<if test="status != null and status != ''"> and status = #{status}</if>
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
${params.dataScope}
|
||||||
</where>ORDER BY g.group_id <!-- 确保正确排序 -->
|
</where>ORDER BY g.group_id <!-- 确保正确排序 -->
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -68,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
WHERE child.parent_id = g.group_id) > 0 THEN 0 ELSE 1 END) AS is_leaf
|
WHERE child.parent_id = g.group_id) > 0 THEN 0 ELSE 1 END) AS is_leaf
|
||||||
FROM bas_sheep_group g
|
FROM bas_sheep_group g
|
||||||
WHERE g.status = '0'
|
WHERE g.status = '0'
|
||||||
|
${params.dataScope}
|
||||||
HAVING is_leaf = 1
|
HAVING is_leaf = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -87,6 +89,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="createTime != null">create_time,</if>
|
<if test="createTime != null">create_time,</if>
|
||||||
<if test="updateBy != null">update_by,</if>
|
<if test="updateBy != null">update_by,</if>
|
||||||
<if test="updateTime != null">update_time,</if>
|
<if test="updateTime != null">update_time,</if>
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="deptId != null">dept_id,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="parentId != null">#{parentId},</if>
|
<if test="parentId != null">#{parentId},</if>
|
||||||
@@ -97,6 +101,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
<if test="createTime != null">#{createTime},</if>
|
<if test="createTime != null">#{createTime},</if>
|
||||||
<if test="updateBy != null">#{updateBy},</if>
|
<if test="updateBy != null">#{updateBy},</if>
|
||||||
<if test="updateTime != null">#{updateTime},</if>
|
<if test="updateTime != null">#{updateTime},</if>
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="deptId != null">#{deptId},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user