93 lines
2.4 KiB
Java
93 lines
2.4 KiB
Java
package com.qihang.oms.controller;
|
||
|
||
|
||
import com.qihang.common.common.AjaxResult;
|
||
import com.qihang.common.common.TableDataInfo;
|
||
import com.qihang.oms.domain.OGoods;
|
||
import com.qihang.oms.service.OGoodsService;
|
||
import com.qihang.oms.vo.GoodsSpecListVo;
|
||
import com.qihang.security.common.BaseController;
|
||
import org.springframework.beans.factory.annotation.Autowired;
|
||
import org.springframework.security.access.prepost.PreAuthorize;
|
||
import org.springframework.web.bind.annotation.*;
|
||
import java.util.List;
|
||
|
||
/**
|
||
* 商品管理Controller
|
||
*
|
||
* @author qihang
|
||
* @date 2023-12-29
|
||
*/
|
||
@RestController
|
||
@RequestMapping("/goods")
|
||
public class GoodsController extends BaseController
|
||
{
|
||
@Autowired
|
||
private OGoodsService goodsService;
|
||
|
||
/**
|
||
* 搜索商品SKU
|
||
* 条件:商品编码、SKU、商品名称
|
||
*/
|
||
@GetMapping("/searchSku")
|
||
public TableDataInfo searchSkuBy(String keyword)
|
||
{
|
||
List<GoodsSpecListVo> list = goodsService.searchGoodsSpec(keyword);
|
||
return getDataTable(list);
|
||
}
|
||
|
||
/**
|
||
* 查询商品管理列表
|
||
*/
|
||
@PreAuthorize("@ss.hasPermi('goods:goods:list')")
|
||
@GetMapping("/list")
|
||
public TableDataInfo list(OGoods goods)
|
||
{
|
||
List<OGoods> list = goodsService.selectGoodsList(goods);
|
||
return getDataTable(list);
|
||
}
|
||
|
||
/**
|
||
* 获取商品管理详细信息
|
||
*/
|
||
@PreAuthorize("@ss.hasPermi('goods:goods:query')")
|
||
@GetMapping(value = "/{id}")
|
||
public AjaxResult getInfo(@PathVariable("id") Long id)
|
||
{
|
||
return success(goodsService.selectGoodsById(id));
|
||
}
|
||
|
||
/**
|
||
* 新增商品管理
|
||
*/
|
||
@PreAuthorize("@ss.hasPermi('goods:goods:add')")
|
||
@PostMapping
|
||
public AjaxResult add(@RequestBody OGoods goods)
|
||
{
|
||
goods.setCreateBy(getUsername());
|
||
int result = goodsService.insertGoods(goods);
|
||
if(result == -1) new AjaxResult(501,"商品编码已存在");
|
||
return toAjax(1);
|
||
}
|
||
|
||
/**
|
||
* 修改商品管理
|
||
*/
|
||
@PreAuthorize("@ss.hasPermi('goods:goods:edit')")
|
||
@PutMapping
|
||
public AjaxResult edit(@RequestBody OGoods goods)
|
||
{
|
||
return toAjax(goodsService.updateGoods(goods));
|
||
}
|
||
|
||
/**
|
||
* 删除商品管理
|
||
*/
|
||
@PreAuthorize("@ss.hasPermi('goods:goods:remove')")
|
||
@DeleteMapping("/{ids}")
|
||
public AjaxResult remove(@PathVariable Long[] ids)
|
||
{
|
||
return toAjax(goodsService.deleteGoodsByIds(ids));
|
||
}
|
||
}
|