| | |
| | | package com.ruoyi.business.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.business.dto.PurchaseRegistrationDto; |
| | | import com.ruoyi.business.entity.PurchaseRegistration; |
| | | import com.ruoyi.business.mapper.PurchaseRegistrationMapper; |
| | | import com.ruoyi.business.service.PurchaseRegistrationService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.common.utils.bean.BeanUtils; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @RequiredArgsConstructor |
| | | public class PurchaseRegistrationServiceImpl extends ServiceImpl<PurchaseRegistrationMapper, PurchaseRegistration> implements PurchaseRegistrationService { |
| | | |
| | | |
| | | private final PurchaseRegistrationMapper purchaseRegistrationMapper; |
| | | |
| | | @Override |
| | | public IPage<PurchaseRegistration> selectPurchaseRegistrationList(Page page, PurchaseRegistrationDto purchaseRegistrationDto) { |
| | | LambdaQueryWrapper<PurchaseRegistration> queryWrapper = new LambdaQueryWrapper<>(); |
| | | queryWrapper.orderByDesc(PurchaseRegistration::getCreateTime); |
| | | return purchaseRegistrationMapper.selectPage(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | public int addOrEditPR(PurchaseRegistrationDto purchaseRegistrationDto) { |
| | | PurchaseRegistration purchaseRegistration = new PurchaseRegistration(); |
| | | BeanUtils.copyProperties(purchaseRegistrationDto,purchaseRegistration); |
| | | |
| | | if (Objects.isNull(purchaseRegistrationDto.getId())) { |
| | | return purchaseRegistrationMapper.insert(purchaseRegistration); |
| | | } else { |
| | | return purchaseRegistrationMapper.updateById(purchaseRegistration); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public int delByIds(Long[] ids) { |
| | | // 检查参数 |
| | | if (ids == null || ids.length == 0) { |
| | | return 0; |
| | | } |
| | | // 构造更新条件 |
| | | UpdateWrapper<PurchaseRegistration> updateWrapper = new UpdateWrapper<>(); |
| | | updateWrapper.in("id", ids) |
| | | .set("deleted", 1); // 设置 deleted 为 1 表示已删除 |
| | | // 执行批量逻辑删除 |
| | | return purchaseRegistrationMapper.update(null, updateWrapper); |
| | | } |
| | | } |