Compare commits
4 Commits
cdc1cefd85
...
a57b4be921
| Author | SHA1 | Date | |
|---|---|---|---|
| a57b4be921 | |||
| fca88ffd68 | |||
| 2f57ff6a4c | |||
| ac677f1728 |
@ -1,16 +1,12 @@
|
||||
package org.cmh.backend.OrganizationManagement.controller;
|
||||
|
||||
import org.aspectj.weaver.ast.Or;
|
||||
import org.cmh.backend.OrganizationManagement.model.Organization;
|
||||
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.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -33,14 +29,14 @@ public class OrganizationController {
|
||||
@PostMapping("/addOrganization")
|
||||
public Organization add(@RequestBody Map<String, String> credentials) {
|
||||
Organization organization = new Organization();
|
||||
if(credentials.get("organizationId") != null){
|
||||
if (credentials.get("organizationId") != null) {
|
||||
organization.setOrganizationId(Long.parseLong(credentials.get("organizationId")));
|
||||
}
|
||||
organization.setOrganizationName(credentials.get("organizationName"));
|
||||
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"))));
|
||||
}else{
|
||||
} else {
|
||||
organization.setParentOrganization(null);
|
||||
}
|
||||
organization.setEmail(credentials.get("email"));
|
||||
|
||||
@ -2,32 +2,31 @@ package org.cmh.backend.UserManagement.controller;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
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.service.TenantManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/tenant")
|
||||
public class TenantManagementController {
|
||||
@Autowired
|
||||
private TenantManagementService tenantManagementService;
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@PostMapping("/addTenant")
|
||||
public Tenant addTenant(@RequestBody Tenant tenant) {
|
||||
Tenant tenant1=tenantManagementService.registerTenant(tenant);
|
||||
Tenant tenant1 = tenantManagementService.registerTenant(tenant);
|
||||
System.out.println(tenant.toString());
|
||||
return tenant1;
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@GetMapping("/getAllTenant")
|
||||
public List<Tenant> getAll() {
|
||||
return tenantManagementService.findAll();
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@PostMapping("/updateTenant")
|
||||
public Tenant update(@RequestBody Tenant tenant) {
|
||||
System.out.println(tenant);
|
||||
@ -35,7 +34,6 @@ public class TenantManagementController {
|
||||
return tenant;
|
||||
}
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@PostMapping("/deleteTenant")
|
||||
@Transactional
|
||||
public void delete(@RequestBody User user) {
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
package org.cmh.backend.UserManagement.controller;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.cmh.backend.UserManagement.service.UserManagementService;
|
||||
import org.cmh.backend.UserManagement.model.User;
|
||||
import org.cmh.backend.UserManagement.service.UserManagementService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/user")
|
||||
public class UserManagementController {
|
||||
@Autowired
|
||||
private UserManagementService userManagementService;
|
||||
@ -15,11 +18,11 @@ public class UserManagementController {
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@PostMapping("/addUser")
|
||||
public User addUser(@RequestBody User user) {
|
||||
User user1=userManagementService.registerUser(user);
|
||||
if(user1 != null){
|
||||
User user1 = userManagementService.registerUser(user);
|
||||
if (user1 != null) {
|
||||
System.out.println(user1);
|
||||
return user1;
|
||||
}else{
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -27,7 +30,7 @@ public class UserManagementController {
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@GetMapping("/getAll")
|
||||
public List<User> getAll() {
|
||||
List<User> userList=userManagementService.findAll();
|
||||
List<User> userList = userManagementService.findAll();
|
||||
return userList;
|
||||
}
|
||||
|
||||
@ -42,9 +45,15 @@ public class UserManagementController {
|
||||
@CrossOrigin(origins = "http://localhost:5173")
|
||||
@PostMapping("/delete")
|
||||
@Transactional
|
||||
public void delete(@RequestBody User user) {
|
||||
public ResponseEntity<String> delete(@RequestBody User user) {
|
||||
System.out.println(user);
|
||||
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;
|
||||
|
||||
@Entity
|
||||
@Setter
|
||||
@Getter
|
||||
public class User {
|
||||
@Setter
|
||||
@Getter
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
@Setter
|
||||
@Getter
|
||||
private String account;
|
||||
@Setter
|
||||
@Getter
|
||||
private String password;
|
||||
@Setter
|
||||
@Getter
|
||||
private String name;
|
||||
@Getter
|
||||
@Setter
|
||||
private String organization;
|
||||
@Setter
|
||||
@Getter
|
||||
private String gender;
|
||||
@Setter
|
||||
@Getter
|
||||
private String email;
|
||||
@Getter
|
||||
@Setter
|
||||
private String phone;
|
||||
|
||||
public User() {
|
||||
@ -48,7 +34,6 @@ public class User {
|
||||
this.gender = gender;
|
||||
this.email = email;
|
||||
this.phone = phone;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
Reference in New Issue
Block a user