Compare commits
4 Commits
cdc1cefd85
...
a57b4be921
| Author | SHA1 | Date | |
|---|---|---|---|
| a57b4be921 | |||
| fca88ffd68 | |||
| 2f57ff6a4c | |||
| ac677f1728 |
@ -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"));
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
@ -1,13 +1,16 @@
|
|||||||
package org.cmh.backend.UserManagement.controller;
|
package org.cmh.backend.UserManagement.controller;
|
||||||
|
|
||||||
import jakarta.transaction.Transactional;
|
import jakarta.transaction.Transactional;
|
||||||
import org.cmh.backend.UserManagement.service.UserManagementService;
|
|
||||||
import org.cmh.backend.UserManagement.model.User;
|
import org.cmh.backend.UserManagement.model.User;
|
||||||
|
import org.cmh.backend.UserManagement.service.UserManagementService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
|
@RequestMapping("/user")
|
||||||
public class UserManagementController {
|
public class UserManagementController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserManagementService userManagementService;
|
private UserManagementService userManagementService;
|
||||||
@ -15,11 +18,11 @@ public class UserManagementController {
|
|||||||
@CrossOrigin(origins = "http://localhost:5173")
|
@CrossOrigin(origins = "http://localhost:5173")
|
||||||
@PostMapping("/addUser")
|
@PostMapping("/addUser")
|
||||||
public User addUser(@RequestBody User user) {
|
public User addUser(@RequestBody User user) {
|
||||||
User user1=userManagementService.registerUser(user);
|
User user1 = userManagementService.registerUser(user);
|
||||||
if(user1 != null){
|
if (user1 != null) {
|
||||||
System.out.println(user1);
|
System.out.println(user1);
|
||||||
return user1;
|
return user1;
|
||||||
}else{
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,7 +30,7 @@ public class UserManagementController {
|
|||||||
@CrossOrigin(origins = "http://localhost:5173")
|
@CrossOrigin(origins = "http://localhost:5173")
|
||||||
@GetMapping("/getAll")
|
@GetMapping("/getAll")
|
||||||
public List<User> getAll() {
|
public List<User> getAll() {
|
||||||
List<User> userList=userManagementService.findAll();
|
List<User> userList = userManagementService.findAll();
|
||||||
return userList;
|
return userList;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,9 +45,15 @@ public class UserManagementController {
|
|||||||
@CrossOrigin(origins = "http://localhost:5173")
|
@CrossOrigin(origins = "http://localhost:5173")
|
||||||
@PostMapping("/delete")
|
@PostMapping("/delete")
|
||||||
@Transactional
|
@Transactional
|
||||||
public void delete(@RequestBody User user) {
|
public ResponseEntity<String> delete(@RequestBody User user) {
|
||||||
System.out.println(user);
|
System.out.println(user);
|
||||||
userManagementService.delete(user.getId());
|
try{
|
||||||
|
userManagementService.delete(user.getId());
|
||||||
|
return ResponseEntity.ok("请求成功");
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
return ResponseEntity.badRequest().body("删除失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,32 +8,18 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
@Entity
|
@Entity
|
||||||
|
@Setter
|
||||||
|
@Getter
|
||||||
public class User {
|
public class User {
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Long id;
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private String account;
|
private String account;
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private String password;
|
private String password;
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private String name;
|
private String name;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String organization;
|
private String organization;
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private String gender;
|
private String gender;
|
||||||
@Setter
|
|
||||||
@Getter
|
|
||||||
private String email;
|
private String email;
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
public User() {
|
public User() {
|
||||||
@ -48,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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user