为了区分于服务器中现有的类,修改了User类名
This commit is contained in:
parent
4f132490c6
commit
2ada18d2af
@ -1,6 +1,6 @@
|
||||
package org.cmh.backend.authentication.controller;
|
||||
|
||||
import org.cmh.backend.authentication.model.User;
|
||||
import org.cmh.backend.authentication.model.UserHS;
|
||||
import org.cmh.backend.authentication.service.UserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@ -16,8 +16,8 @@ public class UserController {
|
||||
private UserService userService;
|
||||
|
||||
@GetMapping("/{username}")
|
||||
public ResponseEntity<User> getUser(@PathVariable String username) {
|
||||
User user = userService.getUserByUsername(username);
|
||||
public ResponseEntity<UserHS> getUser(@PathVariable String username) {
|
||||
UserHS user = userService.getUserByUsername(username);
|
||||
return ResponseEntity.ok(user);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
package org.cmh.backend.authentication.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
|
||||
@Entity
|
||||
public class User {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
package org.cmh.backend.authentication.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@Entity
|
||||
public class UserHS {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
private String username;
|
||||
private String password;
|
||||
private String nickname;
|
||||
private String gender;
|
||||
private String phoneNumber;
|
||||
private String email;
|
||||
private String department;
|
||||
private String role;
|
||||
private LocalDateTime createdAt;
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
package org.cmh.backend.authentication.repository;
|
||||
|
||||
import org.cmh.backend.authentication.model.User;
|
||||
import org.cmh.backend.authentication.model.UserHS;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
public interface UserRepository extends JpaRepository<User, Long> {
|
||||
User findByUsername(String username);
|
||||
public interface UserRepository extends JpaRepository<UserHS, Long> {
|
||||
UserHS findByUsername(String username);
|
||||
}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package org.cmh.backend.authentication.service;
|
||||
|
||||
import org.cmh.backend.authentication.model.User;
|
||||
import org.cmh.backend.authentication.model.UserHS;
|
||||
import org.cmh.backend.authentication.repository.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -10,7 +10,7 @@ public class UserService {
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
public User getUserByUsername(String username) {
|
||||
public UserHS getUserByUsername(String username) {
|
||||
return userRepository.findByUsername(username);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user