package com.ycl.platform.service.impl; import com.ycl.platform.domain.entity.WorkOrderAuditingRecord; import com.ycl.platform.mapper.WorkOrderAuditingRecordMapper; import com.ycl.platform.service.WorkOrderAuditingRecordService; import com.ycl.system.Result; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ycl.platform.domain.vo.WorkOrderAuditingRecordVO; import com.ycl.platform.domain.query.WorkOrderAuditingRecordQuery; import java.util.List; import com.baomidou.mybatisplus.core.metadata.IPage; import com.ycl.system.page.PageUtil; import org.springframework.stereotype.Service; import org.springframework.util.Assert; import java.util.ArrayList; import java.util.stream.Collectors; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import lombok.RequiredArgsConstructor; /** * 工单审核记录 服务实现类 * * @author xp * @since 2024-03-06 */ @Service @RequiredArgsConstructor public class WorkOrderAuditingRecordServiceImpl extends ServiceImpl implements WorkOrderAuditingRecordService { private final WorkOrderAuditingRecordMapper workOrderAuditingRecordMapper; /** * 批量删除 * @param ids * @return */ @Override public Result remove(List ids) { if(baseMapper.deleteBatchIds(ids) > 0) { return Result.ok("删除成功"); } return Result.error("删除失败"); } /** * id删除 * @param id * @return */ @Override public Result removeById(String id) { if(baseMapper.deleteById(id) > 0) { return Result.ok("删除成功"); } return Result.error("删除失败"); } /** * 分页查询 * @param query * @return */ @Override public Result page(WorkOrderAuditingRecordQuery query) { IPage page = new LambdaQueryChainWrapper<>(baseMapper) .orderByDesc(WorkOrderAuditingRecord::getCreateTime) .page(PageUtil.getPage(query, WorkOrderAuditingRecord.class)); List vos = page.getRecords().stream() .map( entity -> WorkOrderAuditingRecordVO.getVoByEntity(entity, null) ) .collect(Collectors.toList()); return Result.ok().data(vos).total(page.getTotal()); } /** * 根据id查找 * @param id * @return */ @Override public Result detail(String id) { WorkOrderAuditingRecord entity = baseMapper.selectById(id); Assert.notNull(entity, "记录不存在"); WorkOrderAuditingRecordVO vo = WorkOrderAuditingRecordVO.getVoByEntity(entity, null); return Result.ok().data(vo); } /** * 列表 * @return */ @Override public Result all() { List entities = baseMapper.selectList(null); List vos = entities.stream() .map( entity -> WorkOrderAuditingRecordVO.getVoByEntity(entity, null) ) .collect(Collectors.toList()); return Result.ok().data(vos); } }