package com.hdkj.lt.bf.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hdkj.lt.bf.entity.dto.StrategyConfigDTO;
import com.hdkj.lt.bf.entity.dto.StrategyConfigDetailDTO;
import com.hdkj.lt.bf.entity.dto.StrategyconfigInfoDTO;
import com.hdkj.lt.bf.entity.vo.FhzgStrategyConfigDetailVO;
import com.hdkj.lt.bf.entity.vo.FhzgStrategyConfigVO;
import com.hdkj.lt.bf.service.FhzgPlanStrategyService;
import com.hdkj.lt.core.mvc.BaseController;
import com.hdkj.hussar.ApiResponse;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
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;

@RestController
@RequestMapping("/fhzgPlanStrategy")
@RequiredArgsConstructor
public class FhzgPlanStrategyController extends BaseController {
    @Autowired
    private FhzgPlanStrategyService strategyService;

    @PostMapping("/getList")
    @ApiOperation(value = "策略配置列表")
    public ApiResponse<Page<FhzgStrategyConfigVO>> getStrategyconfigList(@RequestBody StrategyConfigDTO dto){
        return ApiResponse.success(strategyService.getStrategyconfigList(dto));
    }

    @PostMapping("/getDetail")
    @ApiOperation(value = "策略配置详情")
    public ApiResponse<FhzgStrategyConfigDetailVO> getStrategyconfigDetail(@RequestBody StrategyConfigDetailDTO dto) {
        if (dto == null) {
            return fail("参数不能为空");
        }
        if (dto.getStrategyId() == null) {
            return fail("策略配置ID不能为空");
        }
        return ApiResponse.success(strategyService.getStrategyconfigDetail(dto));
    }

    @PostMapping("/addStrategyconfig")
    @ApiOperation(value = "新增策略配置")
    public ApiResponse<String> addStrategyconfig(@RequestBody StrategyconfigInfoDTO dto) {
        if (dto == null) {
            return fail("参数不能为空");
        }
        return ApiResponse.success(strategyService.addStrategyconfig(dto));
    }

    @PostMapping("/updateStrategyconfig")
    @ApiOperation(value = "编辑策略配置")
    public ApiResponse<String> updateStrategyconfig(@RequestBody StrategyconfigInfoDTO dto) {
        if (dto == null) {
            return fail("参数不能为空");
        }
        return ApiResponse.success(strategyService.updateStrategyconfig(dto));
    }

    @PostMapping("/usedStrategyconfig")
    @ApiOperation(value = "启用策略配置")
    public ApiResponse<String> usedStrategyconfig(@RequestBody StrategyConfigDetailDTO dto) {
        return ApiResponse.success(strategyService.usedStrategyconfig(dto));
    }

}