3.7
fxl
2023-03-07 52cffc4ab8e9787a6f233295502c7c9788dddae1
src/main/java/com/hxzkoa/controller/LoginController.java
@@ -18,6 +18,8 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hxzkoa.json.tb_achor;
import com.hxzkoa.json.tb_login;
import com.hxzkoa.json.tb_system;
import com.hxzkoa.json.tb_user;
import com.hxzkoa.services.LoginService;
@@ -34,6 +36,7 @@
import com.hxzkoa.util.Config;
import com.hxzkoa.util.HttpUtil;
import com.hxzkoa.util.ModifyConfig;
import com.hxzkoa.util.PageUtil;
import net.sf.json.JSONObject;
@@ -67,6 +70,7 @@
      String result = "0";
      String db_password = user.getPassword();
      if (password.equals(db_password)) {
//    if (true) {
         HttpSession session = request.getSession();
         ServletContext application = session.getServletContext();
         application.setAttribute("username", user.getUsername());
@@ -75,27 +79,29 @@
         application.setAttribute("deleteq", user.getDeleteq());
         application.setAttribute("alertq", user.getAlertq());
         application.setAttribute("deleteall", user.getDeleteall());
         application.setAttribute("fenceq", user.getFenceq());
         session.setAttribute("username", user.getUsername());
         session.setAttribute("password", user.getPassword());
         session.setAttribute("superuser", user.getSuperuser());
         session.setAttribute("deleteq", user.getDeleteq());
         session.setAttribute("alertq", user.getAlertq());
         session.setAttribute("deleteall", user.getDeleteall());
         session.setAttribute("fenceq", user.getFenceq());
         result = "1";
         String username2 = (String) application.getAttribute("username");
         System.out.print(username2);
         //System.out.print(username2);
         
//       tb_system system = new tb_system();
//       system.setUdpPort("8234");
//       System.out.print(system);
//       //System.out.print(system);
//       JSONObject jsonObject = JSONObject.fromObject(system);
//       String postUrl = Config.getPostUrl();
//       String url_setting_bw = postUrl + "getSysSetting.do";
//       System.out.print(url_setting_bw);
//       //System.out.print(url_setting_bw);
//       JSONObject re_tb_setting = HttpUtil.doPost(url_setting_bw, jsonObject.toString(), "UTF-8");
//       tb_system re_setting = (tb_system) JSONObject.toBean(JSONObject.fromObject(re_tb_setting.get("result").toString()),
//             tb_system.class);
//       System.out.print(re_setting);
//       //System.out.print(re_setting);
//       String port = re_setting.getUdpPort();
         // 开启报文接收
//       try {
@@ -231,12 +237,14 @@
      application.removeAttribute("deleteq");
      application.removeAttribute("alertq");
      application.removeAttribute("deleteall");
      application.removeAttribute("fenceq");
      session.removeAttribute("username");
      session.removeAttribute("password");
      session.removeAttribute("superuser");
      session.removeAttribute("deleteq");
      session.removeAttribute("alertq");
      session.removeAttribute("deleteall");
      session.removeAttribute("fenceq");
      
      // 停止报文接收
      if (Config.getUdpRunning().equals("1")) {
@@ -255,4 +263,56 @@
      }
      return "redirect:/hxzk/login.jsp";
   }
   @RequestMapping(value = "/loginfa.do", method = { RequestMethod.POST, RequestMethod.GET })
   public String loginfa(HttpServletRequest request) throws Exception {
      String toPage = "forward:/hxzk/sysSetting/loginfa.jsp";
      List<tb_login> logins = loginService.getloginManagement(1);
      int curPage = 1;
      int count = loginService.getloginManagementCount();
      int minPage = PageUtil.getMinPage(count);
      request.setAttribute("dataList", logins);
      request.setAttribute("pageList", PageUtil.getPage(minPage));
      request.setAttribute("curPage", curPage);
      return toPage;
   }
   @ResponseBody
   @RequestMapping(value = "findloginid.do", method = {RequestMethod.POST,RequestMethod.GET})
   public JSONObject findloginid(HttpServletRequest request) throws Exception {
      JSONObject json = new JSONObject();
      String username = request.getParameter("input");
      List<tb_login> logins = loginService.getloginid(username);
      json.put("dataList", logins);
      return json;
   }
   @ResponseBody
   @RequestMapping(value = "/loginManagement_page.do", method = { RequestMethod.POST, RequestMethod.GET })
   public String loginManagement_page(HttpServletRequest request) {
      String pageStr = request.getParameter("page");
      String curPageStr = request.getParameter("curPage");
      int count = loginService.getloginManagementCount();
      int minPage = PageUtil.getMinPage(count);
      int curPage = Integer.parseInt(curPageStr);
      int page = 1;
      if ("pre".equals(pageStr)) {
         if (curPage > 1) {
            page = curPage - 1;
         }
      } else if ("next".equals(pageStr)) {
         if (curPage < minPage) {
            page = curPage + 1;
         }
      } else {
         page = Integer.parseInt(pageStr);
      }
      List<tb_login> loginManagementList = loginService.getloginManagement(page);
      List<Integer> pageList = PageUtil.getPage(PageUtil.getLocPage(page, curPage), page, minPage);
      JSONObject json = new JSONObject();
      json.put("dataList", loginManagementList);
      json.put("pageList", pageList);
      json.put("curPage", page);
      return json.toString();
   }
}