package com.hxzkmonitor.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.hxzkmonitor.pojo.TbBaidumap; import com.hxzkmonitor.pojo.TbBaidumap; import com.hxzkmonitor.mapper.TbBaidumapMapper; import com.hxzkmonitor.service.TbBaidumapService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** *

* 服务实现类 *

* * @author wangfei * @since 2024-08-22 */ @Service public class TbBaidumapServiceImpl extends ServiceImpl implements TbBaidumapService { @Override public IPage searchBaidumap(Page page, String keyword) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("tagid", keyword); QueryWrapper queryWrapper2 = new QueryWrapper<>(); queryWrapper2.eq("alarmname", keyword); List tagid1 = baseMapper.selectList(queryWrapper); List alarmname1 = baseMapper.selectList(queryWrapper2); if (tagid1.size() > 0) { IPage tagid = baseMapper.selectPage(page, queryWrapper); return tagid; } else if (alarmname1.size() > 0) { IPage alarmname = baseMapper.selectPage(page, queryWrapper2); return alarmname; } else { return null; } } @Override public Integer delBaidumap(Integer id) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("id", id); return baseMapper.delete(queryWrapper); } @Override public Integer addorupBaidumap(TbBaidumap tbBaidumap) { Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); tbBaidumap.setAddtime(formatter.format(date)); if (tbBaidumap.getId() != null) { return baseMapper.updateById(tbBaidumap); } else { return baseMapper.insert(tbBaidumap); } } @Override public IPage getBaidumapPage(Page page) { QueryWrapper queryWrapper = new QueryWrapper<>(); IPage userPage = baseMapper.selectPage(page, queryWrapper); return userPage; } }