package com.zhongzheng.controller.goods; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.lang.Validator; 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.common.utils.poi.ExcelUtil; import com.zhongzheng.modules.bank.service.IQuestionService; import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo; import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo; import com.zhongzheng.modules.goods.bo.*; import com.zhongzheng.modules.goods.service.IGoodsAttachedService; import com.zhongzheng.modules.goods.service.IGoodsCourseService; import com.zhongzheng.modules.goods.service.IGoodsService; import com.zhongzheng.modules.goods.vo.*; import com.zhongzheng.modules.order.service.IOrderBusinessConfigGoodsService; import com.zhongzheng.modules.order.vo.CompanyOrderBusinessConfigGoodsVo; import com.zhongzheng.modules.order.vo.OrderBusinessConfigGoodsVo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; 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; import java.util.stream.Collectors; /** * 商品Controller * * @author hjl * @date 2021-10-12 */ @Api(value = "商品控制器", tags = {"商品管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("bs/BsGoods") public class GoodsController extends BaseController { private final IGoodsService iGoodsService; private final IGoodsAttachedService iGoodsAttachedService; private final IQuestionService iQuestionService; private final IOrderBusinessConfigGoodsService iOrderBusinessConfigGoodsService; private final IGoodsCourseService iGoodsCourseService; /** * 查询商品列表 */ @ApiOperation("查询商品列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/goodsList") public TableDataInfo list( GoodsQueryBo bo) { startPage(); List list = iGoodsService.selectBsGoodList(bo); return getDataTable(list); } /** * 查询商品宝列表 */ @ApiOperation("查询商品列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/getBsGoodlist") public TableDataInfo getBsGoodList(GoodsQueryBo bo) { startPage(); List bsGoodsList = iGoodsService.getBsGoodsPackageList(bo); return getDataTable(bsGoodsList); } @ApiOperation("查询商品列表To录单") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/listToInput") public TableDataInfo listToInput(GoodsQueryBo bo) { startPage(); List list = iGoodsService.selectListToInput(bo); return getDataTable(list); } @ApiOperation("获取商品规格模板列表") @GetMapping("/spec/list/{goodsId}") public AjaxResult> getSpecTemplateList(@PathVariable("goodsId") Long goodsId) { List list = iGoodsService.getSpecTemplateList(goodsId); return AjaxResult.success(list); } @ApiOperation("取消商品默认规格模板") @PostMapping("/cancel/spec") public AjaxResult cancelSpecTemplate(@RequestBody GoodsSpecTempEditBo bo) { return toAjax(iGoodsService.cancelSpecTemplate(bo) ? 1 : 0); } /** * 获取商品详细信息 */ @ApiOperation("获取商品详细信息") @PreAuthorize("@ss.hasPermi('system:goods:query')") @GetMapping("/{goodsId}") public AjaxResult getInfo(@PathVariable("goodsId") Long goodsId) { return AjaxResult.success(iGoodsService.selectDetail(goodsId)); } @ApiOperation("新增讲义商品") @PreAuthorize("@ss.hasPermi('system:goods:add')") @Log(title = "商品", businessType = BusinessType.INSERT) @PostMapping("/handouts") public AjaxResult addHandouts(@RequestBody GoodsAddBo bo) { return toAjax(iGoodsService.insertHandoutsByAddBo(bo)>0 ? 1 : 0); } /** * 查询题目业务层次关系列表 */ @ApiOperation("查询题库商品试卷列表") @PreAuthorize("@ss.hasPermi('system:business:list')") @GetMapping("/bank/list") public AjaxResult> bankList(GoodsAttachedQueryBo bo) { List list = iGoodsAttachedService.getList(bo); return AjaxResult.success(list); } /** * 查询考试配置绑定商品列表 */ @ApiOperation("查询前培或补考商品列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/listGoods") public TableDataInfo listGoods(ExamNumberGoodsQueryBo bo) { startPage(); List list = iGoodsService.listGoods(bo); return getDataTable(list); } /** * 查询免费题库商品列表 */ @ApiOperation("查询免费题库商品列表") @GetMapping("/listFreeGoodsList") public TableDataInfo listFreeGoodsList(GoodsQueryBo bo) { startPage(); List list = iQuestionService.listFreeGoodsList(bo); return getDataTable(list); } /** * 查询免费题库商品列表 */ @ApiOperation("查询用户题库商品列表") @GetMapping("/listBankGoodsList") public TableDataInfo listBankGoodsList(GoodsQueryBo bo) { startPage(); List list = iQuestionService.listBankGoodsList(bo); return getDataTable(list); } /** * 获取题库商品每日一练试卷列表 */ @ApiOperation("获取题库商品每日一练试卷列表") @GetMapping("/getBankGoodsExamList/{goodsId}") public AjaxResult> getBankGoodsExamList(@PathVariable("goodsId") Long goodsId) { List list = iQuestionService.getBankGoodsExamList(goodsId); return AjaxResult.success(list); } @ApiOperation("查询商品普通列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/queryList") public AjaxResult> queryList(GoodsQueryBo bo) { bo.setStatus(new ArrayList(){{ add(1); }}); List list = iGoodsService.queryList(bo); return AjaxResult.success(list); } }