package com.yd.dal.service.transaction.Impl;

import com.yd.dal.entity.transaction.TranLog;
import com.yd.dal.mapper.transaction.TranLogMapper;
import com.yd.dal.service.transaction.TranLogDALService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service("tranLogDALService")
public class TranLogDALServiceImpl implements TranLogDALService {
    @Resource
    private TranLogMapper tranLogMapper;
    @Override
    public void logDB(String category,String type,String inOrOut,String tranNo,String tranXml,String returnCode,String returnMessage){
        try {
            TranLog tranLog = new TranLog();
            tranLog.setCategory(category);
            tranLog.setType(type);
            tranLog.setInOrOut(inOrOut);
            tranLog.setTranNo(tranNo);
            tranLog.setTranXml(tranXml);
            tranLog.setReturnCode(returnCode);
            tranLog.setReturnMessage(returnMessage);
            tranLog.setCreateDate(new Date());
            tranLogMapper.insertSelective(tranLog);
        }catch(Exception e){
            e.printStackTrace();
        }
    }

    @Override
    public List<TranLog> findByTranLogOrderBy(TranLog tranLogNew, String orderBy) {
        return tranLogMapper.findByTranLogOrderBy(tranLogNew, orderBy);
    }
}
