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.MessageNoticeCompanyDAO;
import com.jpsoft.shinestar.modules.base.entity.MessageNoticeCompany;
import com.jpsoft.shinestar.modules.base.service.MessageNoticeCompanyService;
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="messageNoticeCompanyService")
public class MessageNoticeCompanyServiceImpl implements MessageNoticeCompanyService {
	@Resource(name="messageNoticeCompanyDAO")
	private MessageNoticeCompanyDAO messageNoticeCompanyDAO;

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

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

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

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

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = messageNoticeCompanyDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	@Override
	public int deleteByNoticeId(String noticeId){
		return messageNoticeCompanyDAO.deleteByNoticeId(noticeId);
	}

	@Override
	public List<MessageNoticeCompany> findByNoticeId(String noticeId){
		return messageNoticeCompanyDAO.findByNoticeId(noticeId);
	}
	
	@Override
	public List<MessageNoticeCompany> list() {
		// TODO Auto-generated method stub
		return messageNoticeCompanyDAO.list();
	}
		
	@Override
	public Page<MessageNoticeCompany> pageSearch(Map<String, Object> searchParams, int pageNumber, int pageSize, boolean count, List<Sort> sortList) {
        Page<MessageNoticeCompany> page = PageHelper.startPage(pageNumber,pageSize,count).doSelectPage(()->{
            messageNoticeCompanyDAO.search(searchParams,sortList);
        });
        
        return page;
	}
}