package com.lightinit.hsdataplatformresdir.impl;

import com.lightinit.hsdataplatformresdir.mapper.SolrserverMapper;
import com.lightinit.hsdataplatformresdir.entity.Solrserver;
import com.lightinit.hsdataplatformresdir.service.ISolrService;
import com.lightinit.hsdataplatformresdir.spring.DynamicDataContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * Created by Mr.Yao on 2017/12/7.
 */
@Service
public class SolrServiceImpl implements ISolrService {
    @Autowired
    private SolrserverMapper mapper;
    @Override
    public List<Solrserver> querySolrServer(String keyword) {
        DynamicDataContextHolder.setCustomerType(DynamicDataContextHolder.DEFAULT);
        String whereStr =null;
        if(StringUtils.isEmpty(keyword)==false) {
            whereStr = "(INSTR(solrcode,'"+keyword+"')>0 OR INSTR(solrname,'"+keyword+"')>0 OR INSTR(solrip,'"+keyword+"')>0)";
        }
        return mapper.selectServer(whereStr);
    }
}
