package com.fjhx.controller.apply;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.entity.apply.ApplyPurchase;
import com.fjhx.params.apply.ApplyPurchaseVo;
import com.fjhx.service.apply.ApplyPurchaseService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 申购单 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2022-11-28
 */
@RestController
@RequestMapping("/apply/purchase")
public class ApplyPurchaseController {

    @Autowired
    private ApplyPurchaseService applyPurchaseService;

    @PostMapping("/page")
    public R page(@RequestBody Map<String, Object> condition) {
        Page<ApplyPurchase> result = applyPurchaseService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody List<ApplyPurchase> list) {
        applyPurchaseService.add(list);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ApplyPurchaseVo applyPurchaseVo) {
        applyPurchaseService.edit(applyPurchaseVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ApplyPurchaseVo applyPurchaseVo) {
        applyPurchaseService.delete(applyPurchaseVo);
        return R.success();
    }

    @PostMapping("/details")
    public R details(@RequestBody ApplyPurchaseVo applyPurchaseVo) {
        return R.success(applyPurchaseService.getById(applyPurchaseVo.getId()));
    }

}

