package com.hxzk.controller; import com.github.pagehelper.PageInfo; import com.hxzk.pojo.TbAchor; import com.hxzk.pojo.TbBaidumap; import com.hxzk.service.BaiduService; import com.hxzk.service.MapShowService; import com.hxzk.util.result; import com.hxzk.util.resultutil; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; @RestController @RequestMapping("/") public class BaiDuController { @Autowired BaiduService baiduService; @Autowired MapShowService mapShowService; @GetMapping("findbaidumap") result> findanchor(Integer page, Integer limit){ PageInfo cz= baiduService.findAll(page, limit); return resultutil.returnSuccess(cz.getTotal(), cz.getList()); } @GetMapping("findbaidumapList") List findList(){ List cz= baiduService.findAllList(); return cz; } @PostMapping("upBaiDuMap") public void upBaiDuMap(TbBaidumap baidumap, HttpServletResponse response) throws IOException { if (baidumap.getIshow() == null || baidumap.equals("null")){ baidumap.setIshow("不显示"); mapShowService.UpBaiDuMap("不显示",baidumap.getMapname()); }else{ baidumap.setIshow("显示"); mapShowService.UpBaiDuMap("显示",baidumap.getMapname()); } if (baidumap.getZhuanhuan() == null || baidumap.getZhuanhuan().equals("null")){ baidumap.setZhuanhuan("WGS84"); }else{ baidumap.setZhuanhuan("百度"); } baidumap.setAddtime(gettime()); baiduService.upBaiDuMap(baidumap); response.sendRedirect("/hxzkuwb/HouTai/DiTuMap/BaiDuDiTu.jsp"); } public String gettime(){ Date now = new Date(); // 创建日期格式化对象,设置格式为 "yyyy-MM-dd HH:mm" SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); // 格式化日期对象,输出字符串结果 String formattedDate = sdf.format(now); return formattedDate; } }