Merge remote-tracking branch 'origin/merge/1' into merge/1

# Conflicts:
#	src/main/java/org/cmh/backend/UserManagement/controller/UserManagementController.java
This commit is contained in:
MiLla 2024-07-05 23:39:31 +08:00
commit 83d6713e93
3 changed files with 7 additions and 14 deletions

View File

@ -1,16 +1,12 @@
package org.cmh.backend.OrganizationManagement.controller; package org.cmh.backend.OrganizationManagement.controller;
import org.aspectj.weaver.ast.Or;
import org.cmh.backend.OrganizationManagement.model.Organization; import org.cmh.backend.OrganizationManagement.model.Organization;
import org.cmh.backend.OrganizationManagement.service.OrganizationService; import org.cmh.backend.OrganizationManagement.service.OrganizationService;
import org.cmh.backend.authentication.model.User;
import org.cmh.backend.authentication.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -33,14 +29,14 @@ public class OrganizationController {
@PostMapping("/addOrganization") @PostMapping("/addOrganization")
public Organization add(@RequestBody Map<String, String> credentials) { public Organization add(@RequestBody Map<String, String> credentials) {
Organization organization = new Organization(); Organization organization = new Organization();
if(credentials.get("organizationId") != null){ if (credentials.get("organizationId") != null) {
organization.setOrganizationId(Long.parseLong(credentials.get("organizationId"))); organization.setOrganizationId(Long.parseLong(credentials.get("organizationId")));
} }
organization.setOrganizationName(credentials.get("organizationName")); organization.setOrganizationName(credentials.get("organizationName"));
organization.setOrganizationStatus(Boolean.parseBoolean(credentials.get("organizationStatus"))); organization.setOrganizationStatus(Boolean.parseBoolean(credentials.get("organizationStatus")));
if(Integer.parseInt(credentials.get("parentOrganization")) != 0){ if (Integer.parseInt(credentials.get("parentOrganization")) != 0) {
organization.setParentOrganization(organizationService.getById(Long.parseLong(credentials.get("parentOrganization")))); organization.setParentOrganization(organizationService.getById(Long.parseLong(credentials.get("parentOrganization"))));
}else{ } else {
organization.setParentOrganization(null); organization.setParentOrganization(null);
} }
organization.setEmail(credentials.get("email")); organization.setEmail(credentials.get("email"));

View File

@ -2,32 +2,31 @@ package org.cmh.backend.UserManagement.controller;
import jakarta.transaction.Transactional; import jakarta.transaction.Transactional;
import org.cmh.backend.UserManagement.model.Tenant; import org.cmh.backend.UserManagement.model.Tenant;
import org.cmh.backend.UserManagement.service.TenantManagementService;
import org.cmh.backend.UserManagement.model.User; import org.cmh.backend.UserManagement.model.User;
import org.cmh.backend.UserManagement.service.TenantManagementService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("/tenant")
public class TenantManagementController { public class TenantManagementController {
@Autowired @Autowired
private TenantManagementService tenantManagementService; private TenantManagementService tenantManagementService;
@CrossOrigin(origins = "http://localhost:5173")
@PostMapping("/addTenant") @PostMapping("/addTenant")
public Tenant addTenant(@RequestBody Tenant tenant) { public Tenant addTenant(@RequestBody Tenant tenant) {
Tenant tenant1=tenantManagementService.registerTenant(tenant); Tenant tenant1 = tenantManagementService.registerTenant(tenant);
System.out.println(tenant.toString()); System.out.println(tenant.toString());
return tenant1; return tenant1;
} }
@CrossOrigin(origins = "http://localhost:5173")
@GetMapping("/getAllTenant") @GetMapping("/getAllTenant")
public List<Tenant> getAll() { public List<Tenant> getAll() {
return tenantManagementService.findAll(); return tenantManagementService.findAll();
} }
@CrossOrigin(origins = "http://localhost:5173")
@PostMapping("/updateTenant") @PostMapping("/updateTenant")
public Tenant update(@RequestBody Tenant tenant) { public Tenant update(@RequestBody Tenant tenant) {
System.out.println(tenant); System.out.println(tenant);
@ -35,7 +34,6 @@ public class TenantManagementController {
return tenant; return tenant;
} }
@CrossOrigin(origins = "http://localhost:5173")
@PostMapping("/deleteTenant") @PostMapping("/deleteTenant")
@Transactional @Transactional
public void delete(@RequestBody User user) { public void delete(@RequestBody User user) {

View File

@ -34,7 +34,6 @@ public class User {
this.gender = gender; this.gender = gender;
this.email = email; this.email = email;
this.phone = phone; this.phone = phone;
} }
@Override @Override