package com.usoftchina.bi.server.controller.user;

import com.usoftchina.bi.server.model.pojo.annotation.CheckToken;
import com.usoftchina.bi.core.base.RepCode;
import com.usoftchina.bi.core.base.RepEntity;
import com.usoftchina.bi.server.model.vo.configVo.RecordInfo;
import com.usoftchina.bi.server.service.chart.ChartsUtilService;
import com.usoftchina.bi.server.service.user.RecodeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(description = "浏览纪录相关接口")
public class RecodeController {
    @Autowired
    RecodeService recodeService;
    @Autowired
    ChartsUtilService chartsUtilService;

    @ApiOperation(value = "查看图表浏览纪录", notes = "查看图表浏览纪录", response = RepEntity.class)
    @CheckToken
    @PostMapping("/getChartRecord")
    public RepEntity getChartRecord(@RequestHeader String token){
        return recodeService.getChartRecord(token);
    }


    @ApiOperation(value = "看板浏览纪录", notes = "看板浏览纪录", response = RepEntity.class)
    @CheckToken
    @PostMapping("/getDashRecord")
    public RepEntity getDashRecord(@RequestHeader String token){
        return recodeService.getDashRecord(token);
    }


    @ApiOperation(value = "添加浏览纪录", notes = "添加浏览纪录", response = RepEntity.class)
    @CheckToken
    @PostMapping("/addRecord")
    public RepEntity inputRecord(@RequestHeader String token,@RequestBody RecordInfo body){
        chartsUtilService.inputRecord(token, body);
        return new RepEntity(RepCode.success);
    }
}
