| ¶Ô±ÈÐÂÎļþ |
| | |
| | | package cn.iocoder.yudao.module.mdm.api.item; |
| | | |
| | | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| | | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| | | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| | | import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemCreateReqDTO; |
| | | import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemRespDTO; |
| | | import cn.iocoder.yudao.module.mdm.api.item.dto.MdmItemUpdateReqDTO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemPageReqVO; |
| | | import cn.iocoder.yudao.module.mdm.controller.admin.item.vo.MdmItemSaveReqVO; |
| | | import cn.iocoder.yudao.module.mdm.dal.dataobject.item.MdmItemDO; |
| | | import cn.iocoder.yudao.module.mdm.dal.mysql.item.MdmItemMapper; |
| | | import cn.iocoder.yudao.module.mdm.service.item.MdmItemService; |
| | | import jakarta.annotation.Resource; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.Collection; |
| | | import java.util.List; |
| | | |
| | | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| | | |
| | | /** |
| | | * MDM ç©æ API å®ç°ç±» |
| | | * |
| | | * @author èéæºç |
| | | */ |
| | | @RestController |
| | | @RequestMapping(MdmItemApi.PREFIX) |
| | | @Validated |
| | | public class MdmItemApiImpl implements MdmItemApi { |
| | | |
| | | @Resource |
| | | private MdmItemService itemService; |
| | | |
| | | @Resource |
| | | private MdmItemMapper itemMapper; |
| | | |
| | | @Override |
| | | public CommonResult<Long> createItem(MdmItemCreateReqDTO createReqDTO) { |
| | | MdmItemSaveReqVO saveReqVO = BeanUtils.toBean(createReqDTO, MdmItemSaveReqVO.class); |
| | | // 设置é»è®¤ç¶æ |
| | | if (saveReqVO.getStatus() == null) { |
| | | saveReqVO.setStatus(0); |
| | | } |
| | | return success(itemService.createItem(saveReqVO)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<Boolean> updateItem(MdmItemUpdateReqDTO updateReqDTO) { |
| | | MdmItemSaveReqVO saveReqVO = BeanUtils.toBean(updateReqDTO, MdmItemSaveReqVO.class); |
| | | itemService.updateItem(saveReqVO); |
| | | return success(true); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<MdmItemRespDTO> getItem(Long id) { |
| | | MdmItemDO item = itemService.getItem(id); |
| | | return success(BeanUtils.toBean(item, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<List<MdmItemRespDTO>> getItemList(Collection<Long> ids) { |
| | | List<MdmItemDO> list = itemService.getItemList(ids); |
| | | return success(BeanUtils.toBean(list, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<PageResult<MdmItemRespDTO>> getItemPage(Integer itemType, Integer status, Integer pageNo, Integer pageSize) { |
| | | MdmItemPageReqVO pageReqVO = new MdmItemPageReqVO(); |
| | | pageReqVO.setItemType(itemType); |
| | | pageReqVO.setStatus(status); |
| | | pageReqVO.setPageNo(pageNo); |
| | | pageReqVO.setPageSize(pageSize); |
| | | PageResult<MdmItemDO> pageResult = itemService.getItemPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<List<MdmItemRespDTO>> getItemListByStatus(Integer status) { |
| | | MdmItemPageReqVO pageReqVO = new MdmItemPageReqVO(); |
| | | pageReqVO.setStatus(status); |
| | | pageReqVO.setPageNo(1); |
| | | pageReqVO.setPageSize(Integer.MAX_VALUE); |
| | | PageResult<MdmItemDO> pageResult = itemService.getItemPage(pageReqVO); |
| | | return success(BeanUtils.toBean(pageResult.getList(), MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<MdmItemRespDTO> validateItemExists(Long id) { |
| | | MdmItemDO item = itemService.validateItemExists(id); |
| | | return success(BeanUtils.toBean(item, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<MdmItemRespDTO> validateItemExistsAndEnable(Long id) { |
| | | MdmItemDO item = itemService.validateItemExistsAndEnable(id); |
| | | return success(BeanUtils.toBean(item, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<MdmItemRespDTO> getItemByCode(String code) { |
| | | MdmItemDO item = itemService.getItemByCode(code); |
| | | return success(BeanUtils.toBean(item, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<MdmItemRespDTO> getItemByBarCode(String barCode) { |
| | | MdmItemDO item = itemMapper.selectByBarCode(barCode); |
| | | return success(BeanUtils.toBean(item, MdmItemRespDTO.class)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<Long> getItemCountByCategoryId(Long categoryId) { |
| | | return success(itemService.getItemCountByCategoryId(categoryId)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<Long> getItemCountByUnitMeasureId(Long unitMeasureId) { |
| | | return success(itemService.getItemCountByUnitMeasureId(unitMeasureId)); |
| | | } |
| | | |
| | | @Override |
| | | public CommonResult<Boolean> updateItemStatus(Long id, Integer status) { |
| | | itemService.updateItemStatus(id, status); |
| | | return success(true); |
| | | } |
| | | |
| | | } |