羊舍管理数据分离
This commit is contained in:
@@ -166,6 +166,10 @@ public class DaSheepfoldController extends BaseController
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody DaSheepfold daSheepfold)
|
||||
{
|
||||
// 👇 新增这两行赋值语句
|
||||
daSheepfold.setDeptId(getDeptId());
|
||||
daSheepfold.setUserId(getUserId());
|
||||
|
||||
return toAjax(daSheepfoldService.insertDaSheepfold(daSheepfold));
|
||||
}
|
||||
|
||||
|
||||
@@ -121,4 +121,26 @@ public class DaSheepfold extends BaseEntity
|
||||
private Integer totalSheepCount;
|
||||
|
||||
|
||||
// 👇 新增数据隔离字段
|
||||
/** 用户编号 */
|
||||
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;
|
||||
|
||||
import com.zhyc.common.annotation.DataScope;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.zhyc.module.base.domain.BasSheep;
|
||||
import com.zhyc.module.base.domain.DaSheepfold;
|
||||
@@ -50,6 +51,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
|
||||
* @param daSheepfold 羊舍管理
|
||||
* @return 羊舍管理
|
||||
*/
|
||||
@DataScope(deptAlias = "ds", userAlias = "ds")
|
||||
@Override
|
||||
public List<DaSheepfold> selectDaSheepfoldList(DaSheepfold daSheepfold)
|
||||
{
|
||||
@@ -60,6 +62,7 @@ public class DaSheepfoldServiceImpl implements IDaSheepfoldService
|
||||
/**
|
||||
* 羊舍级别汇总查询(主表格)
|
||||
*/
|
||||
@DataScope(deptAlias = "ds", userAlias = "ds")
|
||||
public List<DaSheepfold> selectDaSheepfoldSummaryList(DaSheepfold daSheepfold) {
|
||||
return daSheepfoldMapper.selectDaSheepfoldSummaryList(daSheepfold);
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
<where>
|
||||
<if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if>
|
||||
<if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
-- 按羊舍维度分组(牧场+羊舍类型+羊舍编号 唯一标识一个羊舍)
|
||||
GROUP BY ds.ranch_id, ds.sheepfold_type_id, ds.sheepfold_no
|
||||
@@ -92,6 +93,7 @@
|
||||
<if test="ranchId != null ">and ds.ranch_id = #{ranchId}</if>
|
||||
<if test="sheepfoldTypeId != null ">and ds.sheepfold_type_id = #{sheepfoldTypeId}</if>
|
||||
<if test="sheepfoldNo != null and sheepfoldNo != '' ">and ds.sheepfold_no = #{sheepfoldNo}</if>
|
||||
${params.dataScope}
|
||||
</where>
|
||||
GROUP BY ds.id,ds.ranch_id,ds.sheepfold_name,ds.sheepfold_type_id,ds.sheepfold_no,ds.row_no,ds.columns,ds.comment
|
||||
ORDER BY SUBSTRING_INDEX(ds.row_no, '-', 1), CAST(ds.columns AS UNSIGNED)
|
||||
@@ -112,6 +114,8 @@
|
||||
<if test="rowNo != null">row_no,</if>
|
||||
<if test="columns != null">columns,</if>
|
||||
<if test="comment != null">comment,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="deptId != null">dept_id,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="ranchId != null">#{ranchId},</if>
|
||||
@@ -121,6 +125,8 @@
|
||||
<if test="rowNo != null">#{rowNo},</if>
|
||||
<if test="columns != null">#{columns},</if>
|
||||
<if test="comment != null">#{comment},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="deptId != null">#{deptId},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user