package com.friday.custody.service.basicService.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.friday.custody.dao.SubscribeInfoDao;
import com.friday.custody.entity.SubscribeInfoEntity;
import com.friday.custody.service.basicService.SubscribeInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;


@Service("subscribeInfoService")
@Slf4j
public class SubscribeInfoServiceImpl extends ServiceImpl<SubscribeInfoDao, SubscribeInfoEntity> implements SubscribeInfoService {

    @Override
    public List<SubscribeInfoEntity> selectList(SubscribeInfoEntity entity) {
        QueryWrapper<SubscribeInfoEntity> queryWrapper = new QueryWrapper<>();
        if (StringUtils.isNotBlank(entity.getAdmin())){
            queryWrapper.eq("admin", entity.getAdmin());
        }
        if (StringUtils.isNotBlank(entity.getSubscribePrtCode())){
            queryWrapper.likeRight("subscribe_prt_code", entity.getSubscribePrtCode());
        }
        if (StringUtils.isNotBlank(entity.getAccountType())){
            queryWrapper.likeRight("accountType", entity.getAccountType());
        }
        if (StringUtils.isNotBlank(entity.getNotifier())){
            queryWrapper.eq("notifier", entity.getNotifier());
        }
        if (StringUtils.isNotBlank(entity.getEmailAddress())){
            queryWrapper.eq("email_address", entity.getEmailAddress());
        }
        if (StringUtils.isNotBlank(entity.getMobileNo())){
            queryWrapper.eq("mobileNo", entity.getMobileNo());
        }
        queryWrapper.eq("is_deleted", 0);
        queryWrapper.orderBy(true, false, "admin","create_time");
        List<SubscribeInfoEntity> subscribeInfoEntities = baseMapper.selectList(queryWrapper);
        return subscribeInfoEntities;
    }

}