package cn.lihongjie.coal.warehouseGoodsAttr.controller;

import cn.lihongjie.coal.annotation.OrgScope;
import cn.lihongjie.coal.annotation.SysLog;
import cn.lihongjie.coal.base.dto.CommonQuery;
import cn.lihongjie.coal.base.dto.IdRequest;
import cn.lihongjie.coal.warehouseGoodsAttr.dto.CreateWarehouseGoodsAttrDto;
import cn.lihongjie.coal.warehouseGoodsAttr.dto.UpdateWarehouseGoodsAttrDto;
import cn.lihongjie.coal.warehouseGoodsAttr.dto.WarehouseGoodsAttrDto;
import cn.lihongjie.coal.warehouseGoodsAttr.service.WarehouseGoodsAttrService;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
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;

@RestController
@RequestMapping("/warehouseGoodsAttr")
@SysLog(module = "仓库商品属性设置")
@Slf4j
@OrgScope
public class WarehouseGoodsAttrController {
    @Autowired private WarehouseGoodsAttrService service;

    @PostMapping("/create")
    public WarehouseGoodsAttrDto create(@RequestBody CreateWarehouseGoodsAttrDto request) {
        return this.service.create(request);
    }

    @PostMapping("/update")
    public WarehouseGoodsAttrDto update(@RequestBody UpdateWarehouseGoodsAttrDto request) {
        return this.service.update(request);
    }

    @PostMapping("/delete")
    public Object delete(@RequestBody IdRequest request) {
        this.service.delete(request);
        return true;
    }

    @PostMapping("/getById")
    public WarehouseGoodsAttrDto getById(@RequestBody IdRequest request) {
        return this.service.getById(request.getId());
    }

    @PostMapping("/list")
    public Page<WarehouseGoodsAttrDto> list(@RequestBody CommonQuery request) {
        return this.service.list(request);
    }
}
