package cn.lihongjie.coal.warehouseGoodsCategory.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.warehouseGoodsCategory.dto.CreateWarehouseGoodsCategoryDto;
import cn.lihongjie.coal.warehouseGoodsCategory.dto.UpdateWarehouseGoodsCategoryDto;
import cn.lihongjie.coal.warehouseGoodsCategory.dto.WarehouseGoodsCategoryDto;
import cn.lihongjie.coal.warehouseGoodsCategory.service.WarehouseGoodsCategoryService;

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("/warehouseGoodsCategory")
@SysLog(module = "仓库商品类目管理")
@Slf4j
@OrgScope
public class WarehouseGoodsCategoryController {
    @Autowired private WarehouseGoodsCategoryService service;

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

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

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

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

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