diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java index 4c964344..41f0327d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/specialty/ExamSpecialtyController.java @@ -44,6 +44,8 @@ public class ExamSpecialtyController{ return success(BeanUtils.toBean(list, SpecialtyQueryVo.class)); } + + /** * 获取全部数据详细信息 */ diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java index 74b9ac58..992df19b 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/TenantController.java @@ -10,7 +10,9 @@ import pc.exam.pp.framework.excel.core.util.ExcelUtils; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantRespVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; import pc.exam.pp.module.system.service.tenant.TenantService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; @@ -100,6 +102,14 @@ public class TenantController { return success(BeanUtils.toBean(tenant, TenantRespVO.class)); } + @GetMapping("/get-id-by-specialty") + @Operation(summary = "使用租户名,获得专业授权信息", description = "使用租户名,获得专业授权信息") + @Parameter(name = "name", description = "专业授权信息", required = true, example = "1024") + public CommonResult> getTenantIdBySpecialty(@RequestParam("id") Long id) { + List tenantSpcialtyDOS = tenantService.getTenantBySpecialty(id); + return success(tenantSpcialtyDOS); + } + @GetMapping("/page") @Operation(summary = "获得租户分页") @PreAuthorize("@ss.hasPermission('system:tenant:query')") @@ -108,6 +118,7 @@ public class TenantController { return success(BeanUtils.toBean(pageResult, TenantRespVO.class)); } + @GetMapping("/export-excel") @Operation(summary = "导出租户 Excel") @PreAuthorize("@ss.hasPermission('system:tenant:export')") diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java index c0d82ded..676cde1e 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.java @@ -11,6 +11,7 @@ import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.Pattern; import jakarta.validation.constraints.Size; import java.time.LocalDateTime; +import java.util.List; @Schema(description = "管理后台 - 租户创建/修改 Request VO") @Data @@ -66,5 +67,7 @@ public class TenantSaveReqVO { return id != null // 修改时,不需要传递 || (ObjectUtil.isAllNotEmpty(username, password)); // 新增时,必须都传递 username、password } + @Schema(description = "授权专业数量") + private List tenantSpecialtyPointsVOList; } diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsPageVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsPageVO.java new file mode 100644 index 00000000..59ab4bc3 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsPageVO.java @@ -0,0 +1,17 @@ +package pc.exam.pp.module.system.controller.admin.tenant.vo.tenant; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import pc.exam.pp.framework.common.pojo.PageParam; + + +@Schema(description = "管理后台 - 租户创建/修改 Request VO") +@Data +public class TenantSpecialtyPointsPageVO extends PageParam { + + private Long specialtyId; + + private Long tenantId; + + private String points; +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsVO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsVO.java new file mode 100644 index 00000000..628cfe91 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSpecialtyPointsVO.java @@ -0,0 +1,18 @@ +package pc.exam.pp.module.system.controller.admin.tenant.vo.tenant; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import pc.exam.pp.framework.common.pojo.PageParam; + + +@Schema(description = "管理后台 - 租户创建/修改 Request VO") +@Data +public class TenantSpecialtyPointsVO { + private Long id; + + private Long specialtyId; + + private Long tenantId; + + private String points; +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantSpcialtyDO.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantSpcialtyDO.java new file mode 100644 index 00000000..81304c76 --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/dataobject/tenant/TenantSpcialtyDO.java @@ -0,0 +1,26 @@ +package pc.exam.pp.module.system.dal.dataobject.tenant; + + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +@TableName(value = "exam_tenant_specialty") +@Data +@ToString(callSuper = true) +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class TenantSpcialtyDO { + + @TableId(value = "id") + private Long id; + + private Long tenantId; + + private Long specialtyId; + + private String points; +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantSpecialtyMapper.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantSpecialtyMapper.java new file mode 100644 index 00000000..36aca10a --- /dev/null +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/dal/mysql/tenant/TenantSpecialtyMapper.java @@ -0,0 +1,34 @@ +package pc.exam.pp.module.system.dal.mysql.tenant; + +import org.apache.ibatis.annotations.Mapper; +import pc.exam.pp.framework.common.pojo.PageResult; +import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; +import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsPageVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; + +import java.util.List; + +/** + * 租户 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface TenantSpecialtyMapper extends BaseMapperX { + + default PageResult selectPage(TenantSpecialtyPointsPageVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(TenantSpcialtyDO::getTenantId, String.valueOf(reqVO.getTenantId())) + .likeIfPresent(TenantSpcialtyDO::getSpecialtyId, String.valueOf(reqVO.getSpecialtyId())) + .likeIfPresent(TenantSpcialtyDO::getPoints, reqVO.getPoints()) + .orderByDesc(TenantSpcialtyDO::getPoints)); + } + + default List getSpecialtyPoints(Long id) { + return selectList(TenantSpcialtyDO::getTenantId, id); + } +} diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java index b9833fd3..96eb8a36 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantService.java @@ -4,7 +4,9 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.tenant.core.context.TenantContextHolder; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; import pc.exam.pp.module.system.service.tenant.handler.TenantInfoHandler; import pc.exam.pp.module.system.service.tenant.handler.TenantMenuHandler; @@ -73,6 +75,14 @@ public interface TenantService { */ TenantDO getTenantByName(String name); + /** + * 获得名字对应的租户的专业授权信息 + * + * @param id 租户ID + * @return 租户 + */ + List getTenantBySpecialty(Long id); + /** * 获得域名对应的租户 * diff --git a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java index b20125c2..c7a0c899 100644 --- a/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java +++ b/exam-module-system/exam-module-system-biz/src/main/java/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.java @@ -15,12 +15,15 @@ import pc.exam.pp.framework.tenant.core.util.TenantUtils; import pc.exam.pp.module.system.controller.admin.permission.vo.role.RoleSaveReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantPageReqVO; import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSaveReqVO; +import pc.exam.pp.module.system.controller.admin.tenant.vo.tenant.TenantSpecialtyPointsVO; import pc.exam.pp.module.system.convert.tenant.TenantConvert; import pc.exam.pp.module.system.dal.dataobject.permission.MenuDO; import pc.exam.pp.module.system.dal.dataobject.permission.RoleDO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantDO; import pc.exam.pp.module.system.dal.dataobject.tenant.TenantPackageDO; +import pc.exam.pp.module.system.dal.dataobject.tenant.TenantSpcialtyDO; import pc.exam.pp.module.system.dal.mysql.tenant.TenantMapper; +import pc.exam.pp.module.system.dal.mysql.tenant.TenantSpecialtyMapper; import pc.exam.pp.module.system.enums.permission.RoleCodeEnum; import pc.exam.pp.module.system.enums.permission.RoleTypeEnum; import pc.exam.pp.module.system.service.permission.MenuService; @@ -37,6 +40,8 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import jakarta.annotation.Resource; + +import java.util.Collection; import java.util.List; import java.util.Objects; import java.util.Set; @@ -62,6 +67,9 @@ public class TenantServiceImpl implements TenantService { @Resource private TenantMapper tenantMapper; + @Resource + private TenantSpecialtyMapper tenantSpecialtyMapper; + @Resource private TenantPackageService tenantPackageService; @Resource @@ -107,6 +115,15 @@ public class TenantServiceImpl implements TenantService { // 创建租户 TenantDO tenant = BeanUtils.toBean(createReqVO, TenantDO.class); tenantMapper.insert(tenant); + // 创建租户对应的专业的授权点数 + Long tenantId = tenant.getId(); + for (TenantSpecialtyPointsVO specialtyPointsVO : createReqVO.getTenantSpecialtyPointsVOList()) { + // 新增数据 + specialtyPointsVO.setTenantId(tenantId); + TenantSpcialtyDO tenantSpcialtyDO = new TenantSpcialtyDO(); + BeanUtils.copyProperties(specialtyPointsVO, tenantSpcialtyDO); + tenantSpecialtyMapper.insert(tenantSpcialtyDO); + } // 创建租户的管理员 TenantUtils.execute(tenant.getId(), () -> { // 创建角色 @@ -153,6 +170,15 @@ public class TenantServiceImpl implements TenantService { // 更新租户 TenantDO updateObj = BeanUtils.toBean(updateReqVO, TenantDO.class); tenantMapper.updateById(updateObj); + // 创建租户对应的专业的授权点数 + Long tenantId = tenant.getId(); + for (TenantSpecialtyPointsVO specialtyPointsVO : updateReqVO.getTenantSpecialtyPointsVOList()) { + // 新增数据 + specialtyPointsVO.setTenantId(tenantId); + TenantSpcialtyDO tenantSpcialtyDO = new TenantSpcialtyDO(); + BeanUtils.copyProperties(specialtyPointsVO, tenantSpcialtyDO); + tenantSpecialtyMapper.insertOrUpdate(tenantSpcialtyDO); + } // 如果套餐发生变化,则修改其角色的权限 if (ObjectUtil.notEqual(tenant.getPackageId(), updateReqVO.getPackageId())) { updateTenantRoleMenu(tenant.getId(), tenantPackage.getMenuIds()); @@ -250,6 +276,11 @@ public class TenantServiceImpl implements TenantService { return tenantMapper.selectByName(name); } + @Override + public List getTenantBySpecialty(Long id) { + return tenantSpecialtyMapper.getSpecialtyPoints(id); + } + @Override public TenantDO getTenantByWebsite(String website) { return tenantMapper.selectByWebsite(website); diff --git a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/TenantController.class b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/TenantController.class index b2ae21b8..2a7de380 100644 Binary files a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/TenantController.class and b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/TenantController.class differ diff --git a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.class b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.class index 2021fec8..4b850c7f 100644 Binary files a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.class and b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/controller/admin/tenant/vo/tenant/TenantSaveReqVO.class differ diff --git a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantService.class b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantService.class index d41b9817..dd807188 100644 Binary files a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantService.class and b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantService.class differ diff --git a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.class b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.class index a4f61079..deff80d7 100644 Binary files a/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.class and b/exam-module-system/exam-module-system-biz/target/classes/pc/exam/pp/module/system/service/tenant/TenantServiceImpl.class differ diff --git a/exam-server/src/main/resources/application.yaml b/exam-server/src/main/resources/application.yaml index 47def1bb..ffc53b78 100644 --- a/exam-server/src/main/resources/application.yaml +++ b/exam-server/src/main/resources/application.yaml @@ -295,6 +295,7 @@ exam: - /jmreport/* # 积木报表,无法携带租户编号 - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 ignore-tables: + - exam_tenant_specialty - system_tenant - system_tenant_package - system_dict_data diff --git a/exam-server/target/classes/application.yaml b/exam-server/target/classes/application.yaml index 47def1bb..ffc53b78 100644 --- a/exam-server/target/classes/application.yaml +++ b/exam-server/target/classes/application.yaml @@ -295,6 +295,7 @@ exam: - /jmreport/* # 积木报表,无法携带租户编号 - /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号 ignore-tables: + - exam_tenant_specialty - system_tenant - system_tenant_package - system_dict_data