1. 增加 Job 的多租户的能力

This commit is contained in:
YunaiV
2021-12-05 10:44:17 +08:00
parent 535d3c9c01
commit 6cd9b3bf7e
19 changed files with 327 additions and 10 deletions

View File

@ -1,8 +1,8 @@
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.auth;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -25,7 +25,7 @@ import java.util.Date;
@Data
@Builder
@EqualsAndHashCode(callSuper = true)
public class SysUserSessionDO extends BaseDO {
public class SysUserSessionDO extends TenantBaseDO {
/**
* 会话编号, 即 sessionId

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.tenant;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
/**
* 租户 DO
*
* @author 芋道源码
*/
@TableName(value = "sys_tenant", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SysTenantDO extends BaseDO {
/**
* 租户编号,自增
*/
private Long id;
/**
* 租户名,唯一
*/
private String name;
/**
* 联系人
*/
private String contactName;
/**
* 联系手机
*/
private String contactMobile;
/**
* 帐号状态
*
* 枚举 {@link CommonStatusEnum}
*/
private Integer status;
}

View File

@ -0,0 +1,9 @@
package cn.iocoder.yudao.coreservice.modules.system.dal.mysql.tenant;
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.tenant.SysTenantDO;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface SysTenantCoreMapper extends BaseMapperX<SysTenantDO> {
}

View File

@ -0,0 +1,11 @@
package cn.iocoder.yudao.coreservice.modules.system.service.tenant;
import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
/**
* 租户 Service 接口
*
* @author 芋道源码
*/
public interface SysTenantCoreService extends TenantFrameworkService {
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.coreservice.modules.system.service.tenant.impl;
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.tenant.SysTenantDO;
import cn.iocoder.yudao.coreservice.modules.system.dal.mysql.tenant.SysTenantCoreMapper;
import cn.iocoder.yudao.coreservice.modules.system.service.tenant.SysTenantCoreService;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* 租户 Service 实现类
*
* @author 芋道源码
*/
@Service
public class SysTenantCoreServiceImpl implements SysTenantCoreService {
@Resource
private SysTenantCoreMapper tenantCoreMapper;
@Override
public List<Long> getTenantIds() {
List<SysTenantDO> tenants = tenantCoreMapper.selectList();
return CollectionUtils.convertList(tenants, SysTenantDO::getId);
}
}