package com.ozs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ozs.entity.UserRegistrationid;
import com.ozs.mapper.UserRegistrationidMapper;
import com.ozs.service.UserRegistrationidService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import java.util.List;

/**
 * @Author : sunhh
 * @create 2023/3/14 17:08
 */
@Slf4j
@Service
public class UserRegistrationidServiceImpl extends ServiceImpl<UserRegistrationidMapper, UserRegistrationid> implements UserRegistrationidService {
    @Autowired
    private UserRegistrationidMapper userRegistrationidMapper;

    @Override
    public Integer addRegistrationID(UserRegistrationid userRegistrationid) {
        LambdaQueryWrapper<UserRegistrationid> lw = new LambdaQueryWrapper<UserRegistrationid>();
        if (!ObjectUtils.isEmpty(userRegistrationid.getUserId())) {
            lw.in(UserRegistrationid::getUserId, userRegistrationid.getUserId());
        }
        if (!ObjectUtils.isEmpty(userRegistrationid.getRegistrationId())) {
            lw.in(UserRegistrationid::getRegistrationId, userRegistrationid.getRegistrationId());
        }
        log.info("userRegistrationids111111111111111:--------" + userRegistrationid.getUserId());
        log.info("userRegistrationids222222222222222:--------" + userRegistrationid.getRegistrationId());
        List<UserRegistrationid> userRegistrationids = userRegistrationidMapper.selectList(lw);
        log.info("userRegistrationids333333333333333:--------" + userRegistrationids.size());
        if (com.ozs.common.utils.StringUtils.isEmpty(userRegistrationids) && userRegistrationids.size() == 0) {
            userRegistrationidMapper.insert(userRegistrationid);
        }
        return 1;
    }

    @Override
    public List<String> selectRegistrationID(List<String> userIdList) {
        return userRegistrationidMapper.selectRegistrationID(userIdList);
    }
}
