文件名修正
This commit is contained in:
@ -6,7 +6,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
|
||||
@Configuration
|
||||
public class AppConfig {
|
||||
public class SecurityConfig {
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
@ -25,10 +25,6 @@ public class LoginController {
|
||||
public String getStatusByNameOrEmail() {
|
||||
String input="aaa";
|
||||
|
||||
// input 可能是名字 或 email
|
||||
UserEntity userByName = userService.getNameByEntity(input);
|
||||
UserEntity userByEmail = userService.getEmailByEntity(input);
|
||||
|
||||
if (userByName == null && userByEmail == null) {
|
||||
return "全項目に入力してください";
|
||||
}
|
||||
|
@ -1,23 +1,34 @@
|
||||
package co.jp.app.entity;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.*;
|
||||
|
||||
@Entity
|
||||
|
||||
public class UserEntity {
|
||||
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
private int ID;
|
||||
private int id;
|
||||
|
||||
private String name;
|
||||
|
||||
@Column(unique = true, nullable = false)
|
||||
private String email;
|
||||
|
||||
@Column(nullable = false)
|
||||
private String password;
|
||||
|
||||
public UserEntity() {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
@ -34,14 +45,6 @@ public class UserEntity {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public int getID() {
|
||||
return ID;
|
||||
}
|
||||
|
||||
public void setID(int iD) {
|
||||
ID = iD;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
@ -12,4 +12,4 @@ public interface ErraRepository extends JpaRepository<ErrorEntity, Integer>{
|
||||
public default ErrorEntity getById(@Param("id") int id) {
|
||||
return getById(id);
|
||||
}
|
||||
}
|
||||
}
|
@ -7,10 +7,12 @@ import org.springframework.data.repository.query.Param;
|
||||
import co.jp.app.entity.UserEntity;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends JpaRepository<UserEntity, Integer> {
|
||||
|
||||
UserEntity getUserByEmail(@Param("email") String email);
|
||||
|
||||
boolean existsByEmail(String email);
|
||||
|
||||
Optional<UserEntity> findByEmail(String email);
|
||||
}
|
@ -4,16 +4,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import co.jp.app.entity.ErrorEntity;
|
||||
import co.jp.app.repository.erraRepository;
|
||||
import co.jp.app.repository.ErraRepository;
|
||||
|
||||
|
||||
@Service
|
||||
public class ErraService {
|
||||
|
||||
@Autowired
|
||||
erraRepository erraDao;
|
||||
ErraRepository erraRepository;
|
||||
|
||||
public ErrorEntity getStatusById(int id) {
|
||||
return erraDao.getById(id);
|
||||
return erraRepository.getById(id);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package co.jp.app.service;
|
||||
|
||||
import jakarta.transaction.Transactional;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import co.jp.app.entity.UserEntity;
|
||||
@ -11,12 +13,11 @@ import co.jp.app.repository.UserRepository;
|
||||
public class UserService {
|
||||
|
||||
private final UserRepository userEntityRepository;
|
||||
// private final PasswordEncoder passwordEncoder; // 注入密码编码器
|
||||
|
||||
@Autowired
|
||||
public UserService(UserRepository userEntityRepository /*, PasswordEncoder passwordEncoder */) {
|
||||
public UserService(UserRepository userEntityRepository, PasswordEncoder passwordEncoder ) {
|
||||
this.userEntityRepository = userEntityRepository;
|
||||
// this.passwordEncoder = passwordEncoder;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
@Transactional // 整个注册过程应该是一个事务
|
||||
|
Reference in New Issue
Block a user