package com.ningdatech.kqapi.zzsfw.controller;

import com.ningdatech.basic.model.PageVo;
import com.ningdatech.kqapi.zzsfw.entity.dto.NdKqZzsfwPolicyDTO;
import com.ningdatech.kqapi.zzsfw.entity.vo.NdKqZzsfwPolicyVO;
import com.ningdatech.kqapi.zzsfw.manage.PolicyManage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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/")
@Api(value = "PolicyRegulationsController", tags = "柯桥-政策条例")
@RequiredArgsConstructor
public class PolicyRegulationsController {
    private final PolicyManage policyManage;

    @ApiOperation(value = "政策条例分页列表", notes = "政策条例分页列表")
    @GetMapping("/list")
    public PageVo<NdKqZzsfwPolicyVO> list(@RequestParam(defaultValue = "1") long pageNumber, @RequestParam(defaultValue = "10") long pageSize) {
        return policyManage.list(pageNumber,pageSize);
    }

    @ApiOperation(value = "政策条例保存", notes = "政策条例保存")
    @PostMapping("/save")
    public String save(@RequestBody NdKqZzsfwPolicyDTO dto) {
        return policyManage.save(dto);
    }

    @ApiOperation(value = "政策条例保存", notes = "政策条例保存")
    @PostMapping("/save-batch")
    public String saveBatch(@RequestBody List<NdKqZzsfwPolicyDTO> dtos) {

        return policyManage.saveBatch(dtos);
    }


    @ApiOperation(value = "政务事项数据清空", notes = "政务事项数据清空")
    @GetMapping("/remove-all")
    public String removeAll() {
        return policyManage.removeAll();
    }
}
