新增:添加租户接口(去掉权限)

This commit is contained in:
2025-01-20 23:43:40 +08:00
parent 294c2febda
commit f78b7fee47

View File

@@ -47,6 +47,8 @@ public class TenantController extends BaseController {
private CompanyService companyService; private CompanyService companyService;
@Resource @Resource
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Resource
private UserService userService;
@ApiOperation("分页查询租户") @ApiOperation("分页查询租户")
@GetMapping("/page") @GetMapping("/page")
@@ -189,23 +191,30 @@ public class TenantController extends BaseController {
@ApiOperation("创建租户") @ApiOperation("创建租户")
@PostMapping("/saveByPhone") @PostMapping("/saveByPhone")
public ApiResult<?> saveByPhone(@RequestBody Tenant tenant) { public ApiResult<?> saveByPhone(@RequestBody Tenant tenant) {
if (tenantService.count(new LambdaQueryWrapper<Tenant>().eq(Tenant::getTenantCode, tenant.getPhone())) > 0) { final String phone = tenant.getPhone();
return fail("租户编号已存在"); if(tenant.getTenantName() == null){
return null;
}
if(tenant.getTenantCode() == null){
return null;
}
if (tenantService.count(new LambdaQueryWrapper<Tenant>().eq(Tenant::getTenantCode, phone)) > 0) {
return null;
} }
if (tenantService.save(tenant)) { if (tenantService.save(tenant)) {
// 租户初始化 // 租户初始化
final Company company = new Company(); final Company company = new Company();
company.setDomain(tenant.getTenantId().toString().concat(".websoft.top")); company.setDomain(tenant.getTenantId().toString().concat(".websoft.top"));
company.setEmail(""); company.setPhone(phone);
company.setPhone(tenant.getPhone()); company.setEmail(null);
company.setPassword(""); company.setPassword(userService.encodePassword(phone));
company.setTid(tenant.getTenantId()); company.setTid(tenant.getTenantId());
company.setCompanyName(tenant.getTenantName()); company.setCompanyName(tenant.getTenantName());
company.setShortName(tenant.getTenantName()); company.setShortName(tenant.getTenantName());
company.setTenantId(tenant.getTenantId()); company.setTenantId(tenant.getTenantId());
tenantService.initialization(company); tenantService.initialization(company);
return success("添加成功",tenant); return success("创建成功");
} }
return fail("添加失败"); return null;
} }
} }