fix: 分润列表,权限恢复之前模式。

This commit is contained in:
tianyongbao
2026-06-04 11:13:11 +08:00
parent 1e73d7e8ee
commit f463982ebd
3 changed files with 11 additions and 58 deletions

View File

@@ -5,7 +5,6 @@ import java.util.Arrays;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.limap.common.core.domain.entity.SysUser;
import com.limap.common.core.domain.entity.SysRole;
import com.limap.common.utils.StringUtils;
import com.limap.core.basic.service.IBasicUserWithdrawService;
@@ -41,10 +40,6 @@ import com.limap.core.basic.vo.SharingRecordSearchVo;
@RestController
@RequestMapping("/basic/sharingRecord")
public class BasicProfitSharingRecordController extends BaseController {
private static final String DATA_SCOPE_ALL = "1";
private static final String DATA_SCOPE_DEPT = "3";
private static final String DATA_SCOPE_DEPT_AND_CHILD = "4";
@Autowired
private IBasicProfitSharingRecordService basicProfitSharingRecordService;
@Autowired
@@ -58,7 +53,10 @@ public class BasicProfitSharingRecordController extends BaseController {
@GetMapping("/list")
public TableDataInfo list(BasicProfitSharingRecord basicProfitSharingRecord) {
startPage();
applySharingRecordDataScope(basicProfitSharingRecord);
List<SysRole> roles = getLoginUser().getUser().getRoles();
if(roles.stream().noneMatch(role -> role.getRoleId().compareTo(100L) <0)){
basicProfitSharingRecord.setUserId(getUserId());
}
List<BasicProfitSharingRecord> list = basicProfitSharingRecordService.selectBasicProfitSharingRecordList(basicProfitSharingRecord);
return getDataTable(list);
}
@@ -68,7 +66,12 @@ public class BasicProfitSharingRecordController extends BaseController {
@PreAuthorize("@ss.hasPermi('basic:sharingRecord:list')")
@GetMapping("/report")
public AjaxResult reportData(SharingRecordSearchVo searchVo) {
applySharingRecordDataScope(searchVo);
List<SysRole> roles = getLoginUser().getUser().getRoles();
if(roles.stream().noneMatch(role -> role.getRoleId().compareTo(100L) >=0)){
searchVo.setUserId(getUserId());
}else{
searchVo.setDeptId(getDeptId());
}
Map<String, Object> resultMap = basicProfitSharingRecordService.getReportData(searchVo);
return success(resultMap);
}
@@ -81,7 +84,6 @@ public class BasicProfitSharingRecordController extends BaseController {
@Log(title = "分润记录", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, BasicProfitSharingRecord basicProfitSharingRecord) {
applySharingRecordDataScope(basicProfitSharingRecord);
List<BasicProfitSharingRecord> list = basicProfitSharingRecordService.selectBasicProfitSharingRecordList(basicProfitSharingRecord);
ExcelUtil<BasicProfitSharingRecord> util = new ExcelUtil<BasicProfitSharingRecord>(BasicProfitSharingRecord.class);
util.exportExcel(response, list, "分润记录数据");
@@ -147,40 +149,4 @@ public class BasicProfitSharingRecordController extends BaseController {
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(basicProfitSharingRecordService.removeByIds(Arrays.asList(ids)));
}
private void applySharingRecordDataScope(BasicProfitSharingRecord record) {
SysUser user = getLoginUser().getUser();
if (user == null || user.isAdmin() || hasDataScope(user.getRoles(), DATA_SCOPE_ALL)) {
return;
}
if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT_AND_CHILD)) {
record.getParams().put("scopeType", "deptAndChild");
record.getParams().put("scopeDeptId", getDeptId());
} else if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT)) {
record.getParams().put("scopeType", "dept");
record.getParams().put("scopeDeptId", getDeptId());
} else {
record.setUserId(getUserId());
}
}
private void applySharingRecordDataScope(SharingRecordSearchVo searchVo) {
SysUser user = getLoginUser().getUser();
if (user == null || user.isAdmin() || hasDataScope(user.getRoles(), DATA_SCOPE_ALL)) {
return;
}
if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT_AND_CHILD)) {
searchVo.setDeptId(getDeptId());
searchVo.getParams().put("scopeType", "deptAndChild");
} else if (hasDataScope(user.getRoles(), DATA_SCOPE_DEPT)) {
searchVo.setDeptId(getDeptId());
searchVo.getParams().put("scopeType", "dept");
} else {
searchVo.setUserId(getUserId());
}
}
private boolean hasDataScope(List<SysRole> roles, String dataScope) {
return roles != null && roles.stream().anyMatch(role -> dataScope.equals(role.getDataScope()));
}
}

View File

@@ -91,16 +91,6 @@ public class BasicProfitSharingRecordServiceImpl extends ServiceImpl<BasicProfit
}
// 兼容前端params[beginTime]/params[endTime]传参方式
Map<String, Object> params = basicProfitSharingRecord.getParams();
String scopeType = (String) params.get("scopeType");
Long scopeDeptId = (Long) params.get("scopeDeptId");
if (StringUtils.isNotNull(scopeDeptId)) {
if ("deptAndChild".equals(scopeType)) {
queryWrapper.inSql(BasicProfitSharingRecord::getDeptId,
"SELECT dept_id FROM sys_dept WHERE dept_id = " + scopeDeptId + " OR find_in_set(" + scopeDeptId + ", ancestors)");
} else if ("dept".equals(scopeType)) {
queryWrapper.eq(BasicProfitSharingRecord::getDeptId, scopeDeptId);
}
}
String beginTime = (String) params.get("beginTime");
String endTime = (String) params.get("endTime");
if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {

View File

@@ -27,10 +27,7 @@
<if test="userId != null">
AND user_id = #{userId}
</if>
<if test="deptId != null and params.scopeType == 'dept'">
and dept_id = #{deptId}
</if>
<if test="deptId != null and (params.scopeType == null or params.scopeType == 'deptAndChild')">
<if test="deptId != null">
and dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = #{deptId} or find_in_set( #{deptId} , ancestors ))
</if>
</where>