feat: 添加用户登录服务及JWT认证功能

refactor: 重构实体类并添加Lombok注解

docs: 更新数据库表结构文档

style: 清理无用代码并优化格式

fix: 修复用户详情服务中的联系方式更新方法

build: 更新pom.xml配置并添加Lombok插件

test: 添加用户登录测试用例

chore: 添加开发和生产环境配置文件
This commit is contained in:
qingfeng1121
2025-11-28 14:14:38 +08:00
parent 7536c8087e
commit 51086db30e
64 changed files with 6168 additions and 567 deletions

View File

@@ -0,0 +1,57 @@
// /*
// * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
// * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
// */
// package com.qf.backend.config;
// import org.springframework.context.annotation.Bean;
// import org.springframework.context.annotation.Configuration;
// import org.springframework.security.config.annotation.web.builders.HttpSecurity;
// import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
// import org.springframework.security.provisioning.InMemoryUserDetailsManager;
// import org.springframework.security.web.SecurityFilterChain;
// /**
// * 安全配置类(仅开发 禁用安全认证)
// *
// * @author 30803
// */
// @Configuration
// @EnableWebSecurity
// public class SecurityConfig {
// @Bean
// public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
// http
// .authorizeHttpRequests(auth -> auth
// .requestMatchers("/users/**").permitAll() // 公开路径
// .requestMatchers("/admin/**").hasRole("ADMIN") // 需要 ADMIN 角色
// .anyRequest().authenticated() // 其他请求需登录
// )
// .formLogin(form -> form
// .loginPage("/login") // 自定义登录页(可选)
// .permitAll()
// )
// .logout(logout -> logout
// .permitAll()
// );
// return http.build();
// }
// @Bean
// public UserDetailsService userDetailsService() {
// UserDetails user = User.withDefaultPasswordEncoder()
// .username("user")
// .password("123456")
// .roles("USER")
// .build();
// UserDetails admin = User.withDefaultPasswordEncoder()
// .username("admin")
// .password("admin123")
// .roles("USER", "ADMIN")
// .build();
// return new InMemoryUserDetailsManager(user, admin);
// }
// }

View File

@@ -0,0 +1,43 @@
// /*
// * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
// * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
// */
// package com.qf.backend.config;
// import org.springframework.beans.factory.annotation.Autowired;
// import org.springframework.security.core.userdetails.UserDetailsService;
// import org.springframework.stereotype.Component;
// import org.springframework.stereotype.Service;
// import org.springframework.security.core.userdetails.UserDetails;
// import org.springframework.security.core.userdetails.UsernameNotFoundException;
// import org.springframework.security.core.authority.AuthorityUtils;
// import com.qf.backend.mapper.UsersMapper;
// import com.qf.backend.entity.Users;
// import com.qf.backend.mapper.RolesMapper;
// /**
// * 自定义UserDetailsService
// * 用于从数据库加载用户信息进行认证
// * @author 30803
// */
// @Component
// public class UsersDetailsServiceConfig implements UserDetailsService {
// @Autowired
// private UsersMapper usersMapper;
// @Autowired
// private RolesMapper rolesMapper;
// @Override
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
// Users users = usersMapper.selectByUsername(username);
// if (users == null) {
// throw new UsernameNotFoundException("用户不存在"+username);
// }
// int roleType = rolesMapper.selectById(users.getId()).getRoleType();
// }
// }