package com.njzscloud.dispose.goods.controller;

import com.njzscloud.common.core.utils.R;
import com.njzscloud.common.mp.support.PageParam;
import com.njzscloud.common.mp.support.PageResult;
import com.njzscloud.dispose.goods.pojo.entity.GoodsCategoryEntity;
import com.njzscloud.dispose.goods.pojo.param.SearchGoodsCategoryParam;
import com.njzscloud.dispose.goods.service.GoodsCategoryService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产品分类
 * @author ljw
 */
@Slf4j
@RestController
@RequestMapping("/goods_category")
@RequiredArgsConstructor
public class GoodsCategoryController {

    private final GoodsCategoryService goodsCategoryService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody GoodsCategoryEntity goodsCategoryEntity) {
        goodsCategoryService.add(goodsCategoryEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @PostMapping("/modify")
    public R<?> modify(@RequestBody GoodsCategoryEntity goodsCategoryEntity) {
        goodsCategoryService.modify(goodsCategoryEntity);
        return R.success();
    }

    /**
     * 删除
     */
    @PostMapping("/del")
    public R<?> del(@RequestBody List<Long> ids) {
        goodsCategoryService.del(ids);
        return R.success();
    }

    /**
     * 详情
     */
    @GetMapping("/detail")
    public R<GoodsCategoryEntity> detail(@RequestParam("id") Long id) {
        return R.success(goodsCategoryService.detail(id));
    }

    /**
     * 分页查询
     */
    @GetMapping("/paging")
    public R<PageResult<GoodsCategoryEntity>> paging(PageParam pageParam, SearchGoodsCategoryParam searchGoodsCategoryParam) {
        return R.success(goodsCategoryService.paging(pageParam, searchGoodsCategoryParam));
    }
}


