package com.ningdatech.kqapi.zzsfw.controller;

import com.ningdatech.kqapi.common.model.PageVo;
import com.ningdatech.kqapi.zzsfw.model.dto.KqZzsfwPolicyDTO;
import com.ningdatech.kqapi.zzsfw.model.vo.ZzsfwPolicyVO;
import com.ningdatech.kqapi.zzsfw.manage.PolicyManage;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Classname PolicyRegulationsController
 * @Description
 * @Date 2023/11/2 9:55
 * @Author PoffyZhang
 */
@Slf4j
@Validated
@RestController
@RequestMapping("/api/v1/poclicy/")
@RequiredArgsConstructor
public class PolicyRegulationsController {
    private final PolicyManage policyManage;

    @GetMapping("/list")
    public PageVo<ZzsfwPolicyVO> list(@RequestParam(defaultValue = "1") long pageNumber, @RequestParam(defaultValue = "10") long pageSize) {
        return policyManage.list(pageNumber,pageSize);
    }

    @PostMapping("/save")
    public String save(@RequestBody KqZzsfwPolicyDTO dto) {
        return policyManage.save(dto);
    }

    @PostMapping("/save-batch")
    public String saveBatch(@RequestBody List<KqZzsfwPolicyDTO> dtos) {

        return policyManage.saveBatch(dtos);
    }


    @GetMapping("/remove-all")
    public String removeAll() {
        return policyManage.removeAll();
    }
}
