Commit d7c15aba by liuyz

更新人员维护等

parent 8de216c3
......@@ -9,7 +9,6 @@
<value>classpath:com/gaowj/business/host/hostDAO.xml</value>
<value>classpath:com/gaowj/business/trigger/triggerDAO.xml</value>
<value>classpath:com/gaowj/business/usergroup/usergroupDAO.xml</value>
<value>classpath:com/gaowj/business/user/userDAO.xml</value>
<value>classpath:com/gaowj/business/warning/warningDAO.xml</value>
</list>
</property>
......@@ -39,14 +38,6 @@
</bean>
</property>
</bean>
<bean id="UserBusiness" class="com.gaowj.business.user.UserBusinessImpl">
<property name="userDAO">
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.gaowj.business.user.userDAO" />
<property name="sqlSessionFactory" ref="sqlSessionFactory-monitoring" />
</bean>
</property>
</bean>
<bean id="WarningBusiness" class="com.gaowj.business.warning.WarningBusinessImpl">
<property name="warningDAO">
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
......
......@@ -7,6 +7,7 @@
<property name="mapperLocations">
<list>
<value>classpath:com/gaowj/business/student/studentDAO.xml</value>
<value>classpath:com/gaowj/business/user/userDAO.xml</value>
</list>
</property>
</bean>
......@@ -19,4 +20,13 @@
</bean>
</property>
</bean>
<bean id="UserBusiness" class="com.gaowj.business.user.UserBusinessImpl">
<property name="userDAO">
<bean class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.gaowj.business.user.userDAO" />
<property name="sqlSessionFactory" ref="sqlSessionFactory-test" />
</bean>
</property>
</bean>
</beans>
......@@ -8,7 +8,7 @@
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="hostTab_searchForm" style="float:left">
主机名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" >
主机名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" class="tableInput-easyui">
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
......
......@@ -2,7 +2,7 @@
<form id="inputForm" method="post" style="width: 100%;">
<input type="hidden" name="FIELD_OPETYPE" id="OPETYPE" />
<input type="hidden" name="FIELD_TRIGGERID" id="TRIGGERID"/>
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 30px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 35px;">
<tr>
<td style="width: 15%;" class="tableStyleLable">
<span>服务器名:</span>
......
......@@ -41,7 +41,8 @@ var ls_ywlx = 'YBYW';
**/
//加载监控项类型
var v_item_data = [{CODE_ID:'0',CODE_NAME:'CPU使用率'},{CODE_ID:'1',CODE_NAME:'内存使用率'},{CODE_ID:'2',CODE_NAME:'网络流出流量'},{CODE_ID:'3',CODE_NAME:'网络流入流量'},{CODE_ID:'4',CODE_NAME:'磁盘使用空间'},{CODE_ID:'5',CODE_NAME:'磁盘IO(读取)'},{CODE_ID:'6',CODE_NAME:'磁盘IO(写入)'}];
//
var v_status_data = [{CODE_ID:'0',CODE_NAME:'失效'},{CODE_ID:'1',CODE_NAME:'正常'}];
/****/
......@@ -60,7 +61,7 @@ var ls_title="服务器列表";
var is_column = [ [
{field : 'NAME',title : '主机名',width : 100,align : 'center'
},
{field : 'IP',title : 'IP地址',width : 150,align : 'left',formatter:function(value,row,index){
{field : 'IP',title : 'IP地址',width : 250,align : 'center',formatter:function(value,row,index){
var json=eval('('+row.VALUE+')');
var ips=json.ip;
var ipText='';
......@@ -76,7 +77,7 @@ var is_column = [ [
return ipText;
}
},
{field : 'DISK',title : '硬盘',width : 80,align : 'left',formatter:function(value,row,index){
{field : 'DISK',title : '硬盘',width : 100,align : 'center',formatter:function(value,row,index){
var json=eval('('+row.VALUE+')');
var disks=json.disk;
var text='';
......@@ -92,7 +93,7 @@ var is_column = [ [
return text;
}
},
{field : 'CPU',title : 'CPU',width : 350,align : 'left',formatter:function(value,row,index){
{field : 'CPU',title : 'CPU',width : 450,align : 'center',formatter:function(value,row,index){
var json=eval('('+row.VALUE+')');
var cpu=json.cup;
var text='';
......@@ -100,7 +101,7 @@ var is_column = [ [
return text;
}
},
{field : 'MEMORY',title : '内存',width : 50,align : 'center',formatter:function(value,row,index){
{field : 'MEMORY',title : '内存',width : 80,align : 'center',formatter:function(value,row,index){
var json=eval('('+row.VALUE+')');
var memory=json.memory;
var text='';
......@@ -122,7 +123,7 @@ function rowstyler(index,row){
}
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/hostData_list",queryData,is_column,60,80);
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/hostData_list",queryData,is_column,70,80);
/****/
......
......@@ -67,7 +67,7 @@ $('#FIELD_HOSTID').combobox({
* 备注:需更改
**/
//定义grid列表
var ls_title="触发器维护";
var ls_title="触发器维护&nbsp;&nbsp;<font color='#993300'>(1、绿色表示启用&nbsp;&nbsp;2、红色表示停用。)</font>";
var is_column = [ [
{field : 'PRIORITY',title : '严重性',width : 100,align : 'center',formatter:function(value,row,index){
for(var i=0;i<v_priority_data.length;i++){
......@@ -76,11 +76,11 @@ var is_column = [ [
}
}
}},
{field : 'DESCRIPTION',title : '名称',width : 350,align : 'left'
{field : 'COMMENTS',title : '名称',width : 300,align : 'center'
},
{field : 'EXPRESSION',title : '表达式',width : 350,align : 'left'
{field : 'EXPRESSION',title : '表达式',width : 450,align : 'center'
},
{field : 'STATUS',title : '状态',width : 350,align : 'left',formatter:function(value,row,index){
{field : 'STATUS',title : '状态',width : 200,align : 'center',formatter:function(value,row,index){
for(var i=0;i<v_status_data.length;i++){
if(v_status_data[i].CODE_ID==value){
return v_status_data[i].CODE_NAME;
......@@ -101,7 +101,7 @@ function rowstyler(index,row){
}
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/triggerData_list",Object.assign({},$("#triggerTab_searchForm").getFormVal(),queryData),is_column,60,80);
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/triggerData_list",Object.assign({},$("#triggerTab_searchForm").getFormVal(),queryData),is_column,70,80);
/****/
......@@ -232,12 +232,12 @@ function updateData(is_entity){
function deleteRow(index){
var is_row = $('#list').datagrid('getData')[index];
var code = is_row.UUID;
var code = is_row.TRIGGERID;
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = studentModule.studentActAction.deleteStudent(v_query);
var v_result = triggerModule.act.deleteTrigger(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
......
......@@ -2,13 +2,13 @@
<form id="inputForm" method="post" style="width: 100%;">
<input type="hidden" name="FIELD_OPETYPE" id="OPETYPE" />
<input type="hidden" name="FIELD_TRIGGERID" id="TRIGGERID"/>
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 30px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 35px;">
<tr>
<td style="width: 15%;" class="tableStyleLable">
<span>描述:</span>
<span>名称:</span>
</td>
<td style="width: 85%">
<input class="easyui-textbox" id="DESCRIPTION" name="FIELD_DESCRIPTION" style="width:500px" />
<input class="easyui-textbox" id="COMMENTS" name="FIELD_COMMENTS" style="width:500px" />
</td>
</tr>
<tr>
......@@ -29,10 +29,10 @@
</tr>
<tr>
<td style="width: 15%;" class="tableStyleLable">
<span>备注:</span>
<span>描述:</span>
</td>
<td style="width: 85%">
<input class="easyui-textbox" id="COMMENTS" name="FIELD_COMMENTS" style="width:500px" />
<input class="easyui-textbox" id="DESCRIPTION" name="FIELD_DESCRIPTION" style="width:500px" />
</td>
</tr>
</table>
......
......@@ -40,15 +40,7 @@ var ls_ywlx = 'YBYW';
* 备注:需更改
**/
//加载用户组列表
var v_usergrp_data = usergroupModule.data.listAll().rowSet;
$('#FIELD_HOSTID').val(v_host_data[0].HOSTID);
$('#FIELD_usrgrpid').combobox({
data : v_host_data,
valueField : 'HOSTID',
textField : 'NAME',
editable:false,
panelHeight:'auto'
});
var v_host_data = hostModule.data.listAll().rowSet;
/****/
/**
......@@ -64,15 +56,13 @@ $('#FIELD_usrgrpid').combobox({
//定义grid列表
var ls_title="用户维护";
var is_column = [ [
{field : 'Alias',title : '用户名',width : 350,align : 'left'
{field : 'USERNAME',title : '用户名',width : 250,align : 'center'
},
{field : 'USERS_STATUS',title : '状态',width : 350,align : 'left',formatter:function(value,row,index){
for(var i=0;i<v_status_data.length;i++){
if(v_status_data[i].CODE_ID==value){
return v_status_data[i].CODE_NAME;
}
}
}
{field : 'EMAIL',title : '电子邮箱',width : 250,align : 'center'
},
{field : 'TELEPHONE',title : '联系电话',width : 250,align : 'center'
},
{field : 'WECHAT',title : '微信',width : 250,align : 'center'
}
] ];
//列表加载完成回调
......@@ -83,7 +73,7 @@ function rowstyler(index,row){
return 'color:green;height:30px;';
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/usergroupData_list",Object.assign({},$("#tusergroupTab_searchForm").getFormVal(),queryData),is_column,60,80);
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/userData_list",Object.assign({},$("#userTab_searchForm").getFormVal(),queryData),is_column,70,80);
/****/
......@@ -151,23 +141,31 @@ function getOptionMenuCount(){
//加载增加子页面
function addRow(){
var is_row={OPETYPE:'insert'};
openEditRow("usergroupView_usergroupTabDetail",is_row,"新增",true,0.65,0.95,0,0);
openEditRow("userView_userTabDetail",is_row,"新增",true,0.65,0.95,0,0);
}
//加载增加子页面成功后的回调
function addUrlOnloadCallback(is_row){
$('#USERS_STATUS').val(0);
$('#USERS_STATUS').combobox({
data : v_status_data,
valueField : 'CODE_ID',
textField : 'CODE_NAME',
editable:false,
panelHeight:'auto'
$('#HOST').combobox({
data : v_host_data,
valueField : 'HOSTID',
textField : 'NAME',
editable : false,
multiple : true, //支持多选
panelHeight : 'auto',
onLoadSuccess : function() {}
});
}
//保存
function insertData(is_entity){
var v_result = usergroupModule.act.insertUsergroup(is_entity);
var hostIds = "";
var concat_type = $("#HOST").combobox('getValues');
for (var i = 0; i < concat_type.length; i++) {
hostIds = hostIds + concat_type[i] + ",";
}
is_entity.FIELD_LIST_HOST_ID = hostIds;
var v_result = userModule.act.insertUser(is_entity);
$('#list').datagrid('reload');
return v_result;
}
......@@ -176,26 +174,40 @@ function insertData(is_entity){
function editRow(index) {
var is_row = $('#list').datagrid('getRows')[index];
is_row.OPETYPE = 'update';
openEditRow("usergroupView_usergroupTabDetail",is_row,"编辑",true,0.65,0.95,0,0);
openEditRow("userView_userTabDetail",is_row,"编辑",true,0.65,0.95,0,0);
}
//加载修改子页面成功后的回调
function updateUrlOnloadCallback(is_row){
for(k in is_row){
is_row['FIELD_'+k]=is_row[k];
function updateUrlOnloadCallback(is_row) {
for (k in is_row) {
is_row['FIELD_' + k] = is_row[k];
}
$("#inputForm").form('load', is_row);
$('#HOST').combobox({
data : v_host_data,
valueField : 'HOSTID',
textField : 'NAME',
editable : false,
multiple : true, //支持多选
panelHeight : 'auto',
onLoadSuccess : function() {
for (j = 0; j < is_row.FIELD_LIST_HOST_ID.length; j++) {
$('#HOST').combobox('select', is_row.FIELD_LIST_HOST_ID[j]);
}
}
$("#inputForm").form('load',is_row);
$('#USERS_STATUS').combobox({
data : v_status_data,
valueField : 'CODE_ID',
textField : 'CODE_NAME',
editable:false,
panelHeight:'auto'
});
}
//保存
function updateData(is_entity){
var v_result = usergroupModule.act.updateUsergroup(is_entity);
var hostIds = "";
var concat_type = $("#HOST").combobox('getValues');
for (var i = 0; i < concat_type.length; i++) {
hostIds = hostIds + concat_type[i] + ",";
}
is_entity.FIELD_LIST_HOST_ID = hostIds;
var v_result = userModule.act.updateUser(is_entity);
$('#list').datagrid('reload');
return v_result;
}
......@@ -214,12 +226,12 @@ function updateData(is_entity){
**/
function deleteRow(index){
var is_row = $('#list').datagrid('getData').rowSet[index];
var code = is_row.USRGRPID;
var code = is_row.UUID;
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = usergroupModule.act.deleteUsergroup(v_query);
v_query.FIELD_UUID = code;
var v_result = userModule.act.deleteUser(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
......@@ -240,9 +252,8 @@ function deleteRow(index){
function deleteBatchRow(){
var code="";
var rows = $('#list').datagrid('getSelections');
console.log(rows)
for(var i=0; i<rows.length; i++){
code = code + rows[i].USRGRPID+",";
code = code + rows[i].UUID+",";
}
if(rows == null || rows == ""){
$.messager.alert('提示',"请选择需删除的记录!",'info');
......@@ -254,8 +265,8 @@ function deleteBatchRow(){
$.messager.confirm('提示', '确定删除?', function(r) {
if (r) {
var v_query = {};
v_query.FIELD_CODE = code;
var v_result = usergroupModule.act.deleteUsergroup(v_query);
v_query.FIELD_UUID = code;
var v_result = userModule.act.deleteUser(v_query);
$.messager.alert('提示',v_result.VALUE);
$('#list').datagrid('reload');
}
......@@ -274,8 +285,8 @@ function deleteBatchRow(){
* 备注:需更改
**/
function refreshRow(){
$("#usergroupTab_searchForm")[0].reset();
$('#list').datagrid('load',$("#usergroupTab_searchForm").getFormVal());
$("#userTab_searchForm")[0].reset();
$('#list').datagrid('load',$("#userTab_searchForm").getFormVal());
}
/****/
......@@ -290,7 +301,7 @@ function refreshRow(){
* 备注:需更改
**/
function searchRow(){
var v_query = $("#usergroupTab_searchForm").getFormVal();
var v_query = $("#userTab_searchForm").getFormVal();
$('#list').datagrid('load',v_query);
}
/****/
......
......@@ -8,7 +8,7 @@
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="userTab_searchForm" style="float:left">
名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" >
名称: <input id="FIELD_USERNAME" name="FIELD_USERNAME" type="text" style="width: 200px" class="tableInput-easyui">
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
......@@ -17,5 +17,6 @@
</div>
<div id="detail" style="overflow:auto;"></div>
<script type="text/javascript" src="${ctx}/jwapp/pages/standard/js/jwStandardModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/host/js/hostModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/user/js/userModule.js" charset="utf-8"></script>
<script type="text/javascript" src="${ctx}/monitoring/pages/user/js/userTab.js" charset="utf-8"></script>
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'userTabDetail.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
This is my JSP page. <br>
</body>
</html>
<%@page contentType="text/html; charset=UTF-8"%>
<form id="inputForm" method="post" style="width: 100%;">
<input type="hidden" name="FIELD_OPETYPE" id="OPETYPE" value="${is_row.OPETYPE}"/>
<input type="hidden" name="FIELD_UUID" id="UUID" value="${is_row.UUID}"/>
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 35px;">
<tr>
<td style="width: 15%;" class="tableStyleLable">
<span>用户名:</span>
</td>
<td style="width: 85%">
<input class="easyui-textbox" id="USERNAME" name="FIELD_USERNAME" style="width:250px" value="${is_row.NAME}"/>
</td>
</tr>
<tr>
<td class="tableStyleLable">
<span>邮箱:</span>
</td>
<td>
<input class="easyui-textbox" id="EMAIL" name="FIELD_EMAIL" style="width:250px" value="${is_row.EMAIL}" />
</td>
</tr>
<tr>
<td class="tableStyleLable">
<span>联系电话:</span>
</td>
<td>
<input class="easyui-textbox" id="TELEPHONE" name="FIELD_TELEPHONE" style="width:250px" value="${is_row.TELEPHONE}" />
</td>
</tr>
<tr>
<td class="tableStyleLable">
<span>微信:</span>
</td>
<td>
<input class="easyui-textbox" id="WECHAT" name="FIELD_WECHAT" style="width:250px" value="${is_row.WECHAT}"/>
</td>
</tr>
<tr>
<td class="tableStyleLable">
<span>服务器:</span>
</td>
<td>
<input class="easyui-combobox" id="HOST" name="FIELD_LIST_HOST_ID" style="width:250px" value="${is_row.LIST_HOST_ID}"/>
</td>
</tr>
</table>
</form>
\ No newline at end of file
......@@ -56,9 +56,9 @@ var v_status_data = [{CODE_ID:'0',CODE_NAME:'已启用'},{CODE_ID:'1',CODE_NAME:
//定义grid列表
var ls_title="用户组维护";
var is_column = [ [
{field : 'NAME',title : '名称',width : 350,align : 'left'
{field : 'NAME',title : '名称',width : 350,align : 'center'
},
{field : 'USERS_STATUS',title : '状态',width : 350,align : 'left',formatter:function(value,row,index){
{field : 'USERS_STATUS',title : '状态',width : 350,align : 'center',formatter:function(value,row,index){
for(var i=0;i<v_status_data.length;i++){
if(v_status_data[i].CODE_ID==value){
return v_status_data[i].CODE_NAME;
......@@ -75,7 +75,7 @@ function rowstyler(index,row){
return 'color:green;height:30px;';
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/usergroupData_list",Object.assign({},$("#tusergroupTab_searchForm").getFormVal(),queryData),is_column,60,80);
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/usergroupData_list",Object.assign({},$("#tusergroupTab_searchForm").getFormVal(),queryData),is_column,70,80);
/****/
......
......@@ -8,7 +8,7 @@
<table id="list" style="width: 100%; height: 100%;"></table>
<div id="tb">
<form id="usergroupTab_searchForm" style="float:left">
名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" >
名称: <input id="FIELD_NAME" name="FIELD_NAME" type="text" style="width: 200px" class="tableInput-easyui">
</form>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="javascript:searchRow()">查询</a>
<a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-reload',plain:true" onclick="javascript:refreshRow()">刷新</a>
......
......@@ -2,7 +2,7 @@
<form id="inputForm" method="post" style="width: 100%;">
<input type="hidden" name="FIELD_OPETYPE" id="OPETYPE" />
<input type="hidden" name="FIELD_USRGRPID" id="USRGRPID"/>
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 30px;">
<table align="center" border="0" cellpadding="0" cellspacing="0" class="tableStyle" style="margin: 10px 15px; width: 95%; line-height: 35px;">
<tr>
<td style="width: 15%;" class="tableStyleLable">
<span>名称:</span>
......
......@@ -101,25 +101,7 @@ function rowstyler(index,row){
}
}
//展示列表
datagrid("list",ls_title,gaowj.WEB_APP_NAME + "/warningData_list",queryData,is_column,60,80);
/****/
/**
* 序号:4
* 功能:设置主页面操作列菜单
* 参数:
* 说明:
* 作者:高伟杰
* 时间:2016-01-22
* 单位:宁波金网
* 备注:需更改
**/
//操用列显示更多(一般情况下无需更改)
function formatMenu(value, data,index) {
var returnData="";
return returnData;
}
datagridLog("list",ls_title,gaowj.WEB_APP_NAME + "/warningData_list",queryData,is_column,60,80);
/****/
......
......@@ -32,5 +32,4 @@ public interface HostBusiness {
List<Map<String, Object>> list_io_read(Map<String, Object> query)throws BusinessException ;
List<Map<String, Object>> list_io_wirte(Map<String, Object> query)throws BusinessException ;
}
package com.gaowj.business;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
......@@ -16,4 +17,12 @@ public interface UserBusiness {
* @throws BusinessException
*/
Page<Map<String, Object>> list_user(int pageNo, int pageSize, Map<String, Object> query) throws BusinessException;
void insert_user(Map<String, Object> entity) throws BusinessException;
List<Map<String,Object>> list_user(Map<String, Object> query) throws BusinessException;
void update_user(Map<String, Object> entity) throws BusinessException;
void delete_user(List<String> listKey) throws BusinessException;
}
......@@ -29,4 +29,6 @@ public interface hostDAO {
List<Map<String, Object>> list_io_read(Map<String, Object> query) throws BusinessException;
List<Map<String, Object>> list_io_wirte(Map<String, Object> query) throws BusinessException;
Map<String, Object> query_host_id(Integer hostId) throws BusinessException ;
}
package com.gaowj.business.user;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.UserBusiness;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
import com.gaowj.business.util.SessionUtil;
import com.gaowj.standard.utils.CacheKit;
public class UserBusinessImpl implements UserBusiness{
private userDAO userDAO;
......@@ -28,6 +35,20 @@ public class UserBusinessImpl implements UserBusiness{
// 获取列表
List<Map<String, Object>> items = userDAO.list_user(new RowBounds(pageStart, pageSize), query);
for(Map<String, Object> map : items){
Map<String,Object> queryhost = new HashMap<String, Object>();
queryhost.put("USERID", map.get("USERID"));
//查询用户管理的主机信息
List<Map<String, Object>> list_user_host = userDAO.list_user_host(queryhost);
List<Integer> list_host_id = new ArrayList<Integer>();
for(Map<String, Object> user_host : list_user_host){
list_host_id.add(Integer.valueOf(user_host.get("HOSTID").toString()));
}
map.put("LIST_HOST_ID", list_host_id);
/*HostBusiness hostBusiness = BusinessManager.getBusiness(HostBusiness.class);
Map<String,Object> host = hostBusiness.query_host_id(Integer.valueOf(map.get("HOSTID").toString()));
map.put("HOSTNAME", host.get("NAME"));*/
}
// 获取列表个数
int count = userDAO.list_count_user(query);
......@@ -41,4 +62,108 @@ public class UserBusinessImpl implements UserBusiness{
return page;
}
@Override
public void insert_user(Map<String, Object> entity) throws BusinessException {
if (entity.get("UUID") == null) {
entity.put("UUID", java.util.UUID.randomUUID().toString());
}
if (entity.get("CREATE_TIME") == null) {
entity.put("CREATE_TIME", new Date());
}
if (entity.get("CREATE_ID") == null) {
entity.put("CREATE_ID", SessionUtil.getCode());
}
if (entity.get("LIST_HOST_ID") != null) {
insert_user_host(entity);
}
// 动态传值插入
List<String> infoListKey = new ArrayList<String>();
List<Object> infoList = new ArrayList<Object>();
if (entity.keySet() != null) {
Set<String> key = entity.keySet();
// 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) {
infoList.add(entity.get(str));
infoListKey.add(str);
}
entity.put("infoListKey", infoListKey);
entity.put("infoList", infoList);
// 插入
userDAO.insert_user(entity);
}
}
private void insert_user_host(Map<String, Object> entity) {
String hostIds = entity.get("LIST_HOST_ID").toString();
for (String hostId : hostIds.split(",")) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("UUID", java.util.UUID.randomUUID().toString());
map.put("USERID", entity.get("UUID"));
map.put("HOSTID", hostId);
map.put("CREATE_TIME", new Date());
List<String> infoListKey = new ArrayList<String>();
List<Object> infoList = new ArrayList<Object>();
if (map.keySet() != null) {
Set<String> key = map.keySet();
// 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) {
infoList.add(map.get(str));
infoListKey.add(str);
}
map.put("infoListKey", infoListKey);
map.put("infoList", infoList);
}
userDAO.insert_user_host(map);
}
entity.remove("LIST_HOST_ID");
}
@Override
public List<Map<String, Object>> list_user(Map<String, Object> query) throws BusinessException {
List<Map<String, Object>> list_data = CacheKit.get("ehcache10", "user" + query);
if (list_data == null || list_data.size() == 0) {
list_data = userDAO.list_user(query);
CacheKit.put("ehcache10", "user" + query, list_data);
}
return list_data;
}
@Override
public void update_user(Map<String, Object> entity) throws BusinessException {
//删除用户管理主机
delete_user_host(entity);
//插入用户管理主机
insert_user_host(entity);
// 动态传值修改
List<Map<String, Object>> updateList = new ArrayList<Map<String, Object>>();
if (entity.keySet() != null) {
Set<String> key = entity.keySet();
// 将map集合中的key和value 取出来分别放到list集合里
for (String str : key) {
Map<String, Object> updateMap = new HashMap<String, Object>();
if (StringUtils.equalsIgnoreCase("UUID", str))
continue;
updateMap.put("key", str);
updateMap.put("value", entity.get(str));
updateList.add(updateMap);
}
entity.put("info", updateList);
//
userDAO.update_user(entity);
}
}
private void delete_user_host(Map<String, Object> entity) {
String userId = entity.get("UUID").toString();
userDAO.delete_user_host(userId);
}
@Override
public void delete_user(List<String> listKey) throws BusinessException {
userDAO.delete_user(listKey);
}
}
......@@ -11,4 +11,18 @@ public interface userDAO {
List<Map<String, Object>> list_user(RowBounds rowbounds, Map<String, Object> query) throws BusinessException;
int list_count_user(Map<String, Object> query) throws BusinessException;
void insert_user(Map<String,Object> entity) throws BusinessException;
void update_user(Map<String,Object> entity) throws BusinessException;
void delete_user(List<String> list) throws BusinessException;
List<Map<String,Object>> list_user(Map<String,Object> query) throws BusinessException ;
List<Map<String,Object>> list_user_host(Map<String,Object> query) throws BusinessException ;
void insert_user_host(Map<String,Object> entity) throws BusinessException;
void delete_user_host(String userId) throws BusinessException;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.gaowj.business.user.userDAO">
<sql id="Where_Clause">
<trim prefix="WHERE" prefixOverrides="AND |OR">
<if test="NAME != null and NAME != ''">
and u.NAME = #{NAME}
</if>
<insert id="insert_user" parameterType="map">
insert into C_T_ZABBIX_USER(
<trim prefix="" suffixOverrides=",">
<foreach collection="infoListKey" item="key">
${key},
</foreach>
</trim>
</sql>
<![CDATA[ ) values( ]]>
<trim prefix="" suffixOverrides=",">
<foreach collection="infoList" item="value">
#{value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
<update id="update_user" parameterType="map">
<![CDATA[
update C_T_ZABBIX_USER set
]]>
<trim prefix="" suffixOverrides=",">
<foreach collection="info" item="info">
${info.key} = #{info.value} ,
</foreach>
</trim>
<where>
<if test="UUID != null and UUID != ''">
and UUID = #{UUID}
</if>
</where>
</update>
<delete id="delete_user" parameterType="list">
<![CDATA[
delete from C_T_ZABBIX_USER where UUID IN
]]>
<foreach collection="list" item="UUID" open="(" separator=","
close=")">
#{UUID}
</foreach>
</delete>
<select id="list_user" parameterType="map" resultType="upperCaseKeyMap">
SELECT u.*,gr.*
FROM users u
LEFT JOIN users_groups ug ON ug.userid = u.userid
LEFT JOIN usrgrp gr ON ug.usrgrpid = gr.usrgrpid
<include refid="Where_Clause" />
order by u.userid DESC
<![CDATA[
select f.*
from C_T_ZABBIX_USER f where 1=1
]]>
<if test="UUID != null and UUID != ''">
and f.UUID = #{UUID}
</if>
<if test="START_TIME != null and START_TIME != ''">
and f.CREATE_TIME &gt;= #{START_TIME}
</if>
<if test="END_TIME != null and END_TIME != ''">
and f.CREATE_TIME &lt;= #{END_TIME}
</if>
<if test="USERNAME != null and USERNAME != ''">
and f.USERNAME like '%${USERNAME}%'
</if>
order by f.CREATE_TIME DESC
</select>
<select id="list_count_user" parameterType="map" resultType="int">
SELECT count(*)
FROM users u
LEFT JOIN users_groups ug ON ug.userid = u.userid
LEFT JOIN usrgrp gr ON ug.usrgrpid = gr.usrgrpid
<include refid="Where_Clause" />
<![CDATA[
select count(*) c from C_T_ZABBIX_USER f where 1=1
]]>
<if test="UUID != null and UUID != ''">
and f.UUID = #{UUID}
</if>
<if test="START_TIME != null and START_TIME != ''">
and f.CREATE_TIME &gt;= #{START_TIME}
</if>
<if test="END_TIME != null and END_TIME != ''">
and f.CREATE_TIME &lt;= #{END_TIME}
</if>
<if test="USERNAME != null and USERNAME != ''">
and f.USERNAME like '%${USERNAME}%'
</if>
</select>
<select id="list_user_host" parameterType="map" resultType="upperCaseKeyMap">
<![CDATA[
select f.*
from c_t_zabbix_user_host f where 1=1
]]>
<if test="UUID != null and UUID != ''">
and f.UUID = #{UUID}
</if>
<if test="USERID != null and USERID != ''">
and f.USERID = #{USERID}
</if>
<if test="HOSTID != null and HOSTID != ''">
and f.HOSTID = #{HOSTID}
</if>
order by f.CREATE_TIME DESC
</select>
<insert id="insert_user_host" parameterType="map">
insert into c_t_zabbix_user_host(
<trim prefix="" suffixOverrides=",">
<foreach collection="infoListKey" item="key">
${key},
</foreach>
</trim>
<![CDATA[ ) values( ]]>
<trim prefix="" suffixOverrides=",">
<foreach collection="infoList" item="value">
#{value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
<delete id="delete_user_host" parameterType="string">
<![CDATA[
delete from c_t_zabbix_user_host where USERID = #{USERID}
]]>
</delete>
</mapper>
\ No newline at end of file
......@@ -3,15 +3,15 @@ package com.gaowj.user.action;
import java.util.List;
import java.util.Map;
import com.gaowj.business.SystemOpeBusiness;
import com.gaowj.business.UserBusiness;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.QueryParamUtil;
import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;
import com.zabbix4j.ZabbixApi;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.action.ActionCreateRequest;
import com.zabbix4j.action.ActionCreateRequest.Params;
import com.zabbix4j.usergroup.UserGroupCreateRequest;
import com.gaowj.standard.utils.CacheKit;
import net.sf.json.JSONObject;
......@@ -19,7 +19,7 @@ public class actAction extends BasicAction{
/**
*
*/
private static final long serialVersionUID = -6496396449440750926L;
private static final long serialVersionUID = 1559759499504671708L;
private JSONObject jsonObject = new JSONObject();
......@@ -31,35 +31,93 @@ public class actAction extends BasicAction{
this.jsonObject = jsonObject;
}
private static ZabbixApi zabbixApi;
/**
* 插入
* @param entity
* @throws BusinessException
*/
public String insertUser() throws BusinessException {
UserBusiness business = BusinessManager.getBusiness(UserBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
try {
entity = QueryParamUtil.StringToDate(entity);
//去除不要更新的字段
entity.remove("OPETYPE");
//新增
business.insert_user(entity);
static {
String url = "http://192.168.1.142/api_jsonrpc.php";
zabbixApi = new ZabbixApi(url);
// 操作日志
//sysbusiness.insert_logBusiness(具体方法,操作内容,操作描述,操作记录ID,操作记录中文描述,分类)
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("insertUser", "" + entity,
"增加用户数据", (String) entity.get("UUID"), (String) entity.get("USERNAME"), "userdemo1");
//
//更新缓存
CacheKit.update("ehcache11", "com_gaowj_user_dataAction_listAll", business.list_user(null));
//
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
e.printStackTrace();
}
return "json";
}
/**
* 更新
* @param entity
* @throws BusinessException
*/
public String updateUser() throws BusinessException {
UserBusiness business = BusinessManager.getBusiness(UserBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
zabbixApi.login("Admin", "zabbix");
} catch (ZabbixApiException e) {
// TODO Auto-generated catch block
//去除不要更新的字段
entity.remove("OPETYPE");
//修改
entity = QueryParamUtil.StringToDate(entity);
business.update_user(entity);
// 操作日志
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("updateUser", "" + entity,
"修改用户数据",(String) entity.get("UUID"), (String) entity.get("USERNAME"),"userdemo1");
//
jsonObject.putAll(Status.getStatusSuccessMessage("修改成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("修改失败"));
e.printStackTrace();
}
return "json";
}
public String insertUser() throws BusinessException {
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request, RequestUtils.UPDATEDATAFIELDPREFIX);
jsonObject = new JSONObject();
/**
* 在软删除基础上删除记录
* @param entity
* @throws BusinessException
*/
public String deleteUser() throws BusinessException {
UserBusiness business = BusinessManager.getBusiness(UserBusiness.class);
Map<String, Object> entity = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
String deletekey = (String) entity.get("UUID");
List<String> ListKey = QueryParamUtil.StringToList(deletekey);
try {
/*ActionCreateRequest request = new ActionCreateRequest();
List<Params> params = request.getParams();*/
/*UserGroupCreateRequest request = new UserGroupCreateRequest();
UserGroupCreateRequest.Params params = request.getParams();
params.setName(entity.get("NAME").toString());
params.setUsers_status(Integer.valueOf(entity.get("USERS_STATUS").toString()));
zabbixApi.usergroup().create(request);
jsonObject.putAll(Status.getStatusSuccessMessage("保存成功"));*/
business.delete_user(ListKey);
// 操作日志
SystemOpeBusiness sysbusiness = BusinessManager.getBusiness(SystemOpeBusiness.class);
sysbusiness.insert_logBusiness("deleteUser", "" + ListKey,
"删除用户数据", deletekey, "多个流水号","userdemo1");
//
jsonObject.putAll(Status.getStatusSuccessMessage("删除成功"));
} catch (Exception e) {
jsonObject.putAll(Status.getStatusErrorMessage("保存失败"));
jsonObject.putAll(Status.getStatusErrorMessage("删除失败"));
e.printStackTrace();
}
return "json";
......
package com.gaowj.user.action;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.Map;
import com.gaowj.business.UserBusiness;
import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
import com.gaowj.business.util.QueryParamUtil;
import com.gaowj.business.util.RequestUtils;
import net.sf.json.JSONObject;
public class dataAction extends BasicAction{
/**
*
*/
private static final long serialVersionUID = -6083279531948261141L;
private JSONObject jsonObject = new JSONObject();
private int rows = 20;// 每页显示的记录数
private int page = 1;// 当前第几页
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
public int getRows() {
rows = getPageSize();
return rows;
}
public void setRows(int rows) {
setPageSize(rows);
this.rows = getPageSize();
}
public int getPage() {
page = getPageNo();
return page;
}
public void setPage(int page) {
setPageNo(page);
this.page = getPageNo();
}
public String list() throws BusinessException {
UserBusiness business = BusinessManager.getBusiness(UserBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,RequestUtils.UPDATEDATAFIELDPREFIX);
try {
query = QueryParamUtil.StringToDate(query);
Page<Map<String, Object>> pageRows = business.list_user(pageNo,pageSize, query);
setPageCount((pageRows.getCount() - 1) / pageSize + 1);
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateToString(pageRows.getItems()));
data.put("pageNo", pageNo);
data.put("pageSize", pageSize);
data.put("pageCount", pageCount);
data.put("rows", data.get("rowSet"));
data.put("total", pageRows.getCount());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
}
......@@ -10,15 +10,7 @@ import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.Status;
import com.zabbix4j.ZabbixApi;
import com.zabbix4j.ZabbixApiException;
import com.zabbix4j.host.HostCreateRequest;
import com.zabbix4j.trigger.TriggerCreateRequest;
import com.zabbix4j.trigger.TriggerCreateResponse;
import com.zabbix4j.trigger.TriggerDeleteRequest;
import com.zabbix4j.trigger.TriggerDeleteResponse;
import com.zabbix4j.trigger.TriggerUpdateRequest;
import com.zabbix4j.trigger.TriggerUpdateResponse;
import com.zabbix4j.usergroup.UserGroupCreateRequest;
import com.zabbix4j.usergroup.UserGroupCreateResponse;
import com.zabbix4j.usergroup.UserGroupDeleteRequest;
import com.zabbix4j.usergroup.UserGroupUpdateRequest;
......
......@@ -11,7 +11,6 @@ import org.apache.commons.lang.StringUtils;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.StudentBusiness;
import com.gaowj.business.TriggerBusiness;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.Page;
import com.gaowj.business.util.SessionUtil;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment