外键约束

This commit is contained in:
高子兴 2024-07-05 20:21:27 +08:00
parent ffa9189583
commit ba638747df
3 changed files with 12 additions and 9 deletions

View File

@ -24,8 +24,7 @@ public class TenantManagementController {
@CrossOrigin(origins = "http://localhost:5173") @CrossOrigin(origins = "http://localhost:5173")
@GetMapping("/getAllTenant") @GetMapping("/getAllTenant")
public List<Tenant> getAll() { public List<Tenant> getAll() {
List<Tenant> tenantList=tenantManagementService.findAll(); return tenantManagementService.findAll();
return tenantList;
} }
@CrossOrigin(origins = "http://localhost:5173") @CrossOrigin(origins = "http://localhost:5173")

View File

@ -4,6 +4,7 @@ package org.cmh.backend.UserManagement.model;
import jakarta.persistence.*; import jakarta.persistence.*;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import org.cmh.backend.authentication.model.UserHS;
@Entity @Entity
@Getter @Getter
@ -13,9 +14,13 @@ public class Tenant {
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
private String contact; private String contact; // 联系人
private String phone; private String phone; // 联系人电话
private String name; private String name; // 租户名称
private String manager; private String manager; // 租户管理员
private String symbol;
@OneToOne
@JoinColumn(name = "manager", referencedColumnName = "username", insertable = false, updatable = false)
private UserHS managerEntity; // 租户管理员对象
private String symbol; // 租户标识
} }

View File

@ -13,8 +13,7 @@ public class TenantManagementService {
private TenantManagementRepository tenantManagementRepository; private TenantManagementRepository tenantManagementRepository;
public Tenant registerTenant(Tenant tenant) { public Tenant registerTenant(Tenant tenant) {
Tenant savedTenant = tenantManagementRepository.save(tenant); return tenantManagementRepository.save(tenant);
return savedTenant;
} }
public List<Tenant> findAll(){ public List<Tenant> findAll(){