package com.gic.haoban.manage.service.service.impl;

import java.util.Date;
import java.util.List;

import com.gic.commons.util.UniqueIdUtils;
import com.gic.haoban.base.api.common.BasePageInfo;
import com.gic.haoban.common.utils.PageUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gic.commons.util.EntityUtil;
import com.gic.haoban.manage.api.dto.MaidianLogDTO;
import com.gic.haoban.manage.service.dao.mapper.TabHaobanMaidianLogMapper;
import com.gic.haoban.manage.service.entity.TabHaobanMaidianLog;
import com.gic.haoban.manage.service.service.MaidianLogService;

@Service
public class MaidianLogServiceImpl implements MaidianLogService{

	@Autowired
	private TabHaobanMaidianLogMapper mapper;
	@Override
	public void insert(MaidianLogDTO maidianLogDTO) {
		TabHaobanMaidianLog tab = EntityUtil.changeEntityByJSON(TabHaobanMaidianLog.class, maidianLogDTO);
		tab.setMaidianId(UniqueIdUtils.uniqueLong());
		tab.setCreateTime(new Date());
		tab.setUpdateTime(tab.getCreateTime());
		mapper.insert(tab);
		
	}


	@Override
	public com.gic.api.base.commons.Page<MaidianLogDTO> queryList(String hbversion, BasePageInfo pageInfo) {
		PageHelper.startPage(pageInfo);
		List<TabHaobanMaidianLog> logList = mapper.queryList(hbversion);
		com.gic.api.base.commons.Page<MaidianLogDTO> page = PageUtil.changePageHelperToCurrentPage(new PageInfo<TabHaobanMaidianLog>(logList), MaidianLogDTO.class);
		return page;
	}
}
