feat:当不是指定查询某个企业数据的时候,查询自己企业的数据

master
dearLin 2026-01-22 09:47:25 +08:00
parent e6cd88d54a
commit 1dfefd6cd3
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,7 @@ package com.zcloud.accident.persistence.repository.impl;
import com.alibaba.cola.dto.PageResponse; import com.alibaba.cola.dto.PageResponse;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jjb.saas.framework.auth.utils.AuthContext;
import com.jjb.saas.framework.repository.common.PageHelper; import com.jjb.saas.framework.repository.common.PageHelper;
import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl; import com.jjb.saas.framework.repository.repo.impl.BaseRepositoryImpl;
import com.zcloud.accident.domain.model.AccidentCountStat; import com.zcloud.accident.domain.model.AccidentCountStat;
@ -11,6 +12,7 @@ import com.zcloud.accident.persistence.mapper.AccidentMapper;
import com.zcloud.accident.persistence.repository.AccidentRepository; import com.zcloud.accident.persistence.repository.AccidentRepository;
import com.zcloud.gbscommon.utils.PageQueryHelper; import com.zcloud.gbscommon.utils.PageQueryHelper;
import com.zcloud.gbscommon.utils.Query; import com.zcloud.gbscommon.utils.Query;
import com.zcloud.gbscommon.utils.Tools;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -30,6 +32,9 @@ public class AccidentRepositoryImpl extends BaseRepositoryImpl<AccidentMapper, A
@Override @Override
public PageResponse<AccidentDO> listPage(Map<String, Object> params,String menuPerms) { public PageResponse<AccidentDO> listPage(Map<String, Object> params,String menuPerms) {
if (Tools.isEmpty(params.getOrDefault("eqCorpinfoId",""))) {
params.put("localCorpId", AuthContext.getTenantId());
}
IPage<AccidentDO> iPage = new Query<AccidentDO>().getPage(params); IPage<AccidentDO> iPage = new Query<AccidentDO>().getPage(params);
IPage<AccidentDO> result = accidentMapper.listPage(iPage, params,menuPerms); IPage<AccidentDO> result = accidentMapper.listPage(iPage, params,menuPerms);
return PageHelper.pageToResponse(result, result.getRecords()); return PageHelper.pageToResponse(result, result.getRecords());

View File

@ -11,6 +11,9 @@
<if test="params.eqCorpinfoId != null"> <if test="params.eqCorpinfoId != null">
and tenant_id = #{params.eqCorpinfoId} and tenant_id = #{params.eqCorpinfoId}
</if> </if>
<if test="params.localCorpId != null">
and tenant_id = #{params.localCorpId}
</if>
<if test="params.likeIncidentName != null and params.likeIncidentName != ''" > <if test="params.likeIncidentName != null and params.likeIncidentName != ''" >
and incident_name like concat('%',#{params.likeIncidentName},'%') and incident_name like concat('%',#{params.likeIncidentName},'%')
</if> </if>