package com.mortals.xhx.module.operate.service.impl;
import cn.hutool.core.lang.Snowflake;
import cn.hutool.core.util.IdUtil;
import com.mortals.xhx.module.error.model.ErrorLogEntity;
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.operate.dao.OperateLogDao;
import com.mortals.xhx.module.operate.model.OperateLogEntity;
import com.mortals.xhx.module.operate.service.OperateLogService;

import java.util.Date;

/**
* OperateLogService
* 平台用户操作日志业务 service实现
*
* @author zxfei
* @date 2022-08-17
*/
@Service("operateLogService")
public class OperateLogServiceImpl extends AbstractCRUDServiceImpl<OperateLogDao, OperateLogEntity, Long> implements OperateLogService {

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