Beispiel #1
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;
 }
  /**
   * 用户注销
   *
   * @param session
   * @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();
    subject.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;
  }
 @RequestMapping("/login")
 public String login(ModelMap model) {
   PageData pd = new PageData();
   pd = this.getPageData();
   pd.put("SYSNAME", Tools.readTxtFile(Const.SYSNAME)); // 读取系统名称
   model.put("SYSNAME", pd);
   return "system/admin/login";
 }
Beispiel #4
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;
 }
Beispiel #5
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;
 }
Beispiel #6
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;
  }
Beispiel #7
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);
  }
Beispiel #8
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);
  }
  @RequestMapping(value = "/login_login", produces = "application/json;charset=UTF-8")
  @ResponseBody
  public Object tologin(ModelMap model) throws Exception {
    Map<String, String> map = new HashMap<String, String>();
    PageData pd = new PageData();
    pd = this.getPageData();
    String errInfo = "";
    String KEYDATA[] =
        pd.getString("KEYDATA")
            .replaceAll("qq263235040luckyboy", "")
            .replaceAll("*****@*****.**", "")
            .split(",luckyboy,");

    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);
  }
Beispiel #10
0
  /** 访问系统首页 */
  @RequestMapping(value = "/main/{changeMenu}")
  public ModelAndView login_index(@PathVariable("changeMenu") String changeMenu, ModelMap model) {
    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 报表
        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;
  }