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.mapper.TbBaidumapMapper; import com.hxzkmonitor.pojo.TbBaidumap; import com.hxzkmonitor.pojo.TbCompany; import com.hxzkmonitor.mapper.TbCompanyMapper; import com.hxzkmonitor.pojo.TbCompany; import com.hxzkmonitor.service.TbBaidumapService; import com.hxzkmonitor.service.TbCompanyService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; /** *

* 服务实现类 *

* * @author wangfei * @since 2024-08-05 */ @Service public class TbCompanyServiceImpl extends ServiceImpl implements TbCompanyService { @Autowired TbBaidumapService tbBaidumapService; @Autowired TbBaidumapMapper tbBaidumapMapper; @Override public IPage searchCompany(Page page, String keyword) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("Companyname", keyword); IPage tagid = baseMapper.selectPage(page, queryWrapper); return tagid; } @Override public Integer delCompany(Integer id) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("id", id); TbCompany tbCompany = baseMapper.selectOne(queryWrapper); QueryWrapper queryWrapper2 = new QueryWrapper<>(); queryWrapper2.eq("companyname", tbCompany.getCompanyname()); // tbBaidumapMapper.selectOne(queryWrapper2); tbBaidumapMapper.delete(queryWrapper2); return baseMapper.delete(queryWrapper); } @Override public Integer addorupCompany(TbCompany tbCompany) { Date date = new Date(); SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); tbCompany.setAddtime(formatter.format(date)); if (tbCompany.getId() != null) { return baseMapper.updateById(tbCompany); } else { TbBaidumap tbBaidumap = new TbBaidumap(); tbBaidumap.setMapname("百度地图"); tbBaidumap.setIsshow("在线地图"); tbBaidumap.setLevel("19"); tbBaidumap.setCenter("105.86159832032634;37.245153887456491"); tbBaidumap.setFile("/hxzkuwb/tiles"); tbBaidumap.setShijiao("64.5"); tbBaidumap.setHeig("60"); tbBaidumap.setIshow("显示"); tbBaidumap.setZhuanhuan("百度"); tbBaidumap.setMoshi("0"); tbBaidumap.setCompanyname(tbCompany.getCompanyname()); tbBaidumapService.addorupBaidumap(tbBaidumap); return baseMapper.insert(tbCompany); } } @Override public IPage getCompanyPage(Page page) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.orderByDesc("addtime"); IPage CompanyPage = baseMapper.selectPage(page, queryWrapper); return CompanyPage; } @Override public List search(String query) { QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.like("companyname", query); queryWrapper.orderByDesc("addtime"); // queryWrapper.last("LIMIT 5"); return baseMapper.selectList(queryWrapper); } @Override public List searchfive() { QueryWrapper queryWrapper = new QueryWrapper<>(); // queryWrapper.like("companyname", query); queryWrapper.orderByDesc("addtime"); queryWrapper.last("LIMIT 5"); return baseMapper.selectList(queryWrapper); } }