接口
package com.cwk.service;
import com.cwk.pojo.User;
import java.util.List;
public interface UserService {
User login(String username, String password);
}
impl层
package com.cwk.service.impl;
import com.cwk.mapper.UserMapper;
import com.cwk.pojo.User;
import com.cwk.service.UserService;
import com.cwk.util.SqlSessionFactoryUtils;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import java.util.List;
public class UserServiceImpl implements UserService {
SqlSessionFactory sqlSessionFactory = SqlSessionFactoryUtils.getSqlSessionFactory();
@Override
public User login(String username, String password) {
SqlSession sqlSession = sqlSessionFactory.openSession();
UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
User user = userMapper.select(username, password);
sqlSession.close();
return user;
}
}