package com.zhongzheng.controller.goods;

import com.zhongzheng.common.annotation.Log;
import com.zhongzheng.common.core.controller.BaseController;
import com.zhongzheng.common.core.domain.AjaxResult;
import com.zhongzheng.common.core.page.TableDataInfo;
import com.zhongzheng.common.enums.BusinessType;
import com.zhongzheng.modules.goods.bo.*;
import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
import com.zhongzheng.modules.goods.service.IGoodsAuditionConfigService;
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 io.swagger.models.auth.In;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

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 GoodsController 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)));
        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);
    }




}
