/**
   * 帖子类型查询
   *
   * @param model
   * @param request
   * @param response
   * @return
   */
  @RequestMapping("dotopictypelist")
  public String doTopicTypeList(
      Model model, HttpServletRequest request, HttpServletResponse response) {
    int state = 0;
    String memo = "";
    try {

      String id = (String) request.getParameter("id");
      String status = (String) request.getParameter("status");
      String cIndex = request.getParameter("index");

      request.setAttribute("id", id);
      request.setAttribute("status", status);

      TopicType topicType = new TopicType();
      if (CollectionUtil.checkNull(status) && !"all".equals(status)) {
        topicType.setStatus(status);
      }
      if (CollectionUtil.checkNull(id)) {
        topicType.setId(id);
      }

      // 当前页数
      int currentIndex = 1;
      if (CollectionUtil.checkNull(cIndex)) {
        currentIndex = Integer.parseInt(cIndex);
      }
      request.setAttribute("index", currentIndex);
      // url
      String url = "/topictype/dotopictypelist?status=" + status + "&id=" + id;
      // 总行数
      int dataCount = this.topicTypeService.findTopicTypeCount(topicType);
      // 获得该页集合
      List<TopicType> topicTypeList =
          this.topicTypeService.findTopicTypeList(
              topicType, (currentIndex - 1) * PageUtil.PAGECOUNT, PageUtil.PAGECOUNT);
      // 获取翻页拼接html
      String pageinfo = PageUtil.pageUtil(dataCount, currentIndex, url, request);
      request.setAttribute("pageinfo", pageinfo);

      if (topicTypeList != null && topicTypeList.size() > 0) {
        request.setAttribute("topicTypeList", topicTypeList);
      }

      // 记录日志
      memo += "帖子类型查询";
      state = 1;
      this.adminLogService.addAdminLog(Constant.log_tzgl, memo, state, request);

    } catch (Exception e) {
      memo += "帖子类型查询,异常:" + e.getMessage();
      logger.error(memo, e);
      this.adminLogService.addAdminLog(Constant.log_tzgl, memo, state, request);
    }
    return "function/topic/topic_type_list";
  }
  /**
   * 广告图模块查询
   *
   * @param model
   * @param request
   * @param response
   * @return
   */
  @RequestMapping("dobigeyemodulelist")
  public String doBigeyeModuleList(
      Model model, HttpServletRequest request, HttpServletResponse response) {
    int state = 0;
    String memo = "";
    try {

      String module_id = (String) request.getParameter("module_id");
      String status = (String) request.getParameter("status");
      String cIndex = request.getParameter("index");

      request.setAttribute("module_id", module_id);
      request.setAttribute("status", status);

      BigeyeModule BigeyeModule = new BigeyeModule();
      if (CollectionUtil.checkNull(status) && !"all".equals(status)) {
        BigeyeModule.setStatus(status);
      }
      if (CollectionUtil.checkNull(module_id)) {
        BigeyeModule.setModule_id(module_id);
      }

      // 当前页数
      int currentIndex = 1;
      if (CollectionUtil.checkNull(cIndex)) {
        currentIndex = Integer.parseInt(cIndex);
      }
      request.setAttribute("index", currentIndex);
      // url
      String url = "/bigeyemodule/dobigeyemodulelist?status=" + status + "&module_id=" + module_id;
      // 总行数
      int dataCount = this.bigeyeModuleService.findBigeyeModuleCount(BigeyeModule);
      // 获得该页集合
      List<BigeyeModule> BigeyeModuleList =
          this.bigeyeModuleService.findBigeyeModuleList(
              BigeyeModule, (currentIndex - 1) * PageUtil.PAGECOUNT, PageUtil.PAGECOUNT);
      // 获取翻页拼接html
      String pageinfo = PageUtil.pageUtil(dataCount, currentIndex, url, request);
      request.setAttribute("pageinfo", pageinfo);

      if (BigeyeModuleList != null && BigeyeModuleList.size() > 0) {
        request.setAttribute("bigeyemoduleList", BigeyeModuleList);
      }

      // 记录日志
      memo += "广告图模块查询";
      state = 1;
      this.adminLogService.addAdminLog(Constant.log_dyzgl, memo, state, request);

    } catch (Exception e) {
      memo += "广告图模块查询,异常:" + e.getMessage();
      logger.error(memo, e);
      this.adminLogService.addAdminLog(Constant.log_dyzgl, memo, state, request);
    }
    return "function/bigeye/bigeye_module_list";
  }
  /**
   * 语言难度查询
   *
   * @param model
   * @param request
   * @param response
   * @return
   */
  @RequestMapping("dogloballanguagelist")
  public String doGlobalLanguageList(
      Model model, HttpServletRequest request, HttpServletResponse response) {
    int state = 0;
    String memo = "";
    try {

      String id = (String) request.getParameter("id");
      //			String status=(String)request.getParameter("status");
      String cIndex = request.getParameter("index");

      request.setAttribute("id", id);
      //			request.setAttribute("status", status);

      GlobalLanguage GlobalLanguage = new GlobalLanguage();
      //			if(CollectionUtil.checkNull(status) && !"all".equals(status)){
      //				GlobalLanguage.setStatus(status);
      //			}
      if (CollectionUtil.checkNull(id)) {
        GlobalLanguage.setId(id);
      }

      // 当前页数
      int currentIndex = 1;
      if (CollectionUtil.checkNull(cIndex)) {
        currentIndex = Integer.parseInt(cIndex);
      }
      request.setAttribute("index", currentIndex);
      // url
      String url = "/globallanguage/dogloballanguagelist?id=" + id;
      // 总行数
      int dataCount = this.globalLanguageService.findGlobalLanguageCount(GlobalLanguage);
      // 获得该页集合
      List<GlobalLanguage> GlobalLanguageList =
          this.globalLanguageService.findGlobalLanguageList(
              GlobalLanguage, (currentIndex - 1) * PageUtil.PAGECOUNT, PageUtil.PAGECOUNT);
      // 获取翻页拼接html
      String pageinfo = PageUtil.pageUtil(dataCount, currentIndex, url, request);
      request.setAttribute("pageinfo", pageinfo);

      if (GlobalLanguageList != null && GlobalLanguageList.size() > 0) {
        request.setAttribute("globallanguageList", GlobalLanguageList);
      }

      // 记录日志
      memo += "语言难度查询";
      state = 1;
      this.adminLogService.addAdminLog(Constant.log_qjpz, memo, state, request);

    } catch (Exception e) {
      memo += "语言难度查询,异常:" + e.getMessage();
      logger.error(memo, e);
      this.adminLogService.addAdminLog(Constant.log_qjpz, memo, state, request);
    }
    return "function/config/globallanguage/global_language_list";
  }
 public int addAdminLog(AdminLog adminLog, HttpServletRequest request) {
   if (!CollectionUtil.checkNull(adminLog.getOperAdmin())
       && request.getSession().getAttribute("admin_account") != null) {
     adminLog.setOperAdmin((String) request.getSession().getAttribute("admin_account"));
   }
   adminLog.setOperIp(getIpAddr(request));
   return this.adminLogDao.addAdminLog(adminLog);
 }
  /**
   * 进入广告图模块修改页面
   *
   * @param model
   * @param request
   * @param response
   * @return
   */
  @RequestMapping("toupdatebigeyemodule")
  public String toUpdateBigeyeModule(
      Model model, HttpServletRequest request, HttpServletResponse response) {
    try {
      String module_id = (String) request.getParameter("module_id");

      if (!CollectionUtil.checkNull(module_id)) {
        request.setAttribute("msg", "序列号不能为空!");
        return null;
      }
      BigeyeModule BigeyeModule = this.bigeyeModuleService.findBigeyeModuleOne(module_id);
      if (BigeyeModule != null) {
        request.setAttribute("bigeyemodule", BigeyeModule);
      }

      return "function/bigeye/bigeye_module_update";
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
    }
    return null;
  }
  /**
   * 进入语言难度修改页面
   *
   * @param model
   * @param request
   * @param response
   * @return
   */
  @RequestMapping("toupdategloballanguage")
  public String toUpdateGlobalLanguage(
      Model model, HttpServletRequest request, HttpServletResponse response) {
    try {
      String id = (String) request.getParameter("id");

      if (!CollectionUtil.checkNull(id)) {
        request.setAttribute("msg", "序列号不能为空!");
        return null;
      }
      GlobalLanguage globallanguage = this.globalLanguageService.findGlobalLanguageOne(id);
      if (globallanguage != null) {
        request.setAttribute("globallanguage", globallanguage);
      }

      return "function/config/globallanguage/global_language_update";
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
    }
    return null;
  }
  /**
   * 进入帖子类型修改页面
   *
   * @param model
   * @param request
   * @param response
   * @return
   */
  @RequestMapping("toupdatetopictype")
  public String toUpdateTopicType(
      Model model, HttpServletRequest request, HttpServletResponse response) {
    try {
      String id = (String) request.getParameter("id");

      if (!CollectionUtil.checkNull(id)) {
        request.setAttribute("msg", "序列号不能为空!");
        return null;
      }
      TopicType topicType = this.topicTypeService.findTopicTypeOne(id);
      if (topicType != null) {
        request.setAttribute("topicType", topicType);
      }

      return "function/topic/topic_type_update";
    } catch (Exception e) {
      logger.error(e.getMessage(), e);
    }
    return null;
  }
  /**
   * 广告图模块状态修改
   *
   * @param model
   * @param request
   * @param response
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "doupdatestatusbigeyemodule",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doUpdateStatusBigeyeModuleType(
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      PrintWriter printWriter) {
    response.setContentType("text/html; charset=utf-8");
    HttpSession session = request.getSession();
    int state = 0;
    String memo = "";
    JSONObject jsonObj = new JSONObject();
    try {
      jsonObj.put("res", "");
      jsonObj.put("su", "");

      String adminAccount = (String) session.getAttribute("admin_account");
      if (!CollectionUtil.checkNull(adminAccount)) {
        return null;
      }
      String module_id = (String) request.getParameter("module_id");
      String status = (String) request.getParameter("status");

      if (!CollectionUtil.checkNull(module_id)) {
        jsonObj.put("res", "序列号不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(status)) {
        jsonObj.put("res", "状态不能为空!");
        return null;
      }

      BigeyeModule BigeyeModule = new BigeyeModule();
      BigeyeModule.setModule_id(module_id);
      BigeyeModule.setStatus(status);

      int in = this.bigeyeModuleService.updateBigeyeModuleStatus(BigeyeModule);
      if (in > 0) {
        state = 1;
        memo += "修改广告图模块" + module_id + "状态" + status + "成功!";
        jsonObj.put("res", "1");
        jsonObj.put("su", memo);
      } else {
        memo += "修改广告图模块" + module_id + "状态" + status + "失败!";
        jsonObj.put("res", memo);
      }
      // 记录日志
      this.adminLogService.addAdminLog(Constant.log_dyzgl, memo, state, request);
    } catch (Exception e) {
      memo += "广告图模块状态修改 异常:" + e.getMessage();
      logger.error(memo, e);
      jsonObj.put("res", memo);
      this.adminLogService.addAdminLog(Constant.log_dyzgl, memo, state, request);
    } finally {
      printWriter.write(jsonObj.toString());
      printWriter.flush();
      printWriter.close();
    }
    return null;
  }
  /**
   * 广告图模块修改
   *
   * @param model
   * @param request
   * @param response
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "doupdatebigeyemodule",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doUpdateBigeyeModule(
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      PrintWriter printWriter) {
    response.setContentType("text/html; charset=utf-8");
    HttpSession session = request.getSession();
    int state = 0;
    String memo = "";
    JSONObject jsonObj = new JSONObject();
    try {
      jsonObj.put("res", "");
      jsonObj.put("su", "");

      String adminAccount = (String) session.getAttribute("admin_account");
      if (!CollectionUtil.checkNull(adminAccount)) {
        return null;
      }
      String module_id = (String) request.getParameter("module_id");
      String module_name = (String) request.getParameter("module_name");
      String img_width = (String) request.getParameter("img_width");
      String img_height = (String) request.getParameter("img_height");
      String status = (String) request.getParameter("status");

      if (!CollectionUtil.checkNull(module_id)) {
        jsonObj.put("res", "序列号不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(module_name)) {
        jsonObj.put("res", "类型名称不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(status)) {
        jsonObj.put("res", "状态不能为空!");
        return null;
      }
      // 获得该广告图模块信息
      BigeyeModule BigeyeModule = this.bigeyeModuleService.findBigeyeModuleOne(module_id);
      if (BigeyeModule == null) {
        jsonObj.put("res", "广告图模块获取失败或广告图模块序列号错误!");
        return null;
      }

      int ii = this.bigeyeModuleService.checkBigeyeModuleName(module_id, module_name);
      if (ii > 0) {
        jsonObj.put("res", "类型名称已存在,请从新填写类型名称!");
        return null;
      }
      if (CollectionUtil.checkNull(img_width)) {
        BigeyeModule.setImg_width(img_width);
      }
      if (CollectionUtil.checkNull(img_height)) {
        BigeyeModule.setImg_height(img_height);
      }
      BigeyeModule.setModule_name(module_name);
      BigeyeModule.setStatus(status);

      int in = this.bigeyeModuleService.updateBigeyeModule(BigeyeModule);
      if (in > 0) {
        state = 1;
        memo += "修改广告图模块" + module_id + "成功!";
        jsonObj.put("res", memo);
      } else {
        memo += "修改广告图模块" + module_id + "失败!";
        jsonObj.put("res", memo);
      }
      // 记录日志
      this.adminLogService.addAdminLog(Constant.log_dyzgl, memo, state, request);
    } catch (Exception e) {
      memo += "广告图模块修改 异常:" + e.getMessage();
      logger.error(memo, e);
      jsonObj.put("res", memo);
      this.adminLogService.addAdminLog(Constant.log_dyzgl, memo, state, request);
    } finally {
      printWriter.write(jsonObj.toString());
      printWriter.flush();
      printWriter.close();
    }
    return null;
  }
  /**
   * 语言难度删除
   *
   * @param model
   * @param request
   * @param response
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "dodeletegloballanguage",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doDeleteGlobalLanguage(
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      PrintWriter printWriter) {
    response.setContentType("text/html; charset=utf-8");
    HttpSession session = request.getSession();
    int state = 0;
    String memo = "";
    JSONObject jsonObj = new JSONObject();
    try {
      jsonObj.put("res", "");
      jsonObj.put("su", "");

      String adminAccount = (String) session.getAttribute("admin_account");
      if (!CollectionUtil.checkNull(adminAccount)) {
        return null;
      }

      String id = (String) request.getParameter("id");

      if (!CollectionUtil.checkNull(id)) {
        jsonObj.put("res", "序列号不能为空!");
        return null;
      }

      ResourceInfo ResourceInfo = new ResourceInfo();
      ResourceInfo.setLanguage_level(id);
      int ii = this.resourceInfoService.findResourceInfoCount(ResourceInfo);
      if (ii > 0) {
        jsonObj.put("res", "该语言难度在资源信息里面引用到,删除失败!");
        return null;
      }

      int in = this.globalLanguageService.deleteGlobalLanguage(id);
      if (in > 0) {
        state = 1;
        memo += "删除语言难度" + id + "成功!";
        jsonObj.put("res", "1");
        jsonObj.put("su", memo);
      } else {
        memo += "删除语言难度" + id + "失败!";
        jsonObj.put("res", memo);
      }
      // 记录日志
      this.adminLogService.addAdminLog(Constant.log_qjpz, memo, state, request);
    } catch (Exception e) {
      memo += "语言难度删除 异常:" + e.getMessage();
      logger.error(memo, e);
      jsonObj.put("res", memo);
      this.adminLogService.addAdminLog(Constant.log_qjpz, memo, state, request);
    } finally {
      printWriter.write(jsonObj.toString());
      printWriter.flush();
      printWriter.close();
    }
    return null;
  }
  /**
   * 语言难度修改
   *
   * @param model
   * @param request
   * @param response
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "doupdategloballanguage",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doUpdateGlobalLanguage(
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      PrintWriter printWriter) {
    response.setContentType("text/html; charset=utf-8");
    HttpSession session = request.getSession();
    int state = 0;
    String memo = "";
    JSONObject jsonObj = new JSONObject();
    try {
      jsonObj.put("res", "");
      jsonObj.put("su", "");

      String adminAccount = (String) session.getAttribute("admin_account");
      if (!CollectionUtil.checkNull(adminAccount)) {
        return null;
      }
      String id = (String) request.getParameter("id");
      String lan_level_content = (String) request.getParameter("lan_level_content");
      String lan_level_summary = (String) request.getParameter("lan_level_summary");

      if (!CollectionUtil.checkNull(id)) {
        jsonObj.put("res", "序列号不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(lan_level_content)) {
        jsonObj.put("res", "语言难度名称不能为空!");
        return null;
      }

      // 获得该语言难度信息
      GlobalLanguage GlobalLanguage = this.globalLanguageService.findGlobalLanguageOne(id);
      if (GlobalLanguage == null) {
        jsonObj.put("res", "语言难度获取失败或语言难度序列号错误!");
        return null;
      }

      int ii = this.globalLanguageService.checkGlobalLanguageName(id, lan_level_content);
      if (ii > 0) {
        jsonObj.put("res", "语言难度名称已存在,请从新填写语言难度名称!");
        return null;
      }
      GlobalLanguage.setLan_level_content(lan_level_content);
      if (CollectionUtil.checkNull(lan_level_summary)) {
        GlobalLanguage.setLan_level_summary(lan_level_summary);
      }
      GlobalLanguage.setUpdate_adminuser(adminAccount);

      int in = this.globalLanguageService.updateGlobalLanguage(GlobalLanguage);
      if (in > 0) {
        state = 1;
        memo += "修改语言难度" + id + "成功!";
        jsonObj.put("res", memo);
      } else {
        memo += "修改语言难度" + id + "失败!";
        jsonObj.put("res", memo);
      }
      // 记录日志
      this.adminLogService.addAdminLog(Constant.log_qjpz, memo, state, request);
    } catch (Exception e) {
      memo += "语言难度修改 异常:" + e.getMessage();
      logger.error(memo, e);
      jsonObj.put("res", memo);
      this.adminLogService.addAdminLog(Constant.log_qjpz, memo, state, request);
    } finally {
      printWriter.write(jsonObj.toString());
      printWriter.flush();
      printWriter.close();
    }
    return null;
  }
  /**
   * 帖子类型删除
   *
   * @param model
   * @param request
   * @param response
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "dodeletetopictype",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doDeleteTopicType(
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      PrintWriter printWriter) {
    response.setContentType("text/html; charset=utf-8");
    HttpSession session = request.getSession();
    int state = 0;
    String memo = "";
    JSONObject jsonObj = new JSONObject();
    try {
      jsonObj.put("res", "");
      jsonObj.put("su", "");

      String adminAccount = (String) session.getAttribute("admin_account");
      if (!CollectionUtil.checkNull(adminAccount)) {
        return null;
      }

      String id = (String) request.getParameter("id");

      if (!CollectionUtil.checkNull(id)) {
        jsonObj.put("res", "序列号不能为空!");
        return null;
      }

      TopicList TopicList = new TopicList();
      TopicList.setTopic_typeId(id);
      int ii = this.topicListService.findTopicListCount(TopicList);
      if (ii > 0) {
        jsonObj.put("res", "该类型在帖子信息里面引用到,删除失败!");
        return null;
      }

      int in = this.topicTypeService.deleteTopicType(id);
      if (in > 0) {
        state = 1;
        memo += "删除帖子类型" + id + "成功!";
        jsonObj.put("res", "1");
        jsonObj.put("su", memo);
      } else {
        memo += "删除帖子类型" + id + "失败!";
        jsonObj.put("res", memo);
      }
      // 记录日志
      this.adminLogService.addAdminLog(Constant.log_tzgl, memo, state, request);
    } catch (Exception e) {
      memo += "帖子类型删除 异常:" + e.getMessage();
      logger.error(memo, e);
      jsonObj.put("res", memo);
      this.adminLogService.addAdminLog(Constant.log_tzgl, memo, state, request);
    } finally {
      printWriter.write(jsonObj.toString());
      printWriter.flush();
      printWriter.close();
    }
    return null;
  }
  /**
   * 帖子类型修改
   *
   * @param model
   * @param request
   * @param response
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "doupdatetopictype",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doUpdateTopicType(
      Model model,
      HttpServletRequest request,
      HttpServletResponse response,
      PrintWriter printWriter) {
    response.setContentType("text/html; charset=utf-8");
    HttpSession session = request.getSession();
    int state = 0;
    String memo = "";
    JSONObject jsonObj = new JSONObject();
    try {
      jsonObj.put("res", "");
      jsonObj.put("su", "");

      String adminAccount = (String) session.getAttribute("admin_account");
      if (!CollectionUtil.checkNull(adminAccount)) {
        return null;
      }
      String id = (String) request.getParameter("id");
      String name = (String) request.getParameter("name");
      String status = (String) request.getParameter("status");
      String sort = (String) request.getParameter("sort");

      if (!CollectionUtil.checkNull(id)) {
        jsonObj.put("res", "序列号不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(name)) {
        jsonObj.put("res", "类型名称不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(status)) {
        jsonObj.put("res", "状态不能为空!");
        return null;
      }
      if (!CollectionUtil.checkNull(sort)) {
        jsonObj.put("res", "排序不能为空!");
        return null;
      }

      // 获得该帖子类型信息
      TopicType topicType = this.topicTypeService.findTopicTypeOne(id);
      if (topicType == null) {
        jsonObj.put("res", "帖子类型获取失败或帖子类型序列号错误!");
        return null;
      }

      int ii = this.topicTypeService.checkTopicTypeName(id, name);
      if (ii > 0) {
        jsonObj.put("res", "类型名称已存在,请从新填写类型名称!");
        return null;
      }

      int ii2 = this.topicTypeService.checkTopicTypeSort(id, sort);
      if (ii2 > 0) {
        jsonObj.put("res", "排序已存在,请从新填写排序!");
        return null;
      }
      topicType.setSort(sort);
      topicType.setName(name);
      topicType.setStatus(status);

      int in = this.topicTypeService.updateTopicType(topicType);
      if (in > 0) {
        state = 1;
        memo += "修改帖子类型" + id + "成功!";
        jsonObj.put("res", memo);
      } else {
        memo += "修改帖子类型" + id + "失败!";
        jsonObj.put("res", memo);
      }
      // 记录日志
      this.adminLogService.addAdminLog(Constant.log_tzgl, memo, state, request);
    } catch (Exception e) {
      memo += "帖子类型修改 异常:" + e.getMessage();
      logger.error(memo, e);
      jsonObj.put("res", memo);
      this.adminLogService.addAdminLog(Constant.log_tzgl, memo, state, request);
    } finally {
      printWriter.write(jsonObj.toString());
      printWriter.flush();
      printWriter.close();
    }
    return null;
  }