Exemplo n.º 1
0
  /** 去修改用户页面 */
  @RequestMapping(value = "/goEditU")
  public ModelAndView goEditU() throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();

    // 顶部修改个人资料
    String fx = pd.getString("fx");

    logger.info("去修改用户页面," + fx);

    if ("head".equals(fx)) {
      mv.addObject("fx", "head");
    } else {
      mv.addObject("fx", "user");
    }

    List<Role> roleList = roleService.listAllERRoles(); // 列出所有二级角色
    pd = userService.findByUiId(pd); // 根据ID读取
    mv.setViewName("system/user/user_edit");
    mv.addObject("msg", "editU");
    mv.addObject("pd", pd);
    mv.addObject("roleList", roleList);

    return mv;
  }
Exemplo n.º 2
0
  /** 去新增用户页面 */
  @RequestMapping(value = "/goAddU")
  public ModelAndView goAddU() throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();

    // 从session获取用户信息
    Subject currentUser = SecurityUtils.getSubject();
    Session session = currentUser.getSession();
    User user = (User) session.getAttribute(Const.SESSION_USER);
    pd.put("USERID", user.getUSER_ID());
    pd.put("ROLEID", user.getROLE_ID());

    logger.info("pd:" + gson.toJson(pd));

    List<Role> roleList = null;
    if (userService.isAdmin(user.getROLE_ID())) {
      roleList = roleService.listAllERRoles(); // 列出所有角色
    } else if (userService.isCooper(user.getROLE_ID())) {
      roleList = roleService.listSubUserRole(userService.SUBUSER_CODE); // 列出所有二级角色
    }

    mv.setViewName("system/user/user_edit");
    mv.addObject("msg", "saveU");
    mv.addObject("pd", pd);
    mv.addObject("roleList", roleList);

    return mv;
  }
Exemplo n.º 3
0
 /** 列表 */
 @RequestMapping(value = "/list")
 public ModelAndView list(Page page) {
   logBefore(logger, "列表Imgmsg");
   if (!Jurisdiction.buttonJurisdiction(menuUrl, "cha")) {
     return null;
   } // 校验权限
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   try {
     pd = this.getPageData();
     String KEYWORD = pd.getString("KEYWORD");
     if (null != KEYWORD && !"".equals(KEYWORD)) {
       pd.put("KEYWORD", KEYWORD.trim());
     }
     page.setPd(pd);
     List<PageData> varList = imgmsgService.list(page); // 列出Imgmsg列表
     mv.setViewName("weixin/imgmsg/imgmsg_list");
     mv.addObject("varList", varList);
     mv.addObject("pd", pd);
     mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
   } catch (Exception e) {
     logger.error(e.toString(), e);
   }
   return mv;
 }
Exemplo n.º 4
0
  /** 批量删除 */
  @RequestMapping(value = "/deleteAllU")
  @ResponseBody
  public Object deleteAllU() {
    PageData pd = new PageData();
    Map<String, Object> map = new HashMap<String, Object>();
    try {
      pd = this.getPageData();
      List<PageData> pdList = new ArrayList<PageData>();
      String USER_IDS = pd.getString("USER_IDS");

      if (null != USER_IDS && !"".equals(USER_IDS)) {
        String ArrayUSER_IDS[] = USER_IDS.split(",");
        if (Jurisdiction.buttonJurisdiction(menuUrl, "del")) {
          userService.deleteAllU(ArrayUSER_IDS);
        }
        pd.put("msg", "ok");
      } else {
        pd.put("msg", "no");
      }

      pdList.add(pd);
      map.put("list", pdList);
    } catch (Exception e) {
      logger.error(e.toString(), e);
    } finally {
      logAfter(logger);
    }
    return AppUtil.returnObject(pd, map);
  }
Exemplo n.º 5
0
  /**
   * 用户注销
   *
   * @param
   * @return
   */
  @RequestMapping(value = "/logout")
  public ModelAndView logout() {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();

    // shiro管理的session
    Subject currentUser = SecurityUtils.getSubject();
    Session session = currentUser.getSession();

    session.removeAttribute(Const.SESSION_USER);
    session.removeAttribute(Const.SESSION_ROLE_RIGHTS);
    session.removeAttribute(Const.SESSION_allmenuList);
    session.removeAttribute(Const.SESSION_menuList);
    session.removeAttribute(Const.SESSION_QX);
    session.removeAttribute(Const.SESSION_userpds);
    session.removeAttribute(Const.SESSION_USERNAME);
    session.removeAttribute(Const.SESSION_USERROL);
    session.removeAttribute("changeMenu");

    // shiro销毁登录
    //		Subject subject = SecurityUtils.getSubject();
    currentUser.logout();

    pd = this.getPageData();
    String msg = pd.getString("msg");
    pd.put("msg", msg);

    pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
    mv.setViewName("system/admin/login");
    mv.addObject("pd", pd);
    return mv;
  }
Exemplo n.º 6
0
  /** 获取头部信息 */
  @RequestMapping(value = "/getUname")
  @ResponseBody
  public Object getList() {
    PageData pd = new PageData();
    Map<String, Object> map = new HashMap<String, Object>();
    try {
      pd = this.getPageData();
      List<PageData> pdList = new ArrayList<PageData>();

      // shiro管理的session
      Subject currentUser = SecurityUtils.getSubject();
      Session session = currentUser.getSession();

      PageData pds = new PageData();
      pds = (PageData) session.getAttribute("userpds");

      if (null == pds) {
        String USERNAME =
            session.getAttribute(Const.SESSION_USERNAME).toString(); // 获取当前登录者loginname
        pd.put("USERNAME", USERNAME);
        pds = userService.findByUId(pd);
        session.setAttribute("userpds", pds);
      }

      pdList.add(pds);
      map.put("list", pdList);
    } catch (Exception e) {
      logger.error(e.toString(), e);
    } finally {
      logAfter(logger);
    }
    return AppUtil.returnObject(pd, map);
  }
Exemplo n.º 7
0
 /** 批量删除 */
 @RequestMapping(value = "/deleteAll")
 @ResponseBody
 public Object deleteAll() {
   logBefore(logger, "批量删除Imgmsg");
   if (!Jurisdiction.buttonJurisdiction(menuUrl, "dell")) {
     return null;
   } // 校验权限
   PageData pd = new PageData();
   Map<String, Object> map = new HashMap<String, Object>();
   try {
     pd = this.getPageData();
     List<PageData> pdList = new ArrayList<PageData>();
     String DATA_IDS = pd.getString("DATA_IDS");
     if (null != DATA_IDS && !"".equals(DATA_IDS)) {
       String ArrayDATA_IDS[] = DATA_IDS.split(",");
       imgmsgService.deleteAll(ArrayDATA_IDS);
       pd.put("msg", "ok");
     } else {
       pd.put("msg", "no");
     }
     pdList.add(pd);
     map.put("list", pdList);
   } catch (Exception e) {
     logger.error(e.toString(), e);
   } finally {
     logAfter(logger);
   }
   return AppUtil.returnObject(pd, map);
 }
Exemplo n.º 8
0
 /** 保存系统设置2 */
 @RequestMapping(value = "/saveSys2")
 public ModelAndView saveSys2() throws Exception {
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   Tools.writeFile(
       Const.FWATERM,
       pd.getString("isCheck1")
           + ",fh,"
           + pd.getString("fcontent")
           + ",fh,"
           + pd.getString("fontSize")
           + ",fh,"
           + pd.getString("fontX")
           + ",fh,"
           + pd.getString("fontY")); // 文字水印配置
   Tools.writeFile(
       Const.IWATERM,
       pd.getString("isCheck2")
           + ",fh,"
           + pd.getString("imgUrl")
           + ",fh,"
           + pd.getString("imgX")
           + ",fh,"
           + pd.getString("imgY")); // 图片水印配置
   Watermark.fushValue();
   mv.addObject("msg", "OK");
   mv.setViewName("save_result");
   return mv;
 }
Exemplo n.º 9
0
 /**
  * 访问登录页
  *
  * @return
  */
 @RequestMapping(value = "/login_toLogin")
 public ModelAndView toLogin() throws Exception {
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
   mv.setViewName("system/admin/login");
   mv.addObject("pd", pd);
   return mv;
 }
Exemplo n.º 10
0
 /** 保存系统设置3 */
 @RequestMapping(value = "/saveSys3")
 public ModelAndView saveSys3() throws Exception {
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   Tools.writeFile(Const.WEIXIN, pd.getString("Token")); // 写入微信配置
   mv.addObject("msg", "OK");
   mv.setViewName("save_result");
   return mv;
 }
Exemplo n.º 11
0
 /**
  * 获取登录用户的IP
  *
  * @throws Exception
  */
 public void getRemortIP(String USERNAME) throws Exception {
   PageData pd = new PageData();
   HttpServletRequest request = this.getRequest();
   String ip = "";
   if (request.getHeader("x-forwarded-for") == null) {
     ip = request.getRemoteAddr();
   } else {
     ip = request.getHeader("x-forwarded-for");
   }
   pd.put("USERNAME", USERNAME);
   pd.put("IP", ip);
   userService.saveIP(pd);
 }
Exemplo n.º 12
0
 /** 新增 */
 @RequestMapping(value = "/save")
 public ModelAndView save() throws Exception {
   logBefore(logger, "新增Imgmsg");
   if (!Jurisdiction.buttonJurisdiction(menuUrl, "add")) {
     return null;
   } // 校验权限
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   pd.put("IMGMSG_ID", this.get32UUID()); // 主键
   pd.put("CREATETIME", Tools.date2Str(new Date())); // 创建时间
   imgmsgService.save(pd);
   mv.addObject("msg", "success");
   mv.setViewName("save_result");
   return mv;
 }
Exemplo n.º 13
0
  /** 显示用户列表(用户组) */
  @RequestMapping(value = "/listUsers")
  public ModelAndView listUsers(Page page) throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();

    String USERNAME = pd.getString("USERNAME");

    if (null != USERNAME && !"".equals(USERNAME)) {
      USERNAME = USERNAME.trim();
      pd.put("USERNAME", USERNAME);
    }

    String lastLoginStart = pd.getString("lastLoginStart");
    String lastLoginEnd = pd.getString("lastLoginEnd");

    if (lastLoginStart != null && !"".equals(lastLoginStart)) {
      lastLoginStart = lastLoginStart + " 00:00:00";
      pd.put("lastLoginStart", lastLoginStart);
    }
    if (lastLoginEnd != null && !"".equals(lastLoginEnd)) {
      lastLoginEnd = lastLoginEnd + " 00:00:00";
      pd.put("lastLoginEnd", lastLoginEnd);
    }

    // 从session获取用户信息
    Subject currentUser = SecurityUtils.getSubject();
    Session session = currentUser.getSession();
    User user = (User) session.getAttribute(Const.SESSION_USER);
    pd.put("USERID", user.getUSER_ID());
    pd.put("ROLEID", user.getROLE_ID());

    logger.info("pd:" + gson.toJson(pd));

    page.setPd(pd);
    List<PageData> userList = null;
    List<Role> roleList = null;
    if (userService.isAdmin(user.getROLE_ID())) {
      userList = userService.listPdPageUser(page); // 列出用户列表
      roleList = roleService.listAllERRoles(); // 列出所有角色

    } else if (userService.isCooper(user.getROLE_ID())) {
      userList = userService.listSubUser(page); // 列出用户列表
      roleList = roleService.listSubUserRole(userService.SUBUSER_CODE); // 列出所有二级角色
    }

    mv.setViewName("system/user/user_list");
    mv.addObject("userList", userList);
    mv.addObject("roleList", roleList);

    mv.addObject("pd", pd);
    mv.addObject(Const.SESSION_QX, this.getHC()); // 按钮权限
    return mv;
  }
Exemplo n.º 14
0
  /** 保存皮肤 */
  @RequestMapping(value = "/setSKIN")
  public void setSKIN(PrintWriter out) {
    PageData pd = new PageData();
    try {
      pd = this.getPageData();

      // shiro管理的session
      Subject currentUser = SecurityUtils.getSubject();
      Session session = currentUser.getSession();

      String USERNAME = session.getAttribute(Const.SESSION_USERNAME).toString(); // 获取当前登录者loginname
      pd.put("USERNAME", USERNAME);
      userService.setSKIN(pd);
      session.removeAttribute(Const.SESSION_userpds);
      session.removeAttribute(Const.SESSION_USERROL);
      out.write("success");
      out.close();
    } catch (Exception e) {
      logger.error(e.toString(), e);
    }
  }
Exemplo n.º 15
0
 /** @param i 1:保存message 2:保存userinfo,message 3:保存user,userinfo,message */
 public void saveMessage(PageData pd, int i) throws Exception {
   pd.put("create_time", new Date());
   if (i == 1) {
     dao.save("MessageMapper.saveMessage", pd);
   } else if (i == 2) {
     dao.save("UserInfoMapper.saveUserInfo", pd);
     dao.save("MessageMapper.saveMessage", pd);
   } else if (i == 3) {
     dao.save("UserMapper.saveUser", pd);
     dao.save("UserInfoMapper.saveUserInfo", pd);
     dao.save("MessageMapper.saveMessage", pd);
   }
 }
Exemplo n.º 16
0
 /** 修改用户 */
 @RequestMapping(value = "/editU")
 public ModelAndView editU() throws Exception {
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   if (pd.getString("PASSWORD") != null && !"".equals(pd.getString("PASSWORD"))) {
     pd.put(
         "PASSWORD",
         new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());
   }
   if (Jurisdiction.buttonJurisdiction(menuUrl, "edit")) {
     userService.editU(pd);
   }
   mv.addObject("msg", "success");
   mv.setViewName("save_result");
   return mv;
 }
Exemplo n.º 17
0
  /** 发送电子邮件 */
  @RequestMapping(value = "/sendEmail")
  @ResponseBody
  public Object sendEmail() {
    PageData pd = new PageData();
    pd = this.getPageData();
    Map<String, Object> map = new HashMap<String, Object>();
    String msg = "ok"; // 发送状态
    int count = 0; // 统计发送成功条数
    int zcount = 0; // 理论条数

    String strEMAIL = Tools.readTxtFile(Const.EMAIL); // 读取邮件配置

    List<PageData> pdList = new ArrayList<PageData>();

    String toEMAIL = pd.getString("EMAIL"); // 对方邮箱
    String TITLE = pd.getString("TITLE"); // 标题
    String CONTENT = pd.getString("CONTENT"); // 内容
    String TYPE = pd.getString("TYPE"); // 类型
    String isAll = pd.getString("isAll"); // 是否发送给全体成员 yes or no

    String fmsg = pd.getString("fmsg"); // 判断是系统用户还是会员 "appuser"为会员用户

    if (null != strEMAIL && !"".equals(strEMAIL)) {
      String strEM[] = strEMAIL.split(",fh,");
      if (strEM.length == 4) {
        if ("yes".endsWith(isAll)) {
          try {
            List<PageData> userList = new ArrayList<PageData>();

            userList =
                "appuser".equals(fmsg)
                    ? appuserService.listAllUser(pd)
                    : userService.listAllUser(pd);

            zcount = userList.size();
            try {
              for (int i = 0; i < userList.size(); i++) {
                if (Tools.checkEmail(userList.get(i).getString("EMAIL"))) { // 邮箱格式不对就跳过
                  SimpleMailSender.sendEmail(
                      strEM[0],
                      strEM[1],
                      strEM[2],
                      strEM[3],
                      userList.get(i).getString("EMAIL"),
                      TITLE,
                      CONTENT,
                      TYPE); // 调用发送邮件函数
                  count++;
                } else {
                  continue;
                }
              }
              msg = "ok";
            } catch (Exception e) {
              msg = "error";
            }

          } catch (Exception e) {
            msg = "error";
          }
        } else {
          toEMAIL = toEMAIL.replaceAll(";", ";");
          toEMAIL = toEMAIL.replaceAll(" ", "");
          String[] arrTITLE = toEMAIL.split(";");
          zcount = arrTITLE.length;
          try {
            for (int i = 0; i < arrTITLE.length; i++) {
              if (Tools.checkEmail(arrTITLE[i])) { // 邮箱格式不对就跳过
                SimpleMailSender.sendEmail(
                    strEM[0],
                    strEM[1],
                    strEM[2],
                    strEM[3],
                    arrTITLE[i],
                    TITLE,
                    CONTENT,
                    TYPE); // 调用发送邮件函数
                count++;
              } else {
                continue;
              }
            }
            msg = "ok";
          } catch (Exception e) {
            msg = "error";
          }
        }
      } else {
        msg = "error";
      }
    } else {
      msg = "error";
    }
    pd.put("msg", msg);
    pd.put("count", count); // 成功数
    pd.put("ecount", zcount - count); // 失败数
    pdList.add(pd);
    map.put("list", pdList);
    return AppUtil.returnObject(pd, map);
  }
Exemplo n.º 18
0
  /** 获取用户权限 */
  public Map<String, String> getUQX(Session session) {
    PageData pd = new PageData();
    Map<String, String> map = new HashMap<String, String>();
    try {
      String USERNAME = session.getAttribute(Const.SESSION_USERNAME).toString();
      pd.put(Const.SESSION_USERNAME, USERNAME);
      String ROLE_ID = userService.findByUId(pd).get("ROLE_ID").toString();

      pd.put("ROLE_ID", ROLE_ID);

      PageData pd2 = new PageData();
      pd2.put(Const.SESSION_USERNAME, USERNAME);
      pd2.put("ROLE_ID", ROLE_ID);

      pd = roleService.findObjectById(pd);

      pd2 = roleService.findGLbyrid(pd2);
      if (null != pd2) {
        map.put("FX_QX", pd2.get("FX_QX").toString());
        map.put("FW_QX", pd2.get("FW_QX").toString());
        map.put("QX1", pd2.get("QX1").toString());
        map.put("QX2", pd2.get("QX2").toString());
        map.put("QX3", pd2.get("QX3").toString());
        map.put("QX4", pd2.get("QX4").toString());

        pd2.put("ROLE_ID", ROLE_ID);
        pd2 = roleService.findYHbyrid(pd2);
        map.put("C1", pd2.get("C1").toString());
        map.put("C2", pd2.get("C2").toString());
        map.put("C3", pd2.get("C3").toString());
        map.put("C4", pd2.get("C4").toString());
        map.put("Q1", pd2.get("Q1").toString());
        map.put("Q2", pd2.get("Q2").toString());
        map.put("Q3", pd2.get("Q3").toString());
        map.put("Q4", pd2.get("Q4").toString());
      }

      map.put("adds", pd.getString("ADD_QX"));
      map.put("dels", pd.getString("DEL_QX"));
      map.put("edits", pd.getString("EDIT_QX"));
      map.put("chas", pd.getString("CHA_QX"));

      // System.out.println(map);

      this.getRemortIP(USERNAME);
    } catch (Exception e) {
      logger.error(e.toString(), e);
    }
    return map;
  }
Exemplo n.º 19
0
 /*
  * 导出到excel
  * @return
  */
 @RequestMapping(value = "/excel")
 public ModelAndView exportExcel() {
   logBefore(logger, "导出Imgmsg到excel");
   if (!Jurisdiction.buttonJurisdiction(menuUrl, "cha")) {
     return null;
   }
   ModelAndView mv = new ModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   try {
     Map<String, Object> dataMap = new HashMap<String, Object>();
     List<String> titles = new ArrayList<String>();
     titles.add("关键词"); // 1
     titles.add("创建时间"); // 2
     titles.add("状态"); // 3
     titles.add("备注"); // 4
     titles.add("标题1"); // 5
     titles.add("描述1"); // 6
     titles.add("图片地址1"); // 7
     titles.add("超链接1"); // 8
     titles.add("标题2"); // 9
     titles.add("描述2"); // 10
     titles.add("图片地址2"); // 11
     titles.add("超链接2"); // 12
     titles.add("标题3"); // 13
     titles.add("描述3"); // 14
     titles.add("图片地址3"); // 15
     titles.add("超链接3"); // 16
     titles.add("标题4"); // 17
     titles.add("描述4"); // 18
     titles.add("图片地址4"); // 19
     titles.add("超链接4"); // 20
     titles.add("标题5"); // 21
     titles.add("描述5"); // 22
     titles.add("图片地址5"); // 23
     titles.add("超链接5"); // 24
     titles.add("标题6"); // 25
     titles.add("描述6"); // 26
     titles.add("图片地址6"); // 27
     titles.add("超链接6"); // 28
     titles.add("标题7"); // 29
     titles.add("描述7"); // 30
     titles.add("图片地址7"); // 31
     titles.add("超链接7"); // 32
     titles.add("标题8"); // 33
     titles.add("描述8"); // 34
     titles.add("图片地址8"); // 35
     titles.add("超链接8"); // 36
     dataMap.put("titles", titles);
     List<PageData> varOList = imgmsgService.listAll(pd);
     List<PageData> varList = new ArrayList<PageData>();
     for (int i = 0; i < varOList.size(); i++) {
       PageData vpd = new PageData();
       vpd.put("var1", varOList.get(i).getString("KEYWORD")); // 1
       vpd.put("var2", varOList.get(i).getString("CREATETIME")); // 2
       vpd.put("var3", varOList.get(i).get("STATUS").toString()); // 3
       vpd.put("var4", varOList.get(i).getString("BZ")); // 4
       vpd.put("var5", varOList.get(i).getString("TITLE1")); // 5
       vpd.put("var6", varOList.get(i).getString("DESCRIPTION1")); // 6
       vpd.put("var7", varOList.get(i).getString("IMGURL1")); // 7
       vpd.put("var8", varOList.get(i).getString("TOURL1")); // 8
       vpd.put("var9", varOList.get(i).getString("TITLE2")); // 9
       vpd.put("var10", varOList.get(i).getString("DESCRIPTION2")); // 10
       vpd.put("var11", varOList.get(i).getString("IMGURL2")); // 11
       vpd.put("var12", varOList.get(i).getString("TOURL2")); // 12
       vpd.put("var13", varOList.get(i).getString("TITLE3")); // 13
       vpd.put("var14", varOList.get(i).getString("DESCRIPTION3")); // 14
       vpd.put("var15", varOList.get(i).getString("IMGURL3")); // 15
       vpd.put("var16", varOList.get(i).getString("TOURL3")); // 16
       vpd.put("var17", varOList.get(i).getString("TITLE4")); // 17
       vpd.put("var18", varOList.get(i).getString("DESCRIPTION4")); // 18
       vpd.put("var19", varOList.get(i).getString("IMGURL4")); // 19
       vpd.put("var20", varOList.get(i).getString("TOURL4")); // 20
       vpd.put("var21", varOList.get(i).getString("TITLE5")); // 21
       vpd.put("var22", varOList.get(i).getString("DESCRIPTION5")); // 22
       vpd.put("var23", varOList.get(i).getString("IMGURL5")); // 23
       vpd.put("var24", varOList.get(i).getString("TOURL5")); // 24
       vpd.put("var25", varOList.get(i).getString("TITLE6")); // 25
       vpd.put("var26", varOList.get(i).getString("DESCRIPTION6")); // 26
       vpd.put("var27", varOList.get(i).getString("IMGURL6")); // 27
       vpd.put("var28", varOList.get(i).getString("TOURL6")); // 28
       vpd.put("var29", varOList.get(i).getString("TITLE7")); // 29
       vpd.put("var30", varOList.get(i).getString("DESCRIPTION7")); // 30
       vpd.put("var31", varOList.get(i).getString("IMGURL7")); // 31
       vpd.put("var32", varOList.get(i).getString("TOURL7")); // 32
       vpd.put("var33", varOList.get(i).getString("TITLE8")); // 33
       vpd.put("var34", varOList.get(i).getString("DESCRIPTION8")); // 34
       vpd.put("var35", varOList.get(i).getString("IMGURL8")); // 35
       vpd.put("var36", varOList.get(i).getString("TOURL8")); // 36
       varList.add(vpd);
     }
     dataMap.put("varList", varList);
     ObjectExcelView erv = new ObjectExcelView();
     mv = new ModelAndView(erv, dataMap);
   } catch (Exception e) {
     logger.error(e.toString(), e);
   }
   return mv;
 }
Exemplo n.º 20
0
  /** 访问系统首页 */
  @RequestMapping(value = "/main/{changeMenu}")
  public ModelAndView login_index(@PathVariable("changeMenu") String changeMenu) {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();
    try {

      // shiro管理的session
      Subject currentUser = SecurityUtils.getSubject();
      Session session = currentUser.getSession();

      User user = (User) session.getAttribute(Const.SESSION_USER);
      if (user != null) {

        User userr = (User) session.getAttribute(Const.SESSION_USERROL);
        if (null == userr) {
          user = userService.getUserAndRoleById(user.getUSER_ID());
          session.setAttribute(Const.SESSION_USERROL, user);
        } else {
          user = userr;
        }
        Role role = user.getRole();
        String roleRights = role != null ? role.getRIGHTS() : "";
        // 避免每次拦截用户操作时查询数据库,以下将用户所属角色权限、用户权限限都存入session
        session.setAttribute(Const.SESSION_ROLE_RIGHTS, roleRights); // 将角色权限存入session
        session.setAttribute(Const.SESSION_USERNAME, user.getUSERNAME()); // 放入用户名

        List<Menu> allmenuList = new ArrayList<Menu>();

        if (null == session.getAttribute(Const.SESSION_allmenuList)) {
          allmenuList = menuService.listAllMenu();
          if (Tools.notEmpty(roleRights)) {
            for (Menu menu : allmenuList) {
              menu.setHasMenu(RightsHelper.testRights(roleRights, menu.getMENU_ID()));
              if (menu.isHasMenu()) {
                List<Menu> subMenuList = menu.getSubMenu();
                for (Menu sub : subMenuList) {
                  sub.setHasMenu(RightsHelper.testRights(roleRights, sub.getMENU_ID()));
                }
              }
            }
          }
          session.setAttribute(Const.SESSION_allmenuList, allmenuList); // 菜单权限放入session中
        } else {
          allmenuList = (List<Menu>) session.getAttribute(Const.SESSION_allmenuList);
        }

        // 切换菜单=====
        List<Menu> menuList = new ArrayList<Menu>();
        // if(null == session.getAttribute(Const.SESSION_menuList) ||
        // ("yes".equals(pd.getString("changeMenu")))){
        if (null == session.getAttribute(Const.SESSION_menuList) || ("yes".equals(changeMenu))) {
          List<Menu> menuList1 = new ArrayList<Menu>();
          List<Menu> menuList2 = new ArrayList<Menu>();

          // 拆分菜单
          for (int i = 0; i < allmenuList.size(); i++) {
            Menu menu = allmenuList.get(i);
            if ("1".equals(menu.getMENU_TYPE())) {
              menuList1.add(menu);
            } else {
              menuList2.add(menu);
            }
          }

          session.removeAttribute(Const.SESSION_menuList);
          if ("2".equals(session.getAttribute("changeMenu"))) {
            session.setAttribute(Const.SESSION_menuList, menuList1);
            session.removeAttribute("changeMenu");
            session.setAttribute("changeMenu", "1");
            menuList = menuList1;
          } else {
            session.setAttribute(Const.SESSION_menuList, menuList2);
            session.removeAttribute("changeMenu");
            session.setAttribute("changeMenu", "2");
            menuList = menuList2;
          }
        } else {
          menuList = (List<Menu>) session.getAttribute(Const.SESSION_menuList);
        }
        // 切换菜单=====

        if (null == session.getAttribute(Const.SESSION_QX)) {
          session.setAttribute(Const.SESSION_QX, this.getUQX(session)); // 按钮权限放到session中
        }

        // FusionCharts 报表
        //			 	String strXML = "<graph caption='前12个月订单销量柱状图' xAxisName='月份' yAxisName='值'
        // decimalPrecision='0' formatNumberScale='0'><set name='2013-05' value='4'
        // color='AFD8F8'/><set name='2013-04' value='0' color='AFD8F8'/><set name='2013-03'
        // value='0' color='AFD8F8'/><set name='2013-02' value='0' color='AFD8F8'/><set
        // name='2013-01' value='0' color='AFD8F8'/><set name='2012-01' value='0'
        // color='AFD8F8'/><set name='2012-11' value='0' color='AFD8F8'/><set name='2012-10'
        // value='0' color='AFD8F8'/><set name='2012-09' value='0' color='AFD8F8'/><set
        // name='2012-08' value='0' color='AFD8F8'/><set name='2012-07' value='0'
        // color='AFD8F8'/><set name='2012-06' value='0' color='AFD8F8'/></graph>" ;
        //			 	mv.addObject("strXML", strXML);
        // FusionCharts 报表

        // 读取websocket配置
        String strWEBSOCKET = Tools.readTxtFile(Const.WEBSOCKET); // 读取WEBSOCKET配置
        if (null != strWEBSOCKET && !"".equals(strWEBSOCKET)) {
          String strIW[] = strWEBSOCKET.split(",fh,");
          if (strIW.length == 4) {
            pd.put("WIMIP", strIW[0]);
            pd.put("WIMPORT", strIW[1]);
            pd.put("OLIP", strIW[2]);
            pd.put("OLPORT", strIW[3]);
          }
        }
        // 读取websocket配置

        mv.setViewName("system/admin/index");
        mv.addObject("user", user);
        mv.addObject("menuList", menuList);
      } else {
        mv.setViewName("system/admin/login"); // session失效后跳转登录页面
      }

    } catch (Exception e) {
      mv.setViewName("system/admin/login");
      logger.error(e.getMessage(), e);
    }
    pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
    mv.addObject("pd", pd);
    return mv;
  }
Exemplo n.º 21
0
  /** 保存用户 */
  @RequestMapping(value = "/saveU")
  public ModelAndView saveU(PrintWriter out) throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();

    pd.put("USER_ID", this.get32UUID()); // ID
    pd.put("RIGHTS", ""); // 权限
    pd.put("LAST_LOGIN", ""); // 最后登录时间
    pd.put("IP", ""); // IP
    pd.put("STATUS", "0"); // 状态
    pd.put("SKIN", "default"); // 默认皮肤

    // 从session获取用户信息
    Subject currentUser = SecurityUtils.getSubject();
    Session session = currentUser.getSession();
    User user = (User) session.getAttribute(Const.SESSION_USER);
    pd.put("CREATOR", user.getUSER_ID());

    logger.info("pd:" + gson.toJson(pd));

    pd.put(
        "PASSWORD",
        new SimpleHash("SHA-1", pd.getString("USERNAME"), pd.getString("PASSWORD")).toString());

    if (null == userService.findByUId(pd)) {
      if (Jurisdiction.buttonJurisdiction(menuUrl, "add")) {
        userService.saveU(pd);
      } // 判断新增权限
      mv.addObject("msg", "success");
    } else {
      mv.addObject("msg", "failed");
    }
    mv.setViewName("save_result");
    return mv;
  }
Exemplo n.º 22
0
  /** 从EXCEL导入到数据库 */
  @RequestMapping(value = "/readExcel")
  public ModelAndView readExcel(@RequestParam(value = "excel", required = false) MultipartFile file)
      throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    if (!Jurisdiction.buttonJurisdiction(menuUrl, "add")) {
      return null;
    }
    if (null != file && !file.isEmpty()) {
      String filePath = PathUtil.getClasspath() + Const.FILEPATHFILE; // 文件上传路径
      String fileName = FileUpload.fileUp(file, filePath, "userexcel"); // 执行上传

      List<PageData> listPd =
          (List) ObjectExcelRead.readExcel(filePath, fileName, 2, 0, 0); // 执行读EXCEL操作,读出的数据导入List
      // 2:从第3行开始;0:从第A列开始;0:第0个sheet

      /* 存入数据库操作====================================== */
      pd.put("RIGHTS", ""); // 权限
      pd.put("LAST_LOGIN", ""); // 最后登录时间
      pd.put("IP", ""); // IP
      pd.put("STATUS", "0"); // 状态
      pd.put("SKIN", "default"); // 默认皮肤

      List<Role> roleList = roleService.listAllERRoles(); // 列出所有二级角色

      pd.put("ROLE_ID", roleList.get(0).getROLE_ID()); // 设置角色ID为随便第一个
      /** var0 :编号 var1 :姓名 var2 :手机 var3 :邮箱 var4 :备注 */
      for (int i = 0; i < listPd.size(); i++) {
        pd.put("USER_ID", this.get32UUID()); // ID
        pd.put("NAME", listPd.get(i).getString("var1")); // 姓名

        String USERNAME = GetPinyin.getPingYin(listPd.get(i).getString("var1")); // 根据姓名汉字生成全拼
        pd.put("USERNAME", USERNAME);
        if (userService.findByUId(pd) != null) { // 判断用户名是否重复
          USERNAME = GetPinyin.getPingYin(listPd.get(i).getString("var1")) + Tools.getRandomNum();
          pd.put("USERNAME", USERNAME);
        }
        pd.put("BZ", listPd.get(i).getString("var4")); // 备注
        if (Tools.checkEmail(listPd.get(i).getString("var3"))) { // 邮箱格式不对就跳过
          pd.put("EMAIL", listPd.get(i).getString("var3"));
          if (userService.findByUE(pd) != null) { // 邮箱已存在就跳过
            continue;
          }
        } else {
          continue;
        }

        pd.put("NUMBER", listPd.get(i).getString("var0")); // 编号已存在就跳过
        pd.put("PHONE", listPd.get(i).getString("var2")); // 手机号

        pd.put("PASSWORD", new SimpleHash("SHA-1", USERNAME, "123").toString()); // 默认密码123
        if (userService.findByUN(pd) != null) {
          continue;
        }
        userService.saveU(pd);
      }
      /* 存入数据库操作====================================== */

      mv.addObject("msg", "success");
    }

    mv.setViewName("save_result");
    return mv;
  }
Exemplo n.º 23
0
  /*
   * 导出用户信息到EXCEL
   *
   * @return
   */
  @RequestMapping(value = "/excel")
  public ModelAndView exportExcel() {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();
    try {
      if (Jurisdiction.buttonJurisdiction(menuUrl, "cha")) {
        // 检索条件===
        String USERNAME = pd.getString("USERNAME");
        if (null != USERNAME && !"".equals(USERNAME)) {
          USERNAME = USERNAME.trim();
          pd.put("USERNAME", USERNAME);
        }
        String lastLoginStart = pd.getString("lastLoginStart");
        String lastLoginEnd = pd.getString("lastLoginEnd");
        if (lastLoginStart != null && !"".equals(lastLoginStart)) {
          lastLoginStart = lastLoginStart + " 00:00:00";
          pd.put("lastLoginStart", lastLoginStart);
        }
        if (lastLoginEnd != null && !"".equals(lastLoginEnd)) {
          lastLoginEnd = lastLoginEnd + " 00:00:00";
          pd.put("lastLoginEnd", lastLoginEnd);
        }
        // 检索条件===

        Map<String, Object> dataMap = new HashMap<String, Object>();
        List<String> titles = new ArrayList<String>();

        titles.add("用户名"); // 1
        titles.add("编号"); // 2
        titles.add("姓名"); // 3
        titles.add("职位"); // 4
        titles.add("手机"); // 5
        titles.add("邮箱"); // 6
        titles.add("最近登录"); // 7
        titles.add("上次登录IP"); // 8

        dataMap.put("titles", titles);

        List<PageData> userList = userService.listAllUser(pd);
        List<PageData> varList = new ArrayList<PageData>();
        for (int i = 0; i < userList.size(); i++) {
          PageData vpd = new PageData();
          vpd.put("var1", userList.get(i).getString("USERNAME")); // 1
          vpd.put("var2", userList.get(i).getString("NUMBER")); // 2
          vpd.put("var3", userList.get(i).getString("NAME")); // 3
          vpd.put("var4", userList.get(i).getString("ROLE_NAME")); // 4
          vpd.put("var5", userList.get(i).getString("PHONE")); // 5
          vpd.put("var6", userList.get(i).getString("EMAIL")); // 6
          vpd.put("var7", userList.get(i).getString("LAST_LOGIN")); // 7
          vpd.put("var8", userList.get(i).getString("IP")); // 8
          varList.add(vpd);
        }
        dataMap.put("varList", varList);
        ObjectExcelView erv = new ObjectExcelView(); // 执行excel操作
        mv = new ModelAndView(erv, dataMap);
      }
    } catch (Exception e) {
      logger.error(e.toString(), e);
    }
    return mv;
  }
Exemplo n.º 24
0
 /** 保存系统设置1 */
 @RequestMapping(value = "/saveSys")
 public ModelAndView saveSys() throws Exception {
   ModelAndView mv = this.getModelAndView();
   PageData pd = new PageData();
   pd = this.getPageData();
   Tools.writeFile(Const.SYSNAME, pd.getString("YSYNAME")); // 写入系统名称
   Tools.writeFile(Const.PAGE, pd.getString("COUNTPAGE")); // 写入每页条数
   Tools.writeFile(
       Const.EMAIL,
       pd.getString("SMTP")
           + ",fh,"
           + pd.getString("PORT")
           + ",fh,"
           + pd.getString("EMAIL")
           + ",fh,"
           + pd.getString("PAW")); // 写入邮件服务器配置
   Tools.writeFile(
       Const.SMS1, pd.getString("SMSU1") + ",fh," + pd.getString("SMSPAW1")); // 写入短信1配置
   Tools.writeFile(
       Const.SMS2, pd.getString("SMSU2") + ",fh," + pd.getString("SMSPAW2")); // 写入短信2配置
   mv.addObject("msg", "OK");
   mv.setViewName("save_result");
   return mv;
 }
Exemplo n.º 25
0
  /** 请求登录,验证用户 */
  @RequestMapping(value = "/login_login", produces = "application/json;charset=UTF-8")
  @ResponseBody
  public Object login() throws Exception {
    Map<String, String> map = new HashMap<String, String>();
    PageData pd = new PageData();
    pd = this.getPageData();
    String errInfo = "";
    String KEYDATA[] = pd.getString("KEYDATA").split(",fh,");

    if (null != KEYDATA && KEYDATA.length == 3) {
      // shiro管理的session
      Subject currentUser = SecurityUtils.getSubject();
      Session session = currentUser.getSession();
      String sessionCode =
          (String) session.getAttribute(Const.SESSION_SECURITY_CODE); // 获取session中的验证码

      String code = KEYDATA[2];
      if (null == code || "".equals(code)) {
        errInfo = "nullcode"; // 验证码为空
      } else {
        String USERNAME = KEYDATA[0];
        String PASSWORD = KEYDATA[1];
        pd.put("USERNAME", USERNAME);
        if (Tools.notEmpty(sessionCode) && sessionCode.equalsIgnoreCase(code)) {
          String passwd = new SimpleHash("SHA-1", USERNAME, PASSWORD).toString(); // 密码加密
          pd.put("PASSWORD", passwd);
          pd = userService.getUserByNameAndPwd(pd);
          if (pd != null) {
            pd.put("LAST_LOGIN", DateUtil.getTime().toString());
            userService.updateLastLogin(pd);
            User user = new User();
            user.setUSER_ID(pd.getString("USER_ID"));
            user.setUSERNAME(pd.getString("USERNAME"));
            user.setPASSWORD(pd.getString("PASSWORD"));
            user.setNAME(pd.getString("NAME"));
            user.setRIGHTS(pd.getString("RIGHTS"));
            user.setROLE_ID(pd.getString("ROLE_ID"));
            user.setLAST_LOGIN(pd.getString("LAST_LOGIN"));
            user.setIP(pd.getString("IP"));
            user.setSTATUS(pd.getString("STATUS"));
            session.setAttribute(Const.SESSION_USER, user);
            session.removeAttribute(Const.SESSION_SECURITY_CODE);

            // shiro加入身份验证
            Subject subject = SecurityUtils.getSubject();
            UsernamePasswordToken token = new UsernamePasswordToken(USERNAME, PASSWORD);
            try {
              subject.login(token);
            } catch (AuthenticationException e) {
              errInfo = "身份验证失败!";
            }

          } else {
            errInfo = "usererror"; // 用户名或密码有误
          }
        } else {
          errInfo = "codeerror"; // 验证码输入有误
        }
        if (Tools.isEmpty(errInfo)) {
          errInfo = "success"; // 验证成功
        }
      }
    } else {
      errInfo = "error"; // 缺少参数
    }
    map.put("result", errInfo);
    return AppUtil.returnObject(new PageData(), map);
  }
Exemplo n.º 26
0
  /** 去系统设置页面 */
  @RequestMapping(value = "/goSystem")
  public ModelAndView goEditEmail() throws Exception {
    ModelAndView mv = this.getModelAndView();
    PageData pd = new PageData();
    pd = this.getPageData();
    pd.put("YSYNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
    pd.put("COUNTPAGE", Tools.readTxtFile(Const.PAGE)); // 读取每页条数
    String strEMAIL = Tools.readTxtFile(Const.EMAIL); // 读取邮件配置
    String strSMS1 = Tools.readTxtFile(Const.SMS1); // 读取短信1配置
    String strSMS2 = Tools.readTxtFile(Const.SMS2); // 读取短信2配置
    String strFWATERM = Tools.readTxtFile(Const.FWATERM); // 读取文字水印配置
    String strIWATERM = Tools.readTxtFile(Const.IWATERM); // 读取图片水印配置
    pd.put("Token", Tools.readTxtFile(Const.WEIXIN)); // 读取微信配置

    if (null != strEMAIL && !"".equals(strEMAIL)) {
      String strEM[] = strEMAIL.split(",fh,");
      if (strEM.length == 4) {
        pd.put("SMTP", strEM[0]);
        pd.put("PORT", strEM[1]);
        pd.put("EMAIL", strEM[2]);
        pd.put("PAW", strEM[3]);
      }
    }

    if (null != strSMS1 && !"".equals(strSMS1)) {
      String strS1[] = strSMS1.split(",fh,");
      if (strS1.length == 2) {
        pd.put("SMSU1", strS1[0]);
        pd.put("SMSPAW1", strS1[1]);
      }
    }

    if (null != strSMS2 && !"".equals(strSMS2)) {
      String strS2[] = strSMS2.split(",fh,");
      if (strS2.length == 2) {
        pd.put("SMSU2", strS2[0]);
        pd.put("SMSPAW2", strS2[1]);
      }
    }

    if (null != strFWATERM && !"".equals(strFWATERM)) {
      String strFW[] = strFWATERM.split(",fh,");
      if (strFW.length == 5) {
        pd.put("isCheck1", strFW[0]);
        pd.put("fcontent", strFW[1]);
        pd.put("fontSize", strFW[2]);
        pd.put("fontX", strFW[3]);
        pd.put("fontY", strFW[4]);
      }
    }

    if (null != strIWATERM && !"".equals(strIWATERM)) {
      String strIW[] = strIWATERM.split(",fh,");
      if (strIW.length == 4) {
        pd.put("isCheck2", strIW[0]);
        pd.put("imgUrl", strIW[1]);
        pd.put("imgX", strIW[2]);
        pd.put("imgY", strIW[3]);
      }
    }

    mv.setViewName("system/head/sys_edit");
    mv.addObject("pd", pd);

    return mv;
  }
Exemplo n.º 27
0
 public List<Message> messageList(Integer start, Integer limit) throws Exception {
   PageData pd = new PageData();
   pd.put("start", start);
   pd.put("limit", limit);
   return (List<Message>) dao.findForList("MessageMapper.messagePage", pd);
 }
Exemplo n.º 28
0
  /** 发送短信 */
  @RequestMapping(value = "/sendSms")
  @ResponseBody
  public Object sendSms() {
    PageData pd = new PageData();
    pd = this.getPageData();
    Map<String, Object> map = new HashMap<String, Object>();
    String msg = "ok"; // 发送状态
    int count = 0; // 统计发送成功条数
    int zcount = 0; // 理论条数

    List<PageData> pdList = new ArrayList<PageData>();

    String PHONEs = pd.getString("PHONE"); // 对方邮箱
    String CONTENT = pd.getString("CONTENT"); // 内容
    String isAll = pd.getString("isAll"); // 是否发送给全体成员 yes or no
    String TYPE = pd.getString("TYPE"); // 类型 1:短信接口1   2:短信接口2
    String fmsg = pd.getString("fmsg"); // 判断是系统用户还是会员 "appuser"为会员用户

    if ("yes".endsWith(isAll)) {
      try {
        List<PageData> userList = new ArrayList<PageData>();

        userList =
            "appuser".equals(fmsg) ? appuserService.listAllUser(pd) : userService.listAllUser(pd);

        zcount = userList.size();
        try {
          for (int i = 0; i < userList.size(); i++) {
            if (Tools.checkMobileNumber(userList.get(i).getString("PHONE"))) { // 手机号格式不对就跳过
              if ("1".equals(TYPE)) {
                SmsUtil.sendSms1(userList.get(i).getString("PHONE"), CONTENT); // 调用发短信函数1
              } else {
                // SmsUtil.sendSms2(userList.get(i).getString("PHONE"), CONTENT);		//调用发短信函数2
              }
              count++;
            } else {
              continue;
            }
          }
          msg = "ok";
        } catch (Exception e) {
          msg = "error";
        }

      } catch (Exception e) {
        msg = "error";
      }
    } else {
      PHONEs = PHONEs.replaceAll(";", ";");
      PHONEs = PHONEs.replaceAll(" ", "");
      String[] arrTITLE = PHONEs.split(";");
      zcount = arrTITLE.length;
      try {
        for (int i = 0; i < arrTITLE.length; i++) {
          if (Tools.checkMobileNumber(arrTITLE[i])) { // 手机号式不对就跳过
            if ("1".equals(TYPE)) {
              SmsUtil.sendSms1(arrTITLE[i], CONTENT); // 调用发短信函数1
            } else {
              // SmsUtil.sendSms2(arrTITLE[i], CONTENT);		//调用发短信函数2
            }
            count++;
          } else {
            continue;
          }
        }
        msg = "ok";
      } catch (Exception e) {
        msg = "error";
      }
    }
    pd.put("msg", msg);
    pd.put("count", count); // 成功数
    pd.put("ecount", zcount - count); // 失败数
    pdList.add(pd);
    map.put("list", pdList);
    return AppUtil.returnObject(pd, map);
  }