package com.shkj.wcs.controller.base;

import com.shkj.common.annotation.Log;
import com.shkj.common.core.controller.BaseController;
import com.shkj.common.core.domain.Result;
import com.shkj.common.core.page.TableDataInfo;
import com.shkj.common.enums.BusinessType;
import com.shkj.wcs.domain.BasePunch;
import com.shkj.wcs.service.IBasePunchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 冲孔机Controller
 *
 * @author zjx
 * @date 2023-05-12
 */
@RestController
@RequestMapping("/wcs/punch/")
public class BasePunchController extends BaseController
{

    @Autowired
    private IBasePunchService iBasePunchService;

    /**
     * 查询冲孔机列表
     */
    @GetMapping("/list")
    public TableDataInfo<BasePunch> list(BasePunch basePunch)
    {
        startPage();
        List<BasePunch> list = iBasePunchService.selectBasePunchList(basePunch);
        return getDataTable(list);

    }


    /**
     * 获取冲孔机详细信息
     */
    @GetMapping("/getBasePunchByid")
    public Result<BasePunch> getInfo(@RequestParam("id") Long id){
        return Result.ok().data(iBasePunchService.selectBasePunchById(id));
    }

    /**
     * 获取冲孔机
     */
    @GetMapping("/getBasePunchInfo")
    public Result<BasePunch> getBasePunchInfo(BasePunch basePunch) {
        return Result.ok().data(iBasePunchService.selectBasePunchList(basePunch));
    }



    /**
     * 新增冲孔机
     */
    @Log(title = "冲孔机", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public Result<Boolean> add(@RequestBody BasePunch basePunch) {
        return iBasePunchService.insertBasePunch(basePunch);
    }

    /**
     * 修改冲孔机
     */
    @Log(title = "冲孔机", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public Result<Boolean> edit(@RequestBody BasePunch basePunch){
        return iBasePunchService.updateBasePunch(basePunch);
    }

    /**
     * 删除冲孔机
     */
    @Log(title = "冲孔机", businessType = BusinessType.DELETE)
    @PostMapping("/del")
    public Result<Boolean> remove(@RequestParam Long id){
        return iBasePunchService.deleteBasePunchById(id);
    }
}
