package com.gic.haoban.manage.service.service.chat.impl;

import java.util.List;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.commons.util.PageHelperUtils;
import com.gic.haoban.manage.api.dto.chat.GroupChatUserDTO;
import com.gic.haoban.manage.api.dto.qdto.chat.GroupChatUserSearchQDTO;
import com.gic.haoban.manage.service.dao.mapper.chat.GroupChatUserMapper;
import com.gic.haoban.manage.service.service.chat.GroupChatUserService;
import com.github.pagehelper.PageHelper;

@Service
public class GroupChatUserServiceImpl implements GroupChatUserService {

    @Autowired
    private GroupChatUserMapper groupChatUserMapper;

    @Override
    public Page<GroupChatUserDTO> listPage(GroupChatUserSearchQDTO qdto, BasePageInfo basePageInfo) {
        PageHelper.startPage(basePageInfo);
        if (StringUtils.isNotBlank(qdto.getSearchParams())) {
            String params = qdto.getSearchParams();
            qdto.setWxChatId(params + "%");
            qdto.setSearchParams("%" + params + "%");
        }
        List<GroupChatUserDTO> list = this.groupChatUserMapper.listPage(qdto);
        Page<GroupChatUserDTO> retPage = PageHelperUtils.changePageHelperToCurrentPage(list, GroupChatUserDTO.class);
        return retPage;
    }

}