update:多租户待定
parent
fa5e281317
commit
72dd4a9a0c
|
@ -1,13 +1,13 @@
|
|||
package cc.iotkit.data.system;
|
||||
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.model.system.SysUser;
|
||||
import cc.iotkit.model.system.SysTenant;
|
||||
|
||||
/**
|
||||
* 租户数据接口
|
||||
*
|
||||
* @author tfd
|
||||
*/
|
||||
public interface ISysTenantData extends ICommonData<SysUser, Long> {
|
||||
public interface ISysTenantData extends ICommonData<SysTenant, Long> {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.common.utils.StringUtils;
|
||||
import cc.iotkit.data.dao.SysTenantRepository;
|
||||
import cc.iotkit.data.model.TbSysTenant;
|
||||
import cc.iotkit.data.system.ISysTenantData;
|
||||
import cc.iotkit.model.system.SysUser;
|
||||
import cc.iotkit.data.util.PredicateBuilder;
|
||||
import cc.iotkit.model.system.SysTenant;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import static cc.iotkit.data.model.QTbSysTenant.tbSysTenant;
|
||||
|
||||
/**
|
||||
* @Author:tfd
|
||||
* @Date:2023/5/31 9:45
|
||||
|
@ -19,8 +28,51 @@ public class SysTenantDataImpl implements ISysTenantData {
|
|||
|
||||
private SysTenantRepository sysTenantRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
@Override
|
||||
public SysUser findById(Long aLong) {
|
||||
return MapstructUtils.convert(sysTenantRepository.findById(aLong),SysUser.class);
|
||||
public SysTenant findById(Long aLong) {
|
||||
return MapstructUtils.convert(sysTenantRepository.findById(aLong),SysTenant.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTenant save(SysTenant data) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchSave(List<SysTenant> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public long deleteById(Long aLong) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByIds(Collection<Long> longs) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysTenant> findAllByCondition(SysTenant data) {
|
||||
List<TbSysTenant> ret=jpaQueryFactory.selectFrom(tbSysTenant).where(PredicateBuilder.instance()
|
||||
.and(StringUtils.isNotBlank(data.getTenantId()),()->tbSysTenant.tenantId.eq(data.getTenantId()))
|
||||
.and(StringUtils.isNotBlank(data.getContactUserName()),()->tbSysTenant.contactUserName.like(data.getContactUserName()))
|
||||
.and(StringUtils.isNotBlank(data.getContactPhone()),()->tbSysTenant.contactPhone.eq(data.getContactPhone()))
|
||||
.and(StringUtils.isNotBlank(data.getCompanyName()),()->tbSysTenant.companyName.like(data.getCompanyName()))
|
||||
.and(StringUtils.isNotBlank(data.getLicenseNumber()),()->tbSysTenant.licenseNumber.eq(data.getLicenseNumber()))
|
||||
.and(StringUtils.isNotBlank(data.getAddress()),()->tbSysTenant.address.eq(data.getAddress()))
|
||||
.and(StringUtils.isNotBlank(data.getIntro()),()->tbSysTenant.intro.eq(data.getIntro()))
|
||||
.and(StringUtils.isNotBlank(data.getDomain()),()->tbSysTenant.domain.like(data.getDomain()))
|
||||
.and(data.getPackageId() != null,()->tbSysTenant.packageId.eq(data.getPackageId()))
|
||||
.and(data.getExpireTime() != null,()->tbSysTenant.expireTime.eq(data.getExpireTime()))
|
||||
.and(data.getAccountCount() != null,()->tbSysTenant.accountCount.eq(data.getAccountCount()))
|
||||
.and(StringUtils.isNotBlank(data.getStatus()),()->tbSysTenant.status.eq(data.getStatus()))
|
||||
.build()).fetch();
|
||||
return MapstructUtils.convert(ret, SysTenant.class);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package cc.iotkit.system.controller;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.constant.TenantConstants;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.constant.TenantConstants;
|
||||
import cc.iotkit.common.excel.utils.ExcelUtil;
|
||||
import cc.iotkit.common.log.annotation.Log;
|
||||
import cc.iotkit.common.log.enums.BusinessType;
|
||||
|
@ -12,23 +12,18 @@ import cc.iotkit.common.validate.EditGroup;
|
|||
import cc.iotkit.common.web.core.BaseController;
|
||||
import cc.iotkit.system.dto.bo.SysTenantBo;
|
||||
import cc.iotkit.system.dto.vo.SysTenantVo;
|
||||
import cc.iotkit.system.service.ISysTenantService;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaCheckRole;
|
||||
import com.baomidou.lock.annotation.Lock4j;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import cc.iotkit.system.service.ISysTenantService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
@ -42,6 +37,7 @@ import java.util.List;
|
|||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/system/tenant")
|
||||
@Api(tags = "租户管理")
|
||||
public class SysTenantController extends BaseController {
|
||||
|
||||
private final ISysTenantService tenantService;
|
||||
|
@ -49,9 +45,10 @@ public class SysTenantController extends BaseController {
|
|||
/**
|
||||
* 查询租户列表
|
||||
*/
|
||||
@ApiOperation("查询租户列表")
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:list")
|
||||
@GetMapping("/list")
|
||||
@PostMapping("/list")
|
||||
public Paging<SysTenantVo> list(SysTenantBo bo, PageRequest<?> query) {
|
||||
return tenantService.queryPageList(bo, query);
|
||||
}
|
||||
|
@ -59,6 +56,7 @@ public class SysTenantController extends BaseController {
|
|||
/**
|
||||
* 导出租户列表
|
||||
*/
|
||||
@ApiOperation("导出租户列表")
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:export")
|
||||
@Log(title = "租户", businessType = BusinessType.EXPORT)
|
||||
|
@ -73,6 +71,7 @@ public class SysTenantController extends BaseController {
|
|||
*
|
||||
* @param id 主键
|
||||
*/
|
||||
@ApiOperation("获取租户详细信息")
|
||||
@SaCheckRole(TenantConstants.SUPER_ADMIN_ROLE_KEY)
|
||||
@SaCheckPermission("system:tenant:query")
|
||||
@GetMapping("/{id}")
|
||||
|
|
|
@ -7,6 +7,7 @@ import cc.iotkit.common.utils.MapstructUtils;
|
|||
import cc.iotkit.common.utils.SpringUtils;
|
||||
import cc.iotkit.data.system.ISysTenantData;
|
||||
import cc.iotkit.data.system.ISysUserData;
|
||||
import cc.iotkit.model.system.SysTenant;
|
||||
import cc.iotkit.system.dto.bo.SysTenantBo;
|
||||
import cc.iotkit.system.dto.vo.SysTenantVo;
|
||||
import cc.iotkit.system.service.ISysTenantService;
|
||||
|
@ -32,7 +33,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
|||
|
||||
@Override
|
||||
public SysTenantVo queryById(Long id) {
|
||||
return null;
|
||||
return sysTenantData.findById(id).to(SysTenantVo.class);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +52,7 @@ public class SysTenantServiceImpl implements ISysTenantService {
|
|||
|
||||
@Override
|
||||
public List<SysTenantVo> queryList(SysTenantBo bo) {
|
||||
return null;
|
||||
return MapstructUtils.convert(sysTenantData.findAllByCondition(bo.to(SysTenant.class)),SysTenantVo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue