package com.gkhy.safePlatform.specialWork.service.baseService.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gkhy.safePlatform.commons.enums.ResultCodes; import com.gkhy.safePlatform.commons.exception.BusinessException; import com.gkhy.safePlatform.specialWork.entity.WorkAtHeightInfo; import com.gkhy.safePlatform.specialWork.entity.WorkConfinedSpaceInfo; import com.gkhy.safePlatform.specialWork.enums.WorkAtHeightStatusEnum; import com.gkhy.safePlatform.specialWork.enums.WorkConfinedSpaceStatusEnum; import com.gkhy.safePlatform.specialWork.model.query.WorkAtHeightQuery; import com.gkhy.safePlatform.specialWork.model.query.WorkConfinedSpaceQuery; import com.gkhy.safePlatform.specialWork.repository.WorkAtHeightInfoRepository; import com.gkhy.safePlatform.specialWork.repository.WorkConfinedSpaceInfoRepository; import com.gkhy.safePlatform.specialWork.service.baseService.WorkAtHeightInfoService; import com.gkhy.safePlatform.specialWork.service.baseService.WorkConfinedSpaceInfoService; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service("WorkAtHeightInfoService") public class WorkAtHeightInfoServiceImpl extends ServiceImpl implements WorkAtHeightInfoService { /** * 新增 * @param workAtHeightInfo * @return */ @Override public int saveOne(WorkAtHeightInfo workAtHeightInfo) { workAtHeightInfo.setGmtCreate(LocalDateTime.now()); workAtHeightInfo.setStatus(WorkAtHeightStatusEnum.VALID.getCode()); return baseMapper.insert(workAtHeightInfo); } /** * 修改 * @param workAtHeightInfo * @return */ @Override public int updateOne(WorkAtHeightInfo workAtHeightInfo) { if(null == workAtHeightInfo.getId()){ throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } workAtHeightInfo.setGmtModified(LocalDateTime.now()); return baseMapper.updateById(workAtHeightInfo); } /** * 删除-单条 * * @param id * @return */ @Override public int updateStatusById(Long id) { if(null == id){ throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } WorkAtHeightInfo workAtHeightInfo = new WorkAtHeightInfo(); workAtHeightInfo.setId(id); workAtHeightInfo.setStatus(WorkAtHeightStatusEnum.ABANDONED.getCode()); return baseMapper.updateById(workAtHeightInfo); } /** * 批量删除 * @param idList * @return */ @Override public int updateStatutsByIds(List idList) { if(null == idList || idList.size() == 0){ throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } return baseMapper.updateStatutsByIds(idList, WorkAtHeightStatusEnum.ABANDONED.getCode()); } /** * 根据id获取单条数据 * @param id * @return */ // @Override // public WorkAtHeightInfo getById(Long id) { // if(null == id){ // throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); // } // return baseMapper.selectOne(new LambdaQueryWrapper() // .eq(WorkAtHeightInfo::getId,id) // .eq(WorkAtHeightInfo::getStatus,WorkAtHeightStatusEnum.VALID.getCode()) // ); // } /** * 条件查询 * @param query * @return */ @Override public List getListByConditions(WorkAtHeightQuery query) { query.setStatus(WorkAtHeightStatusEnum.VALID.getCode()); return baseMapper.listByConditions(query); } }