add: 登录
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.dota.nexus.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.dota.nexus.entity.User;
|
||||
import com.dota.nexus.mapper.UserMapper;
|
||||
import com.dota.nexus.service.UserService;
|
||||
import com.dota.nexus.util.GlobalMap;
|
||||
import com.dota.nexus.util.PasswordUtil;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
|
||||
public String login(String username, String password) throws Exception {
|
||||
var q = new LambdaQueryWrapper<User>();
|
||||
q.eq(User::getName, username);
|
||||
var u = this.baseMapper.selectOne(q);
|
||||
if (u!=null && PasswordUtil.verify(password, u.getPassword())) {
|
||||
var uuid = UUID.randomUUID().toString();
|
||||
GlobalMap.put(uuid, u.getId());
|
||||
return uuid;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user