【功能新增】system:增加租户的下拉选择,用于登录界面
This commit is contained in:
parent
71add4b058
commit
9b11199665
|
@ -7,14 +7,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
import cn.iocoder.yudao.framework.security.config.SecurityProperties;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthPermissionInfoRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthRegisterReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthResetPasswordReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthSmsLoginReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthSmsSendReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthSocialLoginReqVO;
|
|
||||||
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
import cn.iocoder.yudao.module.system.convert.auth.AuthConvert;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO;
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
|
||||||
|
@ -36,12 +29,7 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
@ -67,8 +67,8 @@ public class MenuController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping({"/list-all-simple", "simple-list"})
|
@GetMapping({"/list-all-simple", "simple-list"})
|
||||||
@Operation(summary = "获取菜单精简信息列表", description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。" +
|
@Operation(summary = "获取菜单精简信息列表",
|
||||||
"在多租户的场景下,会只返回租户所在套餐有的菜单")
|
description = "只包含被开启的菜单,用于【角色分配菜单】功能的选项。在多租户的场景下,会只返回租户所在套餐有的菜单")
|
||||||
public CommonResult<List<MenuSimpleRespVO>> getSimpleMenuList() {
|
public CommonResult<List<MenuSimpleRespVO>> getSimpleMenuList() {
|
||||||
List<MenuDO> list = menuService.getMenuListByTenant(
|
List<MenuDO> list = menuService.getMenuListByTenant(
|
||||||
new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
new MenuListReqVO().setStatus(CommonStatusEnum.ENABLE.getStatus()));
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package cn.iocoder.yudao.module.system.controller.admin.tenant;
|
package cn.iocoder.yudao.module.system.controller.admin.tenant;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
|
||||||
|
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
@ -9,7 +10,6 @@ import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRespVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO;
|
||||||
import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantSimpleRespVO;
|
|
||||||
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
|
import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO;
|
||||||
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
import cn.iocoder.yudao.module.system.service.tenant.TenantService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
@ -27,6 +27,7 @@ import java.util.List;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
@Tag(name = "管理后台 - 租户")
|
@Tag(name = "管理后台 - 租户")
|
||||||
@RestController
|
@RestController
|
||||||
|
@ -45,13 +46,25 @@ public class TenantController {
|
||||||
return success(tenant != null ? tenant.getId() : null);
|
return success(tenant != null ? tenant.getId() : null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping({ "simple-list" })
|
||||||
|
@PermitAll
|
||||||
|
@Operation(summary = "获取租户精简信息列表", description = "只包含被开启的租户,用于【首页】功能的选择租户选项")
|
||||||
|
public CommonResult<List<TenantRespVO>> getTenantSimpleList() {
|
||||||
|
List<TenantDO> list = tenantService.getTenantListByStatus(CommonStatusEnum.ENABLE.getStatus());
|
||||||
|
return success(convertList(list, tenantDO ->
|
||||||
|
new TenantRespVO().setId(tenantDO.getId()).setName(tenantDO.getName())));
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/get-by-website")
|
@GetMapping("/get-by-website")
|
||||||
@PermitAll
|
@PermitAll
|
||||||
@Operation(summary = "使用域名,获得租户信息", description = "登录界面,根据用户的域名,获得租户信息")
|
@Operation(summary = "使用域名,获得租户信息", description = "登录界面,根据用户的域名,获得租户信息")
|
||||||
@Parameter(name = "website", description = "域名", required = true, example = "www.iocoder.cn")
|
@Parameter(name = "website", description = "域名", required = true, example = "www.iocoder.cn")
|
||||||
public CommonResult<TenantSimpleRespVO> getTenantByWebsite(@RequestParam("website") String website) {
|
public CommonResult<TenantRespVO> getTenantByWebsite(@RequestParam("website") String website) {
|
||||||
TenantDO tenant = tenantService.getTenantByWebsite(website);
|
TenantDO tenant = tenantService.getTenantByWebsite(website);
|
||||||
return success(BeanUtils.toBean(tenant, TenantSimpleRespVO.class));
|
if (tenant == null || CommonStatusEnum.isDisable(tenant.getStatus())) {
|
||||||
|
return success(null);
|
||||||
|
}
|
||||||
|
return success(new TenantRespVO().setId(tenant.getId()).setName(tenant.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
|
@ -99,8 +112,7 @@ public class TenantController {
|
||||||
@Operation(summary = "导出租户 Excel")
|
@Operation(summary = "导出租户 Excel")
|
||||||
@PreAuthorize("@ss.hasPermission('system:tenant:export')")
|
@PreAuthorize("@ss.hasPermission('system:tenant:export')")
|
||||||
@ApiAccessLog(operateType = EXPORT)
|
@ApiAccessLog(operateType = EXPORT)
|
||||||
public void exportTenantExcel(@Valid TenantPageReqVO exportReqVO,
|
public void exportTenantExcel(@Valid TenantPageReqVO exportReqVO, HttpServletResponse response) throws IOException {
|
||||||
HttpServletResponse response) throws IOException {
|
|
||||||
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<TenantDO> list = tenantService.getTenantPage(exportReqVO).getList();
|
List<TenantDO> list = tenantService.getTenantPage(exportReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Schema(description = "管理后台 - 租户精简 Response VO")
|
|
||||||
@Data
|
|
||||||
public class TenantSimpleRespVO {
|
|
||||||
|
|
||||||
@Schema(description = "租户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
@Schema(description = "租户名", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道")
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
}
|
|
|
@ -43,4 +43,8 @@ public interface TenantMapper extends BaseMapperX<TenantDO> {
|
||||||
return selectList(TenantDO::getPackageId, packageId);
|
return selectList(TenantDO::getPackageId, packageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<TenantDO> selectListByStatus(Integer status) {
|
||||||
|
return selectList(TenantDO::getStatus, status);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ public interface TenantService {
|
||||||
* 更新租户的角色菜单
|
* 更新租户的角色菜单
|
||||||
*
|
*
|
||||||
* @param tenantId 租户编号
|
* @param tenantId 租户编号
|
||||||
* @param menuIds 菜单编号数组
|
* @param menuIds 菜单编号数组
|
||||||
*/
|
*/
|
||||||
void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds);
|
void updateTenantRoleMenu(Long tenantId, Set<Long> menuIds);
|
||||||
|
|
||||||
|
@ -97,6 +97,14 @@ public interface TenantService {
|
||||||
*/
|
*/
|
||||||
List<TenantDO> getTenantListByPackageId(Long packageId);
|
List<TenantDO> getTenantListByPackageId(Long packageId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得指定状态的租户列表
|
||||||
|
*
|
||||||
|
* @param status 状态
|
||||||
|
* @return 租户列表
|
||||||
|
*/
|
||||||
|
List<TenantDO> getTenantListByStatus(Integer status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 进行租户的信息处理逻辑
|
* 进行租户的信息处理逻辑
|
||||||
* 其中,租户编号从 {@link TenantContextHolder} 上下文中获取
|
* 其中,租户编号从 {@link TenantContextHolder} 上下文中获取
|
||||||
|
|
|
@ -265,6 +265,11 @@ public class TenantServiceImpl implements TenantService {
|
||||||
return tenantMapper.selectListByPackageId(packageId);
|
return tenantMapper.selectListByPackageId(packageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TenantDO> getTenantListByStatus(Integer status) {
|
||||||
|
return tenantMapper.selectListByStatus(status);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void handleTenantInfo(TenantInfoHandler handler) {
|
public void handleTenantInfo(TenantInfoHandler handler) {
|
||||||
// 如果禁用,则不执行逻辑
|
// 如果禁用,则不执行逻辑
|
||||||
|
|
|
@ -271,6 +271,7 @@ yudao:
|
||||||
ignore-urls:
|
ignore-urls:
|
||||||
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
|
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
|
||||||
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
|
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
|
||||||
|
- /admin-api/system/tenant/simple-list # 获取租户列表,不许带租户编号
|
||||||
- /admin-api/system/captcha/get # 获取图片验证码,和租户无关
|
- /admin-api/system/captcha/get # 获取图片验证码,和租户无关
|
||||||
- /admin-api/system/captcha/check # 校验图片验证码,和租户无关
|
- /admin-api/system/captcha/check # 校验图片验证码,和租户无关
|
||||||
- /admin-api/infra/file/*/get/** # 获取图片,和租户无关
|
- /admin-api/infra/file/*/get/** # 获取图片,和租户无关
|
||||||
|
|
Loading…
Reference in New Issue