数据权限的修改

This commit is contained in:
1745237360-cloud
2026-01-10 16:39:33 +08:00
parent 29b24e8450
commit 4b427e1b2e
97 changed files with 3056 additions and 466 deletions
@@ -28,7 +28,7 @@ public class TmsReceiptDTO extends BaseVOEntity{
@ApiModelProperty("一级组织ID")
@Excel(name = "一级组织ID")
private Integer topOrganizationId;
private Long topOrganizationId;
@ApiModelProperty("收款单号")
@Excel(name = "收款单号")
@@ -107,22 +107,19 @@ public class TmsReceiptDTO extends BaseVOEntity{
@Excel(name = "是否删除", readConverterExp = "删除标记:0-无状态,1-正常,2-已删除")
private Integer delFlag;
@ApiModelProperty(name = "组织ID集合")
private List<Long> organizationIdList;
// @ApiModelProperty(name = "组织ID集合")
// @Excel(name = "组织ID集合")
// private List<Long> organizationIdList;
//
// @ApiModelProperty(name = "权限菜单ID")
// @Excel(name = "权限菜单ID")
// private Long permissionMenuId;
//
// @ApiModelProperty("组织表id")
// @Excel(name = "组织表id")
// private Long organizationId;
//
// @ApiModelProperty("组织名称")
// @Excel(name = "组织名称")
// private String organizationName;
@ApiModelProperty(name = "权限菜单ID")
private Long permissionMenuId;
@ApiModelProperty("组织表id")
@Excel(name = "组织表id")
private Long organizationId;
@ApiModelProperty("组织名称")
@Excel(name = "组织名称")
private String organizationName;
@ApiModelProperty("挂账原因")
@Excel(name = "挂账原因")
@@ -15,6 +15,8 @@ import com.linke.finance.domain.reconciliation.repository.po.FinacialReconciliat
import com.linke.finance.infrastructure.util.UniqueKeyUtil;
import com.linke.finance.interfaces.dto.InvoiceOrderDto;
import com.mhd.common.core.domain.dto.BusinessDocumentDetaliDTO;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import com.mhd.common.core.domain.dto.EditPaymentMethodDTO;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
@@ -16,6 +16,8 @@ import com.mhd.common.core.utils.IgnoreNullUtil;
import com.mhd.common.core.utils.bean.BeanUtils;
import com.mhd.common.log.annotation.Log;
import com.mhd.common.log.enums.BusinessType;
import com.mhd.common.security.utils.SecurityUtils;
import com.mhd.system.api.model.LoginUser;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@@ -56,6 +58,39 @@ public class TmsReceiptApi extends BaseController{
// TmsReceiptDO tmsReceiptDO = tmsReceiptAssembler.toDO(tmsReceiptDTO);
TmsReceiptDO tmsReceiptDO = new TmsReceiptDO();
BeanUtils.copyProperties(tmsReceiptDTO, tmsReceiptDO);
// 获取当前登录用户的组织信息,用于SQL中的数据隔离
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) {
Long loginOrgId = loginUser.getUserPo().getOrganizationId();
// 保存前端传入的组织查询条件(如果有)
Long frontendOrgId = tmsReceiptDO.getOrganizationId();
Long frontendTopOrgId = tmsReceiptDO.getTopOrganizationId();
// 如果当前登录用户的organizationId为2827(南光组织),可查询全部组织数据;其他组织只能查询自己组织的数据
if (loginOrgId == null || !loginOrgId.equals(2827L)) {
// 其他组织:只能查询自己组织的数据,忽略前端传入的组织查询条件
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
Long orgId = loginUser.getUserPo().getOrganizationId();
// 强制使用当前登录用户的组织信息,确保只能查询自己组织的数据
if (topOrgId != null) {
tmsReceiptDO.setTopOrganizationId(topOrgId);
}
if (orgId != null) {
tmsReceiptDO.setOrganizationId(orgId);
}
// 注意:organizationName 条件仍然可以使用,但会被 organizationId 条件限制,只能查询自己组织的
} else {
// 南光组织(organizationId = 2827):可以查询全部组织数据
// 如果前端传入了组织查询条件(organizationId、topOrganizationId或organizationName),则使用前端条件
// 如果前端没有传入任何组织查询条件,则不设置组织ID过滤,查询全部(但organization_name IS NOT NULL仍会生效)
if (frontendOrgId == null && frontendTopOrgId == null && (tmsReceiptDO.getOrganizationName() == null || tmsReceiptDO.getOrganizationName().isEmpty())) {
// 前端没有传入任何组织查询条件,清空组织ID过滤,查询全部组织数据
tmsReceiptDO.setTopOrganizationId(null);
tmsReceiptDO.setOrganizationId(null);
}
// 如果前端传入了组织查询条件,则保留使用前端条件(organizationId、topOrganizationId或organizationName
}
}
startPage();
List<TmsReceiptPO> list = tmsReceiptApplicationService.queryList(tmsReceiptDO);
return getDataTable(list);
@@ -71,6 +106,22 @@ public class TmsReceiptApi extends BaseController{
//转换实体
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
BeanUtils.copyProperties(receivingAccountDTO, receivingAccountDO);
// 获取当前登录用户的组织信息,用于数据隔离
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) {
Long organizationId = loginUser.getUserPo().getOrganizationId();
// 如果当前登录用户的organizationId为2827(南光组织),可查询全部组织数据;其他组织只能查询自己组织的数据
if (organizationId == null || !organizationId.equals(2827L)) {
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
Long orgId = loginUser.getUserPo().getOrganizationId();
if (topOrgId != null) {
receivingAccountDO.setTopOrganizationId(String.valueOf(topOrgId));
}
if (orgId != null) {
receivingAccountDO.setOrganizationId(String.valueOf(orgId));
}
}
}
startPage();
List<ReceivingAccountPO> list = receivingAccountApplicationService.queryList(receivingAccountDO);
return getDataTable(list);
@@ -87,6 +138,18 @@ public class TmsReceiptApi extends BaseController{
//转换实体
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
BeanUtils.copyProperties(receivingAccountDTO, receivingAccountDO);
// 获取当前登录用户的组织信息
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null && loginUser.getUserPo() != null) {
Long topOrganizationId = loginUser.getUserPo().getTopOrganizationId();
Long organizationId = loginUser.getUserPo().getOrganizationId();
if (topOrganizationId != null) {
receivingAccountDO.setTopOrganizationId(String.valueOf(topOrganizationId));
}
if (organizationId != null) {
receivingAccountDO.setOrganizationId(String.valueOf(organizationId));
}
}
return toAjax(receivingAccountApplicationService.insert(receivingAccountDO));
}
@@ -98,11 +161,28 @@ public class TmsReceiptApi extends BaseController{
@PostMapping("/batchAddAccount")
public AjaxResult batchAddAccount(@RequestBody List<ReceivingAccountDTO> receivingAccountDTOList)
{
// 获取当前登录用户的组织信息
LoginUser loginUser = SecurityUtils.getLoginUser();
String topOrganizationId = null;
String organizationId = null;
if (loginUser != null && loginUser.getUserPo() != null) {
Long topOrgId = loginUser.getUserPo().getTopOrganizationId();
Long orgId = loginUser.getUserPo().getOrganizationId();
if (topOrgId != null) {
topOrganizationId = String.valueOf(topOrgId);
}
if (orgId != null) {
organizationId = String.valueOf(orgId);
}
}
//转换实体
List<ReceivingAccountDO> receivingAccountDOList = new ArrayList<>();
for (ReceivingAccountDTO dto : receivingAccountDTOList) {
ReceivingAccountDO receivingAccountDO = new ReceivingAccountDO();
BeanUtils.copyProperties(dto, receivingAccountDO);
// 设置当前登录用户的组织信息
receivingAccountDO.setTopOrganizationId(topOrganizationId);
receivingAccountDO.setOrganizationId(organizationId);
receivingAccountDOList.add(receivingAccountDO);
}
return toAjax(receivingAccountApplicationService.batchInsert(receivingAccountDOList));