|
|
@ -4,17 +4,22 @@ import cn.hutool.core.util.ArrayUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
|
import com.cloud.kicc.common.core.api.R; |
|
|
|
import com.cloud.kicc.common.core.api.R; |
|
|
|
import com.cloud.kicc.common.core.constant.AppConstants; |
|
|
|
import com.cloud.kicc.common.core.constant.AppConstants; |
|
|
|
import com.cloud.kicc.common.log.annotation.SysLog; |
|
|
|
import com.cloud.kicc.common.log.annotation.SysLog; |
|
|
|
|
|
|
|
import com.cloud.kicc.common.security.util.SecurityUtils; |
|
|
|
import com.cloud.kicc.system.api.entity.Tenant; |
|
|
|
import com.cloud.kicc.system.api.entity.Tenant; |
|
|
|
|
|
|
|
import com.cloud.kicc.system.api.entity.User; |
|
|
|
import com.cloud.kicc.system.service.TenantService; |
|
|
|
import com.cloud.kicc.system.service.TenantService; |
|
|
|
|
|
|
|
import com.cloud.kicc.system.service.UserService; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
*<p> |
|
|
|
*<p> |
|
|
@ -30,10 +35,10 @@ import java.util.Arrays; |
|
|
|
public class TenantController { |
|
|
|
public class TenantController { |
|
|
|
|
|
|
|
|
|
|
|
private final TenantService tenantService; |
|
|
|
private final TenantService tenantService; |
|
|
|
|
|
|
|
private final UserService userService; |
|
|
|
|
|
|
|
|
|
|
|
private LambdaQueryWrapper<Tenant> getQueryWrapper(Tenant tenant) { |
|
|
|
private LambdaQueryWrapper<Tenant> getQueryWrapper(Tenant tenant) { |
|
|
|
return new LambdaQueryWrapper<Tenant>() |
|
|
|
return new LambdaQueryWrapper<Tenant>() |
|
|
|
.in(ArrayUtil.isNotEmpty(tenant.getTenantIds()), Tenant::getCode, tenant.getTenantIds()) |
|
|
|
|
|
|
|
.like(StrUtil.isNotBlank(tenant.getName()), Tenant::getName, tenant.getName()) |
|
|
|
.like(StrUtil.isNotBlank(tenant.getName()), Tenant::getName, tenant.getName()) |
|
|
|
.eq(StrUtil.isNotBlank(tenant.getCode()), Tenant::getCode, tenant.getCode()) |
|
|
|
.eq(StrUtil.isNotBlank(tenant.getCode()), Tenant::getCode, tenant.getCode()) |
|
|
|
.eq(StrUtil.isNotBlank(tenant.getStatus()), Tenant::getStatus, tenant.getStatus()); |
|
|
|
.eq(StrUtil.isNotBlank(tenant.getStatus()), Tenant::getStatus, tenant.getStatus()); |
|
|
@ -46,6 +51,14 @@ public class TenantController { |
|
|
|
return R.ok(tenantPage.getRecords(), tenantPage.getTotal()); |
|
|
|
return R.ok(tenantPage.getRecords(), tenantPage.getTotal()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/currentUserTenantList") |
|
|
|
|
|
|
|
@PreAuthorize("@pms.hasPermission('tenant_view')") |
|
|
|
|
|
|
|
public R currentUserTenantList() { |
|
|
|
|
|
|
|
User user = userService.getCurrentUserInfo(); |
|
|
|
|
|
|
|
List<Tenant> tenantList = tenantService.list(Wrappers.<Tenant>query().lambda().in(Tenant::getId, StrUtil.split(",", user.getTenantId()))); |
|
|
|
|
|
|
|
return R.ok(tenantList); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/{id:\\w+}") |
|
|
|
@GetMapping("/{id:\\w+}") |
|
|
|
public R getById(@PathVariable("id") String id) { |
|
|
|
public R getById(@PathVariable("id") String id) { |
|
|
|
return R.ok(tenantService.getById(id)); |
|
|
|
return R.ok(tenantService.getById(id)); |
|
|
|