package com.ankaibei.workFlow.webadmin.ankaibei.service.impl;

import com.ankaibei.workFlow.webadmin.ankaibei.entity.LoginTokenEntity;
import com.ankaibei.workFlow.webadmin.ankaibei.entity.UserInfoEntity;
import com.ankaibei.workFlow.webadmin.ankaibei.enums.CodeEnum;
import com.ankaibei.workFlow.webadmin.ankaibei.mapper.LoginTokenMapper;
import com.ankaibei.workFlow.webadmin.ankaibei.mapper.UserInfoMapper;
import com.ankaibei.workFlow.webadmin.ankaibei.service.LoginService;
import com.ankaibei.workFlow.webadmin.ankaibei.utils.JwtUtil;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ResMsg;
import com.ankaibei.workFlow.webadmin.ankaibei.vo.ReturnToken;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author lwq
 * @version 1.0
 * @description:
 * @date 2022/9/5 14:18
 */
@Service
public class LoginServiceImpl implements LoginService {

    @Resource
    private UserInfoMapper loginMapper;
    @Resource
    private LoginTokenMapper loginTokenMapper;

    @Override
    public ResMsg login(UserInfoEntity userInfoEntity) {
//
//         List<UserInfoEntity> user = loginMapper.findByUserAcctEqualsAndUserStatusIsNot(userInfoEntity.getLoginName(),0);
//        if(user.size()==0){
//            return new ResMsg(CodeEnum.ACCOUNT_NO_PASSWORD_ERROR);
//        }
//        if(user.size()>1){
//            return new ResMsg(CodeEnum.MULTIPLE_DUPLICATE_ACCOUNTS_ARE_FOUND);
//        }
//        UserInfoEntity userInfo = user.get(0);
//        if(userInfoEntity.getPassword().equals(userInfo.getPassword())){
//
////            String token = JwtUtil.createTokenVo(userInfo.getLoginName(), userInfo.getUserId());
////            loginTokenMapper.save(new LoginTokenEntity(userInfo.getUserId(),token));
//            return new ResMsg(CodeEnum.OK);
//        }
        return new ResMsg(CodeEnum.ACCOUNT_NO_PASSWORD_ERROR);
    }
}
