package com.jpsoft.shinestar.modules.base.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.jpsoft.shinestar.modules.base.dao.WarningPusherDAO;
import com.jpsoft.shinestar.modules.base.entity.WarningPusher;
import com.jpsoft.shinestar.modules.base.service.WarningPusherService;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Transactional
@Component(value="warningPusherService")
public class WarningPusherServiceImpl implements WarningPusherService {
	@Resource(name="warningPusherDAO")
	private WarningPusherDAO warningPusherDAO;

	@Override
	public WarningPusher get(String id) {
		// TODO Auto-generated method stub
		return warningPusherDAO.get(id);
	}

	@Override
	public int insert(WarningPusher model) {
		// TODO Auto-generated method stub
		//model.setId(UUID.randomUUID().toString());

		return warningPusherDAO.insert(model);
	}

	@Override
	public int update(WarningPusher model) {
		// TODO Auto-generated method stub
		return warningPusherDAO.update(model);
	}

	@Override
	public int delete(String id) {
		// TODO Auto-generated method stub
		return warningPusherDAO.delete(id);
	}

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = warningPusherDAO.exist(id);

		return count > 0 ? true : false;
	}

	@Override
	public List<WarningPusher> list() {
		// TODO Auto-generated method stub
		return warningPusherDAO.list();
	}

	@Override
	public Page<WarningPusher> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize,boolean count,List<Sort> sortList) {
        Page<WarningPusher> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            warningPusherDAO.search(searchParams,sortList);
        });

        return page;
	}

	@Override
	public List<WarningPusher> findByCompanyId(String companyId) {
		return warningPusherDAO.findByCompanyId(companyId);
	}

	@Override
	public List<WarningPusher> findByCompanyIdList(List<String> idList) {
		return warningPusherDAO.findByCompanyIdList(idList);
	}
}