package cn.ysk.cashier.controller;

import cn.ysk.cashier.dto.TbPlatformDictTypeQueryCriteria;
import cn.ysk.cashier.pojo.TbPlatformDictType;
import cn.ysk.cashier.service.TbPlatformDictTypeService;
import org.springframework.data.domain.Pageable;
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-05-11
 **/
@RestController
@RequiredArgsConstructor
@Api(tags = "资源类别管理")
@RequestMapping("/api/tbPlatformDictType")
public class TbPlatformDictTypeController {

    private final TbPlatformDictTypeService tbPlatformDictTypeService;

    @GetMapping
    @ApiOperation("查询资源类别列表")
    public ResponseEntity<Object> queryTbPlatformDictType(TbPlatformDictTypeQueryCriteria criteria, Pageable pageable){
        return new ResponseEntity<>(tbPlatformDictTypeService.queryAll(criteria,pageable),HttpStatus.OK);
    }

    @PostMapping
    @ApiOperation("新增资源类别")
    public ResponseEntity<Object> createTbPlatformDictType(@Validated @RequestBody TbPlatformDictType resources){
        return new ResponseEntity<>(tbPlatformDictTypeService.create(resources),HttpStatus.CREATED);
    }

    @PutMapping
    @ApiOperation("修改资源类别")
    public ResponseEntity<Object> updateTbPlatformDictType(@Validated @RequestBody TbPlatformDictType resources){
        tbPlatformDictTypeService.update(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @ApiOperation("删除资源类别")
    public ResponseEntity<Object> deleteTbPlatformDictType(@RequestBody Integer[] ids) {
        tbPlatformDictTypeService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }
}