package com.zhongzheng.controller.goods; import java.util.ArrayList; import java.util.List; import java.util.Arrays; import com.zhongzheng.modules.bank.bo.ExamQuestionQueryBo; import com.zhongzheng.modules.bank.vo.ExamQuestionVo; import com.zhongzheng.modules.goods.bo.*; import com.zhongzheng.modules.goods.domain.Goods; 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.GoodsAuditionConfigVo; import com.zhongzheng.modules.goods.vo.GoodsVo; import lombok.RequiredArgsConstructor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.zhongzheng.common.annotation.Log; import com.zhongzheng.common.core.controller.BaseController; import com.zhongzheng.common.core.domain.AjaxResult; import com.zhongzheng.common.enums.BusinessType; import com.zhongzheng.common.utils.poi.ExcelUtil; import com.zhongzheng.common.core.page.TableDataInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; /** * 商品Controller * * @author hjl * @date 2021-10-12 */ @Api(value = "商品控制器", tags = {"商品管理"}) @RequiredArgsConstructor(onConstructor_ = @Autowired) @RestController @RequestMapping("/goods") public class GoodsController extends BaseController { private final IGoodsService iGoodsService; private final IGoodsAttachedService iGoodsAttachedService; @Autowired private IGoodsAuditionConfigService iGoodsAuditionConfigService; /** * 查询商品列表 */ @ApiOperation("查询商品列表") @PreAuthorize("@ss.hasPermi('system:goods:list')") @GetMapping("/list") public TableDataInfo list(GoodsQueryBo bo) { bo.setStatus(new ArrayList(){{ add(1); }}); startPage(); List list = iGoodsService.selectList(bo); return getDataTable(list); } /** * 导出商品列表 */ /*selectList*/ /** * 获取商品详细信息 */ @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() public AjaxResult add(@RequestBody GoodsAddBo bo) { return toAjax(iGoodsService.insertByAddBo(bo) ? 1 : 0); } /** * 修改商品 */ @ApiOperation("修改商品") @PreAuthorize("@ss.hasPermi('system:goods:edit')") @Log(title = "商品", businessType = BusinessType.UPDATE) @PostMapping("/edit") public AjaxResult edit(@RequestBody GoodsEditBo bo) { return toAjax(iGoodsService.updateByEditBo(bo) ? 1 : 0); } /** * 删除商品 */ /* @ApiOperation("删除商品") @PreAuthorize("@ss.hasPermi('system:goods:remove')") @Log(title = "商品" , businessType = BusinessType.DELETE) @DeleteMapping("/{goodsIds}") public AjaxResult remove(@PathVariable Long[] goodsIds) { return toAjax(iGoodsService.deleteWithValidByIds(Arrays.asList(goodsIds), true) ? 1 : 0); }*/ /** * 新增题库商品 */ @ApiOperation("新增题库商品") @PreAuthorize("@ss.hasPermi('system:goods:add')") @Log(title = "商品", businessType = BusinessType.INSERT) @PostMapping("/bank") public AjaxResult addBank(@RequestBody GoodsBankAddBo bo) { return toAjax(iGoodsService.insertBankByAddBo(bo) ? 1 : 0); } /** * 修改商品 */ @ApiOperation("修改题库商品") @PreAuthorize("@ss.hasPermi('system:goods:edit')") @Log(title = "题库商品", businessType = BusinessType.UPDATE) @PostMapping("/bank/edit") public AjaxResult editBank(@RequestBody GoodsBankEditBo bo) { return toAjax(iGoodsService.updateBankByEditBo(bo) ? 1 : 0); } /** * 查询题目业务层次关系列表 */ @ApiOperation("查询商品题库列表") @PreAuthorize("@ss.hasPermi('system:business:list')") @GetMapping("/bank/list") public AjaxResult> bankList(GoodsAttachedQueryBo bo) { List list = iGoodsAttachedService.selectList(bo); return AjaxResult.success(list); } /** * 新增课程商品 */ @ApiOperation("新增补考商品") @PreAuthorize("@ss.hasPermi('system:goods:add')") @Log(title = "商品", businessType = BusinessType.INSERT) @PostMapping("/make") public AjaxResult addMake(@RequestBody GoodsAddBo bo) { return toAjax(iGoodsService.insertMakeByAddBo(bo) ? 1 : 0); } /** * 修改商品 */ @ApiOperation("修改补考商品") @PreAuthorize("@ss.hasPermi('system:goods:edit')") @Log(title = "商品", businessType = BusinessType.UPDATE) @PostMapping("/make/edit") public AjaxResult editMake(@RequestBody GoodsEditBo bo) { return toAjax(iGoodsService.updateMakeByEditBo(bo) ? 1 : 0); } /** * 新增课程商品 */ @ApiOperation("新增前培商品") @PreAuthorize("@ss.hasPermi('system:goods:add')") @Log(title = "商品", businessType = BusinessType.INSERT) @PostMapping("/front") public AjaxResult addFront(@RequestBody GoodsAddBo bo) { return toAjax(iGoodsService.insertFrontByAddBo(bo) ? 1 : 0); } /** * 修改商品 */ @ApiOperation("修改前培商品") @PreAuthorize("@ss.hasPermi('system:goods:edit')") @Log(title = "商品", businessType = BusinessType.UPDATE) @PostMapping("/front/edit") public AjaxResult editFront(@RequestBody GoodsEditBo bo) { return toAjax(iGoodsService.updateFrontByEditBo(bo) ? 1 : 0); } }