123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- package com.zhongzheng.controller.goods;
- import java.util.List;
- import java.util.Arrays;
- import com.zhongzheng.modules.goods.bo.GoodsAddBo;
- import com.zhongzheng.modules.goods.bo.GoodsEditBo;
- import com.zhongzheng.modules.goods.bo.GoodsQueryBo;
- import com.zhongzheng.modules.goods.service.IGoodsService;
- 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;
- /**
- * 查询商品列表
- */
- @ApiOperation("查询商品列表")
- @PreAuthorize("@ss.hasPermi('system:goods:list')")
- @GetMapping("/list")
- public TableDataInfo<GoodsVo> list(GoodsQueryBo bo) {
- startPage();
- List<GoodsVo> list = iGoodsService.queryList(bo);
- return getDataTable(list);
- }
- /**
- * 导出商品列表
- */
- /*@ApiOperation("导出商品列表")
- @PreAuthorize("@ss.hasPermi('system:goods:export')")
- @Log(title = "商品", businessType = BusinessType.EXPORT)
- @GetMapping("/export")
- public AjaxResult<GoodsVo> export(GoodsQueryBo bo) {
- List<GoodsVo> list = iGoodsService.queryList(bo);
- ExcelUtil<GoodsVo> util = new ExcelUtil<GoodsVo>(GoodsVo.class);
- return util.exportExcel(list, "商品");
- }*/
- /**
- * 获取商品详细信息
- */
- @ApiOperation("获取商品详细信息")
- @PreAuthorize("@ss.hasPermi('system:goods:query')")
- @GetMapping("/{goodsId}")
- public AjaxResult<GoodsVo> getInfo(@PathVariable("goodsId" ) Long goodsId) {
- return AjaxResult.success(iGoodsService.queryById(goodsId));
- }
- /**
- * 新增商品
- */
- @ApiOperation("新增商品")
- @PreAuthorize("@ss.hasPermi('system:goods:add')")
- @Log(title = "商品", businessType = BusinessType.INSERT)
- @PostMapping()
- public AjaxResult<Void> 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<Void> 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<Void> remove(@PathVariable Long[] goodsIds) {
- return toAjax(iGoodsService.deleteWithValidByIds(Arrays.asList(goodsIds), true) ? 1 : 0);
- }*/
- }
|