/**
   * 帖子类型查询
   *
   * @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
   * @param printWriter
   * @return
   */
  @RequestMapping(
      value = "doupdatestatustopictype",
      method = {RequestMethod.POST, RequestMethod.GET})
  public String doUpdateStatusTopicTypeType(
      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 status = (String) request.getParameter("status");

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

      TopicType topicType = new TopicType();
      topicType.setId(id);
      topicType.setStatus(status);

      int in = this.topicTypeService.updateTopicTypeStatus(topicType);
      if (in > 0) {
        state = 1;
        memo += "修改帖子类型" + id + "状态" + status + "成功!";
        jsonObj.put("res", "1");
        jsonObj.put("su", memo);
      } else {
        memo += "修改帖子类型" + id + "状态" + status + "失败!";
        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;
  }