This commit is contained in:
xiao-fajia 2024-09-19 15:26:25 +08:00
commit d1cd46f67f
3 changed files with 20 additions and 0 deletions

View File

@ -54,6 +54,17 @@ public class TenantController {
return success(tenant != null ? tenant.getId() : null);
}
@GetMapping("/getListByWebsite")
@PermitAll
@Operation(summary = "使用域名,获得租户信息", description = "登录界面,根据用户的域名,获得租户信息")
@Parameter(name = "website", description = "域名", required = true, example = "www.iocoder.cn")
public CommonResult<?> getListByWebsite(@RequestParam("website") String website) {
List<TenantDO> tenants = tenantService.getListByWebsite(website);
return success(tenants);
}
@PostMapping("/create")
@Operation(summary = "创建租户")
@PreAuthorize("@ss.hasPermission('system:tenant:create')")

View File

@ -135,4 +135,5 @@ public interface TenantService {
*/
void validTenant(Long id);
List<TenantDO> getListByWebsite(String website);
}

View File

@ -39,6 +39,7 @@ import cn.iocoder.yudao.module.system.service.tenant.handler.TenantMenuHandler;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
@ -106,6 +107,13 @@ public class TenantServiceImpl implements TenantService {
}
}
@Override
public List<TenantDO> getListByWebsite(String website) {
QueryWrapper<TenantDO> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("website", website);
return tenantMapper.selectList(queryWrapper);
}
@Override
@DSTransactional // 多数据源使用 @DSTransactional 保证本地事务以及数据源的切换
public Long createTenant(TenantSaveReqVO createReqVO) {