package com.crunii.micro.service.sysmgr.service.impl;

import com.crunii.micro.domain.entity.main.TsmDownloadRecord;
import com.crunii.micro.domain.entity.main.TsmVisitorRecord;
import com.crunii.micro.domain.repo.main.TsmDownloadRecordRepo;
import com.crunii.micro.domain.repo.main.TsmVisitorRecordRepo;
import com.crunii.micro.service.sysmgr.dto.sysmgr.VisitorRecordReq;
import com.crunii.micro.service.sysmgr.service.OperationsAnalysisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author denggl
 * date 2024/1/7
 */
@Service
public class OperationsAnalysisServiceImpl implements OperationsAnalysisService {
    @Autowired
    private TsmDownloadRecordRepo   tsmDownloadRecordRepo;

    @Autowired
    private TsmVisitorRecordRepo tsmVisitorRecordRepo;

    @Override
    public void appDownloadRecord() {
        TsmDownloadRecord tsmDownloadRecord=new  TsmDownloadRecord();
        tsmDownloadRecord.setCreateTime(new Date());
        tsmDownloadRecord.setDelFlag(0);
        tsmDownloadRecordRepo.saveAndFlush(tsmDownloadRecord);
    }

    @Override
    public void visitorRecord(VisitorRecordReq visitorRecordReq) {
        TsmVisitorRecord visitorRecord=new TsmVisitorRecord();
        visitorRecord.setScope(visitorRecordReq.getScope());
        visitorRecord.setVisitorCode(visitorRecordReq.getVisitorCode());
        visitorRecord.setCreateTime(new Date());
        tsmVisitorRecordRepo.saveAndFlush(visitorRecord);
    }


}
