package com.crm.manager.controller;

import com.crm.manager.service.follow.FollowCptFeignService;
import com.crm.rely.backend.core.dto.base.BaseResultDto;
import com.crm.rely.backend.core.dto.base.BaseResultWithPagerDto;
import com.crm.rely.backend.core.dto.follow.cpt.FollowCptDailyDto;
import com.crm.rely.backend.core.dto.follow.cpt.FollowCptInfoDto;
import com.crm.rely.backend.core.dto.follow.cpt.FollowCptResultDto;
import com.crm.rely.backend.core.entity.follow.cpt.FollowCptRankSearchEntity;
import com.crm.rely.backend.util.DateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/follow/cpt")
public class FollowCptController {

    @Autowired
    private FollowCptFeignService followCptFeignService;

    @PostMapping("/info")
    public BaseResultDto<List<FollowCptInfoDto>> cptInfo() throws Exception {
        return followCptFeignService.cptInfo();
    }

    @PostMapping("/result")
    public BaseResultWithPagerDto<List<FollowCptResultDto>> cptResult(@RequestBody @Validated FollowCptRankSearchEntity entity) throws Exception {
        entity.setDate(DateUtil.getPureDate(new Date()));
        return followCptFeignService.cptResult(entity);
    }

    @PostMapping("/daily")
    public BaseResultWithPagerDto<List<FollowCptDailyDto>> cptDaily(@RequestBody @Validated FollowCptRankSearchEntity entity) throws Exception {
        return followCptFeignService.cptDaily(entity);
    }

}
