package cn.iocoder.yudao.module.system.service.auth;

import cn.iocoder.yudao.module.system.dal.dataobject.auth.AdminWxMpInfoDO;
import cn.iocoder.yudao.module.system.dal.mysql.auth.AdminWxMpInfoMapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 微信公众号用户信息表(用户暂存没有注册用户的关注信息)  Service 实现类
 *
 * @author 艾楷
 */
@Service
@Validated
public class AdminWxMpInfoServiceImpl implements AdminWxMpInfoService {

    @Resource
    private AdminWxMpInfoMapper adminWxMpInfoMapper;

    @Override
    public void save(AdminWxMpInfoDO adminWxMpInfoDO) {
        adminWxMpInfoMapper.insert(adminWxMpInfoDO);
    }

    @Override
    public void del(String appId, String unionId) {
        adminWxMpInfoMapper.delete(new LambdaQueryWrapper<AdminWxMpInfoDO>()
                .eq(AdminWxMpInfoDO::getAppId, appId)
                .eq(AdminWxMpInfoDO::getUnionId, unionId));
    }

    @Override
    public AdminWxMpInfoDO getByCondition(String wxMpAppId, String unionId) {
        return adminWxMpInfoMapper.selectOne(new LambdaQueryWrapper<AdminWxMpInfoDO>()
                .eq(AdminWxMpInfoDO::getAppId, wxMpAppId)
                .eq(AdminWxMpInfoDO::getUnionId, unionId));
    }
}
