package com.hxzk.controller; import com.github.pagehelper.PageInfo; import com.hxzk.pojo.TbHomeSetting; import com.hxzk.pojo.TbMarsHomeset; import com.hxzk.pojo.TbUser; import com.hxzk.service.MarsHomeSetService; import com.hxzk.util.SessionManager; 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.HttpServletRequest; 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 MarsHomeSetController { @Autowired MarsHomeSetService marsHomeSetService; @Autowired SessionManager sessionManager; @PostMapping("MarsHome") public TbMarsHomeset MarsHome(){ return marsHomeSetService.MarsHome(); } @GetMapping("FindMarsHomeSet") result> FindMarsHomeSet(Integer page, Integer limit){ PageInfo cz= marsHomeSetService.findAll(page, limit); return resultutil.returnSuccess(cz.getTotal(), cz.getList()); } @PostMapping("UpMarsHomeSet") public Integer UpMarsHomeSet(TbMarsHomeset marsHomeset){ return marsHomeSetService.UpMarsHomeSet(marsHomeset); }; @PostMapping("UpMarsHomeSetFrom") public void UpMarsHomeSetFrom(TbMarsHomeset marsHomeset, HttpServletResponse response, HttpServletRequest request) throws IOException { TbUser user = sessionManager.getCurrentUser(request); try { if (marsHomeset.getDetail()!=null){ marsHomeset.setDetail("1"); }else{ marsHomeset.setDetail("0"); } if (marsHomeset.getOfflinehide()!=null){ marsHomeset.setOfflinehide("1"); }else{ marsHomeset.setOfflinehide("0"); } if (marsHomeset.getVoice()!=null){ marsHomeset.setVoice("1"); }else{ marsHomeset.setVoice("0"); } if (marsHomeset.getShowfence()!=null){ marsHomeset.setShowfence("1"); }else{ marsHomeset.setShowfence("0"); } if (marsHomeset.getShowanchor()!=null){ marsHomeset.setShowanchor("1"); }else{ marsHomeset.setShowanchor("0"); } if (marsHomeset.getShowgateway()!=null){ marsHomeset.setShowgateway("1"); }else{ marsHomeset.setShowgateway("0"); } if (marsHomeset.getNoterrain()!=null){ marsHomeset.setNoterrain("1"); }else{ marsHomeset.setNoterrain("0"); } if (marsHomeset.getLayer()!=null){ marsHomeset.setLayer("1"); }else{ marsHomeset.setLayer("0"); } if (marsHomeset.getImage()!=null){ marsHomeset.setImage("1"); }else{ marsHomeset.setImage("0"); } if (marsHomeset.getBasemap()!=null){ marsHomeset.setBasemap("1"); }else{ marsHomeset.setBasemap("0"); } if (marsHomeset.getThreemap()!=null){ marsHomeset.setThreemap("1"); }else{ marsHomeset.setThreemap("0"); } marsHomeSetService.UpMarsHomeSet(marsHomeset); String content = "修改了地图设置"; String contentew= ""; String ipAddress = request.getRemoteAddr(); SystemLogController.InsertSystemLog(user.getUsername(),gettime(),content,"修改",ipAddress); }catch (Exception e){ } 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; } }