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

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


   * @throws Exception
   */
  @RequestMapping(params = "saveFiles", method = RequestMethod.POST)
  @ResponseBody
  public AjaxJson saveFiles(HttpServletRequest request, HttpServletResponse response, TSDocument document) {
    AjaxJson j = new AjaxJson();
    Map<String, Object> attributes = new HashMap<String, Object>();
    TSTypegroup tsTypegroup=systemService.getTypeGroup("fieltype","文档分类");
    TSType tsType = systemService.getType("files","附件", tsTypegroup);
    String fileKey = oConvertUtils.getString(request.getParameter("fileKey"));// 文件ID
    String documentTitle = oConvertUtils.getString(request.getParameter("documentTitle"));// 文件标题
    if (StringUtil.isNotEmpty(fileKey)) {
      document.setId(fileKey);
      document = systemService.getEntity(TSDocument.class, fileKey);
      document.setDocumentTitle(documentTitle);

    }
    document.setSubclassname(MyClassLoader.getPackPath(document));
    document.setCreatedate(DataUtils.gettimestamp());
    document.setTSType(tsType);
    UploadFile uploadFile = new UploadFile(request, document);
    uploadFile.setCusPath("files");
    uploadFile.setSwfpath("swfpath");
    document = systemService.uploadFile(uploadFile);
    attributes.put("url", document.getRealpath());
    attributes.put("fileKey", document.getId());
    attributes.put("name", document.getAttachmenttitle());
    attributes.put("viewhref", "commonController.do?objfileList&fileKey=" + document.getId());
    attributes.put("delurl", "commonController.do?delObjFile&fileKey=" + document.getId());
    j.setMsg("文件添加成功");
    j.setAttributes(attributes);
    return j;
  }
View Full Code Here


   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(TSTimeTaskEntity timeTask, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    timeTask = systemService.getEntity(TSTimeTaskEntity.class, timeTask.getId());
    message = "定时任务管理删除成功";
    timeTaskService.delete(timeTask);
    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(TSTimeTaskEntity timeTask, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    CronTrigger trigger = new CronTrigger();
    try {
      trigger.setCronExpression(timeTask.getCronExpression());
    } catch (ParseException e) {
      j.setMsg("Cron表达式错误");
      return j;
    }
    if (StringUtil.isNotEmpty(timeTask.getId())) {
      message = "定时任务管理更新成功";
      TSTimeTaskEntity t = timeTaskService.get(TSTimeTaskEntity.class, timeTask.getId());
      try {
        if(!timeTask.getCronExpression().equals(t.getCronExpression())){
          timeTask.setIsEffect("0");
        }
        MyBeanUtils.copyBeanNotNull2Bean(timeTask, t);
        timeTaskService.saveOrUpdate(t);
        systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
      } catch (Exception e) {
        e.printStackTrace();
        message = "定时任务管理更新失败";
      }
    } else {
      message = "定时任务管理添加成功";
      timeTaskService.save(timeTask);
      systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    }
    j.setMsg(message);
    return j;
  }
View Full Code Here

   * 更新任务时间使之生效
   */
  @RequestMapping(params = "updateTime")
  @ResponseBody
  public AjaxJson updateTime(TSTimeTaskEntity timeTask, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    timeTask = timeTaskService.get(TSTimeTaskEntity.class, timeTask.getId());
    boolean isUpdate = dynamicTask.updateCronExpression(timeTask.getTaskId() , timeTask.getCronExpression());
    if(isUpdate){
      timeTask.setIsEffect("1");
      timeTask.setIsStart("1");
      timeTaskService.updateEntitie(timeTask);
    }
    j.setMsg(isUpdate?"定时任务管理更新成功":"定时任务管理更新失败");
    return j;
  }
View Full Code Here

   * 启动或者停止任务
   */
  @RequestMapping(params = "startOrStopTask")
  @ResponseBody
  public AjaxJson startOrStopTask(TSTimeTaskEntity timeTask, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    boolean isStart = timeTask.getIsStart().equals("1");
    timeTask = timeTaskService.get(TSTimeTaskEntity.class, timeTask.getId());
    boolean isSuccess = dynamicTask.startOrStop(timeTask.getTaskId() ,isStart);
    if(isSuccess){
      timeTask.setIsStart(isStart?"1":"0");
      timeTaskService.updateEntitie(timeTask);
      systemService.addLog((isStart?"开启任务":"停止任务")+timeTask.getTaskId(),
          Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
    }
    j.setMsg(isSuccess?"定时任务管理更新成功":"定时任务管理更新失败");
    return j;
  }
View Full Code Here

          CgFormHeadEntity.class, cgFormHead.getId());
      getCgformConfig(cgFormHead, generateEntity);
    }else{
      throw new RuntimeException("表单配置不存在");
    }
    AjaxJson j =  new AjaxJson();
    String tableName = generateEntity.getTableName();
    String ftlDescription = generateEntity.getFtlDescription();
    try {
      //step.2 判断表是否存在
      boolean tableexist = new JeecgReadTable().checkTableExist(tableName);
      if(tableexist){
        //step.3 调用代码生成器
        new CgformCodeGenerate(createFileProperty,generateEntity).generateToFile();
        j.setMsg("成功生成增删改查->功能:"+ftlDescription);
      }else{
        j.setMsg("表["+tableName+"] 在数据库中,不存在");
      }
     
    } catch (Exception e1) {
      e1.printStackTrace();
      j.setMsg(e1.getMessage());
      throw new RuntimeException(e1.getMessage());
    }
    try {
      String projectPath = URLEncoder.encode(generateEntity.getProjectPath(), "UTF-8");
      Cookie cookie = new Cookie("cookie_projectPath",projectPath );       
      cookie.setMaxAge(60*60*24*30); //cookie 保存30天
      response.addCookie(cookie);
      response.getWriter().print(j.getJsonStr());
      response.getWriter().flush();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "dogenerateOne2Many")
  @ResponseBody
  public void dogenerateOne2Many(CodeParamEntity codeParamEntityIn,GenerateSubListEntity subTableListEntity,HttpServletRequest request,HttpServletResponse response){
    AjaxJson j =  new AjaxJson();
    //step.1 设置主表
    //从前台获取:codeParamEntityIn
    //step.2 设置子表集合
    //从前台获取:subTabParamIn,并设置外键字段
    try{
      //step.3 填充主表的所有智能表单配置
      String mainTable = codeParamEntityIn.getTableName();
      //主表的智能表单配置
      GenerateEntity mainG = new GenerateEntity();
      mainG.setProjectPath(subTableListEntity.getProjectPath());
      CgFormHeadEntity mCgFormHead = cgFormFieldService.getCgFormHeadByTableName(mainTable);
      getCgformConfig(mCgFormHead, mainG);
      //step.4 填充子表的所有智能表单配置
      Map<String,GenerateEntity> subsG = new HashMap<String,GenerateEntity>();
      List<SubTableEntity>  subTabParamIn = subTableListEntity.getSubTabParamIn();
      for(SubTableEntity po:subTabParamIn){
        String sTableName = po.getTableName();
        CgFormHeadEntity cgSubHead = cgFormFieldService.getCgFormHeadByTableName(sTableName);
        List<CgFormFieldEntity> colums = cgSubHead.getColumns();
        String[] foreignKeys =getForeignkeys(colums);
        po.setForeignKeys(foreignKeys);
        GenerateEntity subG = new GenerateEntity();
        getCgformConfig(cgSubHead, subG);
        subG.setEntityName(po.getEntityName());
        subG.setEntityPackage(po.getEntityPackage());
        subG.setFieldRowNum(1);
        subG.setFtlDescription(po.getFtlDescription());
        subG.setForeignKeys(foreignKeys);
        subG.setTableName(po.getTableName());
        subG.setProjectPath(subTableListEntity.getProjectPath());
        subsG.put(sTableName, subG);
      }
      codeParamEntityIn.setSubTabParam(subTabParamIn);
      //step.5 一对多(父子表)数据模型,代码生成
         CgformCodeGenerateOneToMany.oneToManyCreate(subTabParamIn, codeParamEntityIn,mainG,subsG);
      j.setMsg("成功生成增删改查->功能:"+codeParamEntityIn.getFtlDescription());
    }catch (Exception e) {
      e.printStackTrace();
      j.setMsg(e.getMessage());
      throw new RuntimeException(e.getMessage());
    }
    try {
      String projectPath = URLEncoder.encode(subTableListEntity.getProjectPath(), "UTF-8");
      Cookie cookie = new Cookie("cookie_projectPath",projectPath );           
      cookie.setMaxAge(60*60*24*30); //cookie 保存30天
      response.addCookie(cookie);
      response.getWriter().print(j.getJsonStr());
      response.getWriter().flush();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

   */
  @RequestMapping(params = "doDuplicateCheck")
  @ResponseBody
  public AjaxJson doDuplicateCheck(DuplicateCheckPage duplicateCheckPage, HttpServletRequest request) {

    AjaxJson j = new AjaxJson();
    Long num = null;
   
    if(StringUtils.isNotBlank(duplicateCheckPage.getRowObid())){
      //[2].编辑页面校验
      String sql = "SELECT count(*) FROM "+duplicateCheckPage.getTableName()
            +" WHERE "+duplicateCheckPage.getFieldName() +" =? and id != ?";
      num = jdbcDao.getCountForJdbcParam(sql, new Object[]{duplicateCheckPage.getFieldVlaue(),duplicateCheckPage.getRowObid()});
    }else{
      //[1].添加页面校验
      String sql = "SELECT count(*) FROM "+duplicateCheckPage.getTableName()
            +" WHERE "+duplicateCheckPage.getFieldName() +" =?";
      num = jdbcDao.getCountForJdbcParam(sql, new Object[]{duplicateCheckPage.getFieldVlaue()});
    }
   
    if(num==null||num==0){
      //该值可用
      j.setSuccess(true);
      j.setMsg("该值可用!");
    }else{
      //该值不可用
      j.setSuccess(false);
      j.setMsg("该值不可用,系统中已存在!");
    }
    return j;
  }
View Full Code Here

   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(TSConfig config, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    config = systemService.getEntity(TSConfig.class, config.getId());
    message = "配置信息: " + config.getName() + "被删除 成功";
    systemService.delete(config);
    systemService.addLog(message, Globals.Log_Type_DEL,
        Globals.Log_Leavel_INFO);
View Full Code Here

      message = "配置信息: " + tsConfig.getName() + "被修改成功";
      systemService.updateEntitie(tsConfig);
      systemService.addLog(message, Globals.Log_Type_INSERT,
          Globals.Log_Leavel_INFO);
    }
    AjaxJson j = new AjaxJson();
    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.