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