package com.jwipc.order.controller.pc;

import com.google.common.collect.Lists;
import com.jwipc.order.dto.PcnChangeApplyListDTO;
import com.jwipc.order.logic.PcnManagerLogic;
import com.jwipc.order.model.query.PcnManagerQuery;
import com.jwipc.page.PageView;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.stream.Collectors;

import static com.jwipc.order.constant.ModuleConst.MODULE_ROOT;

/**
 * 功能描述:
 *
 * @Author: zx
 * @Date: 2024/3/19 0019 10:23
 */
@RestController
@RequestMapping(MODULE_ROOT + "/pcn/rest")
@RequiredArgsConstructor
@Slf4j
public class PcnManagerRestController {

    @Autowired
    PcnManagerLogic pcnManagerLogic;

    @RequestMapping("/queryPcnByPage")
    public PageView queryPcnByPage(PcnManagerQuery pcnManagerQuery) {
        return pcnManagerLogic.queryPcnByPage(pcnManagerQuery);
    }


    /**
     * 保存记录
     *
     * @param dto
     * @return
     */
    @RequestMapping("/save/form")
    public ResponseEntity add(PcnChangeApplyListDTO dto) {
        pcnManagerLogic.saveFrom(dto);
        return ResponseEntity.ok(true);

    }


    @RequestMapping("/del")
    @Transactional
    public ResponseEntity deleteRecord(String id) {
        pcnManagerLogic.deleteRecord(id);
        return ResponseEntity.ok(true);
    }





}
