package io.renren.modules.admin.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.admin.dao.HotalDao;
import io.renren.modules.admin.entity.HotalEntity;
import io.renren.modules.admin.service.HotalService;


@Service("hotalService")
public class HotalServiceImpl extends ServiceImpl<HotalDao, HotalEntity> implements HotalService {

    @Override
    public PageUtils queryPage(Map<String, Object> params, Long meetingId) {
        String key = (String) params.get("key");

        IPage<HotalEntity> page = this.page(
                new Query<HotalEntity>().getPage(params),
                new QueryWrapper<HotalEntity>()
                .eq("meeting_id", meetingId)
                .like(StringUtils.isNotBlank(key),"truename", key)
                .or()
                .like(StringUtils.isNotBlank(key),"organization", key)
        );

        return new PageUtils(page);
    }

}