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