Skip to content

Commit

Permalink
Merge pull request #343 from Jzow/master
Browse files Browse the repository at this point in the history
Add tenant management function
  • Loading branch information
Jzow authored Jun 26, 2024
2 parents 204bd45 + 9a2d047 commit 4ef92e9
Show file tree
Hide file tree
Showing 30 changed files with 1,222 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public Expression getTenantId() {
public boolean ignoreTable(String tableName) {
return "sys_user".equalsIgnoreCase(tableName) || "sys_menu".equalsIgnoreCase(tableName)
|| "sys_user_role_rel".equalsIgnoreCase(tableName) || "sys_user_dept_rel".equalsIgnoreCase(tableName)
|| "sys_role_menu_rel".equalsIgnoreCase(tableName) || "sys_platform_config".equalsIgnoreCase(tableName);
|| "sys_role_menu_rel".equalsIgnoreCase(tableName) || "sys_platform_config".equalsIgnoreCase(tableName)
|| "sys_tenant".equalsIgnoreCase(tableName);
}
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,49 @@
*/
package com.wansenai.api.tenant;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.tenant.AddOrUpdateTenantDTO;
import com.wansenai.dto.tenant.TenantListDTO;
import com.wansenai.service.tenant.ISysTenantService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.TenantInfoVO;
import org.springframework.web.bind.annotation.*;

/**
* <p>
* 租户 前端控制器
* </p>
*
* @author James Zow
* @since 2023-09-05
*/
@RestController
@RequestMapping("/sysTenant")
@RequestMapping("/tenant")
public class SysTenantController {

private final ISysTenantService tenantService;

public SysTenantController(ISysTenantService tenantService) {
this.tenantService = tenantService;
}

@PostMapping(value = "list")
public Response<Page<TenantInfoVO>> tenantList(@RequestBody TenantListDTO tenantListDTO) {
return tenantService.tenantList(tenantListDTO);
}

@PostMapping(value = "addOrUpdate")
public Response<String> addOrUpdate(@RequestBody AddOrUpdateTenantDTO addOrUpdateTenantDTO) {
return tenantService.addOrUpdate(addOrUpdateTenantDTO);
}

@GetMapping(value = "checkAddUser")
public Response<String> checkAddUser() {
return tenantService.checkAddUser();
}

@PostMapping(value= "update")
public Response<String> update(@RequestBody AddOrUpdateTenantDTO updateDTO) {
return tenantService.update(updateDTO);
}

@PostMapping(value = "delete")
public Response<String> delete(@RequestParam(value = "tenantId") String tenantId) {
return tenantService.delete(tenantId);
}
}
13 changes: 13 additions & 0 deletions core/api/src/main/resources/logback-spring.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@
<logger name="erp-api-logger" level="debug"/>
</springProfile>

<springProfile name="docker">
<logger name="erp-api-logger" level="debug"/>
</springProfile>

<root level="info">
<appender-ref ref="CONSOLE"/>
<appender-ref ref="DEBUG_FILE"/>
Expand All @@ -168,4 +172,13 @@
<!-- <appender-ref ref="WARN_FILE" />-->
<!-- </root>-->
<!-- </springProfile>-->
<springProfile name="docker">
<root level="info">
<appender-ref ref="CONSOLE" />
<appender-ref ref="DEBUG_FILE" />
<appender-ref ref="INFO_FILE" />
<appender-ref ref="ERROR_FILE" />
<appender-ref ref="WARN_FILE" />
</root>
</springProfile>
</configuration>
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* Copyright 2024-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.dto.tenant;

import com.wansenai.dto.user.AddOrUpdateUserDTO;
import lombok.Data;

import java.util.List;

@Data
public class AddOrUpdateTenantDTO {

private Long id;

private String tenantName;

private Integer userNumLimit;

private Integer type;

private Integer status;

private String remark;

private String expireTime;

private String phoneNumber;

private String username;

private String password;

private String email;

private List<Long> deptId;

private List<Long> roleId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright 2024-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.dto.tenant;

import lombok.Data;

@Data
public class TenantListDTO {

private String loginUser;

private String tenantName;

private Integer type;

private Integer status;

private Long page;

private Long pageSize;
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public class SysTenant implements Serializable {
*/
private Long tenantId;

/**
* 关联的用户id
*/
private Long userId;

/**
* 租户名称
*/
Expand All @@ -58,12 +63,12 @@ public class SysTenant implements Serializable {
/**
* 租户类型,0免费租户,1付费租户
*/
private Boolean type;
private Integer type;

/**
* 启用 0-禁用 1-启用
*/
private Boolean status;
private Integer status;

/**
* 备注
Expand Down
63 changes: 63 additions & 0 deletions core/domain/src/main/java/com/wansenai/vo/TenantInfoVO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* Copyright 2024-2033 WanSen AI Team, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance
* with the License. A copy of the License is located at
*
* http://opensource.wansenai.com/apache2.0/
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
* OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package com.wansenai.vo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Builder;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@Data
@Builder
@JsonInclude(JsonInclude.Include.NON_NULL)
public class TenantInfoVO {

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long id;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private Long tenantId;

private String tenantName;

private Integer userNumLimit;

private String phoneNumber;

private String username;

private String password;

private String email;

private Integer type;

private Integer status;

private String remark;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime createTime;

@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime expireTime;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private List<Long> roleId;

@JsonFormat(shape = JsonFormat.Shape.STRING)
private List<Long> deptId;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
*/
package com.wansenai.service.tenant;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wansenai.dto.tenant.AddOrUpdateTenantDTO;
import com.wansenai.dto.tenant.TenantListDTO;
import com.wansenai.entities.tenant.SysTenant;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wansenai.utils.response.Response;
import com.wansenai.vo.TenantInfoVO;

/**
* <p>
Expand All @@ -22,4 +27,15 @@
*/
public interface ISysTenantService extends IService<SysTenant> {

Response<Page<TenantInfoVO>> tenantList(TenantListDTO tenantListDTO);

Response<String> addOrUpdate(AddOrUpdateTenantDTO addOrUpdateTenantDTO);

Response<String> checkAddUser();

Boolean checkTenantExpire(Long tenantId);

Response<String> update(AddOrUpdateTenantDTO updateDTO);

Response<String> delete(String tenantId);
}
Loading

0 comments on commit 4ef92e9

Please sign in to comment.