package com.huatek.frame.base.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huatek.frame.base.entity.ErrLogWithBLOBs;
import com.huatek.frame.base.mapper.ErrLogDao;
import com.huatek.frame.base.mapper.ErrLogMapper;
import com.huatek.frame.base.service.ErrLogService;
import com.huatek.torch.frame.tools.ConstantUtil;
import com.huatek.torch.frame.tools.ResultUtil;

@Component
@Service(interfaceClass = ErrLogService.class,timeout=100000)
public class ErrLogServiceImpl implements ErrLogService {

	@Autowired
	private ErrLogMapper errLogMapper;

	@Autowired
	private ErrLogDao errLogDao;

	@Override
	public Map<String, Object> findLogPage(ErrLogWithBLOBs log) {
		PageHelper.startPage(log.getPage(), log.getLimit());
		Page<ErrLogWithBLOBs> logs = errLogMapper.selectErrLogPage(log);
		return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, logs.getTotal(), "", logs.getResult());
	}

	@Override
	public Map<String, Object> deleteLogs(String[] ids) {
		for (String id : ids) {
			errLogDao.del(id);
		}
		return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", "");
	}

	@Override
	public Map<String, Object> findLogs(String id) {
		ErrLogWithBLOBs log = errLogDao.get(id);
		return ResultUtil.put(ConstantUtil.REQUEST_SUCCESS, "", log);
	}

}
