package cn.ysk.cashier.controller.points;

import cn.ysk.cashier.mybatis.entity.TbPointsGoodsSetting;
import cn.ysk.cashier.mybatis.service.TbPointsGoodsSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


/**
 * 积分商品设置
 *
 * @author Tankaikai tankaikai@aliyun.com
 * @since 2.0 2024-10-25
 */
@RestController
@RequestMapping("/api/points/goods-setting")
@Api(tags = "积分商品设置")
public class TbPointsGoodsSettingController {

    @Resource
    private TbPointsGoodsSettingService tbPointsGoodsSettingService;

    @GetMapping("page")
    @ApiOperation("分页")
    public ResponseEntity page(@RequestParam Map<String, Object> params) {
        Map<String, Object> data = tbPointsGoodsSettingService.page(params);
        return ResponseEntity.ok().body(data);
    }

    @GetMapping("{id}")
    @ApiOperation("信息")
    public ResponseEntity get(@PathVariable("id") Long id) {
        TbPointsGoodsSetting data = tbPointsGoodsSettingService.getById(id);
        return ResponseEntity.ok().body(data);
    }

    @PostMapping
    @ApiOperation("保存")
    public ResponseEntity save(@RequestBody TbPointsGoodsSetting entity) {
        boolean ret = tbPointsGoodsSettingService.save(entity);
        return ResponseEntity.ok().body(ret);
    }

    @PutMapping
    @ApiOperation("修改")
    public ResponseEntity update(@RequestBody TbPointsGoodsSetting dto) {
        boolean ret = tbPointsGoodsSettingService.update(dto);
        return ResponseEntity.ok().body(ret);
    }

    @DeleteMapping("{id}")
    @ApiOperation("删除")
    public ResponseEntity delete(@PathVariable("id") Long id) {
        tbPointsGoodsSettingService.delete(id);
        return ResponseEntity.ok().build();
    }
}