Package org.jeecgframework.core.common.model.json

Examples of org.jeecgframework.core.common.model.json.AjaxJson


   * @return
   */
  @RequestMapping(params = "active")
  @ResponseBody
  public AjaxJson active(CgformFtlEntity cgformFtl, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    try {
      // 判断有没有激活过的模板
      cgformFtl = systemService.getEntity(CgformFtlEntity.class,
          cgformFtl.getId());
      if (!cgformFtlService.hasActive(cgformFtl.getCgformId())) {
        cgformFtl.setFtlStatus("1");
        cgformFtlService.saveOrUpdate(cgformFtl);
        message = "激活成功";
        systemService.addLog(message, Globals.Log_Type_UPDATE,
            Globals.Log_Leavel_INFO);
        j.setSuccess(true);
        j.setMsg(message);
      } else {
        message = "已有激活模板,请取消后再进行激活";
        j.setSuccess(true);
        j.setMsg(message);
      }
    } catch (Exception e) {
      logger.info(e.getMessage());
      message = "激活失败";
      j.setSuccess(false);
      j.setMsg(message);
    }
    return j;
  }
View Full Code Here


   */
  @RequestMapping(params = "cancleActive")
  @ResponseBody
  public AjaxJson cancleActive(CgformFtlEntity cgformFtl,
      HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    try {
      cgformFtl = systemService.getEntity(CgformFtlEntity.class,
          cgformFtl.getId());
      cgformFtl.setFtlStatus("0");
      cgformFtlService.saveOrUpdate(cgformFtl);
      message = "取消激活成功";
      systemService.addLog(message, Globals.Log_Type_UPDATE,
          Globals.Log_Leavel_INFO);
      j.setSuccess(true);
      j.setMsg(message);
    } catch (Exception e) {
      logger.info(e.getMessage());
      message = "取消激活失败";
      j.setSuccess(false);
      j.setMsg(message);
    }
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "save")
  @ResponseBody
  public AjaxJson save(CgformFtlEntity cgformFtl, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    if (StringUtil.isNotEmpty(cgformFtl.getId())) {
      message = "更新成功";
      CgformFtlEntity t = cgformFtlService.get(CgformFtlEntity.class,
          cgformFtl.getId());
      try {
View Full Code Here

   */
  @RequestMapping(params = "saveWordFiles", method = RequestMethod.POST)
  @ResponseBody
  public AjaxJson saveWordFiles(HttpServletRequest request,
      HttpServletResponse response, CgformFtlEntity cgformFtl) {
    AjaxJson j = new AjaxJson();
    Map<String, Object> attributes = new HashMap<String, Object>();

    LogUtil.info("-------------------------step.1-------------------------------------");
    String fileKey = oConvertUtils.getString(request.getParameter("id"));// 文件ID
    String cgformId = oConvertUtils.getString(request
        .getParameter("cgformId"));// formid
    String cgformName = oConvertUtils.getString(request
        .getParameter("cgformName"));// formname
    String ftlStatus = oConvertUtils.getString(request
        .getParameter("ftlStatus"));// formStatus
    if (oConvertUtils.isEmpty(ftlStatus)) {
      ftlStatus = "0";
    }

    if (StringUtil.isNotEmpty(fileKey)) {
      cgformFtl.setId(fileKey);
      cgformFtl = systemService.getEntity(CgformFtlEntity.class, fileKey);
    } else {
      cgformFtl.setFtlVersion(cgformFtlService.getNextVarsion(cgformId));
    }
    LogUtil.info("-------------------------step.2-------------------------------------");
    cgformFtl.setCgformId(cgformId);
    cgformFtl.setCgformName(cgformName);
    cgformFtl.setFtlStatus(ftlStatus);

    UploadFile uploadFile = new UploadFile(request, cgformFtl);
    uploadFile.setCusPath("forms");
    message = null;
    try {

      uploadFile.getMultipartRequest().setCharacterEncoding("UTF-8");
      MultipartHttpServletRequest multipartRequest = uploadFile
          .getMultipartRequest();

      String uploadbasepath = uploadFile.getBasePath();// 文件上传根目录
      if (uploadbasepath == null) {
        uploadbasepath = ResourceUtil.getConfigByName("uploadpath");
      }
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      // 文件数据库保存路径
      String path = uploadbasepath + "\\";// 文件保存在硬盘的相对路径
      String realPath = uploadFile.getMultipartRequest().getSession()
          .getServletContext().getRealPath("\\")
          + path;// 文件的硬盘真实路径
      File file = new File(realPath);
      if (!file.exists()) {
        file.mkdir();// 创建根目录
      }
      if (uploadFile.getCusPath() != null) {
        realPath += uploadFile.getCusPath() + "\\";
        path += uploadFile.getCusPath() + "\\";
        file = new File(realPath);
        if (!file.exists()) {
          file.mkdir();// 创建文件自定义子目录
        }
      } else {
        realPath += DataUtils.getDataString(DataUtils.yyyyMMdd) + "\\";
        path += DataUtils.getDataString(DataUtils.yyyyMMdd) + "\\";
        file = new File(realPath);
        if (!file.exists()) {
          file.mkdir();// 创建文件时间子目录
        }
      }
      LogUtil.info("-------------------------step.3-------------------------------------");
      String fileName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        String extend = FileUtils.getExtend(fileName);// 获取文件扩展名
        String myfilename = "";
        String myhtmlfilename = "";
        String noextfilename = "";// 不带扩展名
        if (uploadFile.isRename()) {

          noextfilename = DataUtils
              .getDataString(DataUtils.yyyymmddhhmmss)
              + StringUtil.random(8);// 自定义文件名称
          myfilename = noextfilename + "." + extend;// 自定义文件名称
        } else {
          myfilename = fileName;
        }

        String savePath = realPath + myfilename;// 文件保存全路径
        cgformFtl.setFtlWordUrl(fileName);
        File savefile = new File(savePath);
        FileCopyUtils.copy(mf.getBytes(), savefile);

        myhtmlfilename = realPath + noextfilename + ".html";
        String myftlfilename = realPath + noextfilename + ".ftl";
        LogUtil.info("-------------------------step.4-------------------------------------");
        // 开始转换表单文件
        OfficeHtmlUtil officeHtml = new OfficeHtmlUtil();

        // 方式一:jacob.jar方式word转html
        officeHtml.wordToHtml(savePath, myhtmlfilename);
        String htmlStr = officeHtml.getInfo(myhtmlfilename);
        htmlStr = officeHtml.doHtml(htmlStr);

        // 方式二:poi方式word转html
        // officeHtml.WordConverterHtml(savePath, myhtmlfilename);
        // String htmlStr = officeHtml.getInfo(myhtmlfilename);
        // htmlStr = officeHtml.doPoiHtml(htmlStr);

        officeHtml.stringToFile(htmlStr, myftlfilename);
        // js plugin start
        StringBuilder script = new StringBuilder("");
        script.append("<script type=\"text/javascript\">");
        script.append("${js_plug_in?if_exists}");
        script.append("</script>");
        htmlStr = htmlStr.replace("</html>", script.toString()
            + "</html>");
        // js plugin end
        cgformFtl.setFtlContent(htmlStr);
        cgformFtlService.saveOrUpdate(cgformFtl);
        LogUtil.info("-------------------------step.5-------------------------------------");
      }
    } catch (Exception e1) {
      LogUtil.error(e1.toString());
      message = e1.toString();
    }

    attributes.put("id", cgformFtl.getId());
    if (StringUtil.isNotEmpty(message))
      j.setMsg("Word转Ftl失败," + message);
    else
      j.setMsg("Word转Ftl成功");
    j.setAttributes(attributes);

    return j;
  }
View Full Code Here

  @RequestMapping(params = "saveEditor")
  @ResponseBody
  public AjaxJson saveEditor(CgformFtlEntity cgformFtl,
      HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    String fileKey = oConvertUtils.getString(request.getParameter("id"));// 文件ID
    String cgformId = oConvertUtils.getString(request
        .getParameter("cgformId"));
    String cgformName = oConvertUtils.getString(request
        .getParameter("cgformName"));
    String ftlStatus = oConvertUtils.getString(request
        .getParameter("ftlStatus"));
    String ftlVersion = oConvertUtils.getString(request
        .getParameter("ftlVersion"));
    String ftlWordUrl = oConvertUtils.getString(request
        .getParameter("ftlWordUrl"));
    String createBy = oConvertUtils.getString(request
        .getParameter("createBy"));
    String createName = oConvertUtils.getString(request
        .getParameter("createName"));
    String createDate = oConvertUtils.getString(request
        .getParameter("createDate"));
    if (oConvertUtils.isEmpty(ftlStatus))
      ftlStatus = "0";

    cgformFtl.setCgformId(cgformId);
    cgformFtl.setCgformName(cgformName);
    cgformFtl.setFtlStatus(ftlStatus);
    if (StringUtil.isNotEmpty(fileKey)) {
      cgformFtl.setId(fileKey);
      if(StringUtil.isNotEmpty(ftlVersion))
        cgformFtl.setFtlVersion(Integer.valueOf(ftlVersion));
      if (StringUtil.isNotEmpty(ftlWordUrl))
        cgformFtl.setFtlWordUrl(ftlWordUrl);
      if (StringUtil.isNotEmpty(createBy))
        cgformFtl.setCreateBy(createBy);
      if (StringUtil.isNotEmpty(createName))
        cgformFtl.setCreateName(createName);
      if (StringUtil.isNotEmpty(createDate))
        cgformFtl.setCreateDate(DataUtils.str2Date(createDate, DataUtils.date_sdf));

      if (!"<form".equalsIgnoreCase(cgformFtl.getFtlContent())) {
        String ls_form = "<form action=\"cgFormBuildController.do?saveOrUpdate\" id=\"formobj\" name=\"formobj\" method=\"post\">"
            + "<input type=\"hidden\" name=\"tableName\" value=\"${tableName?if_exists?html}\" />"
            + "<input type=\"hidden\" name=\"id\" value=\"${id?if_exists?html}\" />"
            + "<input type=\"hidden\" id=\"btn_sub\" class=\"btn_sub\" />#{jform_hidden_field}<table";
        cgformFtl.setFtlContent(cgformFtl.getFtlContent().replace(
            "<table", ls_form));
        cgformFtl.setFtlContent(cgformFtl.getFtlContent().replace(
            "</table>", "</table></form>"));
      }
      cgformFtlService.saveOrUpdate(cgformFtl);
      j.setMsg("修改成功");
    } else {
      cgformFtl.setFtlVersion(cgformFtlService.getNextVarsion(cgformId));

      String ls_form = "<form action=\"cgFormBuildController.do?saveOrUpdate\" id=\"formobj\" name=\"formobj\" method=\"post\">"
          + "<input type=\"hidden\" name=\"tableName\" value=\"${tableName?if_exists?html}\" />"
          + "<input type=\"hidden\" name=\"id\" value=\"${id?if_exists?html}\" />"
          + "<input type=\"hidden\" id=\"btn_sub\" class=\"btn_sub\" />#{jform_hidden_field}<table";
      cgformFtl.setFtlContent(cgformFtl.getFtlContent().replace("<table",
          ls_form));
      cgformFtl.setFtlContent(cgformFtl.getFtlContent().replace(
          "</table>", "</table></form>"));
      cgformFtlService.save(cgformFtl);
      j.setMsg("上传成功");
    }
    Map<String, Object> attributes = new HashMap<String, Object>();
    attributes.put("id", cgformFtl.getId());
    j.setAttributes(attributes);
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "saveCkeditor")
  @ResponseBody
  public AjaxJson saveCkeditor(HttpServletRequest request,CKEditorEntity cKEditor , String contents) {
    AjaxJson j = new AjaxJson();
    if (StringUtil.isNotEmpty(cKEditor.getId())) {
      CKEditorEntity t =jeecgDemoService.get(CKEditorEntity.class, cKEditor.getId());
      try {
        MyBeanUtils.copyBeanNotNull2Bean(cKEditor, t);
        t.setContents(contents.getBytes());
        jeecgDemoService.saveOrUpdate(t);
        j.setMsg("更新成功");
      } catch (Exception e) {
        e.printStackTrace();
        j.setMsg("更新失败");
      }
    } else {
      cKEditor.setContents(contents.getBytes());
      jeecgDemoService.save(cKEditor);
    }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(JeecgDemo jeecgDemo, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    jeecgDemo = systemService.getEntity(JeecgDemo.class, jeecgDemo.getId());
    message = "JeecgDemo例子: " + jeecgDemo.getUserName() + "被删除 成功";
    jeecgDemoService.delete(jeecgDemo);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
   
    j.setMsg(message);
    return j;
  }
View Full Code Here

   */
  @RequestMapping(params = "save")
  @ResponseBody
  @AutoMenuOperation(name="添加",code = "add")
  public AjaxJson save(JeecgDemo jeecgDemo, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    if (StringUtil.isNotEmpty(jeecgDemo.getId())) {
      message = "JeecgDemo例子: " + jeecgDemo.getUserName() + "被更新成功";
      JeecgDemo t =jeecgDemoService.get(JeecgDemo.class, jeecgDemo.getId());
      try {
        MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t);
View Full Code Here

   * @return
   */
  @RequestMapping(params = "saveAuthor")
  @ResponseBody
  public AjaxJson saveAuthor(JeecgDemo jeecgDemo, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    if (StringUtil.isNotEmpty(jeecgDemo.getId())) {
      message = "测试-用户申请成功";
      JeecgDemo t =jeecgDemoService.get(JeecgDemo.class, jeecgDemo.getId());
      try {
        MyBeanUtils.copyBeanNotNull2Bean(jeecgDemo, t);
        t.setStatus("1");
        jeecgDemoService.saveOrUpdate(t);
        j.setMsg(message);
        systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
View Full Code Here

   * @date 2013-07-13 14:53:00
   */
  @RequestMapping(params = "doDeleteALLSelect")
  @ResponseBody
  public AjaxJson doDeleteALLSelect(JeecgDemo jeecgDemo, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    String ids = request.getParameter("ids");
    String[] entitys = ids.split(",");
      List<JeecgDemo> list = new ArrayList<JeecgDemo>();
    for(int i=0;i<entitys.length;i++){
      jeecgDemo = systemService.getEntity(JeecgDemo.class, entitys[i]);
            list.add(jeecgDemo);     
    }
    message = "删除成功";
    jeecgDemoService.deleteAllEntitie(list);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
    j.setMsg(message);
    return j;
  }
View Full Code Here

TOP

Related Classes of org.jeecgframework.core.common.model.json.AjaxJson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.