recovery
This commit is contained in:
parent
aa8ca4e274
commit
7a6d2b5c4b
@ -3,6 +3,7 @@ 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.service.TenantManagementService;
|
||||||
|
import org.cmh.backend.authentication.model.User;
|
||||||
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;
|
||||||
@ -38,10 +39,8 @@ public class TenantManagementController {
|
|||||||
@CrossOrigin(origins = "http://localhost:5173")
|
@CrossOrigin(origins = "http://localhost:5173")
|
||||||
@PostMapping("/deleteTenant")
|
@PostMapping("/deleteTenant")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean delete(@RequestBody Tenant tenant) {
|
public void delete(@RequestBody User user) {
|
||||||
System.out.println(tenant);
|
tenantManagementService.delete(user.getId());
|
||||||
tenantManagementService.delete(tenant.getName());
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,10 +42,9 @@ public class UserManagementController {
|
|||||||
@CrossOrigin(origins = "http://localhost:5173")
|
@CrossOrigin(origins = "http://localhost:5173")
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
@Transactional
|
@Transactional
|
||||||
public boolean delete(@RequestBody User user) {
|
public void delete(@RequestBody User user) {
|
||||||
System.out.println(user);
|
System.out.println(user);
|
||||||
userManagementService.delete(user.getAccount());
|
userManagementService.delete(user.getId());
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,4 +12,6 @@ public interface TenantManagementRepository extends JpaRepository<Tenant, Long>{
|
|||||||
Tenant findTenantById(Long id);
|
Tenant findTenantById(Long id);
|
||||||
|
|
||||||
Tenant deleteByName(String Name);
|
Tenant deleteByName(String Name);
|
||||||
|
|
||||||
|
void deleteById(Long id);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,4 +19,6 @@ public interface UserManagementRepository extends JpaRepository<User, Long> {
|
|||||||
|
|
||||||
User deleteByAccount(String account);
|
User deleteByAccount(String account);
|
||||||
|
|
||||||
|
void deleteById(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,4 +24,6 @@ public class TenantManagementService {
|
|||||||
public Tenant update(Tenant tenant){return tenantManagementRepository.save(tenant);}
|
public Tenant update(Tenant tenant){return tenantManagementRepository.save(tenant);}
|
||||||
|
|
||||||
public Tenant delete(String name){return tenantManagementRepository.deleteByName(name);}
|
public Tenant delete(String name){return tenantManagementRepository.deleteByName(name);}
|
||||||
|
|
||||||
|
public void delete(Long id){tenantManagementRepository.deleteById(id);}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,6 @@ public class UserManagementService {
|
|||||||
|
|
||||||
public User update(User user){return userManagementRepository.save(user);}
|
public User update(User user){return userManagementRepository.save(user);}
|
||||||
|
|
||||||
public User delete(String account){return userManagementRepository.deleteByAccount(account);}
|
public void delete(Long id){userManagementRepository.deleteById(id);}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import static org.springframework.http.ResponseEntity.ok;
|
|||||||
@RestController
|
@RestController
|
||||||
public class UserController {
|
public class UserController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
@CrossOrigin(origins = "http://localhost:5173")
|
@CrossOrigin(origins = "http://localhost:5173")
|
||||||
@PostMapping("/checkLogin")
|
@PostMapping("/checkLogin")
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user