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

import com.crunii.micro.common.dto.Result;
import com.crunii.micro.domain.dto.Worker;
import com.crunii.micro.service.sysmgr.dto.sysmgr.SignSubmitReqVo;
import com.crunii.micro.service.sysmgr.dto.sysmgr.VisitLogReq;
import com.crunii.micro.service.sysmgr.dto.sysmgr.VisitorRecordReq;
import com.crunii.micro.service.sysmgr.service.FrequentVisitMenuService;
import com.crunii.micro.service.sysmgr.service.OperationsAnalysisService;
import com.crunii.micro.service.sysmgr.service.WorkerService;
import com.crunii.micro.web.mvc.CurrWorker;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author gongsongtao
 * @date 2023/12/7 14:30
 */
@Api(value = "公开接口")
@RestController
@RequestMapping("/openController")
public class OpenController {

    @Resource
    private WorkerService workerService;

    @Autowired
    private OperationsAnalysisService operationsAnalysisService;
    @Autowired
    private FrequentVisitMenuService frequentVisitMenuService;
    @PostMapping(path = "/doSubmitSign")
    @ApiOperation(value = "签名提交接口(App端)")
    public Result doSubmitSign(@RequestBody SignSubmitReqVo signSubmitReqVo){
        workerService.doSubmitSign(signSubmitReqVo);
        return Result.ofSuccess();
    }
    @ApiOperation(value = "记录APP下载记录")
    @GetMapping("/appDownloadRecord")
    public Result<String> appDownloadRecord(){
        operationsAnalysisService.appDownloadRecord();
        return Result.ofSuccess();
    }
    @ApiOperation(value = "记录访客记录")
    @PostMapping("/visitorRecord")
    public Result<String> visitorRecord( @RequestBody VisitorRecordReq visitorRecordReq){
        operationsAnalysisService.visitorRecord(visitorRecordReq);
        return Result.ofSuccess();
    }

    @PostMapping("/doVisitLog")
    @ApiOperation(value = "记录访客模式菜单记录")
    public Result<String>  doVisitLog( @RequestBody VisitLogReq req, HttpServletRequest request){
        frequentVisitMenuService.saveVisitLog( req, request);
        return Result.ofSuccess();
    }

}
