package com.kuyuntech.vrv.coreservice.service.core.impl;

import com.kuyuntech.vrv.coreapi.bean.auth.PassportBean;
import com.kuyuntech.vrv.coreapi.bean.core.UserBean;
import com.kuyuntech.vrv.coreapi.service.core.AuthService;
import com.kuyuntech.vrv.coreapi.service.core.UserService;
import com.kuyuntech.vrv.coreapi.until.core.PasswordEncryptUtils;
import com.kuyuntech.vrv.coreservice.dao.core.UserDao;
import com.kuyuntech.vrv.coreservice.domain.core.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;

@Service("authService")
@Transactional(rollbackFor = Exception.class, transactionManager = "vrvCoreServiceTransactionManager")
public class AuthServiceImpl implements AuthService {

    @Autowired
    private UserService userService;

    @Autowired
    private UserDao userDao;

    @Override
    public boolean updateUserPassword(UserBean userBean, String newPassword) {


        Assert.hasText(userBean.getCode(), "passport code 不能为空！");


        return this.userService.updateUserPassword(UserBean.builder().code(userBean.getCode()).build(), newPassword);

    }


    @Override
    public UserBean login(UserBean userBean) {
        if (userBean == null) {
            return null;
        }

        userBean = userService.login(userBean);

        return userBean;
    }
}
