package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.sys.dto.TaxDTO;
import com.jwipc.sys.logic.TaxLogic;
import com.jwipc.sys.model.param.TaxParam;
import com.jwipc.sys.model.query.TaxQuery;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

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

/**
 * @author Al
 * @create 2024-02-22 12:13
 */
@RestController
@RequestMapping(MODULE_ROOT + "/tax/rest/")
@RequiredArgsConstructor
public class TaxRestController {
    private final TaxLogic taxLogic;
    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(TaxQuery query) {
        return taxLogic.findByPage(query);
    }
    /**
     * 保存更新
     *
     * @param param 参数
     */
    @PostMapping("/saveOrUpdate")
    public ResponseEntity saveOrUpdate(TaxParam param) {
        taxLogic.saveOrUpdate(param);
        return ResponseEntity.ok(true);
    }
    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/listAll")
    public ResponseEntity<List<TaxDTO>> listAll(TaxQuery query) {
        return ResponseEntity.ok(taxLogic.listAll(query));
    }
    /**
     * 删除
     *
     * @param taxCode 参数
     */
    @PostMapping("/remove")
    public ResponseEntity remove(String taxCode) {
        taxLogic.remove(taxCode);
        return ResponseEntity.ok(true);
    }
}
