文件名修正

This commit is contained in:
2025-05-08 11:26:28 +09:00
parent 011821c6be
commit 55997855f6
7 changed files with 29 additions and 27 deletions

View File

@ -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() {

View File

@ -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 "全項目に入力してください";
}

View File

@ -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;
}

View File

@ -12,4 +12,4 @@ public interface ErraRepository extends JpaRepository<ErrorEntity, Integer>{
public default ErrorEntity getById(@Param("id") int id) {
return getById(id);
}
}
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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 // 整个注册过程应该是一个事务