改造租户
This commit is contained in:
parent
dfbd80dad7
commit
71139a21c3
@ -8,32 +8,28 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.validate.AddGroup;
|
||||
import org.dromara.common.core.validate.EditGroup;
|
||||
import org.dromara.common.encrypt.annotation.ApiEncrypt;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
||||
import org.dromara.common.log.annotation.Log;
|
||||
import org.dromara.common.log.enums.BusinessType;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.common.web.core.BaseController;
|
||||
import org.dromara.system.domain.SysTenant;
|
||||
import org.dromara.system.domain.bo.SysTenantBo;
|
||||
import org.dromara.system.domain.bo.SysTenantExtendBo;
|
||||
import org.dromara.system.domain.dto.TenantDTO;
|
||||
import org.dromara.system.domain.vo.SysTenantVo;
|
||||
import org.dromara.system.service.ISysTenantService;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -149,20 +145,35 @@ public class SysTenantController extends BaseController {
|
||||
return toAjax(tenantService.updateTenantStatus(bo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// @Log(title = "租户管理", businessType = BusinessType.DELETE)
|
||||
// @DeleteMapping("/{id}")
|
||||
// public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
// @PathVariable Long id) {
|
||||
// return toAjax(tenantService.deleteWithValidByIds(List.of(ids), true));
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 删除租户
|
||||
*
|
||||
* @param ids 主键串
|
||||
* @param
|
||||
*/
|
||||
@Tag(name = "删除租户表")
|
||||
@Log(title = "租户表", businessType = BusinessType.DELETE)
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:remove")
|
||||
@Log(title = "租户管理", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||
@PathVariable Long[] ids) {
|
||||
return toAjax(tenantService.deleteWithValidByIds(List.of(ids), true));
|
||||
@DeleteMapping("/remove")
|
||||
public R batchRemove(@RequestParam("ids") String ids) {
|
||||
List<Long> idList = Arrays.stream(ids.split(","))
|
||||
.map(Long::parseLong)
|
||||
.toList();
|
||||
return toAjax(tenantService.batchRemoveByIds(idList));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 动态切换租户
|
||||
*
|
||||
|
@ -73,10 +73,10 @@ public class SysTenant extends BaseEntity {
|
||||
private LocalDateTime joinTime;
|
||||
|
||||
@Schema(description = "营业执照附件")
|
||||
private String attachmentimg;
|
||||
private String attachment;
|
||||
|
||||
@Schema(description = "推广附件")
|
||||
private String promoteListimg;
|
||||
private String promoteList;
|
||||
|
||||
@Schema(description = "营业执照有效期")
|
||||
private LocalDateTime expireTime;
|
||||
@ -91,7 +91,7 @@ public class SysTenant extends BaseEntity {
|
||||
private String businessTypes;
|
||||
|
||||
@Schema(description = "相关资质名称及附件")
|
||||
private String relatedimg;
|
||||
private String related;
|
||||
|
||||
@Schema(description = "联系人")
|
||||
private String contactUserName;
|
||||
|
@ -1,10 +1,8 @@
|
||||
package org.dromara.system.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.dromara.common.core.domain.model.BaseAudit;
|
||||
@ -33,7 +31,7 @@ public class SysTenantExtend extends BaseAudit {
|
||||
private String idCardType;
|
||||
|
||||
@Schema(description = "证件图片")
|
||||
private String certificateimg;
|
||||
private String certificate;
|
||||
|
||||
@Schema(description = "负责人姓名")
|
||||
private String personName;
|
||||
@ -81,7 +79,7 @@ public class SysTenantExtend extends BaseAudit {
|
||||
private String contractYear;
|
||||
|
||||
@Schema(description = "签约附件")
|
||||
private String contractAttachmentimg;
|
||||
private String contractAttachment;
|
||||
|
||||
@Schema(description = "签约状态")
|
||||
private String signStatus;
|
||||
|
@ -53,10 +53,10 @@ public class SysTenantExtendBo {
|
||||
private LocalDateTime joinTime;
|
||||
|
||||
@Schema(description = "营业执照附件")
|
||||
private String attachmentimg;
|
||||
private String attachment;
|
||||
|
||||
@Schema(description = "推广附件")
|
||||
private String promoteListimg;
|
||||
private String promoteList;
|
||||
|
||||
@Schema(description = "营业执照有效期")
|
||||
private LocalDateTime expireTime;
|
||||
@ -71,7 +71,7 @@ public class SysTenantExtendBo {
|
||||
private String businessTypes;
|
||||
|
||||
@Schema(description = "相关资质名称及附件")
|
||||
private String relatedimg;
|
||||
private String related;
|
||||
|
||||
@Schema(description = "店铺id")
|
||||
private Long storeId;
|
||||
@ -83,7 +83,7 @@ public class SysTenantExtendBo {
|
||||
private String idCardType;
|
||||
|
||||
@Schema(description = "证件图片")
|
||||
private String certificateimg;
|
||||
private String certificate;
|
||||
|
||||
@Schema(description = "负责人姓名")
|
||||
private String personName;
|
||||
@ -138,7 +138,7 @@ public class SysTenantExtendBo {
|
||||
private String contractYear;
|
||||
|
||||
@Schema(description = "签约附件")
|
||||
private String contractAttachmentimg;
|
||||
private String contractAttachment;
|
||||
|
||||
@Schema(description = "签约状态")
|
||||
private String signStatus;
|
||||
|
@ -1,10 +1,7 @@
|
||||
package org.dromara.system.domain.dto;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
@ -56,10 +53,10 @@ public class TenantDTO {
|
||||
private LocalDateTime joinTime;
|
||||
|
||||
@Schema(description = "营业执照附件")
|
||||
private String attachmentimg;
|
||||
private String attachment;
|
||||
|
||||
@Schema(description = "推广附件")
|
||||
private String promoteListimg;
|
||||
private String promoteList;
|
||||
|
||||
@Schema(description = "营业执照有效期")
|
||||
private LocalDateTime expireTime;
|
||||
@ -74,7 +71,7 @@ public class TenantDTO {
|
||||
private String businessTypes;
|
||||
|
||||
@Schema(description = "相关资质名称及附件")
|
||||
private String relatedimg;
|
||||
private String related;
|
||||
|
||||
@Schema(description = "店铺id")
|
||||
private Long storeId;
|
||||
@ -86,7 +83,7 @@ public class TenantDTO {
|
||||
private String idCardType;
|
||||
|
||||
@Schema(description = "证件图片")
|
||||
private String certificateimg;
|
||||
private String certificate;
|
||||
|
||||
@Schema(description = "负责人姓名")
|
||||
private String personName;
|
||||
@ -143,7 +140,7 @@ public class TenantDTO {
|
||||
private String contractYear;
|
||||
|
||||
@Schema(description = "签约附件")
|
||||
private String contractAttachmentimg;
|
||||
private String contractAttachment;
|
||||
|
||||
@Schema(description = "签约状态")
|
||||
private String signStatus;
|
||||
|
@ -50,10 +50,10 @@ public class SysTenantExtendVo {
|
||||
private LocalDateTime joinTime;
|
||||
|
||||
@Schema(description = "营业执照附件")
|
||||
private String attachmentimg;
|
||||
private String attachment;
|
||||
|
||||
@Schema(description = "推广附件")
|
||||
private String promoteListimg;
|
||||
private String promoteList;
|
||||
|
||||
@Schema(description = "营业执照有效期")
|
||||
private DateTime expireTime;
|
||||
@ -68,7 +68,7 @@ public class SysTenantExtendVo {
|
||||
private String businessType;
|
||||
|
||||
@Schema(description = "相关资质名称及附件")
|
||||
private String relatedimg;
|
||||
private String related;
|
||||
|
||||
@Schema(description = "店铺id")
|
||||
private Long storeId;
|
||||
@ -80,7 +80,7 @@ public class SysTenantExtendVo {
|
||||
private String idCardType;
|
||||
|
||||
@Schema(description = "证件图片")
|
||||
private String certificateimg;
|
||||
private String certificate;
|
||||
|
||||
@Schema(description = "负责人姓名")
|
||||
private String personName;
|
||||
@ -134,7 +134,7 @@ public class SysTenantExtendVo {
|
||||
private String contractYear;
|
||||
|
||||
@Schema(description = "签约附件")
|
||||
private String contractAttachmentimg;
|
||||
private String contractAttachment;
|
||||
|
||||
@Schema(description = "签约状态")
|
||||
private String signStatus;
|
||||
|
@ -67,10 +67,10 @@ public class SysTenantVo implements Serializable {
|
||||
private LocalDateTime joinTime;
|
||||
|
||||
@Schema(description = "营业执照附件")
|
||||
private String attachmentimg;
|
||||
private String attachment;
|
||||
|
||||
@Schema(description = "推广附件")
|
||||
private String promoteListimg;
|
||||
private String promoteList;
|
||||
|
||||
@Schema(description = "营业执照有效期")
|
||||
private LocalDateTime expireTime;
|
||||
@ -85,7 +85,7 @@ public class SysTenantVo implements Serializable {
|
||||
private String businessTypes;
|
||||
|
||||
@Schema(description = "相关资质名称及附件")
|
||||
private String relatedimg;
|
||||
private String related;
|
||||
|
||||
@Schema(description = "店铺id")
|
||||
private Long storeId;
|
||||
@ -97,7 +97,7 @@ public class SysTenantVo implements Serializable {
|
||||
private String idCardType;
|
||||
|
||||
@Schema(description = "证件图片")
|
||||
private String certificateimg;
|
||||
private String certificate;
|
||||
|
||||
@Schema(description = "负责人姓名")
|
||||
private String personName;
|
||||
@ -152,7 +152,7 @@ public class SysTenantVo implements Serializable {
|
||||
private String contractYear;
|
||||
|
||||
@Schema(description = "签约附件")
|
||||
private String contractAttachmentimg;
|
||||
private String contractAttachment;
|
||||
|
||||
@Schema(description = "签约状态")
|
||||
private String signStatus;
|
||||
|
@ -2,6 +2,7 @@ package org.dromara.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
@ -63,4 +64,11 @@ public interface SysTenantMapper extends BaseMapperPlus<SysTenant, SysTenantVo>
|
||||
"LEFT JOIN ums_member m ON e.invite_user_id = m.id\n" +
|
||||
"WHERE t.id = #{id}")
|
||||
TenantDTO getById(Long id);
|
||||
|
||||
|
||||
|
||||
|
||||
int batchDeleteTenantExtendByStoreIds(List<Long> ids);
|
||||
|
||||
int batchDeleteTenantByIds(List<Long> ids);
|
||||
}
|
||||
|
@ -95,4 +95,7 @@ public interface ISysTenantService {
|
||||
List<TenantDTO> getAll(SysTenantBo bo);
|
||||
|
||||
TenantDTO getById(Long id);
|
||||
|
||||
|
||||
Boolean batchRemoveByIds(List<Long> ids);
|
||||
}
|
||||
|
@ -11,15 +11,12 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.commons.beanutils.BeanUtils;
|
||||
import org.dromara.common.core.constant.CacheNames;
|
||||
import org.dromara.common.core.constant.Constants;
|
||||
import org.dromara.common.core.constant.SystemConstants;
|
||||
import org.dromara.common.core.constant.TenantConstants;
|
||||
import org.dromara.common.core.exception.ServiceException;
|
||||
import org.dromara.common.core.service.WorkflowService;
|
||||
import org.dromara.common.core.utils.MapstructUtils;
|
||||
import org.dromara.common.core.utils.SpringUtils;
|
||||
import org.dromara.common.core.utils.StreamUtils;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
@ -40,7 +37,6 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
|
||||
@ -149,13 +145,13 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
tenant.setDelFlag(bo.getDelFlag());
|
||||
tenant.setBusinessLicense(bo.getBusinessLicense());
|
||||
tenant.setJoinTime(LocalDateTime.now());
|
||||
tenant.setAttachmentimg(bo.getAttachmentimg());
|
||||
tenant.setPromoteListimg(bo.getPromoteListimg());
|
||||
tenant.setAttachment(bo.getAttachment());
|
||||
tenant.setPromoteList(bo.getPromoteList());
|
||||
tenant.setExpireTime(bo.getExpireTime());
|
||||
tenant.setStoreName(bo.getStoreName());
|
||||
tenant.setCompanyType(bo.getCompanyType());
|
||||
tenant.setBusinessTypes(bo.getBusinessTypes());
|
||||
tenant.setRelatedimg(bo.getRelatedimg());
|
||||
tenant.setRelated(bo.getRelated());
|
||||
tenant.setContactUserName(bo.getContactUserName());
|
||||
tenant.setContactPhone(bo.getContactPhone());
|
||||
|
||||
@ -174,7 +170,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
tenantExtend.setStoreId(tenant.getId());
|
||||
tenantExtend.setIdCard(bo.getIdCard());
|
||||
tenantExtend.setIdCardType(bo.getIdCardType());
|
||||
tenantExtend.setCertificateimg(bo.getCertificateimg());
|
||||
tenantExtend.setCertificate(bo.getCertificate());
|
||||
tenantExtend.setPersonName(bo.getPersonName());
|
||||
tenantExtend.setPersonPhone(bo.getPersonPhone());
|
||||
tenantExtend.setBankType(bo.getBankType());
|
||||
@ -190,7 +186,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
tenantExtend.setSplitRatio(bo.getSplitRatio());
|
||||
tenantExtend.setSigner(bo.getSigner());
|
||||
tenantExtend.setContractYear(bo.getContractYear());
|
||||
tenantExtend.setContractAttachmentimg(bo.getContractAttachmentimg());
|
||||
tenantExtend.setContractAttachment(bo.getContractAttachment());
|
||||
tenantExtend.setSignStatus(bo.getSignStatus());
|
||||
|
||||
boolean extendInserted = tenantExtendMapper.insert(tenantExtend) > 0;
|
||||
@ -366,13 +362,13 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
existingTenant.setIntro(bo.getIntro());
|
||||
existingTenant.setPackageId(bo.getPackageId());
|
||||
existingTenant.setBusinessLicense(bo.getBusinessLicense());
|
||||
existingTenant.setAttachmentimg(bo.getAttachmentimg());
|
||||
existingTenant.setPromoteListimg(bo.getPromoteListimg());
|
||||
existingTenant.setAttachment(bo.getAttachment());
|
||||
existingTenant.setPromoteList(bo.getPromoteList());
|
||||
existingTenant.setExpireTime(bo.getExpireTime());
|
||||
existingTenant.setStoreName(bo.getStoreName());
|
||||
existingTenant.setCompanyType(bo.getCompanyType());
|
||||
existingTenant.setBusinessTypes(bo.getBusinessTypes());
|
||||
existingTenant.setRelatedimg(bo.getRelatedimg());
|
||||
existingTenant.setRelated(bo.getRelated());
|
||||
existingTenant.setContactUserName(bo.getContactUserName());
|
||||
existingTenant.setContactPhone(bo.getContactPhone());
|
||||
|
||||
@ -387,7 +383,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
// 5. 更新扩展表
|
||||
existingExtend.setIdCard(bo.getIdCard());
|
||||
existingExtend.setIdCardType(bo.getIdCardType());
|
||||
existingExtend.setCertificateimg(bo.getCertificateimg());
|
||||
existingExtend.setCertificate(bo.getCertificate());
|
||||
existingExtend.setPersonName(bo.getPersonName());
|
||||
existingExtend.setPersonPhone(bo.getPersonPhone());
|
||||
existingExtend.setBankType(bo.getBankType());
|
||||
@ -403,7 +399,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
existingExtend.setSplitRatio(bo.getSplitRatio());
|
||||
existingExtend.setSigner(bo.getSigner());
|
||||
existingExtend.setContractYear(bo.getContractYear());
|
||||
existingExtend.setContractAttachmentimg(bo.getContractAttachmentimg());
|
||||
existingExtend.setContractAttachment(bo.getContractAttachment());
|
||||
existingExtend.setSignStatus(bo.getSignStatus());
|
||||
|
||||
// 执行更新
|
||||
@ -641,4 +637,21 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
||||
return baseMapper.getById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean batchRemoveByIds(List<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
if (TenantConstants.SUPER_ADMIN_ROLE_KEY.equals(id.toString())) {
|
||||
throw new ServiceException("超级管理员租户不能删除");
|
||||
}
|
||||
}
|
||||
|
||||
int extendDeleteCount = baseMapper.batchDeleteTenantExtendByStoreIds(ids);
|
||||
int tenantDeleteCount = baseMapper.batchDeleteTenantByIds(ids);
|
||||
|
||||
return extendDeleteCount >= 0 && tenantDeleteCount >= 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -7,12 +7,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<select id="getlist" resultType="org.dromara.system.domain.dto.TenantDTO">
|
||||
SELECT
|
||||
t.*,
|
||||
e.*
|
||||
e.*,
|
||||
m.nickname AS inviteUserName
|
||||
FROM
|
||||
sys_tenant t
|
||||
LEFT JOIN
|
||||
sys_tenant_extend e ON t.tenant_id = e.tenant_id
|
||||
|
||||
LEFT JOIN
|
||||
ums_member m ON e.invite_user_id = m.id
|
||||
<where>
|
||||
<if test="query.tenantId != null and query.tenantId != ''">
|
||||
AND t.tenant_id LIKE CONCAT('%', #{query.tenantId}, '%')
|
||||
@ -39,6 +41,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
AND e.sign_status = #{query.signStatus}
|
||||
</if>
|
||||
</where>
|
||||
|
||||
</select>
|
||||
|
||||
<delete id="batchDeleteTenantExtendByStoreIds">
|
||||
DELETE FROM sys_tenant_extend
|
||||
WHERE store_id IN
|
||||
<foreach item="id" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="batchDeleteTenantByIds">
|
||||
DELETE FROM sys_tenant
|
||||
WHERE id IN
|
||||
<foreach item="id" index="index" collection="list" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
Loading…
x
Reference in New Issue
Block a user