【新增】租户创建修改的时候新增专业的点位数据创建和新增
This commit is contained in:
@@ -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<List<TenantSpcialtyDO>> getTenantIdBySpecialty(@RequestParam("id") Long id) {
|
||||
List<TenantSpcialtyDO> 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')")
|
||||
|
@@ -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<TenantSpecialtyPointsVO> tenantSpecialtyPointsVOList;
|
||||
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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;
|
||||
}
|
@@ -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<TenantSpcialtyDO> {
|
||||
|
||||
default PageResult<TenantSpcialtyDO> selectPage(TenantSpecialtyPointsPageVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<TenantSpcialtyDO>()
|
||||
.likeIfPresent(TenantSpcialtyDO::getTenantId, String.valueOf(reqVO.getTenantId()))
|
||||
.likeIfPresent(TenantSpcialtyDO::getSpecialtyId, String.valueOf(reqVO.getSpecialtyId()))
|
||||
.likeIfPresent(TenantSpcialtyDO::getPoints, reqVO.getPoints())
|
||||
.orderByDesc(TenantSpcialtyDO::getPoints));
|
||||
}
|
||||
|
||||
default List<TenantSpcialtyDO> getSpecialtyPoints(Long id) {
|
||||
return selectList(TenantSpcialtyDO::getTenantId, id);
|
||||
}
|
||||
}
|
@@ -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<TenantSpcialtyDO> getTenantBySpecialty(Long id);
|
||||
|
||||
/**
|
||||
* 获得域名对应的租户
|
||||
*
|
||||
|
@@ -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<TenantSpcialtyDO> getTenantBySpecialty(Long id) {
|
||||
return tenantSpecialtyMapper.getSpecialtyPoints(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TenantDO getTenantByWebsite(String website) {
|
||||
return tenantMapper.selectByWebsite(website);
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user