@@ -1,12 +1,11 @@ | |||
package com.tuoheng.admin.controller; | |||
import com.tuoheng.admin.entity.domain.Goods; | |||
import com.tuoheng.admin.entity.request.goods.QueryGoodsListByWarehouseIdRequest; | |||
import com.tuoheng.admin.service.goods.IGoodsService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.web.bind.annotation.GetMapping; | |||
import org.springframework.web.bind.annotation.RequestMapping; | |||
import org.springframework.web.bind.annotation.RestController; | |||
import org.springframework.web.bind.annotation.*; | |||
/** | |||
* @desc: 仓库物资 前端控制器 | |||
@@ -29,4 +28,38 @@ public class GoodsController { | |||
return goodsService.getListByWarehouseId(request); | |||
} | |||
/** | |||
* 添加物资 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@PostMapping("/add") | |||
public JsonResult add(@RequestBody Goods entity) { | |||
return goodsService.editInfo(entity); | |||
} | |||
/** | |||
* 编辑物资 | |||
* | |||
* @param entity 实体对象 | |||
* @return | |||
*/ | |||
@PutMapping("/edit") | |||
public JsonResult edit(@RequestBody Goods entity) { | |||
return goodsService.editInfo(entity); | |||
} | |||
/** | |||
* 删除物资 | |||
* | |||
* @param ids 物资ID | |||
* @return | |||
*/ | |||
@DeleteMapping("/delete/{ids}") | |||
public JsonResult delete(@PathVariable("ids") Integer[] ids) { | |||
return goodsService.deleteByIds(ids); | |||
} | |||
} |
@@ -1,8 +1,15 @@ | |||
package com.tuoheng.admin.service.goods; | |||
import cn.hutool.core.util.ObjectUtil; | |||
import com.tuoheng.admin.entity.domain.Goods; | |||
import com.tuoheng.admin.entity.request.goods.QueryGoodsListByWarehouseIdRequest; | |||
import com.tuoheng.admin.mapper.GoodsMapper; | |||
import com.tuoheng.admin.service.goods.query.QueryGoodsListByWarehouseIdService; | |||
import com.tuoheng.admin.utils.GaodeUtil; | |||
import com.tuoheng.common.common.BaseServiceImpl; | |||
import com.tuoheng.common.exception.ServiceException; | |||
import com.tuoheng.common.utils.JsonResult; | |||
import com.tuoheng.common.utils.StringUtils; | |||
import org.springframework.beans.factory.annotation.Autowired; | |||
import org.springframework.stereotype.Service; | |||
@@ -14,7 +21,7 @@ import org.springframework.stereotype.Service; | |||
* @date 2023-02-06 | |||
*/ | |||
@Service | |||
public class GoodsServiceImpl implements IGoodsService { | |||
public class GoodsServiceImpl extends BaseServiceImpl<GoodsMapper, Goods> implements IGoodsService { | |||
@Autowired | |||
private QueryGoodsListByWarehouseIdService queryGoodsListService; | |||
@@ -41,4 +48,19 @@ public class GoodsServiceImpl implements IGoodsService { | |||
return null; | |||
} | |||
@Override | |||
public JsonResult editInfo(Goods entity) { | |||
//新增 | |||
if (StringUtils.isNull(entity.getId())) { | |||
if (StringUtils.isEmpty(entity.getGoodsName())) { | |||
throw new ServiceException("物资名称不能为空"); | |||
} | |||
if (ObjectUtil.isEmpty(entity.getGoodsType())) { | |||
throw new ServiceException("物资类型不能为空"); | |||
} | |||
} | |||
super.edit(entity); | |||
return JsonResult.success(); | |||
} | |||
} |
@@ -1,6 +1,8 @@ | |||
package com.tuoheng.admin.service.goods; | |||
import com.tuoheng.admin.entity.domain.Goods; | |||
import com.tuoheng.admin.entity.request.goods.QueryGoodsListByWarehouseIdRequest; | |||
import com.tuoheng.common.common.IBaseService; | |||
import com.tuoheng.common.utils.JsonResult; | |||
/** | |||
@@ -10,7 +12,7 @@ import com.tuoheng.common.utils.JsonResult; | |||
* @team tuoheng | |||
* @date 2023-02-06 | |||
*/ | |||
public interface IGoodsService { | |||
public interface IGoodsService extends IBaseService<Goods> { | |||
/** | |||
@@ -28,4 +30,12 @@ public interface IGoodsService { | |||
* @return 物资 | |||
*/ | |||
JsonResult getOnesById(String id); | |||
/** | |||
* 新增或编辑物资 | |||
* | |||
* @param entity | |||
* @return | |||
*/ | |||
JsonResult editInfo(Goods entity); | |||
} |