package com.microservices.dms.resourceLibrary.controller;


import com.microservices.common.core.web.domain.AjaxResult;
import com.microservices.dms.resourceLibrary.domain.*;
import com.microservices.dms.resourceLibrary.service.TaskResourceLibraryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@Api(tags = "数据管理体系-用户行为信息接口")
@RestController
@RequestMapping("/collectUserActData")
@RequiredArgsConstructor
public class CollectUserActDataController {

    private final TaskResourceLibraryService taskResourceLibraryService;

    @PostMapping("/addClicker")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "clickType", value = "点击类型(任务：makerSpaceTask、竞赛：CompetitionInfo、项目：Project、成果：Achievements、专家：Experts,校企：schoolEnterprise,成果用户对接：userDocking)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "clickId", value = "点击对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)
    })
    @ApiOperation(value = "记录点击次数")
    public AjaxResult addTaskClick(@RequestBody Clicker clicker) {
        return AjaxResult.success(taskResourceLibraryService.addClick(clicker));
    }

    @PostMapping("/addDownloader")
    @ApiOperation(value = "记录下载次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "downloadType", value = "下载类型(任务：makerSpaceTask、竞赛作品：CompetitionOpusDownload、成果：Achievements、专家：Experts)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "downloadId", value = "下载对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)
    })
    public AjaxResult addDownloader(@RequestBody Downloader downloader) {
        return AjaxResult.success(taskResourceLibraryService.addDownloader(downloader));
    }

    @PostMapping("/addSearcher")
    @ApiOperation(value = "记录搜索次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "searchType", value = "搜索类型(任务：makerSpaceTask、项目：Project、竞赛：CompetitionInfo)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "searchId", value = "搜索对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)
    })
    public AjaxResult addSearcher(@RequestBody Searcher searcher) {
        return AjaxResult.success(taskResourceLibraryService.addSearcher(searcher));
    }

    @PostMapping("/addSearcher2")
    @ApiOperation(value = "记录搜索次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "searchType", value = "搜索类型(任务：makerSpaceTask、项目：Project、竞赛：CompetitionInfo)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "searchIds", value = "搜索对象ID,多个,分隔", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)
    })
    public AjaxResult addSearcher2(@RequestBody Searcher searcher) {
        return AjaxResult.success(taskResourceLibraryService.addSearcher2(searcher));
    }

    @PostMapping("/addFavorite")
    @ApiOperation(value = "记录收藏次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "favoriteType", value = "收藏类型(成果：Achievements、专家：Experts)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "favoriteId", value = "对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)
    })
    public AjaxResult addFavorite(@RequestBody Favorite favorite) {
        return AjaxResult.success(taskResourceLibraryService.addFavorite(favorite));
    }

    @PostMapping("/addWatcher")
    @ApiOperation(value = "记录关注次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "favoriteType", value = "关注类型(成果：Achievements、专家：Experts)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "favoriteId", value = "对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "extInfo", value = "补充信息", paramType = "query", dataTypeClass = String.class)
    })
    public AjaxResult addFavorite(@RequestBody Watcher watcher) {
        return AjaxResult.success(taskResourceLibraryService.addWatcher(watcher));
    }

    @DeleteMapping("/delFavorite")
    @ApiOperation(value = "删除收藏次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "favoriteType", value = "收藏类型(成果：Achievements、专家：Experts)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "favoriteId", value = "对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
    })
    public AjaxResult delFavorite(Favorite favorite) {
        return AjaxResult.success(taskResourceLibraryService.delFavorite(favorite));
    }

    @DeleteMapping("/delWatcher")
    @ApiOperation(value = "删除关注次数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "favoriteType", value = "关注类型(成果：Achievements、专家：Experts)", paramType = "query", dataTypeClass = String.class),
            @ApiImplicitParam(name = "favoriteId", value = "对象ID", paramType = "query", dataTypeClass = Integer.class),
            @ApiImplicitParam(name = "userId", value = "用户ID", paramType = "query", dataTypeClass = Integer.class),
    })
    public AjaxResult delWatcher(Watcher watcher) {
        return AjaxResult.success(taskResourceLibraryService.delWatcher(watcher));
    }
}
