You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
4.6 KiB
Java
104 lines
4.6 KiB
Java
|
1 month ago
|
//package com.sztzjy.blockchainsmartclaim.config.security;
|
||
|
|
//
|
||
|
|
//
|
||
|
|
////import cn.hutool.core.convert.Convert;
|
||
|
|
////import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||
|
|
////import com.sztzjy.blockchainsmartclaim.entity.StuUserAi;
|
||
|
|
////import com.sztzjy.blockchainsmartclaim.mapper.StuUserAiMapper;
|
||
|
|
////import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
////import org.springframework.security.core.userdetails.UserDetails;
|
||
|
|
////import org.springframework.security.core.userdetails.UserDetailsService;
|
||
|
|
////import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||
|
|
////import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||
|
|
////import org.springframework.stereotype.Service;
|
||
|
|
////import org.springframework.util.ObjectUtils;
|
||
|
|
////
|
||
|
|
////@Service
|
||
|
|
////public class AuthenticationService implements UserDetailsService {
|
||
|
|
////
|
||
|
|
////
|
||
|
|
//// @Autowired
|
||
|
|
//// StuUserAiMapper userAiMapper;
|
||
|
|
////
|
||
|
|
////
|
||
|
|
////
|
||
|
|
//// @Override
|
||
|
|
//// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||
|
|
////
|
||
|
|
//// LambdaQueryWrapper<StuUserAi> queryWrapper = new LambdaQueryWrapper<>();
|
||
|
|
//// queryWrapper.eq(StuUserAi::getStudentId,username);
|
||
|
|
//// StuUserAi userinfo = userAiMapper.selectOne(queryWrapper);
|
||
|
|
////
|
||
|
|
////
|
||
|
|
//// if (ObjectUtils.isEmpty(userinfo)) {
|
||
|
|
//// throw new UsernameNotFoundException(username);
|
||
|
|
//// }
|
||
|
|
////
|
||
|
|
//// JwtUser jwtUser = new JwtUser();
|
||
|
|
//// jwtUser.setUsername(userinfo.getStudentId());
|
||
|
|
//// jwtUser.setCollegeId(Convert.toInt(userinfo.getSchoolId()));
|
||
|
|
//// jwtUser.setClassId(Convert.toInt(userinfo.getClassId()));
|
||
|
|
//// jwtUser.setPassword(new BCryptPasswordEncoder().encode(userinfo.getPassword())); //不加密会报错Encoded password does not look like BCrypt
|
||
|
|
//// jwtUser.setUserId(userinfo.getUserId());
|
||
|
|
//// jwtUser.setName(userinfo.getName());
|
||
|
|
//// jwtUser.setRoleId(userinfo.getRoleId());
|
||
|
|
//// jwtUser.setStudentId(userinfo.getStudentId());
|
||
|
|
//// jwtUser.setSchoolId(Convert.toInt(userinfo.getSchoolId()));
|
||
|
|
//// jwtUser.setSchoolName(userinfo.getSchoolName());
|
||
|
|
//// jwtUser.setClassName(userinfo.getClassName());
|
||
|
|
//// return jwtUser;
|
||
|
|
//// }
|
||
|
|
////
|
||
|
|
////}
|
||
|
|
//
|
||
|
|
//import cn.hutool.core.convert.Convert;
|
||
|
|
//import com.sztzjy.blockchainsmartclaim.entity.UsersInfo;
|
||
|
|
//import com.sztzjy.blockchainsmartclaim.entity.UsersInfoExample;
|
||
|
|
//import com.sztzjy.blockchainsmartclaim.mapper.UsersInfoMapper;
|
||
|
|
//import io.jsonwebtoken.lang.Assert;
|
||
|
|
//import org.springframework.beans.factory.annotation.Autowired;
|
||
|
|
//import org.springframework.security.core.userdetails.UserDetails;
|
||
|
|
//import org.springframework.security.core.userdetails.UserDetailsService;
|
||
|
|
//import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||
|
|
//import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||
|
|
//import org.springframework.stereotype.Service;
|
||
|
|
//import org.springframework.util.CollectionUtils;
|
||
|
|
//
|
||
|
|
//import javax.annotation.Resource;
|
||
|
|
//import java.util.List;
|
||
|
|
//
|
||
|
|
//
|
||
|
|
//@Service
|
||
|
|
//public class AuthenticationService implements UserDetailsService {
|
||
|
|
//
|
||
|
|
//
|
||
|
|
// @Autowired
|
||
|
|
// UsersInfoMapper userinfoMapper;
|
||
|
|
//
|
||
|
|
// @Override
|
||
|
|
// public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||
|
|
// UsersInfoExample stuUserExample=new UsersInfoExample();
|
||
|
|
// stuUserExample.createCriteria().andStudentIdEqualTo(username);
|
||
|
|
// List<UsersInfo> list = userinfoMapper.selectByExample(stuUserExample);
|
||
|
|
// if (CollectionUtils.isEmpty(list)) {
|
||
|
|
// throw new UsernameNotFoundException(username);
|
||
|
|
// }
|
||
|
|
// UsersInfo userinfo = list.get(0);
|
||
|
|
// JwtUser jwtUser = new JwtUser();
|
||
|
|
// jwtUser.setUsername(userinfo.getStudentId());
|
||
|
|
// jwtUser.setCollegeId(Convert.toInt(userinfo.getSchoolId()));
|
||
|
|
// jwtUser.setClassId(Convert.toInt(userinfo.getClassId()));
|
||
|
|
// jwtUser.setPassword(new BCryptPasswordEncoder().encode(userinfo.getPassword())); //不加密会报错Encoded password does not look like BCrypt
|
||
|
|
// jwtUser.setUserId(userinfo.getUserId());
|
||
|
|
// jwtUser.setName(userinfo.getUserName());
|
||
|
|
// jwtUser.setRoleId(userinfo.getRoleId());
|
||
|
|
// jwtUser.setStudentId(userinfo.getStudentId());
|
||
|
|
// jwtUser.setSchoolName(userinfo.getSchoolName());
|
||
|
|
// jwtUser.setClassName(userinfo.getClassName());
|
||
|
|
// jwtUser.setSchoolId(Integer.valueOf(userinfo.getSchoolId()));
|
||
|
|
// jwtUser.setClassId(Integer.valueOf(userinfo.getClassId()));
|
||
|
|
// return jwtUser;
|
||
|
|
// }
|
||
|
|
//
|
||
|
|
//}
|