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

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