Commit 6b6d676a6baa2dad16ae9bf03d5002209064c8cc
1 parent
79311ecc
【新增】租户套餐的管理,可配置每个租户的可使用的功能
Showing
38 changed files
with
1088 additions
and
49 deletions
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java
| ... | ... | @@ -102,16 +102,20 @@ public interface ErrorCodeConstants { |
| 102 | 102 | ErrorCode SMS_CODE_IS_EXISTS = new ErrorCode(1002013007, "手机号已被使用"); |
| 103 | 103 | ErrorCode SMS_CODE_IS_UNUSED = new ErrorCode(1002013008, "验证码未被使用"); |
| 104 | 104 | |
| 105 | - // ========== 租户模块 1002014000 ========== | |
| 105 | + // ========== 租户信息 1002014000 ========== | |
| 106 | 106 | ErrorCode TENANT_NOT_EXISTS = new ErrorCode(1002014000, "租户不存在"); |
| 107 | 107 | |
| 108 | - // ========== 错误码模块 1002015000 ========== | |
| 109 | - ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002015000, "错误码不存在"); | |
| 110 | - ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002015001, "已经存在编码为【{}】的错误码"); | |
| 108 | + // ========== 租户套餐 1002015000 ========== | |
| 109 | + ErrorCode TENANT_PACKAGE_NOT_EXISTS = new ErrorCode(1002015000, "租户套餐不存在"); | |
| 110 | + ErrorCode TENANT_PACKAGE_USED = new ErrorCode(1002015001, "租户正在使用该套餐,请给租户重新设置套餐后再尝试删除"); | |
| 111 | 111 | |
| 112 | - // ========== 社交用户 1002015000 ========== | |
| 113 | - ErrorCode SOCIAL_USER_AUTH_FAILURE = new ErrorCode(1002015000, "社交授权失败,原因是:{}"); | |
| 114 | - ErrorCode SOCIAL_USER_UNBIND_NOT_SELF = new ErrorCode(1002015001, "社交解绑失败,非当前用户绑定"); | |
| 115 | - ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1002015001, "社交授权失败,找不到对应的用户"); | |
| 112 | + // ========== 错误码模块 1002016000 ========== | |
| 113 | + ErrorCode ERROR_CODE_NOT_EXISTS = new ErrorCode(1002016000, "错误码不存在"); | |
| 114 | + ErrorCode ERROR_CODE_DUPLICATE = new ErrorCode(1002016001, "已经存在编码为【{}】的错误码"); | |
| 115 | + | |
| 116 | + // ========== 社交用户 1002017000 ========== | |
| 117 | + ErrorCode SOCIAL_USER_AUTH_FAILURE = new ErrorCode(1002017000, "社交授权失败,原因是:{}"); | |
| 118 | + ErrorCode SOCIAL_USER_UNBIND_NOT_SELF = new ErrorCode(1002017001, "社交解绑失败,非当前用户绑定"); | |
| 119 | + ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1002017001, "社交授权失败,找不到对应的用户"); | |
| 116 | 120 | |
| 117 | 121 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/permission/vo/menu/MenuSimpleRespVO.java
| ... | ... | @@ -6,6 +6,8 @@ import lombok.AllArgsConstructor; |
| 6 | 6 | import lombok.Data; |
| 7 | 7 | import lombok.NoArgsConstructor; |
| 8 | 8 | |
| 9 | +import javax.validation.constraints.NotNull; | |
| 10 | + | |
| 9 | 11 | @ApiModel("管理后台 - 菜单精简信息 Response VO") |
| 10 | 12 | @Data |
| 11 | 13 | @NoArgsConstructor |
| ... | ... | @@ -21,4 +23,8 @@ public class MenuSimpleRespVO { |
| 21 | 23 | @ApiModelProperty(value = "父菜单 ID", required = true, example = "1024") |
| 22 | 24 | private Long parentId; |
| 23 | 25 | |
| 26 | + @ApiModelProperty(value = "类型", required = true, example = "1", notes = "参见 MenuTypeEnum 枚举类") | |
| 27 | + @NotNull(message = "菜单类型不能为空") | |
| 28 | + private Integer type; | |
| 29 | + | |
| 24 | 30 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantController.java
| 1 | 1 | package cn.iocoder.yudao.module.system.controller.admin.tenant; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.*; | |
| 3 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.*; | |
| 4 | 4 | import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert; |
| 5 | 5 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 6 | 6 | import cn.iocoder.yudao.module.system.service.tenant.TenantService; | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/TenantPackageController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageRespVO; | |
| 8 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageUpdateReqVO; | |
| 9 | +import cn.iocoder.yudao.module.system.convert.tenant.TenantPackageConvert; | |
| 10 | +import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | |
| 11 | +import cn.iocoder.yudao.module.system.service.tenant.TenantPackageService; | |
| 12 | +import io.swagger.annotations.Api; | |
| 13 | +import io.swagger.annotations.ApiImplicitParam; | |
| 14 | +import io.swagger.annotations.ApiOperation; | |
| 15 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | +import org.springframework.validation.annotation.Validated; | |
| 17 | +import org.springframework.web.bind.annotation.*; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import javax.validation.Valid; | |
| 21 | +import java.util.Collection; | |
| 22 | +import java.util.List; | |
| 23 | + | |
| 24 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 25 | + | |
| 26 | +@Api(tags = "管理后台 - 租户套餐") | |
| 27 | +@RestController | |
| 28 | +@RequestMapping("/system/tenant-package") | |
| 29 | +@Validated | |
| 30 | +public class TenantPackageController { | |
| 31 | + | |
| 32 | + @Resource | |
| 33 | + private TenantPackageService tenantPackageService; | |
| 34 | + | |
| 35 | + @PostMapping("/create") | |
| 36 | + @ApiOperation("创建租户套餐") | |
| 37 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:create')") | |
| 38 | + public CommonResult<Long> createTenantPackage(@Valid @RequestBody TenantPackageCreateReqVO createReqVO) { | |
| 39 | + return success(tenantPackageService.createTenantPackage(createReqVO)); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @PutMapping("/update") | |
| 43 | + @ApiOperation("更新租户套餐") | |
| 44 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:update')") | |
| 45 | + public CommonResult<Boolean> updateTenantPackage(@Valid @RequestBody TenantPackageUpdateReqVO updateReqVO) { | |
| 46 | + tenantPackageService.updateTenantPackage(updateReqVO); | |
| 47 | + return success(true); | |
| 48 | + } | |
| 49 | + | |
| 50 | + @DeleteMapping("/delete") | |
| 51 | + @ApiOperation("删除租户套餐") | |
| 52 | + @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = Long.class) | |
| 53 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:delete')") | |
| 54 | + public CommonResult<Boolean> deleteTenantPackage(@RequestParam("id") Long id) { | |
| 55 | + tenantPackageService.deleteTenantPackage(id); | |
| 56 | + return success(true); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @GetMapping("/get") | |
| 60 | + @ApiOperation("获得租户套餐") | |
| 61 | + @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class) | |
| 62 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:query')") | |
| 63 | + public CommonResult<TenantPackageRespVO> getTenantPackage(@RequestParam("id") Long id) { | |
| 64 | + TenantPackageDO tenantPackage = tenantPackageService.getTenantPackage(id); | |
| 65 | + return success(TenantPackageConvert.INSTANCE.convert(tenantPackage)); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @GetMapping("/list") | |
| 69 | + @ApiOperation("获得租户套餐列表") | |
| 70 | + @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) | |
| 71 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:query')") | |
| 72 | + public CommonResult<List<TenantPackageRespVO>> getTenantPackageList(@RequestParam("ids") Collection<Long> ids) { | |
| 73 | + List<TenantPackageDO> list = tenantPackageService.getTenantPackageList(ids); | |
| 74 | + return success(TenantPackageConvert.INSTANCE.convertList(list)); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @GetMapping("/page") | |
| 78 | + @ApiOperation("获得租户套餐分页") | |
| 79 | + @PreAuthorize("@ss.hasPermission('system:tenant-package:query')") | |
| 80 | + public CommonResult<PageResult<TenantPackageRespVO>> getTenantPackagePage(@Valid TenantPackagePageReqVO pageVO) { | |
| 81 | + PageResult<TenantPackageDO> pageResult = tenantPackageService.getTenantPackagePage(pageVO); | |
| 82 | + return success(TenantPackageConvert.INSTANCE.convertPage(pageResult)); | |
| 83 | + } | |
| 84 | + | |
| 85 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/packages/TenantPackageBaseVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModelProperty; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import javax.validation.constraints.NotNull; | |
| 7 | +import java.util.List; | |
| 8 | + | |
| 9 | +/** | |
| 10 | +* 租户套餐 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 11 | +* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 12 | +*/ | |
| 13 | +@Data | |
| 14 | +public class TenantPackageBaseVO { | |
| 15 | + | |
| 16 | + @ApiModelProperty(value = "套餐名", required = true, example = "VIP") | |
| 17 | + @NotNull(message = "套餐名不能为空") | |
| 18 | + private String name; | |
| 19 | + | |
| 20 | + @ApiModelProperty(value = "状态", required = true, example = "1", notes = "参见 CommonStatusEnum 枚举") | |
| 21 | + @NotNull(message = "状态不能为空") | |
| 22 | + private Integer status; | |
| 23 | + | |
| 24 | + @ApiModelProperty(value = "备注", example = "好") | |
| 25 | + private String remark; | |
| 26 | + | |
| 27 | + @ApiModelProperty(value = "关联的菜单编号", required = true) | |
| 28 | + @NotNull(message = "关联的菜单编号不能为空") | |
| 29 | + private List<Long> menuIds; | |
| 30 | + | |
| 31 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/packages/TenantPackageCreateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +@ApiModel("管理后台 - 租户套餐创建 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class TenantPackageCreateReqVO extends TenantPackageBaseVO { | |
| 13 | + | |
| 14 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/packages/TenantPackagePageReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import io.swagger.annotations.ApiModel; | |
| 5 | +import io.swagger.annotations.ApiModelProperty; | |
| 6 | +import lombok.Data; | |
| 7 | +import lombok.EqualsAndHashCode; | |
| 8 | +import lombok.ToString; | |
| 9 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 10 | + | |
| 11 | +import java.util.Date; | |
| 12 | + | |
| 13 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 14 | + | |
| 15 | +@ApiModel("管理后台 - 租户套餐分页 Request VO") | |
| 16 | +@Data | |
| 17 | +@EqualsAndHashCode(callSuper = true) | |
| 18 | +@ToString(callSuper = true) | |
| 19 | +public class TenantPackagePageReqVO extends PageParam { | |
| 20 | + | |
| 21 | + @ApiModelProperty(value = "套餐名", example = "VIP") | |
| 22 | + private String name; | |
| 23 | + | |
| 24 | + @ApiModelProperty(value = "状态", example = "1") | |
| 25 | + private Integer status; | |
| 26 | + | |
| 27 | + @ApiModelProperty(value = "备注", example = "好") | |
| 28 | + private String remark; | |
| 29 | + | |
| 30 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 31 | + @ApiModelProperty(value = "开始创建时间") | |
| 32 | + private Date beginCreateTime; | |
| 33 | + | |
| 34 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 35 | + @ApiModelProperty(value = "结束创建时间") | |
| 36 | + private Date endCreateTime; | |
| 37 | + | |
| 38 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/packages/TenantPackageRespVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | +import lombok.EqualsAndHashCode; | |
| 7 | +import lombok.ToString; | |
| 8 | + | |
| 9 | +import java.util.Date; | |
| 10 | + | |
| 11 | +@ApiModel("管理后台 - 租户套餐 Response VO") | |
| 12 | +@Data | |
| 13 | +@EqualsAndHashCode(callSuper = true) | |
| 14 | +@ToString(callSuper = true) | |
| 15 | +public class TenantPackageRespVO extends TenantPackageBaseVO { | |
| 16 | + | |
| 17 | + @ApiModelProperty(value = "套餐编号", required = true, example = "1024") | |
| 18 | + private Long id; | |
| 19 | + | |
| 20 | + @ApiModelProperty(value = "创建时间", required = true) | |
| 21 | + private Date createTime; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/packages/TenantPackageUpdateReqVO.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages; | |
| 2 | + | |
| 3 | +import lombok.*; | |
| 4 | +import java.util.*; | |
| 5 | +import io.swagger.annotations.*; | |
| 6 | +import javax.validation.constraints.*; | |
| 7 | + | |
| 8 | +@ApiModel("管理后台 - 租户套餐更新 Request VO") | |
| 9 | +@Data | |
| 10 | +@EqualsAndHashCode(callSuper = true) | |
| 11 | +@ToString(callSuper = true) | |
| 12 | +public class TenantPackageUpdateReqVO extends TenantPackageBaseVO { | |
| 13 | + | |
| 14 | + @ApiModelProperty(value = "套餐编号", required = true, example = "1024") | |
| 15 | + @NotNull(message = "套餐编号不能为空") | |
| 16 | + private Long id; | |
| 17 | + | |
| 18 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantBaseVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantBaseVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantCreateReqVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantCreateReqVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantExcelVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantExcelVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantExportReqVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantExportReqVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantPageReqVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantPageReqVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantRespVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantRespVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/TenantUpdateReqVO.java renamed to yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenant/vo/tenant/TenantUpdateReqVO.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/tenant/TenantConvert.java
| 1 | 1 | package cn.iocoder.yudao.module.system.convert.tenant; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantCreateReqVO; | |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantExcelVO; | |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantRespVO; | |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantUpdateReqVO; | |
| 3 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantCreateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExcelVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantRespVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantUpdateReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 8 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 9 | 9 | import org.mapstruct.Mapper; | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/convert/tenant/TenantPackageConvert.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.convert.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageRespVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | |
| 8 | +import org.mapstruct.Mapper; | |
| 9 | +import org.mapstruct.factory.Mappers; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 租户套餐 Convert | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@Mapper | |
| 19 | +public interface TenantPackageConvert { | |
| 20 | + | |
| 21 | + TenantPackageConvert INSTANCE = Mappers.getMapper(TenantPackageConvert.class); | |
| 22 | + | |
| 23 | + TenantPackageDO convert(TenantPackageCreateReqVO bean); | |
| 24 | + | |
| 25 | + TenantPackageDO convert(TenantPackageUpdateReqVO bean); | |
| 26 | + | |
| 27 | + TenantPackageRespVO convert(TenantPackageDO bean); | |
| 28 | + | |
| 29 | + List<TenantPackageRespVO> convertList(List<TenantPackageDO> list); | |
| 30 | + | |
| 31 | + PageResult<TenantPackageRespVO> convertPage(PageResult<TenantPackageDO> page); | |
| 32 | + | |
| 33 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantDO.java
| ... | ... | @@ -2,9 +2,12 @@ package cn.iocoder.yudao.module.system.dal.dataobject.tenant; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; |
| 4 | 4 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 5 | +import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; | |
| 5 | 6 | import com.baomidou.mybatisplus.annotation.TableName; |
| 6 | 7 | import lombok.*; |
| 7 | 8 | |
| 9 | +import java.util.Date; | |
| 10 | + | |
| 8 | 11 | /** |
| 9 | 12 | * 租户 DO |
| 10 | 13 | * |
| ... | ... | @@ -28,6 +31,12 @@ public class TenantDO extends BaseDO { |
| 28 | 31 | */ |
| 29 | 32 | private String name; |
| 30 | 33 | /** |
| 34 | + * 联系人的用户编号 | |
| 35 | + * | |
| 36 | + * 关联 {@link AdminUserDO#getId()} | |
| 37 | + */ | |
| 38 | + private Long contactUserId; | |
| 39 | + /** | |
| 31 | 40 | * 联系人 |
| 32 | 41 | */ |
| 33 | 42 | private String contactName; |
| ... | ... | @@ -36,10 +45,30 @@ public class TenantDO extends BaseDO { |
| 36 | 45 | */ |
| 37 | 46 | private String contactMobile; |
| 38 | 47 | /** |
| 39 | - * 帐号状态 | |
| 48 | + * 租户状态 | |
| 40 | 49 | * |
| 41 | 50 | * 枚举 {@link CommonStatusEnum} |
| 42 | 51 | */ |
| 43 | 52 | private Integer status; |
| 53 | + /** | |
| 54 | + * 绑定域名 | |
| 55 | + * | |
| 56 | + * TODO 芋艿:目前是预留字段,未来会支持根据域名,自动查询到对应的租户。等等 | |
| 57 | + */ | |
| 58 | + private String domain; | |
| 59 | + /** | |
| 60 | + * 租户套餐编号 | |
| 61 | + * | |
| 62 | + * 关联 {@link TenantPackageDO#getId()} | |
| 63 | + */ | |
| 64 | + private Long packageId; | |
| 65 | + /** | |
| 66 | + * 过期时间 | |
| 67 | + */ | |
| 68 | + private Date expireTime; | |
| 69 | + /** | |
| 70 | + * 账号数量 | |
| 71 | + */ | |
| 72 | + private Integer accountCount; | |
| 44 | 73 | |
| 45 | 74 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenant/TenantPackageDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.dal.dataobject.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.type.JsonLongSetTypeHandler; | |
| 6 | +import com.baomidou.mybatisplus.annotation.TableField; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 8 | +import lombok.*; | |
| 9 | + | |
| 10 | +import java.util.Set; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 租户套餐 DO | |
| 14 | + * | |
| 15 | + * @author 芋道源码 | |
| 16 | + */ | |
| 17 | +@TableName(value = "system_tenant_package", autoResultMap = true) | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +@Builder | |
| 22 | +@AllArgsConstructor | |
| 23 | +@NoArgsConstructor | |
| 24 | +public class TenantPackageDO extends BaseDO { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 套餐编号,自增 | |
| 28 | + */ | |
| 29 | + private Long id; | |
| 30 | + /** | |
| 31 | + * 套餐名,唯一 | |
| 32 | + */ | |
| 33 | + private String name; | |
| 34 | + /** | |
| 35 | + * 租户状态 | |
| 36 | + * | |
| 37 | + * 枚举 {@link CommonStatusEnum} | |
| 38 | + */ | |
| 39 | + private Integer status; | |
| 40 | + /** | |
| 41 | + * 备注 | |
| 42 | + */ | |
| 43 | + private String remark; | |
| 44 | + /** | |
| 45 | + * 关联的菜单编号 | |
| 46 | + */ | |
| 47 | + @TableField(typeHandler = JsonLongSetTypeHandler.class) | |
| 48 | + private Set<Long> menuIds; | |
| 49 | + | |
| 50 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/package-info.java
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.system.dal.mysql.tenant; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantExportReqVO; | |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantPageReqVO; | |
| 3 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExportReqVO; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; | |
| 5 | 5 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | 7 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| ... | ... | @@ -41,4 +41,9 @@ public interface TenantMapper extends BaseMapperX<TenantDO> { |
| 41 | 41 | default TenantDO selectByName(String name) { |
| 42 | 42 | return selectOne(TenantDO::getName, name); |
| 43 | 43 | } |
| 44 | + | |
| 45 | + default Integer selectCountByPackageId(Long packageId) { | |
| 46 | + return selectCount("package_id", packageId); | |
| 47 | + } | |
| 48 | + | |
| 44 | 49 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenant/TenantPackageMapper.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.dal.mysql.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | |
| 8 | +import org.apache.ibatis.annotations.Mapper; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 租户套餐 Mapper | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@Mapper | |
| 16 | +public interface TenantPackageMapper extends BaseMapperX<TenantPackageDO> { | |
| 17 | + | |
| 18 | + default PageResult<TenantPackageDO> selectPage(TenantPackagePageReqVO reqVO) { | |
| 19 | + return selectPage(reqVO, new LambdaQueryWrapperX<TenantPackageDO>() | |
| 20 | + .likeIfPresent(TenantPackageDO::getName, reqVO.getName()) | |
| 21 | + .eqIfPresent(TenantPackageDO::getStatus, reqVO.getStatus()) | |
| 22 | + .eqIfPresent(TenantPackageDO::getRemark, reqVO.getRemark()) | |
| 23 | + .betweenIfPresent(TenantPackageDO::getCreateTime, reqVO.getBeginCreateTime(), reqVO.getEndCreateTime()) | |
| 24 | + .orderByDesc(TenantPackageDO::getId)); | |
| 25 | + } | |
| 26 | + | |
| 27 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageService.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.service.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | |
| 8 | + | |
| 9 | +import javax.validation.Valid; | |
| 10 | +import java.util.Collection; | |
| 11 | +import java.util.List; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 租户套餐 Service 接口 | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +public interface TenantPackageService { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 创建租户套餐 | |
| 22 | + * | |
| 23 | + * @param createReqVO 创建信息 | |
| 24 | + * @return 编号 | |
| 25 | + */ | |
| 26 | + Long createTenantPackage(@Valid TenantPackageCreateReqVO createReqVO); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 更新租户套餐 | |
| 30 | + * | |
| 31 | + * @param updateReqVO 更新信息 | |
| 32 | + */ | |
| 33 | + void updateTenantPackage(@Valid TenantPackageUpdateReqVO updateReqVO); | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 删除租户套餐 | |
| 37 | + * | |
| 38 | + * @param id 编号 | |
| 39 | + */ | |
| 40 | + void deleteTenantPackage(Long id); | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 获得租户套餐 | |
| 44 | + * | |
| 45 | + * @param id 编号 | |
| 46 | + * @return 租户套餐 | |
| 47 | + */ | |
| 48 | + TenantPackageDO getTenantPackage(Long id); | |
| 49 | + | |
| 50 | + /** | |
| 51 | + * 获得租户套餐列表 | |
| 52 | + * | |
| 53 | + * @param ids 编号 | |
| 54 | + * @return 租户套餐列表 | |
| 55 | + */ | |
| 56 | + List<TenantPackageDO> getTenantPackageList(Collection<Long> ids); | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * 获得租户套餐分页 | |
| 60 | + * | |
| 61 | + * @param pageReqVO 分页查询 | |
| 62 | + * @return 租户套餐分页 | |
| 63 | + */ | |
| 64 | + PageResult<TenantPackageDO> getTenantPackagePage(TenantPackagePageReqVO pageReqVO); | |
| 65 | + | |
| 66 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImpl.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.service.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.convert.tenant.TenantPackageConvert; | |
| 8 | +import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | |
| 9 | +import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; | |
| 10 | +import org.springframework.stereotype.Service; | |
| 11 | +import org.springframework.validation.annotation.Validated; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | +import java.util.Collection; | |
| 15 | +import java.util.List; | |
| 16 | + | |
| 17 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 18 | +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.TENANT_PACKAGE_NOT_EXISTS; | |
| 19 | +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.TENANT_PACKAGE_USED; | |
| 20 | + | |
| 21 | +/** | |
| 22 | + * 租户套餐 Service 实现类 | |
| 23 | + * | |
| 24 | + * @author 芋道源码 | |
| 25 | + */ | |
| 26 | +@Service | |
| 27 | +@Validated | |
| 28 | +public class TenantPackageServiceImpl implements TenantPackageService { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private TenantPackageMapper tenantPackageMapper; | |
| 32 | + | |
| 33 | + @Resource | |
| 34 | + private TenantService tenantService; | |
| 35 | + | |
| 36 | + @Override | |
| 37 | + public Long createTenantPackage(TenantPackageCreateReqVO createReqVO) { | |
| 38 | + // 插入 | |
| 39 | + TenantPackageDO tenantPackage = TenantPackageConvert.INSTANCE.convert(createReqVO); | |
| 40 | + tenantPackageMapper.insert(tenantPackage); | |
| 41 | + // 返回 | |
| 42 | + return tenantPackage.getId(); | |
| 43 | + } | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + public void updateTenantPackage(TenantPackageUpdateReqVO updateReqVO) { | |
| 47 | + // 校验存在 | |
| 48 | + this.validateTenantPackageExists(updateReqVO.getId()); | |
| 49 | + // 更新 | |
| 50 | + TenantPackageDO updateObj = TenantPackageConvert.INSTANCE.convert(updateReqVO); | |
| 51 | + tenantPackageMapper.updateById(updateObj); | |
| 52 | + } | |
| 53 | + | |
| 54 | + @Override | |
| 55 | + public void deleteTenantPackage(Long id) { | |
| 56 | + // 校验存在 | |
| 57 | + this.validateTenantPackageExists(id); | |
| 58 | + // 校验正在使用 | |
| 59 | + this.validateTenantUsed(id); | |
| 60 | + // 删除 | |
| 61 | + tenantPackageMapper.deleteById(id); | |
| 62 | + } | |
| 63 | + | |
| 64 | + private void validateTenantPackageExists(Long id) { | |
| 65 | + if (tenantPackageMapper.selectById(id) == null) { | |
| 66 | + throw exception(TENANT_PACKAGE_NOT_EXISTS); | |
| 67 | + } | |
| 68 | + } | |
| 69 | + | |
| 70 | + private void validateTenantUsed(Long id) { | |
| 71 | + if (tenantService.getTenantCountByPackageId(id) > 0) { | |
| 72 | + throw exception(TENANT_PACKAGE_USED); | |
| 73 | + } | |
| 74 | + } | |
| 75 | + | |
| 76 | + @Override | |
| 77 | + public TenantPackageDO getTenantPackage(Long id) { | |
| 78 | + return tenantPackageMapper.selectById(id); | |
| 79 | + } | |
| 80 | + | |
| 81 | + @Override | |
| 82 | + public List<TenantPackageDO> getTenantPackageList(Collection<Long> ids) { | |
| 83 | + return tenantPackageMapper.selectBatchIds(ids); | |
| 84 | + } | |
| 85 | + | |
| 86 | + @Override | |
| 87 | + public PageResult<TenantPackageDO> getTenantPackagePage(TenantPackagePageReqVO pageReqVO) { | |
| 88 | + return tenantPackageMapper.selectPage(pageReqVO); | |
| 89 | + } | |
| 90 | + | |
| 91 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantService.java
| ... | ... | @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.system.service.tenant; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService; |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantExportReqVO; | |
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantPageReqVO; | |
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantUpdateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExportReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantUpdateReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 10 | 10 | |
| 11 | 11 | import javax.validation.Valid; |
| ... | ... | @@ -81,4 +81,12 @@ public interface TenantService extends TenantFrameworkService { |
| 81 | 81 | */ |
| 82 | 82 | TenantDO getTenantByName(String name); |
| 83 | 83 | |
| 84 | + /** | |
| 85 | + * 获得使用指定套餐的租户数量 | |
| 86 | + * | |
| 87 | + * @param packageId 租户套餐编号 | |
| 88 | + * @return 租户数量 | |
| 89 | + */ | |
| 90 | + Integer getTenantCountByPackageId(Long packageId); | |
| 91 | + | |
| 84 | 92 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/main/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceImpl.java
| ... | ... | @@ -2,10 +2,10 @@ package cn.iocoder.yudao.module.system.service.tenant; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantCreateReqVO; | |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantExportReqVO; | |
| 7 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantPageReqVO; | |
| 8 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantUpdateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantCreateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExportReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; | |
| 8 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantUpdateReqVO; | |
| 9 | 9 | import cn.iocoder.yudao.module.system.convert.tenant.TenantConvert; |
| 10 | 10 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 11 | 11 | import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper; |
| ... | ... | @@ -94,4 +94,9 @@ public class TenantServiceImpl implements TenantService { |
| 94 | 94 | return tenantMapper.selectByName(name); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | + @Override | |
| 98 | + public Integer getTenantCountByPackageId(Long packageId) { | |
| 99 | + return tenantMapper.selectCountByPackageId(packageId); | |
| 100 | + } | |
| 101 | + | |
| 97 | 102 | } | ... | ... |
yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantPackageServiceImplTest.java
0 → 100755
| 1 | +package cn.iocoder.yudao.module.system.service.tenant; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackagePageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.packages.TenantPackageUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantPackageDO; | |
| 8 | +import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantPackageMapper; | |
| 9 | +import cn.iocoder.yudao.module.system.test.BaseDbUnitTest; | |
| 10 | +import org.junit.jupiter.api.Test; | |
| 11 | +import org.springframework.context.annotation.Import; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 16 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; | |
| 19 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 20 | +import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.TENANT_PACKAGE_NOT_EXISTS; | |
| 21 | +import static org.junit.jupiter.api.Assertions.*; | |
| 22 | + | |
| 23 | +/** | |
| 24 | +* {@link TenantPackageServiceImpl} 的单元测试类 | |
| 25 | +* | |
| 26 | +* @author 芋道源码 | |
| 27 | +*/ | |
| 28 | +@Import(TenantPackageServiceImpl.class) | |
| 29 | +public class TenantPackageServiceImplTest extends BaseDbUnitTest { | |
| 30 | + | |
| 31 | + @Resource | |
| 32 | + private TenantPackageServiceImpl tenantPackageService; | |
| 33 | + | |
| 34 | + @Resource | |
| 35 | + private TenantPackageMapper tenantPackageMapper; | |
| 36 | + | |
| 37 | + @Test | |
| 38 | + public void testCreateTenantPackage_success() { | |
| 39 | + // 准备参数 | |
| 40 | + TenantPackageCreateReqVO reqVO = randomPojo(TenantPackageCreateReqVO.class); | |
| 41 | + | |
| 42 | + // 调用 | |
| 43 | + Long tenantPackageId = tenantPackageService.createTenantPackage(reqVO); | |
| 44 | + // 断言 | |
| 45 | + assertNotNull(tenantPackageId); | |
| 46 | + // 校验记录的属性是否正确 | |
| 47 | + TenantPackageDO tenantPackage = tenantPackageMapper.selectById(tenantPackageId); | |
| 48 | + assertPojoEquals(reqVO, tenantPackage); | |
| 49 | + } | |
| 50 | + | |
| 51 | + @Test | |
| 52 | + public void testUpdateTenantPackage_success() { | |
| 53 | + // mock 数据 | |
| 54 | + TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); | |
| 55 | + tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 | |
| 56 | + // 准备参数 | |
| 57 | + TenantPackageUpdateReqVO reqVO = randomPojo(TenantPackageUpdateReqVO.class, o -> { | |
| 58 | + o.setId(dbTenantPackage.getId()); // 设置更新的 ID | |
| 59 | + }); | |
| 60 | + | |
| 61 | + // 调用 | |
| 62 | + tenantPackageService.updateTenantPackage(reqVO); | |
| 63 | + // 校验是否更新正确 | |
| 64 | + TenantPackageDO tenantPackage = tenantPackageMapper.selectById(reqVO.getId()); // 获取最新的 | |
| 65 | + assertPojoEquals(reqVO, tenantPackage); | |
| 66 | + } | |
| 67 | + | |
| 68 | + @Test | |
| 69 | + public void testUpdateTenantPackage_notExists() { | |
| 70 | + // 准备参数 | |
| 71 | + TenantPackageUpdateReqVO reqVO = randomPojo(TenantPackageUpdateReqVO.class); | |
| 72 | + | |
| 73 | + // 调用, 并断言异常 | |
| 74 | + assertServiceException(() -> tenantPackageService.updateTenantPackage(reqVO), TENANT_PACKAGE_NOT_EXISTS); | |
| 75 | + } | |
| 76 | + | |
| 77 | + @Test | |
| 78 | + public void testDeleteTenantPackage_success() { | |
| 79 | + // mock 数据 | |
| 80 | + TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class); | |
| 81 | + tenantPackageMapper.insert(dbTenantPackage);// @Sql: 先插入出一条存在的数据 | |
| 82 | + // 准备参数 | |
| 83 | + Long id = dbTenantPackage.getId(); | |
| 84 | + | |
| 85 | + // 调用 | |
| 86 | + tenantPackageService.deleteTenantPackage(id); | |
| 87 | + // 校验数据不存在了 | |
| 88 | + assertNull(tenantPackageMapper.selectById(id)); | |
| 89 | + } | |
| 90 | + | |
| 91 | + @Test | |
| 92 | + public void testDeleteTenantPackage_notExists() { | |
| 93 | + // 准备参数 | |
| 94 | + Long id = randomLongId(); | |
| 95 | + | |
| 96 | + // 调用, 并断言异常 | |
| 97 | + assertServiceException(() -> tenantPackageService.deleteTenantPackage(id), TENANT_PACKAGE_NOT_EXISTS); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @Test // TODO 请修改 null 为需要的值 | |
| 101 | + public void testGetTenantPackagePage() { | |
| 102 | + // mock 数据 | |
| 103 | + TenantPackageDO dbTenantPackage = randomPojo(TenantPackageDO.class, o -> { // 等会查询到 | |
| 104 | + o.setName(null); | |
| 105 | + o.setStatus(null); | |
| 106 | + o.setRemark(null); | |
| 107 | + o.setCreateTime(null); | |
| 108 | + }); | |
| 109 | + tenantPackageMapper.insert(dbTenantPackage); | |
| 110 | + // 测试 name 不匹配 | |
| 111 | + tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setName(null))); | |
| 112 | + // 测试 status 不匹配 | |
| 113 | + tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setStatus(null))); | |
| 114 | + // 测试 remark 不匹配 | |
| 115 | + tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setRemark(null))); | |
| 116 | + // 测试 createTime 不匹配 | |
| 117 | + tenantPackageMapper.insert(cloneIgnoreId(dbTenantPackage, o -> o.setCreateTime(null))); | |
| 118 | + // 准备参数 | |
| 119 | + TenantPackagePageReqVO reqVO = new TenantPackagePageReqVO(); | |
| 120 | + reqVO.setName(null); | |
| 121 | + reqVO.setStatus(null); | |
| 122 | + reqVO.setRemark(null); | |
| 123 | + reqVO.setBeginCreateTime(null); | |
| 124 | + reqVO.setEndCreateTime(null); | |
| 125 | + | |
| 126 | + // 调用 | |
| 127 | + PageResult<TenantPackageDO> pageResult = tenantPackageService.getTenantPackagePage(reqVO); | |
| 128 | + // 断言 | |
| 129 | + assertEquals(1, pageResult.getTotal()); | |
| 130 | + assertEquals(1, pageResult.getList().size()); | |
| 131 | + assertPojoEquals(dbTenantPackage, pageResult.getList().get(0)); | |
| 132 | + } | |
| 133 | + | |
| 134 | +} | ... | ... |
yudao-module-system/yudao-module-system-impl/src/test/java/cn/iocoder/yudao/module/system/service/tenant/TenantServiceTest.java
| 1 | 1 | package cn.iocoder.yudao.module.system.service.tenant; |
| 2 | 2 | |
| 3 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantCreateReqVO; | |
| 4 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantExportReqVO; | |
| 5 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantPageReqVO; | |
| 6 | -import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.TenantUpdateReqVO; | |
| 3 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantCreateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantExportReqVO; | |
| 5 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.system.controller.admin.tenant.vo.tenant.TenantUpdateReqVO; | |
| 7 | 7 | import cn.iocoder.yudao.module.system.dal.dataobject.tenant.TenantDO; |
| 8 | 8 | import cn.iocoder.yudao.module.system.dal.mysql.tenant.TenantMapper; |
| 9 | 9 | import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ... | ... |
yudao-module-system/yudao-module-system-impl/src/test/resources/sql/clean.sql
yudao-module-system/yudao-module-system-impl/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -404,3 +404,17 @@ CREATE TABLE IF NOT EXISTS "system_tenant" ( |
| 404 | 404 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 405 | 405 | PRIMARY KEY ("id") |
| 406 | 406 | ) COMMENT '租户'; |
| 407 | + | |
| 408 | +CREATE TABLE IF NOT EXISTS "system_tenant_package" ( | |
| 409 | + "id" bigint NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 410 | + "name" varchar(30) NOT NULL, | |
| 411 | + "status" tinyint NOT NULL, | |
| 412 | + "remark" varchar(256), | |
| 413 | + "menu_ids" varchar(2048) NOT NULL, | |
| 414 | + "creator" varchar(64) DEFAULT '', | |
| 415 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 416 | + "updater" varchar(64) DEFAULT '', | |
| 417 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
| 418 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 419 | + PRIMARY KEY ("id") | |
| 420 | +) COMMENT '租户套餐表'; | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/java/controller/controller.vm
| ... | ... | @@ -40,6 +40,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 40 | 40 | @PostMapping("/create") |
| 41 | 41 | @ApiOperation("创建${table.classComment}") |
| 42 | 42 | #if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:create')")#end |
| 43 | + | |
| 43 | 44 | public CommonResult<${primaryColumn.javaType}> create${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}CreateReqVO createReqVO) { |
| 44 | 45 | return success(${classNameVar}Service.create${simpleClassName}(createReqVO)); |
| 45 | 46 | } |
| ... | ... | @@ -47,6 +48,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 47 | 48 | @PutMapping("/update") |
| 48 | 49 | @ApiOperation("更新${table.classComment}") |
| 49 | 50 | #if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:update')")#end |
| 51 | + | |
| 50 | 52 | public CommonResult<Boolean> update${simpleClassName}(@Valid @RequestBody ${sceneEnum.prefixClass}${table.className}UpdateReqVO updateReqVO) { |
| 51 | 53 | ${classNameVar}Service.update${simpleClassName}(updateReqVO); |
| 52 | 54 | return success(true); |
| ... | ... | @@ -56,6 +58,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 56 | 58 | @ApiOperation("删除${table.classComment}") |
| 57 | 59 | @ApiImplicitParam(name = "id", value = "编号", required = true, dataTypeClass = ${primaryColumn.javaType}.class) |
| 58 | 60 | #if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:delete')")#end |
| 61 | + | |
| 59 | 62 | public CommonResult<Boolean> delete${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { |
| 60 | 63 | ${classNameVar}Service.delete${simpleClassName}(id); |
| 61 | 64 | return success(true); |
| ... | ... | @@ -64,7 +67,8 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 64 | 67 | @GetMapping("/get") |
| 65 | 68 | @ApiOperation("获得${table.classComment}") |
| 66 | 69 | @ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = ${primaryColumn.javaType}.class) |
| 67 | - @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')") | |
| 70 | +#if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end | |
| 71 | + | |
| 68 | 72 | public CommonResult<${sceneEnum.prefixClass}${table.className}RespVO> get${simpleClassName}(@RequestParam("id") ${primaryColumn.javaType} id) { |
| 69 | 73 | ${table.className}DO ${classNameVar} = ${classNameVar}Service.get${simpleClassName}(id); |
| 70 | 74 | return success(${table.className}Convert.INSTANCE.convert(${classNameVar})); |
| ... | ... | @@ -74,6 +78,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 74 | 78 | @ApiOperation("获得${table.classComment}列表") |
| 75 | 79 | @ApiImplicitParam(name = "ids", value = "编号列表", required = true, example = "1024,2048", dataTypeClass = List.class) |
| 76 | 80 | #if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end |
| 81 | + | |
| 77 | 82 | public CommonResult<List<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}List(@RequestParam("ids") Collection<${primaryColumn.javaType}> ids) { |
| 78 | 83 | List<${table.className}DO> list = ${classNameVar}Service.get${simpleClassName}List(ids); |
| 79 | 84 | return success(${table.className}Convert.INSTANCE.convertList(list)); |
| ... | ... | @@ -82,6 +87,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 82 | 87 | @GetMapping("/page") |
| 83 | 88 | @ApiOperation("获得${table.classComment}分页") |
| 84 | 89 | #if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:query')")#end |
| 90 | + | |
| 85 | 91 | public CommonResult<PageResult<${sceneEnum.prefixClass}${table.className}RespVO>> get${simpleClassName}Page(@Valid ${sceneEnum.prefixClass}${table.className}PageReqVO pageVO) { |
| 86 | 92 | PageResult<${table.className}DO> pageResult = ${classNameVar}Service.get${simpleClassName}Page(pageVO); |
| 87 | 93 | return success(${table.className}Convert.INSTANCE.convertPage(pageResult)); |
| ... | ... | @@ -90,6 +96,7 @@ public class ${sceneEnum.prefixClass}${table.className}Controller { |
| 90 | 96 | @GetMapping("/export-excel") |
| 91 | 97 | @ApiOperation("导出${table.classComment} Excel") |
| 92 | 98 | #if ($sceneEnum.scene == 1) @PreAuthorize("@ss.hasPermission('${permissionPrefix}:export')")#end |
| 99 | + | |
| 93 | 100 | @OperateLog(type = EXPORT) |
| 94 | 101 | public void export${simpleClassName}Excel(@Valid ${sceneEnum.prefixClass}${table.className}ExportReqVO exportReqVO, |
| 95 | 102 | HttpServletResponse response) throws IOException { | ... | ... |
yudao-module-tool/yudao-module-tool-impl/src/main/resources/codegen/vue/views/index.vue.vm
| ... | ... | @@ -74,7 +74,7 @@ |
| 74 | 74 | #elseif("" != $column.dictType)## 数据字典 |
| 75 | 75 | <el-table-column label="${comment}" align="center" prop="${javaField}"> |
| 76 | 76 | <template slot-scope="scope"> |
| 77 | - <dict-type :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" /> | |
| 77 | + <dict-tag :type="DICT_TYPE.$dictType.toUpperCase()" :value="scope.row.${column.javaField}" /> | |
| 78 | 78 | </template> |
| 79 | 79 | </el-table-column> |
| 80 | 80 | #else | ... | ... |
yudao-server/src/main/resources/application.yaml
| ... | ... | @@ -80,7 +80,7 @@ yudao: |
| 80 | 80 | tenant: # 多租户相关配置项 |
| 81 | 81 | enable: true |
| 82 | 82 | ignore-urls: /admin-api/system/captcha/get-image, /admin-api/infra/file/get/* |
| 83 | - ignore-tables: infra_config, infra_file, infra_job, infra_job_log, infra_job_log, system_tenant, system_dict_data, system_dict_type, system_error_code, system_menu, system_role, system_role_menu, system_sms_channel, tool_codegen_column, tool_codegen_table, tool_test_demo | |
| 83 | + ignore-tables: infra_config, infra_file, infra_job, infra_job_log, infra_job_log, system_tenant, system_tenant_package, system_dict_data, system_dict_type, system_error_code, system_menu, system_role, system_role_menu, system_sms_channel, tool_codegen_column, tool_codegen_table, tool_test_demo, tables, columns | |
| 84 | 84 | sms-code: # 短信验证码相关的配置项 |
| 85 | 85 | expire-times: 10m |
| 86 | 86 | send-frequency: 1m | ... | ... |
yudao-ui-admin/src/api/system/tenantPackage.js
0 → 100755
| 1 | +import request from '@/utils/request' | |
| 2 | + | |
| 3 | +// 创建租户套餐 | |
| 4 | +export function createTenantPackage(data) { | |
| 5 | + return request({ | |
| 6 | + url: '/system/tenant-package/create', | |
| 7 | + method: 'post', | |
| 8 | + data: data | |
| 9 | + }) | |
| 10 | +} | |
| 11 | + | |
| 12 | +// 更新租户套餐 | |
| 13 | +export function updateTenantPackage(data) { | |
| 14 | + return request({ | |
| 15 | + url: '/system/tenant-package/update', | |
| 16 | + method: 'put', | |
| 17 | + data: data | |
| 18 | + }) | |
| 19 | +} | |
| 20 | + | |
| 21 | +// 删除租户套餐 | |
| 22 | +export function deleteTenantPackage(id) { | |
| 23 | + return request({ | |
| 24 | + url: '/system/tenant-package/delete?id=' + id, | |
| 25 | + method: 'delete' | |
| 26 | + }) | |
| 27 | +} | |
| 28 | + | |
| 29 | +// 获得租户套餐 | |
| 30 | +export function getTenantPackage(id) { | |
| 31 | + return request({ | |
| 32 | + url: '/system/tenant-package/get?id=' + id, | |
| 33 | + method: 'get' | |
| 34 | + }) | |
| 35 | +} | |
| 36 | + | |
| 37 | +// 获得租户套餐分页 | |
| 38 | +export function getTenantPackagePage(query) { | |
| 39 | + return request({ | |
| 40 | + url: '/system/tenant-package/page', | |
| 41 | + method: 'get', | |
| 42 | + params: query | |
| 43 | + }) | |
| 44 | +} | |
| 45 | + | |
| 46 | +// 导出租户套餐 Excel | |
| 47 | +export function exportTenantPackageExcel(query) { | |
| 48 | + return request({ | |
| 49 | + url: '/system/tenant-package/export-excel', | |
| 50 | + method: 'get', | |
| 51 | + params: query, | |
| 52 | + responseType: 'blob' | |
| 53 | + }) | |
| 54 | +} | ... | ... |
yudao-ui-admin/src/views/system/role/index.vue
| ... | ... | @@ -149,16 +149,8 @@ |
| 149 | 149 | <el-form-item label="菜单权限"> |
| 150 | 150 | <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox> |
| 151 | 151 | <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox> |
| 152 | - <el-tree | |
| 153 | - class="tree-border" | |
| 154 | - :data="menuOptions" | |
| 155 | - show-checkbox | |
| 156 | - ref="menu" | |
| 157 | - node-key="id" | |
| 158 | - :check-strictly="form.menuCheckStrictly" | |
| 159 | - empty-text="加载中,请稍后" | |
| 160 | - :props="defaultProps" | |
| 161 | - ></el-tree> | |
| 152 | + <el-tree class="tree-border" :data="menuOptions" show-checkbox ref="menu" node-key="id" | |
| 153 | + :check-strictly="form.menuCheckStrictly" empty-text="加载中,请稍后" :props="defaultProps"></el-tree> | |
| 162 | 154 | </el-form-item> |
| 163 | 155 | </el-form> |
| 164 | 156 | <div slot="footer" class="dialog-footer"> | ... | ... |
yudao-ui-admin/src/views/system/tenantPackage/index.vue
0 → 100755
| 1 | +<template> | |
| 2 | + <div class="app-container"> | |
| 3 | + | |
| 4 | + <!-- 搜索工作栏 --> | |
| 5 | + <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px"> | |
| 6 | + <el-form-item label="套餐名" prop="name"> | |
| 7 | + <el-input v-model="queryParams.name" placeholder="请输入套餐名" clearable size="small" @keyup.enter.native="handleQuery"/> | |
| 8 | + </el-form-item> | |
| 9 | + <el-form-item label="状态" prop="status"> | |
| 10 | + <el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small"> | |
| 11 | + <el-option v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | |
| 12 | + :key="dict.value" :label="dict.label" :value="dict.value"/> | |
| 13 | + </el-select> | |
| 14 | + </el-form-item> | |
| 15 | + <el-form-item label="创建时间"> | |
| 16 | + <el-date-picker v-model="dateRangeCreateTime" size="small" style="width: 240px" value-format="yyyy-MM-dd" | |
| 17 | + type="daterange" range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期" /> | |
| 18 | + </el-form-item> | |
| 19 | + <el-form-item> | |
| 20 | + <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button> | |
| 21 | + <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button> | |
| 22 | + </el-form-item> | |
| 23 | + </el-form> | |
| 24 | + | |
| 25 | + <!-- 操作工具栏 --> | |
| 26 | + <el-row :gutter="10" class="mb8"> | |
| 27 | + <el-col :span="1.5"> | |
| 28 | + <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" | |
| 29 | + v-hasPermi="['system:tenant-package:create']">新增</el-button> | |
| 30 | + </el-col> | |
| 31 | + <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> | |
| 32 | + </el-row> | |
| 33 | + | |
| 34 | + <!-- 列表 --> | |
| 35 | + <el-table v-loading="loading" :data="list"> | |
| 36 | + <el-table-column label="套餐编号" align="center" prop="id" width="120" /> | |
| 37 | + <el-table-column label="套餐名" align="center" prop="name" /> | |
| 38 | + <el-table-column label="状态" align="center" prop="status" width="100"> | |
| 39 | + <template slot-scope="scope"> | |
| 40 | + <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> | |
| 41 | + </template> | |
| 42 | + </el-table-column> | |
| 43 | + <el-table-column label="备注" align="center" prop="remark" /> | |
| 44 | + <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | |
| 45 | + <template slot-scope="scope"> | |
| 46 | + <span>{{ parseTime(scope.row.createTime) }}</span> | |
| 47 | + </template> | |
| 48 | + </el-table-column> | |
| 49 | + <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | |
| 50 | + <template slot-scope="scope"> | |
| 51 | + <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" | |
| 52 | + v-hasPermi="['system:tenant-package:update']">修改</el-button> | |
| 53 | + <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" | |
| 54 | + v-hasPermi="['system:tenant-package:delete']">删除</el-button> | |
| 55 | + </template> | |
| 56 | + </el-table-column> | |
| 57 | + </el-table> | |
| 58 | + <!-- 分页组件 --> | |
| 59 | + <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize" | |
| 60 | + @pagination="getList"/> | |
| 61 | + | |
| 62 | + <!-- 对话框(添加 / 修改) --> | |
| 63 | + <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> | |
| 64 | + <el-form ref="form" :model="form" :rules="rules" label-width="80px"> | |
| 65 | + <el-form-item label="套餐名" prop="name"> | |
| 66 | + <el-input v-model="form.name" placeholder="请输入套餐名" /> | |
| 67 | + </el-form-item> | |
| 68 | + <el-form-item label="菜单权限"> | |
| 69 | + <el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event)">展开/折叠</el-checkbox> | |
| 70 | + <el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event)">全选/全不选</el-checkbox> | |
| 71 | + <el-tree class="tree-border" :data="menuOptions" show-checkbox ref="menu" node-key="id" | |
| 72 | + :check-strictly="menuCheckStrictly" empty-text="加载中,请稍后" :props="defaultProps"></el-tree> | |
| 73 | + </el-form-item> | |
| 74 | + <el-form-item label="状态" prop="status"> | |
| 75 | + <el-radio-group v-model="form.status"> | |
| 76 | + <el-radio v-for="dict in this.getDictDatas(DICT_TYPE.COMMON_STATUS)" | |
| 77 | + :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio> | |
| 78 | + </el-radio-group> | |
| 79 | + </el-form-item> | |
| 80 | + <el-form-item label="备注" prop="remark"> | |
| 81 | + <el-input v-model="form.remark" placeholder="请输入备注" /> | |
| 82 | + </el-form-item> | |
| 83 | + </el-form> | |
| 84 | + <div slot="footer" class="dialog-footer"> | |
| 85 | + <el-button type="primary" @click="submitForm">确 定</el-button> | |
| 86 | + <el-button @click="cancel">取 消</el-button> | |
| 87 | + </div> | |
| 88 | + </el-dialog> | |
| 89 | + </div> | |
| 90 | +</template> | |
| 91 | + | |
| 92 | +<script> | |
| 93 | +import { createTenantPackage, updateTenantPackage, deleteTenantPackage, getTenantPackage, getTenantPackagePage} from "@/api/system/tenantPackage"; | |
| 94 | +import {CommonStatusEnum, SystemMenuTypeEnum} from "@/utils/constants"; | |
| 95 | +import {listSimpleMenus} from "@/api/system/menu"; | |
| 96 | + | |
| 97 | +export default { | |
| 98 | + name: "TenantPackage", | |
| 99 | + components: { | |
| 100 | + }, | |
| 101 | + data() { | |
| 102 | + return { | |
| 103 | + // 遮罩层 | |
| 104 | + loading: true, | |
| 105 | + // 导出遮罩层 | |
| 106 | + exportLoading: false, | |
| 107 | + // 显示搜索条件 | |
| 108 | + showSearch: true, | |
| 109 | + // 总条数 | |
| 110 | + total: 0, | |
| 111 | + // 租户套餐列表 | |
| 112 | + list: [], | |
| 113 | + // 弹出层标题 | |
| 114 | + title: "", | |
| 115 | + // 是否显示弹出层 | |
| 116 | + open: false, | |
| 117 | + dateRangeCreateTime: [], | |
| 118 | + // 查询参数 | |
| 119 | + queryParams: { | |
| 120 | + pageNo: 1, | |
| 121 | + pageSize: 10, | |
| 122 | + name: null, | |
| 123 | + status: null, | |
| 124 | + remark: null, | |
| 125 | + }, | |
| 126 | + // 表单参数 | |
| 127 | + form: {}, | |
| 128 | + menuExpand: false, | |
| 129 | + menuNodeAll: false, | |
| 130 | + menuCheckStrictly: true, | |
| 131 | + defaultProps: { | |
| 132 | + label: "name", | |
| 133 | + children: "children" | |
| 134 | + }, | |
| 135 | + menuOptions: [], // 菜单列表 | |
| 136 | + // 表单校验 | |
| 137 | + rules: { | |
| 138 | + name: [{ required: true, message: "套餐名不能为空", trigger: "blur" }], | |
| 139 | + status: [{ required: true, message: "状态不能为空", trigger: "blur" }], | |
| 140 | + menuIds: [{ required: true, message: "关联的菜单编号不能为空", trigger: "blur" }], | |
| 141 | + } | |
| 142 | + }; | |
| 143 | + }, | |
| 144 | + created() { | |
| 145 | + this.getList(); | |
| 146 | + this.getMenus(); | |
| 147 | + }, | |
| 148 | + methods: { | |
| 149 | + /** 查询列表 */ | |
| 150 | + getList() { | |
| 151 | + this.loading = true; | |
| 152 | + // 处理查询参数 | |
| 153 | + let params = {...this.queryParams}; | |
| 154 | + this.addBeginAndEndTime(params, this.dateRangeCreateTime, 'createTime'); | |
| 155 | + // 执行查询 | |
| 156 | + getTenantPackagePage(params).then(response => { | |
| 157 | + this.list = response.data.list; | |
| 158 | + this.total = response.data.total; | |
| 159 | + this.loading = false; | |
| 160 | + }); | |
| 161 | + }, | |
| 162 | + /** 取消按钮 */ | |
| 163 | + cancel() { | |
| 164 | + this.open = false; | |
| 165 | + this.reset(); | |
| 166 | + }, | |
| 167 | + /** 表单重置 */ | |
| 168 | + reset() { | |
| 169 | + // 菜单选择重置 | |
| 170 | + if (this.$refs.menu !== undefined) { | |
| 171 | + this.$refs.menu.setCheckedKeys([]); | |
| 172 | + } | |
| 173 | + this.menuExpand = false; | |
| 174 | + this.menuNodeAll = false; | |
| 175 | + this.menuCheckStrictly = true; | |
| 176 | + // 表单重置 | |
| 177 | + this.form = { | |
| 178 | + id: undefined, | |
| 179 | + name: undefined, | |
| 180 | + status: CommonStatusEnum.ENABLE, | |
| 181 | + remark: undefined, | |
| 182 | + menuIds: undefined, | |
| 183 | + }; | |
| 184 | + this.resetForm("form"); | |
| 185 | + }, | |
| 186 | + /** 搜索按钮操作 */ | |
| 187 | + handleQuery() { | |
| 188 | + this.queryParams.pageNo = 1; | |
| 189 | + this.getList(); | |
| 190 | + }, | |
| 191 | + /** 重置按钮操作 */ | |
| 192 | + resetQuery() { | |
| 193 | + this.dateRangeCreateTime = []; | |
| 194 | + // 表单重置 | |
| 195 | + this.resetForm("queryForm"); | |
| 196 | + this.handleQuery(); | |
| 197 | + }, | |
| 198 | + /** 新增按钮操作 */ | |
| 199 | + handleAdd() { | |
| 200 | + this.reset(); | |
| 201 | + this.open = true; | |
| 202 | + this.title = "添加租户套餐"; | |
| 203 | + }, | |
| 204 | + /** 修改按钮操作 */ | |
| 205 | + handleUpdate(row) { | |
| 206 | + this.reset(); | |
| 207 | + const id = row.id; | |
| 208 | + this.open = true; | |
| 209 | + this.title = "修改租户套餐"; | |
| 210 | + // 获得菜单列表 | |
| 211 | + getTenantPackage(id).then(response => { | |
| 212 | + this.form = response.data; | |
| 213 | + // 设置菜单项 | |
| 214 | + // 设置为严格,避免设置父节点自动选中子节点,解决半选中问题 | |
| 215 | + this.menuCheckStrictly = true | |
| 216 | + // 设置选中 | |
| 217 | + this.$refs.menu.setCheckedKeys(response.data.menuIds); | |
| 218 | + // 设置为非严格,继续使用半选中 | |
| 219 | + this.menuCheckStrictly = false | |
| 220 | + }); | |
| 221 | + }, | |
| 222 | + /** 获得菜单 */ | |
| 223 | + getMenus() { | |
| 224 | + listSimpleMenus().then(response => { | |
| 225 | + // 移除 BUTTON 类型,暂支只需要发 DIR、MENU 类型 | |
| 226 | + for (let i = response.data.length -1; i >= 0 ; i--) { | |
| 227 | + if (response.data[i].type === SystemMenuTypeEnum.BUTTON) { | |
| 228 | + response.data.splice(i, 1); | |
| 229 | + } | |
| 230 | + } | |
| 231 | + // 处理 menuOptions 参数 | |
| 232 | + this.menuOptions = []; | |
| 233 | + // 只需要配置 | |
| 234 | + this.menuOptions.push(...this.handleTree(response.data, "id")); | |
| 235 | + }); | |
| 236 | + }, | |
| 237 | + /** 提交按钮 */ | |
| 238 | + submitForm() { | |
| 239 | + this.$refs["form"].validate(valid => { | |
| 240 | + if (!valid) { | |
| 241 | + return; | |
| 242 | + } | |
| 243 | + // 修改的提交 | |
| 244 | + if (this.form.id != null) { | |
| 245 | + updateTenantPackage({ | |
| 246 | + ...this.form, | |
| 247 | + menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()] | |
| 248 | + }).then(response => { | |
| 249 | + this.$modal.msgSuccess("修改成功"); | |
| 250 | + this.open = false; | |
| 251 | + this.getList(); | |
| 252 | + }); | |
| 253 | + return; | |
| 254 | + } | |
| 255 | + // 添加的提交 | |
| 256 | + createTenantPackage({ | |
| 257 | + ...this.form, | |
| 258 | + menuIds: [...this.$refs.menu.getCheckedKeys(), ...this.$refs.menu.getHalfCheckedKeys()] | |
| 259 | + }).then(response => { | |
| 260 | + this.$modal.msgSuccess("新增成功"); | |
| 261 | + this.open = false; | |
| 262 | + this.getList(); | |
| 263 | + }); | |
| 264 | + }); | |
| 265 | + }, | |
| 266 | + /** 删除按钮操作 */ | |
| 267 | + handleDelete(row) { | |
| 268 | + const id = row.id; | |
| 269 | + this.$modal.confirm('是否确认删除租户套餐编号为"' + id + '"的数据项?').then(function() { | |
| 270 | + return deleteTenantPackage(id); | |
| 271 | + }).then(() => { | |
| 272 | + this.getList(); | |
| 273 | + this.$modal.msgSuccess("删除成功"); | |
| 274 | + }).catch(() => {}); | |
| 275 | + }, | |
| 276 | + // 树权限(展开/折叠) | |
| 277 | + handleCheckedTreeExpand(value, type) { | |
| 278 | + let treeList = this.menuOptions; | |
| 279 | + for (let i = 0; i < treeList.length; i++) { | |
| 280 | + this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value; | |
| 281 | + } | |
| 282 | + }, | |
| 283 | + // 树权限(全选/全不选) | |
| 284 | + handleCheckedTreeNodeAll(value) { | |
| 285 | + this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []); | |
| 286 | + }, | |
| 287 | + // 树权限(父子联动) | |
| 288 | + handleCheckedTreeConnect(value) { | |
| 289 | + this.form.menuCheckStrictly = value; | |
| 290 | + }, | |
| 291 | + } | |
| 292 | +}; | |
| 293 | +</script> | ... | ... |
更新日志.md
| ... | ... | @@ -26,7 +26,10 @@ TODO |
| 26 | 26 | |
| 27 | 27 | ### ⭐ New Features |
| 28 | 28 | |
| 29 | -TODO | |
| 29 | +* 【新增】后端 `yudao.tenant.enable` 配置项,前端 `VUE_APP_TENANT_ENABLE` 配置项,用于开关租户功能。 [commit](https://gitee.com/zhijiantianya/ruoyi-vue-pro/commit/79311ecc71f0c6beabe0e5f84e1423ce745a5f09) | |
| 30 | +* 【优化】调整默认所有表开启多租户的特性,可通过 `yudao.tenant.ignore-tables` 配置项进行忽略,替代原本默认不开启的策略 [commit](https://gitee.com/zhijiantianya/ruoyi-vue-pro/commit/79311ecc71f0c6beabe0e5f84e1423ce745a5f09) | |
| 31 | +* 【新增】通过 `yudao.tenant.ignore-urls` 配置忽略多租户的请求,例如说 ,例如说短信回调、支付回调等 Open API [commit](https://gitee.com/zhijiantianya/ruoyi-vue-pro/commit/79311ecc71f0c6beabe0e5f84e1423ce745a5f09) | |
| 32 | +* 【新增】租户套餐的管理,可配置每个租户的可使用的功能 | |
| 30 | 33 | |
| 31 | 34 | ### 🐞 Bug Fixes |
| 32 | 35 | ... | ... |