package com.red.circle.console.infra.database.rds.service.app.impl;

import com.red.circle.console.infra.database.rds.dao.app.IUserBaseInfoDAO;
import com.red.circle.console.infra.database.rds.entity.app.IUserBaseInfo;
import com.red.circle.console.infra.database.rds.service.app.IUserBaseInfoService;
import com.red.circle.framework.mybatis.service.impl.BaseServiceImpl;
import com.red.circle.tool.core.date.TimestampUtils;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.List;
import java.util.Objects;

/**
 * app用户表 服务实现类.
 *
 * @author lixiaofei
 */
@Service
@RequiredArgsConstructor
public class IUserBaseInfoServiceImpl extends BaseServiceImpl<IUserBaseInfoDAO, IUserBaseInfo> implements IUserBaseInfoService {

  @Override
  public IUserBaseInfo getUserByUserId(Long userId) {
      return query().eq(IUserBaseInfo::getId, userId)
              .getOne();
  }

    @Override
    public List<IUserBaseInfo> countUserByRegion(String originSys, LocalDate countTime, LocalDate endCountTime) {
        return query()
                .eq(IUserBaseInfo::getOriginSys, originSys)
                .ge(IUserBaseInfo::getCreateTime, countTime)
                .le(IUserBaseInfo::getCreateTime, endCountTime)
                .list();
    }
}
