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

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


   * @return
   */
  @RequestMapping(params = "saveFiles", method = RequestMethod.POST)
  @ResponseBody
  public AjaxJson saveFiles(HttpServletRequest request, HttpServletResponse response, CgUploadEntity cgUploadEntity) {
    AjaxJson j = new AjaxJson();
    Map<String, Object> attributes = new HashMap<String, Object>();
    String fileKey = oConvertUtils.getString(request.getParameter("fileKey"));// 文件ID
    String id = oConvertUtils.getString(request.getParameter("cgFormId"));//动态表主键ID
    String tableName = oConvertUtils.getString(request.getParameter("cgFormName"));//动态表名
    String cgField = oConvertUtils.getString(request.getParameter("cgFormField"));//动态表上传控件字段
    if(!StringUtil.isEmpty(id)){
      cgUploadEntity.setCgformId(id);
      cgUploadEntity.setCgformName(tableName);
      cgUploadEntity.setCgformField(cgField);
    }
    if (StringUtil.isNotEmpty(fileKey)) {
      cgUploadEntity.setId(fileKey);
      cgUploadEntity = systemService.getEntity(CgUploadEntity.class, fileKey);
    }
    UploadFile uploadFile = new UploadFile(request, cgUploadEntity);
    uploadFile.setCusPath("files");
    uploadFile.setSwfpath("swfpath");
    uploadFile.setByteField(null);//不存二进制内容
    cgUploadEntity = systemService.uploadFile(uploadFile);
    cgUploadService.writeBack(id, tableName, cgField, fileKey, cgUploadEntity.getRealpath());
    attributes.put("fileKey", cgUploadEntity.getId());
    attributes.put("viewhref", "commonController.do?objfileList&fileKey=" + cgUploadEntity.getId());
    attributes.put("delurl", "commonController.do?delObjFile&fileKey=" + cgUploadEntity.getId());
    j.setMsg("操作成功");
    j.setAttributes(attributes);
    return j;
  }
View Full Code Here


   * @return
   */
  @RequestMapping(params = "delFile")
  @ResponseBody
  public AjaxJson delFile( HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    String id  = request.getParameter("id");
    CgUploadEntity file = systemService.getEntity(CgUploadEntity.class, id);
    message = "" + file.getAttachmenttitle() + "被删除成功";
    cgUploadService.deleteFile(file);
    systemService.addLog(message, Globals.Log_Type_DEL,
        Globals.Log_Leavel_INFO);
    j.setSuccess(true);
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(JeecgJdbcEntity jeecgJdbc, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
   
    String sql = "delete from jeecg_demo where id='" + jeecgJdbc.getId() + "'";
    jeecgJdbcService.executeSql(sql);

    message = "删除成功";
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
   
    j.setMsg(message);
    return j;
  }
View Full Code Here

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

   */
  @RequestMapping(params = "doMigrateIn", method = RequestMethod.POST)
  @ResponseBody
  public AjaxJson doMigrateIn(HttpServletRequest request,
      HttpServletResponse response) {
    AjaxJson j = new AjaxJson();
    String ls_file = "";
    UploadFile uploadFile = new UploadFile(request, ls_file);
    uploadFile.setCusPath("");
    uploadFile.setSwfpath("");
    String uploadbasepath = uploadFile.getBasePath();// 文件上传根目录
    if (uploadbasepath == null) {
      uploadbasepath = ResourceUtil.getConfigByName("uploadpath");
    }
    String path = uploadbasepath + "\\";// 文件保存在硬盘的相对路径
    String realPath = uploadFile.getMultipartRequest().getSession()
        .getServletContext().getRealPath("\\")
        + path;// 文件的硬盘真实路径
    message = null;
    try {
      File file = new File(realPath);
      if (!file.exists()) {
        file.mkdir();// 若目录不存在,创建根目录
      }
      uploadFile.getMultipartRequest().setCharacterEncoding("UTF-8");
      MultipartHttpServletRequest multipartRequest = uploadFile
          .getMultipartRequest();
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      String fileName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        String savePath = realPath + fileName;
        File savefile = new File(savePath);
        String ls_tmp = savefile.getName();
        /*String sqlfilename = realPath
            + ls_tmp.substring(0, ls_tmp.lastIndexOf(".")) + "\\"
            + ls_tmp.substring(0, ls_tmp.lastIndexOf(".")) + ".sql";*/
        FileCopyUtils.copy(mf.getBytes(), savefile);
        MigrateForm.unzip(savePath, "");
        String sqlFileDir = realPath + ls_tmp.substring(0, ls_tmp.lastIndexOf("."));
        File sqlDirFile = new File(sqlFileDir);
        String sqlfilename = sqlDirFile.getPath() + "/";
        if(sqlDirFile.isDirectory()){
          sqlfilename += sqlDirFile.list()[0];
        }
        /*OfficeHtmlUtil officeHtml = new OfficeHtmlUtil();
        String sqlStr = officeHtml.getInfo(sqlfilename);
        String[] sqlStrs = sqlStr.split(";");
        for (String exesql : sqlStrs) {
          if (!StringUtil.isEmpty(exesql) && !"\n".equals(exesql)) {
            jdbcTemplate.execute(exesql);
          }
        }*/
        XStream xStream = new XStream();
        xStream.processAnnotations(DBTable.class);
        @SuppressWarnings("unchecked")
        List<DBTable> dbTables = (List<DBTable>) xStream.fromXML(new File(sqlfilename));
        if(!dbTables.isEmpty() && dbTables.size()>0){
          for (DBTable dbTable : dbTables) {
            mergeMigrateInComponent(dbTable);
          }
        }
      }
    } catch (Exception e1) {
      e1.printStackTrace();
      LogUtil.error(e1.toString());
      message = e1.toString();
    }
    if (StringUtil.isNotEmpty(message))
      j.setMsg("SQL文件导入失败," + message);
    else
      j.setMsg("SQL文件导入成功");

    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(CgformEnhanceJsEntity cgformenhanceJs, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    cgformenhanceJs = systemService.getEntity(CgformEnhanceJsEntity.class, cgformenhanceJs.getId());
    message = "删除成功";
    cgformenhanceJsService.delete(cgformenhanceJs);
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);
   
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "doCgformEnhanceJs")
  @ResponseBody 
  public AjaxJson doCgformEnhanceJs(CgformEnhanceJsEntity cgformenhanceJs, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    CgformEnhanceJsEntity cgformenJs = cgformenhanceJsService.getCgformEnhanceJsByTypeFormId(cgformenhanceJs.getCgJsType(), cgformenhanceJs.getFormId());
    if(cgformenJs!=null){
      j.setObj(cgformenJs);
      j.setSuccess(true);
    }else{
      j.setSuccess(false);
    }
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "save")
  @ResponseBody
  public AjaxJson save(CgformEnhanceJsEntity cgformenhanceJs, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    if (StringUtil.isNotEmpty(cgformenhanceJs.getId())) {
      message = "更新成功";
      CgformEnhanceJsEntity t = cgformenhanceJsService.get(CgformEnhanceJsEntity.class, cgformenhanceJs.getId());
      try {
        MyBeanUtils.copyBeanNotNull2Bean(cgformenhanceJs, t);
        cgformenhanceJsService.saveOrUpdate(t);
        systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      message = "添加成功";
      cgformenhanceJsService.save(cgformenhanceJs);
      systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * @param response
   */
  @ResponseBody
  @RequestMapping(params = "doMigrateIn")
  public AjaxJson doMigrateIn(HttpServletRequest request,HttpServletResponse response){
    AjaxJson j = new AjaxJson();
    String ls_file = "";
    UploadFile uploadFile = new UploadFile(request, ls_file);
    uploadFile.setCusPath("");
    uploadFile.setSwfpath("");
    String uploadbasepath = uploadFile.getBasePath();// 文件上传根目录
    if (uploadbasepath == null) {
      uploadbasepath = ResourceUtil.getConfigByName("uploadpath");
    }
    String path = uploadbasepath + "\\";// 文件保存在硬盘的相对路径
    String realPath = uploadFile.getMultipartRequest().getSession()
        .getServletContext().getRealPath("\\")
        + path;// 文件的硬盘真实路径
    message = null;
    try {
      File file = new File(realPath);
      if (!file.exists()) {
        file.mkdir();// 若目录不存在,创建根目录
      }
      uploadFile.getMultipartRequest().setCharacterEncoding("UTF-8");
      MultipartHttpServletRequest multipartRequest = uploadFile
          .getMultipartRequest();
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      String fileName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        String savePath = realPath + fileName;
        File savefile = new File(savePath);
        String ls_tmp = savefile.getName();
        FileCopyUtils.copy(mf.getBytes(), savefile);
        MigrateForm.unzip(savePath, "");
        String sqlFileDir = realPath + ls_tmp.substring(0, ls_tmp.lastIndexOf("."));
        File sqlDirFile = new File(sqlFileDir);
        String sqlfilename = sqlDirFile.getPath() + "/";
        if(sqlDirFile.isDirectory()){
          sqlfilename += sqlDirFile.list()[0];
        }
        XStream xStream = new XStream();
        xStream.processAnnotations(DBTable.class);
        DBTable dbTable = (DBTable) xStream.fromXML(new File(sqlfilename));
        if(dbTable.getClass1() != null ){
          //List list = dbTable.getTableData();
          commonService.batchSave(dbTable.getTableData());
          /*org.jeecgframework.core.util.LogUtil.info(list.size());
          for (Object object : list) {
            commonService.save(object);
          }*/
        }
      }
    } catch (Exception e1) {
      LogUtil.error(e1.toString());
      message = e1.toString();
    }
    if (StringUtil.isNotEmpty(message))
      j.setMsg("SQL文件导入失败," + message);
    else
      j.setMsg("SQL文件导入成功");

    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(CourseEntity course, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    course = systemService.getEntity(CourseEntity.class, course.getId());
    message = "课程删除成功";
    courseService.delete(course);
    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.