package com.docus.server.sys.service.impl;

import com.docus.core.util.Func;
import com.docus.server.sys.common.pojo.entity.PowerThirdLogin;
import com.docus.server.sys.infrastructure.dao.IPowerThirdLoginDao;
import com.docus.server.sys.service.IPowerThirdLoginService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 第三方登陆 服务实现类
 * </p>
 *
 * @author jiashi
 * @since 2021-04-26
 */
@Service
public class PowerThirdLoginServiceImpl implements IPowerThirdLoginService {
    @Resource
    private IPowerThirdLoginDao powerThirdLoginDao;

    @Override
    public void savePowerThirdLogin(PowerThirdLogin powerThirdLogin) {
        powerThirdLoginDao.save(powerThirdLogin);
    }

    @Override
    public PowerThirdLogin findByUserName(String userName) {
        return powerThirdLoginDao.findOneBy("user", userName);
    }

    @Override
    public void updateThirdLogin(String pwd, String userName) {
        PowerThirdLogin user = findByUserName(userName);
        if (Func.notNull(user)) {
            user.setPwd(pwd);
            powerThirdLoginDao.updateById(user);
        }
    }
}

