package com.gkhy.safePlatform.specialWork.service.baseService.impl; 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.WorkHotInfo; import com.gkhy.safePlatform.specialWork.enums.WorkHotStatusEnum; import com.gkhy.safePlatform.specialWork.model.query.db.WorkHotQuery; import com.gkhy.safePlatform.specialWork.repository.WorkHotInfoRepository; import com.gkhy.safePlatform.specialWork.service.baseService.WorkHotInfoService; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; @Service("WorkHotInfoService") public class WorkHotInfoServiceImpl extends ServiceImpl implements WorkHotInfoService { /** * 新增 */ @Override public int saveOne(WorkHotInfo workHotInfo){ workHotInfo.setGmtCreate(LocalDateTime.now()); workHotInfo.setStatus(WorkHotStatusEnum.VALID.getCode()); return baseMapper.insert(workHotInfo); } /** * 更新 * @param workHotInfo * @return */ @Override public int updateOne(WorkHotInfo workHotInfo){ if(null == workHotInfo.getId()){ throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } workHotInfo.setGmtModified(LocalDateTime.now()); return baseMapper.updateById(workHotInfo); } /** * 删除 - 单条 * @param id * @return */ @Override public int updateOneStatus(Long id){ if(null == id){ throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } return baseMapper.updateOneStatus(id,WorkHotStatusEnum.ABANDONED.getCode()); } /** * 删除 - 批量 * @param ids * @return */ @Override public int batchUpdateStatus(List ids){ if(ids.size() == 0){ throw new BusinessException(ResultCodes.CLIENT_PARAM_NULL); } return baseMapper.batchUpdateStatus(ids, WorkHotStatusEnum.ABANDONED.getCode()); } /** * 列表 */ @Override public List listWorkHot(WorkHotQuery query){ query.setStatus(WorkHotStatusEnum.VALID.getCode()); return baseMapper.listByConditions(query); } }