package com.mortals.xhx.module.biz.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.mortals.xhx.module.access.model.AccessLogEntity;
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.biz.dao.BizLogDao;
import com.mortals.xhx.module.biz.model.BizLogEntity;
import com.mortals.xhx.module.biz.service.BizLogService;

import java.util.Date;

/**
* BizLogService
* 业务日志 service实现
*
* @author zxfei
* @date 2022-08-17
*/
@Service("bizLogService")
public class BizLogServiceImpl extends AbstractCRUDServiceImpl<BizLogDao, BizLogEntity, Long> implements BizLogService {

    @Override
    public BizLogEntity get(Long key, Context context) throws AppException {
        BizLogEntity bizLogEntity = new BizLogEntity();
        Snowflake snowflake = IdUtil.getSnowflake(0, 1);
        long generateDateTime = snowflake.getGenerateDateTime(key);
        bizLogEntity.setCreateTime(new Date(generateDateTime));
        return this.getDao().get(key,bizLogEntity);
    }
}