zhangmei
2025-03-27 1fad0578c97abbb7fc30f59eb1de0f23f08ddde1
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TTenantServiceImpl.java
@@ -6,8 +6,9 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.constant.DictConstants;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.dto.TTenantDTO;
import com.ruoyi.system.mapper.TContractMapper;
import com.ruoyi.system.mapper.THouseMapper;
import com.ruoyi.system.mapper.TTenantMapper;
@@ -23,7 +24,6 @@
import com.ruoyi.system.vo.TBillVO;
import com.ruoyi.system.vo.TenantVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.token.TokenService;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
@@ -49,7 +49,14 @@
    @Override
    public PageInfo<TenantVO> pageList(TTenantQuery query) {
        PageInfo<TenantVO> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TenantVO> list = this.baseMapper.pageList(query,pageInfo);
        String businessDeptId = SecurityUtils.getBusinessDeptId();
        List<TenantVO> list = null;
        if (StringUtils.isBlank(businessDeptId) || "0".equals(businessDeptId)) {
            list = this.baseMapper.pageList(query, pageInfo);
        } else {
            query.setBusinessDeptId(businessDeptId);
            list = this.baseMapper.pageListByBusinessDeptId(query,pageInfo);
        }
        for (TenantVO tenantVO : list) {
            tenantVO.setTenantAttributesName(StringUtils.isNotBlank(tenantVO.getTenantAttributes())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_ATTRIBUTE,tenantVO.getTenantAttributes()):"");
            tenantVO.setTenantTypeName(StringUtils.isNotBlank(tenantVO.getTenantType())?DictUtils.getDictLabel(DictConstants.DICT_TYPE_TENANT_TYPE,tenantVO.getTenantType()):"");
@@ -139,4 +146,15 @@
        pageInfo.setRecords(list);
        return pageInfo;
    }
    @Override
    public boolean isExit(TTenantDTO dto) {
        if(StringUtils.isNotEmpty(dto.getId())){
            // 修改
            return this.count(Wrappers.lambdaQuery(TTenant.class).ne(TTenant::getId, dto.getId()).eq(TTenant::getPhone, dto.getPhone())) > 0;
        }else {
            // 新增
            return this.count(Wrappers.lambdaQuery(TTenant.class).eq(TTenant::getPhone, dto.getPhone())) > 0;
        }
    }
}