package com.bonus.canteen.core.order.common.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bonus.canteen.core.order.common.constants.OrderErrorStateEnum;
import com.bonus.canteen.core.order.common.constants.OrderErrorTypeEnum;
import com.bonus.canteen.core.order.common.mapper.OrderErrorLogMapper;
import com.bonus.canteen.core.order.common.model.OrderErrorLog;
import com.bonus.canteen.core.order.common.service.OrderErrorLogService;
import com.bonus.common.houqin.utils.id.Id;
import org.springframework.stereotype.Service;

@Service
public class OrderErrorLogServiceImpl extends ServiceImpl<OrderErrorLogMapper, OrderErrorLog> implements OrderErrorLogService {
   public void saveError(Long relatedId, String traceId, OrderErrorTypeEnum typeEnum, String msg, String data) {
      OrderErrorLog orderErrorLog = new OrderErrorLog();
      orderErrorLog.setLogId(Id.next());
      orderErrorLog.setRelatedId(relatedId);
      orderErrorLog.setTraceId(traceId);
      orderErrorLog.setOrderErrorType(typeEnum.getKey());
      orderErrorLog.setOrderErrorState(OrderErrorStateEnum.CREATED.getKey());
      orderErrorLog.setMsg(msg);
      orderErrorLog.setData(data);
      ((OrderErrorLogMapper)this.baseMapper).insert(orderErrorLog);
   }
}
