package com.zhongzheng.controller.cmmon;

import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.modules.goods.bo.GoodsAttachedQueryBo;
import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
import com.zhongzheng.modules.goods.service.IGoodsService;
import com.zhongzheng.modules.goods.vo.GoodsAttachedVo;
import com.zhongzheng.modules.goods.vo.GoodsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * 商品Controller
 *
 * @author hjl
 * @date 2021-10-12
 */
@Api(value = "游客商品管理", tags = {"游客商品管理"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/app/common/goods")
public class CommonGoodsController extends BaseController {

    private final IGoodsService iGoodsService;

    private final IGoodsAttachedService iGoodsAttachedService;

    /**
     * 查询商品列表
     */
    @ApiOperation("查询商品列表")
    @GetMapping("/list")
    public TableDataInfo<GoodsVo> list(GoodsQueryBo bo) {
        bo.setStatus(new ArrayList<Integer>(Arrays.asList(1)));
        bo.setGoodsStatus(1);
        startPage();
        List<GoodsVo> list = iGoodsService.selectList(bo);
        return getDataTable(list);
    }

    /**
     * 导出商品列表
     */
    /*selectList*/

    /**
     * 获取商品详细信息
     */
    @ApiOperation("获取商品详细信息")
    @GetMapping("/{goodsId}")
    public AjaxResult<GoodsVo> getInfo(@PathVariable("goodsId" ) Long goodsId) {
        return AjaxResult.success(iGoodsService.selectDetail(goodsId));
    }



    @ApiOperation("查询商品题库目录列表")
    @GetMapping("/bank/list")
    public AjaxResult<List<GoodsAttachedVo>> bankList(GoodsAttachedQueryBo bo) {
        List<GoodsAttachedVo> list = iGoodsAttachedService.selectList(bo);
        return AjaxResult.success(list);
    }




}
