28 lines
995 B
Java
28 lines
995 B
Java
|
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;
|
||
|
}
|
||
|
}
|