package com.community.huiju.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.community.commom.mode.ResponseBean;
import com.community.huiju.dao.TpActivitySignInMapper;
import com.community.huiju.model.TpActivitySignIn;
import com.community.huiju.service.ITpActivitySignInService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 活动签到表 服务实现类
 * </p>
 *
 * @author jobob
 * @since 2019-04-09
 */
@Service
public class TpTpActivitySignInServiceImpl extends ServiceImpl<TpActivitySignInMapper, TpActivitySignIn> implements ITpActivitySignInService {

    @Override
    public ResponseBean getActivitySignIn(Integer activityId, String userName, String userTel, Integer pageNum, Integer pageSize) {
        ResponseBean responseBean = new ResponseBean();

        Page<TpActivitySignIn> page = new Page<>();
        QueryWrapper<TpActivitySignIn> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("activity_id", activityId);
        queryWrapper.like(StringUtils.isNotBlank(userName), "user_name", userName);
        queryWrapper.like(StringUtils.isNotBlank(userTel), "user_tel", userTel);

        IPage<TpActivitySignIn> signInIPage = this.page(page, queryWrapper);

        responseBean.addSuccess(signInIPage);
        return responseBean;
    }
}
