<%--<%@ include file="paraConf1.jsp" %> --%>
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String path1 = request.getContextPath();
String basePath1 = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path1 + "/";
%>
type="text/css" />
type="text/css" />
type="text/css" />
type="text/css" />
id="style_color" />
type="text/css" />
href="media/css/select2_metro.css" />
<%--<%@ include file="paraConf1.jsp" %> --%>
jQuery(document).ready(function() {
App.init();
TableManaged.init();
// UIModals.init();
TableEditable.init();
});
var nRow1;
var edit="";
var oTable;
load();
function load() {
if (oTable) {
oTable.fnDestroy();
}
oTable=$("#sample_1").dataTable({
"bPaginate": true,
"bProcessing" : true,
"bServerSide" : true,
"bSort" : true,
"oSearch" : { "sSearch": "", "bRegex": false, "bSmart": false },
"sPaginationType": "bootstrap",
"sAjaxSource" : "/admin/getParaConfList1",
"aoColumns": [
{ "mData": null },
{ "mData": "cfgGroupCode"},
{ "mData": "cfgGroupName"} ,
{ }
] ,
"aoColumnDefs": [{
"aTargets": [0],
"sClass1": "btn red",
"bSortable": false,
"mData": null,
"mRender": function(data, type, full) {
return''
}
},
{ "aTargets": [3],
"bSortable": true,
"mData": function(){return '编辑' +" "+'删除' }
} ] ,
}
)
}
$('#cfgNew').live('click', function (e) {
e.preventDefault();
$("#cfgGroupName2").val('');
$("#cfgGroupCode2").val('');
});
$('#sample_1 a.edit').live('click', function (e) {
e.preventDefault();
var nRow = $(this).parents('tr')[0];
nRow1=nRow;
edit="1";
aData = oTable.fnGetData( nRow);
$("#cfgGroupName2").val(aData.cfgGroupName);
$("#cfgGroupCode2").val(aData.cfgGroupCode);
});
$('#sample_1 a.delete').live('click', function (e) {
e.preventDefault();
if (confirm("你真的要删除该条记录吗?") == false) {
return;
}
var nRow2 = $(this).parents('tr')[0];
aData = oTable.fnGetData(nRow2);
var id= aData.cfgGroupCode;
$.ajax({
type : "post",
url : "admin/delParaConf",
data : {
cfgGroupCode :id
},
success : function(data) {
if (data == "success") {
load();
alert("删除成功");
} else {
alert("删除失败");
}
}
});
// oTable.fnDeleteRow(nRow2);
//
// oTable.fnDraw();
});
jQuery('#sample_1 .group-checkable').change(function () {
var set = jQuery(this).attr("data-set");
var checked = jQuery(this).is(":checked");
jQuery(set).each(function () {
if (checked) {
$(this).attr("checked", true);
} else {
$(this).attr("checked", false);
}
});
jQuery.uniform.update(set);
});
function saveConf1() {
var strCode="";
strCode=$("#cfgGroupCode2").val();
var strVal=$("#cfgGroupName2").val();
if (strVal == "" || strVal == null || strVal == "undefined" ) {
$("#myDiv").html( "参数配置名称不能为空值");
// alert("提示信息", "参数配置名称不能为空值");
return;
}
htmlobj=$.ajax({url:"/admin/addParaConf1?cfgGroupCode="+strCode+"&cfgGroupName="+strVal ,async:false});
result=htmlobj.responseText;
$("#myDiv").html( "");
if (result == "success") {
$("#myDiv").html( "保存成功");
if (edit == "1") {oTable.fnUpdate(strVal, nRow1, 2, false); edit =''}
else oTable.fnDraw();
}
else if (result == "existed") {
//$.messager.alert("提示信息", "参数配置名称已经存在!");
$("#myDiv").html("参数配置名称已经存在!");
return;
}
else {
$("#myDiv").html("系统错误,请稍后再试!");
}
}
$(document).ready(function(){
$("#b01").click(function(){
htmlobj=$.ajax({url:"/jquery/test1.txt",async:false});
$("#myDiv").html(htmlobj.responseText);
});
});
test1.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
工具管理系统 参数配置
href="#portlet-config" data-toggle="modal" class="config"> href="javascript:;" class="reload"> class="remove">
ParaConfController.java
package com.gy.inventory.controller;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import com.gy.inventory.model.ParaConfigGroup;
import com.gy.inventory.service.ParaConfService;
@Controller
@RequestMapping("/admin")
public class ParaConfController {
@Autowired
private ParaConfService paraConfService;
@RequestMapping("/getParaConfList")
@ResponseBody
public Map
Integer page, Integer rows) {// 蓝色的就是你在ajax提交的时候传递的数据
// 设置当前页
int intPage = page == null || page <= 0 ? 1 : page;
// 设置每页显示的数量:
int intPageSize = rows == null || rows <= 0 ? 10 : rows;
int size = paraConfService.getQueryCounts(cfgGroupName).size();
List
intPage, intPageSize);// 传进去的page要进行处理
if (list != null) {
Map
result.put("total", size);
result.put("rows", list);
return result;
}
return null;
}
public List
Integer firstRow = 1;
if (pageNo != null && pageSize != null) {
pageNo = pageNo < 1 ? 1 : pageNo;
pageSize = pageSize < 1 ? 10 : pageSize;
int firstRow1 = (pageNo - 1) * pageSize;
firstRow = firstRow1;
}
return paraConfService.getParaConfList(cfgGroupName, firstRow,
pageSize);
}
@RequestMapping("/getParaConfList1")
@ResponseBody
public JSONObject searchPrepayPage1(String cfgGroupName,
Integer start, Integer length, HttpServletRequest request) {
start=Integer.parseInt(request.getParameter("iDisplayStart"));
length=Integer.parseInt(request.getParameter("iDisplayLength"));
cfgGroupName=request.getParameter("sSearch");
int size = paraConfService.getQueryCounts(cfgGroupName).size();
JSONObject list = paraConfService.getParaConfList1(cfgGroupName, start, length);
list.put("iTotalRecords", size);
list.put("iTotalDisplayRecords", size);
return list;
}
@RequestMapping(value = "/getParaConfJsp")
public ModelAndView getParaConf(HttpServletRequest request,
HttpServletResponse response) {
return new ModelAndView("admin/paraConf");
}
@RequestMapping("/addParaConf")
@ResponseBody
public String addConfName(@ModelAttribute ParaConfigGroup conf,String cfgGroupName1) {
if (cfgGroupName1!=""){
int size = paraConfService.getQueryCounts(cfgGroupName1).size();
if (size>0 ) return "existed";
else conf.setCfgGroupName(cfgGroupName1);
}
int result= paraConfService.addParaConf(conf);
if (result == 1)
return "success";
else
return "null";
}
@RequestMapping("/addParaConf1")
@ResponseBody
public String addConfName1(@ModelAttribute ParaConfigGroup conf,String cfgGroupName1,HttpServletRequest request) {
conf.setCfgGroupCode(request.getParameter("cfgGroupCode"));
cfgGroupName1=request.getParameter("cfgGroupName");
if (cfgGroupName1!=""){
int size = paraConfService.getQueryCounts(cfgGroupName1).size();
if (size>0 ) return "existed";
else conf.setCfgGroupName(cfgGroupName1);
}
int result= paraConfService.addParaConf(conf);
if (result == 1)
return "success";
else
return "null";
}
@RequestMapping("/delParaConf")
@ResponseBody
public String delConfName(String cfgGroupCode) {
int result=paraConfService.delParaConf(cfgGroupCode);
if (result == 1)
return "success";
else
return "null";
}
@RequestMapping("/getParaConfName")
@ResponseBody
public String getParaConfName() {
return "success";
}
}
ParaConfService.java
package com.gy.inventory.service;
import java.util.List;
import net.sf.json.JSONObject;
import com.gy.inventory.model.ParaConfigGroup;
public interface ParaConfService {
public List
public List
public int addParaConf(ParaConfigGroup conf);
public int updateParaConf(ParaConfigGroup conf);
public int delParaConf(String id);
JSONObject getParaConfList1(String confName, Integer firstRow,
Integer rowSize);
}
ParaConfServiceImpl.java
package com.gy.inventory.service.impl;
import java.util.Collection;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.gy.inventory.mapper.ParaConfMapper;
import com.gy.inventory.model.ParaConfigGroup;
import com.gy.inventory.service.ParaConfService;
import net.sf.ezmorph.Morpher;
import net.sf.ezmorph.MorpherRegistry;
import net.sf.ezmorph.bean.BeanMorpher;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONUtils;
@Service
public class ParaConfServiceImpl implements ParaConfService {
@Autowired
private ParaConfMapper paraConfMapper;
@Override
public List
List
return result;
}
@Override
public List
Integer firstRow, Integer rowSize) {
List
firstRow, rowSize);
return result;
}
@Override
public JSONObject getParaConfList1(String confName, Integer firstRow,
Integer rowSize) {
List
firstRow, rowSize);
JSONArray jsonobj = JSONArray.fromObject(result);
JSONObject returnjobj = new JSONObject();
returnjobj.put("aaData", jsonobj );
return returnjobj;
}
@Override
public int addParaConf(ParaConfigGroup conf) {
int result = 0;
if (conf.getCfgGroupCode().isEmpty())
result = paraConfMapper.addParaConf(conf);
else
result = paraConfMapper.updateParaConf(conf);
return result;
}
@Override
public int updateParaConf(ParaConfigGroup conf) {
int result = paraConfMapper.updateParaConf(conf);
return result;
}
@Override
public int delParaConf(String id) {
int result = paraConfMapper.delParaConf(id);
return result;
}
}
ParaConfMapper.java
package com.gy.inventory.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.gy.inventory.model.ParaConfigGroup;
public interface ParaConfMapper {
public List
@Param(value = "cfgGroupName") String paraName);
public List
@Param(value = "cfgGroupName") String cfgGroupName,
@Param(value = "firstRow") Integer firstRow,
@Param(value = "rowSize") Integer rowSize);
public int addParaConf(@Param(value = "cfg")ParaConfigGroup cfg);
public int updateParaConf(@Param(value = "cfg")ParaConfigGroup cfg);
public int delParaConf(@Param(value = "cfgGroupCode")String cfgGroupCode);
}
ParaConfMapper.xml
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
SELECT
INVENTORY_CFG_GROUP_CODE_ID,
CFGGROUPNAME
FROM T_INVENTORY_PARA_CONFIG_GROUP
WHERE 1 = 1
and CFGGROUPNAME = #{cfgGroupName}
SELECT
INVENTORY_CFG_GROUP_CODE_ID,
CFGGROUPNAME
FROM T_INVENTORY_PARA_CONFIG_GROUP g
WHERE 1 = 1
and CFGGROUPNAME = #{cfgGroupName}
INSERT INTO T_INVENTORY_PARA_CONFIG_GROUP
(CFGGROUPNAME
)
VALUES
(
#{cfg.cfgGroupName}
)
UPDATE
T_INVENTORY_PARA_CONFIG_GROUP
SET
CFGGROUPNAME = #{cfg.cfgGroupName}
WHERE INVENTORY_CFG_GROUP_CODE_ID = #{cfg.cfgGroupCode}
flushCache="true"> delete from T_INVENTORY_PARA_CONFIG_GROUP where INVENTORY_CFG_GROUP_CODE_ID = #{cfgGroupCode}
applicationContext.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation=" http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
jdbc.properties
jdbc.driverClassName=org.gjt.mm.mysql.Driver
jdbc.url=jdbc:mysql://localhost:3306/inventory?useUnicode=true&characterEncoding=UTF-8
jdbc.username=root
jdbc.password=123456
jdbc.alias=inventory
#proxool
jdbc.houseKeepingSleepTime=90000
#
jdbc.maximumnewConnections=10
#
jdbc.prototypeCount=5
#
jdbc.maximumConnectionCount=20
#
jdbc.minimumConnectionCount=5
#
proxool.maximumActiveTime = 60000000
#
proxool.maximumConnectionLifetime=18000000
#
simultaneous-build-throttle=10
#trace
jdbc.trace=true
#verbose
jdbc.verbose=true
#
proxool.houseKeepingTestSql=SELECT CURRENT_DATE
proxool.statistics=1800s,1000m,1d
#INFO DEBUG
proxool.statisticsLogLevel=INFO
log4j.xml
spring-servlet.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"> class="org.springframework.web.servlet.view.InternalResourceViewResolver">
web.xml
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:jsp="http://java.sun.com/xml/ns/javaee/jsp" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5"> org.logicalcobwebs.proxool.admin.servlet.AdminServlet
pom.xml
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
delimiter $$
CREATE TABLE `T_SAL_PARA_CONFIG_GROUP` (
`SAL_CFG_GROUP_CODE_ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '参数配置编码',
`CFGGROUPNAME` varchar(100) DEFAULT NULL COMMENT '参数配置名称',
`ISACTIVE` char(1) DEFAULT NULL COMMENT '标记此条记录的状态,逻辑删除标志',
`CREATED` datetime DEFAULT NULL COMMENT '创建时间,取记录创建时的系统时间',
`CREATEDBY` char(32) DEFAULT NULL COMMENT '由谁创建,值为用户的为主键ID',
`UPDATED` datetime DEFAULT NULL COMMENT '更新时间,取记录更新时的系统时间',
`UPDATEDBY` char(32) DEFAULT NULL COMMENT '由谁更新,值为用户的为主键ID',
PRIMARY KEY (`SAL_CFG_GROUP_CODE_ID`),
UNIQUE KEY `AK_UQ_ENUMNAME` (`CFGGROUPNAME`)
) ENGINE=MyISAM AUTO_INCREMENT=36 DEFAULT CHARSET=utf8 COMMENT='参数配置表'$$
delimiter $$
CREATE TABLE `DEMO_PARA_CONFIG_ITEMS` (
`SAL_CFG_ID` int(11) NOT NULL AUTO_INCREMENT COMMENT '参数配置项id',
`SAL_CFG_GROUP_CODE_ID` int(11) DEFAULT NULL COMMENT '参数组编码',
`CFGKEY` varchar(100) NOT NULL COMMENT '参数配置项键名',
`CFGVALUE` varchar(100) NOT NULL COMMENT '参数配置项键值',
`CFGSTATUS` char(1) DEFAULT NULL COMMENT '状态(启用0、禁用1)',
`CFGLEVEL` char(1) DEFAULT NULL COMMENT '参数访问级别(0-不可见,1-只读,2-读和改)',
`SORT` int(11) DEFAULT NULL COMMENT '排序',
`ISACTIVE` char(1) DEFAULT NULL COMMENT '标记此条记录的状态,逻辑删除标志',
`CREATED` datetime DEFAULT NULL COMMENT '创建时间,取记录创建时的系统时间',
`CREATEDBY` char(32) DEFAULT NULL COMMENT '由谁创建,值为用户的为主键ID',
`UPDATED` datetime DEFAULT NULL COMMENT '更新时间,取记录更新时的系统时间',
`UPDATEDBY` char(32) DEFAULT NULL COMMENT '由谁更新,值为用户的为主键ID',
`REMARK` varchar(100) DEFAULT NULL COMMENT '参数配置项说明',
`DEMO_PARA_CONFIG_ITEMScol` varchar(45) DEFAULT NULL,
PRIMARY KEY (`SAL_CFG_ID`),
KEY `FK_Reference_17` (`SAL_CFG_GROUP_CODE_ID`)
) ENGINE=InnoDB AUTO_INCREMENT=85 DEFAULT CHARSET=utf8 COMMENT='参数配置项列表'$$