예제 #1
0
 /**
  * 通过JDBC访问数据库列表页面跳转
  *
  * @return
  */
 @RequestMapping(params = "addorupdate")
 public ModelAndView addorupdate(SbJdbcEntity sbJdbc, HttpServletRequest req) {
   if (StringUtil.isNotEmpty(sbJdbc.getId())) {
     sbJdbc = sbJdbcService.getEntity(SbJdbcEntity.class, sbJdbc.getId());
     req.setAttribute("sbJdbcPage", sbJdbc);
   }
   List<Department> departList = systemService.getList(Department.class);
   req.setAttribute("departList", departList);
   return new ModelAndView("sb/demo/notag/sbEasyUI");
 }
예제 #2
0
  /**
   * 添加通过JDBC访问数据库
   *
   * @param ids
   * @return
   */
  @RequestMapping(params = "save")
  @ResponseBody
  public AjaxJson save(SbJdbcEntity sbJdbc, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();
    if (StringUtil.isNotEmpty(sbJdbc.getId())) {
      message = "更新成功";
      SbJdbcEntity t = sbJdbcService.get(SbJdbcEntity.class, sbJdbc.getId());
      try {
        MyBeanUtils.copyBeanNotNull2Bean(sbJdbc, t);
        sbJdbcService.saveOrUpdate(t);
        systemService.addLog(message, Globals.Log_Type_UPDATE, Globals.Log_Leavel_INFO);
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      message = "添加成功";
      sbJdbcService.save(sbJdbc);
      systemService.addLog(message, Globals.Log_Type_INSERT, Globals.Log_Leavel_INFO);
    }

    return j;
  }
예제 #3
0
  /**
   * 删除通过JDBC访问数据库
   *
   * @return
   */
  @RequestMapping(params = "del")
  @ResponseBody
  public AjaxJson del(SbJdbcEntity sbJdbc, HttpServletRequest request) {
    AjaxJson j = new AjaxJson();

    String sql = "delete from sb_demo where id='" + sbJdbc.getId() + "'";
    sbJdbcService.executeSql(sql);

    message = "删除成功";
    systemService.addLog(message, Globals.Log_Type_DEL, Globals.Log_Leavel_INFO);

    j.setMessage(message);
    return j;
  }