package com.njzscloud.supervisory.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.supervisory.goods.pojo.entity.GoodsInfoEntity;
import com.njzscloud.supervisory.goods.service.GoodsInfoService;
import com.njzscloud.supervisory.sys.log.annotation.Log;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 产品信息
 */
@Slf4j
@RestController
@RequestMapping("/goods_info")
@RequiredArgsConstructor
public class GoodsInfoController {

    private final GoodsInfoService goodsInfoService;

    /**
     * 新增
     */
    @PostMapping("/add")
    public R<?> add(@RequestBody GoodsInfoEntity goodsInfoEntity) {
        goodsInfoService.add(goodsInfoEntity);
        return R.success();
    }

    /**
     * 修改
     */
    @Log("产品信息修改")
    @PostMapping("/modify")
    public R<?> modify(@RequestBody GoodsInfoEntity goodsInfoEntity) {
        goodsInfoService.modify(goodsInfoEntity);
        return R.success();
    }

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

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

    /**
     * 分页查询
     */
    @Log("产品信息分页查询")
    @GetMapping("/paging")
    public R<PageResult<GoodsInfoEntity>> paging(PageParam pageParam, GoodsInfoEntity goodsInfoEntity) {
        return R.success(goodsInfoService.paging(pageParam, goodsInfoEntity));
    }

    /**
     * 设置是否确认磅重
     */
    @PostMapping("/setPoundWeight")
    public R<?> setPoundWeight(@RequestParam Long id, @RequestParam Boolean isPoundWeight) {
        goodsInfoService.setPoundWeight(id, isPoundWeight);
        return R.success();
    }

    /**
     * 设置是否有回执单
     */
    @PostMapping("/setReceipt")
    public R<?> setReceipt(@RequestParam Long id, @RequestParam Boolean isReceipt) {
        goodsInfoService.setReceipt(id, isReceipt);
        return R.success();
    }

    /**
     * 设置是否上报
     */
    @PostMapping("/setReport")
    public R<?> setReport(@RequestParam Long id, @RequestParam Boolean isReport) {
        goodsInfoService.setReport(id, isReport);
        return R.success();
    }

    /**
     * 设置是否预约
     */
    @PostMapping("/setSubscribe")
    public R<?> setSubscribe(@RequestParam Long id, @RequestParam Boolean isSubscribe) {
        goodsInfoService.setSubscribe(id, isSubscribe);
        return R.success();
    }

}
