package com.jwipc.sys.controller.pc;

import com.jwipc.page.PageView;
import com.jwipc.sys.dto.PurchaseCategoryDTO;
import com.jwipc.sys.logic.PurchaseCategoryLogic;
import com.jwipc.sys.model.query.PurchaseCategoryQuery;
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 shenyang.ou
 * @date 2024/2/4 14:47
 * @desc
 */
@RestController
@RequestMapping(MODULE_ROOT + "/purchaseCategory/rest")
@RequiredArgsConstructor
public class PurchaseCategoryRestController {
    private final PurchaseCategoryLogic purchaseCategoryLogic;
    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/list")
    public PageView list(PurchaseCategoryQuery query) {
        return purchaseCategoryLogic.findByPage(query);
    }

    /**
     * 列表
     *
     * @param query
     * @return
     */
    @RequestMapping("/listAll")
    public ResponseEntity<List<PurchaseCategoryDTO>> listAll(PurchaseCategoryQuery query) {
        return ResponseEntity.ok(purchaseCategoryLogic.listAll(query));
    }

    /**
     * 禁用/启用
     *
     * @param id 参数
     */
    @PostMapping("/disable")
    public ResponseEntity disable(Long id,Integer status) {
        purchaseCategoryLogic.disable(id,status);
        return ResponseEntity.ok(true);
    }
}
