package com.mortals.xhx.module.error.service.impl;

import cn.hutool.core.lang.Snowflake;
import com.mortals.xhx.module.access.model.AccessLogEntity;
import com.mortals.xhx.module.error.model.ErrorLogQuery;
import org.springframework.stereotype.Service;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.xhx.module.error.dao.ErrorLogDao;
import com.mortals.xhx.module.error.model.ErrorLogEntity;
import com.mortals.xhx.module.error.service.ErrorLogService;
import cn.hutool.core.util.IdUtil;
import org.springframework.util.ObjectUtils;

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

/**
 * ErrorLogService
 * 异常日志 service实现
 *
 * @author zxfei
 * @date 2022-08-24
 */
@Service("errorLogService")
public class ErrorLogServiceImpl extends AbstractCRUDServiceImpl<ErrorLogDao, ErrorLogEntity, Long> implements ErrorLogService {
    @Override
    protected void saveBefore(ErrorLogEntity entity, Context context) throws AppException {

        //判断当前是否有重复的

        //非系统自增，需这里设置主键
        entity.setId(IdUtil.getSnowflake(0, 1).nextId());





        super.saveBefore(entity, context);
    }

    @Override
    public int save(List<ErrorLogEntity> list, Context context) throws AppException {
        list.forEach(item->{
            item.setId(IdUtil.getSnowflake(0, 1).nextId());
        });
        return super.save(list, context);
    }


}