Bläddra i källkod

git-svn-id: https://192.168.57.71/svn/jsgkj@442 931142cf-59ea-a443-aa0e-51397b428577

ld_zhoutl 9 år sedan
förälder
incheckning
72c38ba31c

+ 8 - 0
xtdsp/trunk/src/main/java/com/xt/dsp/common/BaseVo.java

@@ -5,6 +5,8 @@ public class BaseVo{
 	private Integer page;
 	/** 每页行数 */
 	private Integer rows;
+	/** 当前操作 */
+	private String opt;
 	public Integer getPage() {
 		return page;
 	}
@@ -17,4 +19,10 @@ public class BaseVo{
 	public void setRows(Integer rows) {
 		this.rows = rows;
 	}
+	public String getOpt() {
+		return opt;
+	}
+	public void setOpt(String opt) {
+		this.opt = opt;
+	}
 }

+ 13 - 0
xtdsp/trunk/src/main/java/com/xt/dsp/common/util/ConstUtil.java

@@ -0,0 +1,13 @@
+package com.xt.dsp.common.util;
+
+
+public class ConstUtil {
+	
+	public static String OPER_ADD = "ADD";
+	public static String OPER_DEL = "DEL";
+	public static String OPER_EDIT = "EDIT";
+	public static String OPER_SAVE = "SAVE";
+	public static String OPER_VIEW = "VIEW";
+
+
+}

+ 22 - 12
xtdsp/trunk/src/main/java/com/xt/dsp/controller/DatasourceCtl.java

@@ -2,15 +2,15 @@ package com.xt.dsp.controller;
 
 import java.util.List;
 
-import org.h2.util.StringUtils;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.ResponseBody;
 
+import com.xt.dsp.common.util.ConstUtil;
 import com.xt.dsp.model.DataSourceBean;
-import com.xt.dsp.model.TaskBean;
 import com.xt.dsp.service.DataSourceService;
 import com.xt.dsp.vo.DataSourceVo;
 import com.yuanxd.tools.pagehelper.PageHelper;
@@ -30,7 +30,7 @@ public class DatasourceCtl {
 	@RequestMapping("main")
 	public String main() {
 		//DataSourceBean bean = new DataSourceBean();
-		return "rwgl/datasource/datasource";
+		return "sys/datasource/datasource";
 	}
 	
 	/**
@@ -47,7 +47,7 @@ public class DatasourceCtl {
 			vo.setRows(1);
 		}
 		PageHelper.startPage(vo.getPage(), vo.getRows());
-		List<DataSourceBean> list = null;//datasourceService;
+		List<DataSourceBean> list = datasourceService.selectAll();
 		PageInfo<DataSourceBean> pageResult = new PageInfo<>(list);
     	return pageResult;
     }
@@ -62,17 +62,27 @@ public class DatasourceCtl {
 	public DataSourceBean saveDataSource(Model model,DataSourceVo vo) {
 		DataSourceBean saveBean = new DataSourceBean();
 		// 新增
-		if(StringUtils.isNullOrEmpty(vo.getId())) {
-//			BeanUtils.copyProperties(vo, saveBean);
-//			saveBean.setId(CommonUtil.getUUID());
-			//saveBean.setStatus("0");
+		if(ConstUtil.OPER_ADD.equals(vo.getOpt())) {
+			BeanUtils.copyProperties(vo, saveBean);
+			datasourceService.insert(saveBean);
 		} else {
 			// 修改
-//			saveBean = datasourceService.findOne(vo.getId());
-//			saveBean.setName(vo.getName());
-//			saveBean.setCode(vo.getCode());
+			saveBean = datasourceService.selectByPrimaryKey(vo.getId());
+			saveBean.setUrl(vo.getUrl());
+			saveBean.setDriverclassname(vo.getDriverclassname());
+			saveBean.setUsername(vo.getUsername());
+			saveBean.setPassword(vo.getPassword());
+			saveBean.setInitialsize(vo.getInitialsize());
+			saveBean.setMinidle(vo.getMinidle());
+			saveBean.setMaxactive(vo.getMaxactive());
+			saveBean.setTimebetweenevictionrunsmillis(vo.getTimebetweenevictionrunsmillis());
+			saveBean.setMinevictableidletimemillis(vo.getMinevictableidletimemillis());
+			saveBean.setTestonreturn(vo.getTestonreturn());
+			saveBean.setPoolpreparedstatements(vo.getPoolpreparedstatements());
+			saveBean.setMaxpoolpreparedstatementpercon(vo.getMaxpoolpreparedstatementpercon());
+			saveBean.setValidationquery(vo.getValidationquery());
+			datasourceService.updateByPrimaryKey(saveBean);
 		}
-//		datasourceService.save(saveBean);
 		return saveBean;
 	}