package com.hai.service.impl;

import com.hai.dao.BsTripartiteReqLogMapper;
import com.hai.entity.BsTripartiteReqLog;
import com.hai.enum_type.TripartiteReqLogReqType;
import com.hai.enum_type.TripartiteReqLogType;
import com.hai.service.BsTripartiteReqLogService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

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

@Service("tripartiteReqLogService")
public class BsTripartiteReqLogServiceImpl implements BsTripartiteReqLogService {

    @Resource
    private BsTripartiteReqLogMapper tripartiteReqLogMapper;

    @Override
    @Transactional(propagation = Propagation.NOT_SUPPORTED, isolation = Isolation.READ_UNCOMMITTED)
    public void insert(TripartiteReqLogType logType, String logSerialNo, TripartiteReqLogReqType reqType, String reqUrl, String reqContent, String respContent) {
        BsTripartiteReqLog log = new BsTripartiteReqLog();
        log.setLogType(logType.getType());
        log.setLogTypeName(logType.getName());
        log.setLogSerialNo(logSerialNo);
        log.setRequestType(reqType.getType());
        log.setRequestUrl(reqUrl);
        log.setRequestContent(reqContent);
        log.setResponseContent(respContent);
        log.setCreateTime(new Date());
        tripartiteReqLogMapper.insert(log);
    }
}
