package cn.ysk.cashier.controller.shop;

import cn.ysk.cashier.pojo.shop.TbPurchaseNotice;
import cn.ysk.cashier.service.shop.TbPurchaseNoticeService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;

/**
 * @author ww
 * @date 2024-04-25
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "购买须知/价格说明管理")
@RequestMapping("/api/tbPurchaseNotice")
public class TbPurchaseNoticeController {

    private final TbPurchaseNoticeService tbPurchaseNoticeService;

    @PostMapping
    @ApiOperation("新增购买须知/价格说明")
    public ResponseEntity<Object> createTbPurchaseNotice(@Validated @RequestBody TbPurchaseNotice resources){
        return new ResponseEntity<>(tbPurchaseNoticeService.create(resources),HttpStatus.CREATED);
    }

    @PutMapping
    @ApiOperation("修改购买须知/价格说明")
    public ResponseEntity<Object> updateTbPurchaseNotice(@Validated @RequestBody TbPurchaseNotice resources){
        tbPurchaseNoticeService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @ApiOperation("删除购买须知/价格说明")
    public ResponseEntity<Object> deleteTbPurchaseNotice(@RequestBody Integer[] ids) {
        tbPurchaseNoticeService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}