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

import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.jpsoft.shinestar.modules.wechat.dao.ReplyMessageDAO;
import com.jpsoft.shinestar.modules.wechat.entity.ReplyMessage;
import com.jpsoft.shinestar.modules.wechat.service.ReplyMessageService;
import com.github.pagehelper.Page;
import com.jpsoft.shinestar.modules.common.dto.Sort;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="replyMessageService")
public class ReplyMessageServiceImpl implements ReplyMessageService {
	@Resource(name="replyMessageDAO")
	private ReplyMessageDAO replyMessageDAO;

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

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

		return replyMessageDAO.insert(model);
	}

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

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

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

		return count > 0 ? true : false;
	}

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

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

        return page;
	}

	@Override
	public ReplyMessage findByEvent(String event) {
		return replyMessageDAO.findByEvent(event);
	}
}