提交 a7922f1b 编写于 作者: R roo00

增加授权

上级 9b42e868
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject)
{
if(typeof uri== 'boolean'){
iframeHtml += ' src="' + 'javascript:false' + '"';
}
else if(typeof uri== 'string'){
iframeHtml += ' src="' + uri + '"';
}
}
iframeHtml += ' />';
jQuery(iframeHtml).appendTo(document.body);
return jQuery('#' + frameId).get(0);
},
createUploadForm: function(id, fileElementId)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
var oldElement = jQuery('#' + fileElementId);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);
//set attributes
jQuery(form).css('position', 'absolute');
jQuery(form).css('top', '-1200px');
jQuery(form).css('left', '-1200px');
jQuery(form).appendTo('body');
return form;
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime()
var form = jQuery.createUploadForm(id, s.fileElementId);
var io = jQuery.createUploadIframe(id, s.secureuri);
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
{
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {}
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout)
{
var io = document.getElementById(frameId);
try
{
if(io.contentWindow)
{
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
}else if(io.contentDocument)
{
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
}
}catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if ( xml || isTimeout == "timeout")
{
requestDone = true;
var status;
try {
status = isTimeout != "timeout" ? "success" : "error";
// Make sure that the request was successful or notmodified
if ( status != "error" )
{
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.uploadHttpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data
if ( s.success )
s.success( data, status );
// Fire the global callback
if( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else
jQuery.handleError(s, xml, status);
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
// Process result
if ( s.complete )
s.complete(xml, status);
jQuery(io).unbind()
setTimeout(function()
{ try
{
jQuery(io).remove();
jQuery(form).remove();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
}, 100)
xml = null
}
}
// Timeout checker
if ( s.timeout > 0 )
{
setTimeout(function(){
// Check to see if the request is still happening
if( !requestDone ) uploadCallback( "timeout" );
}, s.timeout);
}
try
{
var form = jQuery('#' + formId);
jQuery(form).attr('action', s.url);
jQuery(form).attr('method', 'POST');
jQuery(form).attr('target', frameId);
if(form.encoding)
{
jQuery(form).attr('encoding', 'multipart/form-data');
}
else
{
jQuery(form).attr('enctype', 'multipart/form-data');
}
jQuery(form).submit();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
jQuery('#' + frameId).load(uploadCallback );
return {abort: function () {}};
},
uploadHttpData: function( r, type ) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
eval( "data = " + data );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
return data;
}
})
function failure(data) {
console.log(data);
alert(data.message);
}
function splitValue(str) {
if (str) {
if (str.length > 0) {
return str.split(',');
}
}
return [];
}
function joinValue(o, split) {
var s = ',';
if (split) {
s = '' + split;
}
if (o) {
if (toString.apply(o) === '[object Array]') {
return o.join(s);
}
}
return o;
}
function data_query() {
str = '<table border="1" width="100%">';
str += '<tr><td>id:</td><td><input type="text" id="id" style="width:95%"/></td></tr>';
str += '<tr><td>type:</td><td>';
str += '<select id="type">';
str += '<option value="appInfo">appInfo</option>';
str += '<option value="catagoryInfo">catagoryInfo</option>';
str += '<option value="fileInfo">fileInfo</option>';
str += '<option value="appCatagoryPermission">appCatagoryPermission</option>';
str += '<option value="appCatagoryAdmin">appCatagoryAdmin</option>';
str += '<option value="log">log</option>';
str += '</select>';
str += '</td></tr>';
str += '<tr><td colspan="2"><button id="get">get</button>&nbsp;<button id="put">put</button>&nbsp;<button id="post">post</button>&nbsp;<button id="uuid">UUID</button></td></tr>';
str += '<tr><td colspan="2"><textarea id="data" style="width:95%;height:500px"/></td></tr>';
str += '</table>';
$('#content').html(str);
$('#result').html('');
$('#get', '#content').click(function() {
data_get($('#id').val(), $('#type').val());
});
$('#put', '#content').click(function() {
data_put($('#id').val(), $('#type').val());
});
$('#post', '#content').click(function() {
data_post($('#id').val(), $('#type').val());
});
$('#uuid', '#content').click(function() {
get_uuid();
});
}
function get_uuid( ) {
$('#data', '#content').val('');
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/uuid/random',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(data) {
if (data.type == 'success') {
$('#content').html(JSON.stringify(json.data));
} else {
failure(data);
}
});
}
function data_get(id, type) {
$('#data', '#content').val('');
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/' + type + '/' + id,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(data, null, 4));
if (json.type == 'success') {
$('#data', '#content').val(JSON.stringify(json.data, null, 4));
} else {
failure(data);
}
}).fail(function(data) {
failure(data);
});
}
function data_put( id, type ) {
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/' + type + '/' + id,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#data', '#content').val())),
crossDomain : true
}).done(function(data) {
$('#result').html(JSON.stringify(data.data, null, 4));
});
}
function data_post( id, type ) {
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/' + type ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#data', '#content').val())),
crossDomain : true
}).done(function(data) {
$('#result').html(JSON.stringify(data.data, null, 4));
});
}
\ No newline at end of file
debug_parameter = {};
function debug_init() {
$('#result').html('');
$('#content').html('');
var str = '<table border="1" width="100%">';
str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp<a href="#" id="on">on</a>&nbsp;<a href="#" id="off">off</a></td></tr>';
str += '<tr><td>debug:</td><td id="status">&nbsp;</td></tr>';
str += '</table>';
$('#content').html(str);
$('#get').click(function() {
debug_get();
});
$('#on').click(function() {
debug_on();
});
$('#off').click(function() {
debug_off();
});
}
function debug_get() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function debug_on() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug/true',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function debug_off() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug/false',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
\ No newline at end of file
......@@ -200,20 +200,20 @@ Describe.prototype = {
switch (p.name) {
case 'flag':
case 'id':
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid" value="(0)"/></td><td>' + p.name
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; " value="(0)"/></td><td>' + p.name
+ ':' + p.description + '</td></tr>';
break;
case 'count':
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid" value="20"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; " value="20"/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
break;
default:
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
break
}
} else {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
}
});
......@@ -225,10 +225,10 @@ Describe.prototype = {
txt += '<table >';
$.each(m.formParameters, function(pi, p) {
if (p.type == "File") {
txt += '<tr><td><input type="file" name="' + p.name + '" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>'
txt += '<tr><td><input type="file" name="' + p.name + '" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>'
+ p.name + ':' + p.description + '</td></tr>';
} else {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
}
});
......@@ -239,7 +239,7 @@ Describe.prototype = {
txt += '<fieldset id="queryParameters"><legend>Query Parameter</legend>';
txt += '<table >';
$.each(m.queryParameters, function(pi, p) {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':' + p.description
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':' + p.description
+ '</td></tr>';
});
txt += '</table>';
......@@ -250,10 +250,10 @@ Describe.prototype = {
txt += '<table>';
$.each(m.ins, function(ii, i) {
if (i.isCollection) {
txt += '<tr><td><textarea id="' + i.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + i.name + ':' + i.description
txt += '<tr><td><textarea id="' + i.name + '" style="width:600px; padding:1px; "/></td><td>' + i.name + ':' + i.description
'</td></tr>';
} else {
txt += '<tr><td><input type="text" id="' + i.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + i.name + ':'
txt += '<tr><td><input type="text" id="' + i.name + '" style="width:600px; padding:1px; "/></td><td>' + i.name + ':'
+ i.description
'</td></tr>';
}
......@@ -264,7 +264,7 @@ Describe.prototype = {
if (m.useJsonElementParameter) {
txt += '<fieldset><legend>JsonElement</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="jsonElement" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '<textarea id="jsonElement" style="height:300px; width:600px; padding:1px; "/>';
txt += '</td><td>json</td></tr>';
txt += '</table>';
txt += '</fieldset>';
......@@ -272,7 +272,7 @@ Describe.prototype = {
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; "/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
......@@ -308,6 +308,7 @@ Describe.prototype = {
if (m.contentType.indexOf('application/json') > -1) {
switch (m.type) {
case 'POST':
debugger;
var data = {};
if (m.ins && m.ins.length > 0) {
$.each(m.ins, function(ii, i) {
......@@ -320,11 +321,21 @@ Describe.prototype = {
data[i.name] = $('#' + i.name, '#ins').val();
}
} else {
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
if (i.isCollection) {
data[i.name] = Describe.splitValue($('#' + i.name, '#ins').val());
} else {
if( $('#' + i.name, '#ins').val() == null || typeof($('#' + i.name, '#ins').val()) == "undefind" || $('#' + i.name, '#ins').val() == "" ){
$('#' + i.name, '#ins').val("{}");
}
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
}
}
}
});
} else if (m.useJsonElementParameter) {
if( $('#jsonElement').val() == null || typeof($('#jsonElement').val()) == "undefind" || $('#jsonElement').val() == "" ){
$('#jsonElement').val("{}");
}
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
......@@ -344,11 +355,21 @@ Describe.prototype = {
data[i.name] = $('#' + i.name, '#ins').val();
}
} else {
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
if (i.isCollection) {
data[i.name] = Describe.splitValue($('#' + i.name, '#ins').val());
} else {
if( $('#' + i.name, '#ins').val() == null || typeof($('#' + i.name, '#ins').val()) == "undefind" || $('#' + i.name, '#ins').val() == "" ){
$('#' + i.name, '#ins').val("{}");
}
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
}
}
}
});
} else if (m.useJsonElementParameter) {
if( $('#jsonElement').val() == null || typeof($('#jsonElement').val()) == "undefind" || $('#jsonElement').val() == "" ){
$('#jsonElement').val("{}");
}
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
......
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./do_statistic.js"></script>
<script>
$(document).ready(function() {
$('#dostatistic').click(function() {
do_statistic();
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>type:</td>
<td>
Do_Statistic
</td>
</tr>
<tr>
<td colspan="2">
<button id="dostatistic">do_statistic</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function do_statistic() {
var query_url = '../jaxrs/statistic/do';
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceAdmin.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendanceadmin($('#id').val());
});
$('#post').click(function() {
data_post_attendanceadmin();
});
$('#delete').click(function() {
data_delete_attendanceadmin( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceAdmin
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function data_get_attendanceadmin( id ) {
var query_url = '../jaxrs/attendanceadmin/' + id;
//如果未输入ID,那么就查询所有的应用信息
if( id == null || id == undefined || id == "" ){
query_url = '../jaxrs/attendanceadmin/list/all';
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_post_attendanceadmin( id ) {
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceadmin' ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_delete_attendanceadmin( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceadmin/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceAppeal.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendanceappeal();
});
$('#put').click(function() {
data_put_attendanceappeal();
});
$('#delete').click(function() {
data_delete_attendanceappeal( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:<input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td width="50px">last_id:<input type="text" id="last_id" style="width:95%" value="(0)"/></td>
<td width="50px">count:<input type="text" id="count" style="width:95%" value="10"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceAppeal
</td>
</tr>
<tr>
<td width="50px">GET:/jaxrs/attendanceappealInfo/
<select id="service_url">
<option value="{id}">{id}</option>
</select>
</td>
</tr>
<tr>
<td width="50px">PUT:/jaxrs/attendanceappealInfo/
<select id="put_url">
<option value="appeal/{id}">appeal/{id}</option>
<option value="process/{id}">process/{id}</option>
<option value="process2/{id}">process2/{id}</option>
<option value="filter/list/{id}/next/{count}">filter/list/{id}/next/{count}</option>
<option value="filter/list/{id}/prev/{count}">filter/list/{id}/prev/{count}</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="put">PUT</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
var service_base_path = '../jaxrs/attendanceappealInfo';
function data_get_attendanceappeal( ) {
var service_url = $("#service_url").val();
var query_url = service_base_path + "/" + service_url;
//获取用户所填写的参数
var id = $("#id").val();
//根据参数组织URL
query_url = query_url.replace( "{id}",id );
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_put_attendanceappeal( ) {
var service_url = $("#put_url").val();
var query_url = service_base_path + "/" + service_url;
//获取用户所填写的参数
var id = $("#id").val();
var last_id = $("#last_id").val();
var count = $("#count").val();
//根据参数组织URL
if( "filter/list/{id}/next/{count}" == service_url ){
query_url = query_url.replace( "{id}",last_id );
query_url = query_url.replace( "{count}",count );
}else if( "filter/list/{id}/prev/{count}" == service_url ){
query_url = query_url.replace( "{id}",last_id );
query_url = query_url.replace( "{count}",count );
}else{
query_url = query_url.replace( "{id}",id );
query_url = query_url.replace( "{count}",count );
}
alert("PUT:"+query_url);
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_delete_attendanceappeal( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendancedetail/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceDetail.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendancedetail();
});
$('#put').click(function() {
data_put_attendancedetail();
});
$('#delete').click(function() {
data_delete_attendancedetail( $('#id').val() );
});
$('#analyse').click(function() {
data_Analyse( $('#anlyseStartDate').val(), $('#anlyseEndDate').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:<input type="text" id="id" style="width:95%"/></td>
<td>file_id:<input type="text" id="file_id" style="width:95%"/></td>
</tr>
<tr>
<td width="50px">last_id:<input type="text" id="last_id" style="width:95%" value="(0)"/></td>
<td width="50px">count:<input type="text" id="count" style="width:95%" value="10"/></td>
</tr>
<tr>
<td>anlyseStartDate:<input type="text" id="anlyseStartDate" style="width:95%" value="(0)"/></td>
<td>anlyseEndDate:<input type="text" id="anlyseEndDate" style="width:95%" value="(0)"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceDetail
</td>
</tr>
<tr>
<td width="50px">GET:/jaxrs/attendancedetail/
<select id="service_url">
<option value="list/{file_id}">list/{file_id}</option>
<option value="{id}">{id}</option>
</select>
</td>
</tr>
<tr>
<td width="50px">PUT:/jaxrs/attendancedetail/
<select id="put_url">
<option value="filter/list">filter/list</option>
<option value="filter/list/user">filter/list/user</option>
<option value="filter/list/department">filter/list/department</option>
<option value="filter/list/company">filter/list/company</option>
<option value="filter/list/{id}/next/{count}">filter/list/{id}/next/{count}</option>
<option value="filter/list/{id}/prev/{count}">filter/list/{id}/prev/{count}</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="put">PUT</button>
<button id="delete">DELETE</button>
<button id="analyse">Analyse</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
var service_base_path = '../jaxrs/attendancedetail';
function data_get_attendancedetail( ) {
var service_url = $("#service_url").val();
var query_url = service_base_path + "/" + service_url;
//获取用户所填写的参数
var id = $("#id").val();
var file_id = $("#file_id").val();
var last_id = $("#last_id").val();
var count = $("#count").val();
//根据参数组织URL
if( "{id}" == service_url ){
query_url = query_url.replace( "{id}",id );
if( id == null || id == "" || id == undefined){
alert("请填写ID");return false;
}
}else if( "list/{file_id}" == service_url ){
if( file_id == null || file_id == "" || file_id == undefined){
alert("请填写file_id");return false;
}
query_url = query_url.replace( "{file_id}",file_id );
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_put_attendancedetail( ) {
var service_url = $("#put_url").val();
var query_url = service_base_path + "/" + service_url;
//获取用户所填写的参数
var last_id = $("#last_id").val();
var count = $("#count").val();
//根据参数组织URL
if( "filter/list/{id}/next/{count}" == service_url ){
query_url = query_url.replace( "{id}",last_id );
query_url = query_url.replace( "{count}",count );
if( last_id == null || last_id == "" || last_id == undefined){
alert("请填写last_id");return false;
}
if( count == null || count == "" || count == undefined){
alert("请填写count");return false;
}
}else if( "filter/list/{id}/prev/{count}" == service_url ){
query_url = query_url.replace( "{id}",last_id );
query_url = query_url.replace( "{count}",count );
if( last_id == null || last_id == "" || last_id == undefined){
alert("请填写last_id");return false;
}
if( count == null || count == "" || count == undefined){
alert("请填写count");return false;
}
}
alert("PUT:"+query_url);
alert(JSON.stringify($.parseJSON($('#content').val())));
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_Analyse( anlyseStartDate, anlyseEndDate ) {
var query_url = '../jaxrs/attendancedetail/analyse/{startDate}/{endDate}';
//如果未输入ID,那么就查询所有的应用信息
query_url = query_url.replace( "{startDate}",anlyseStartDate );
query_url = query_url.replace( "{endDate}",anlyseEndDate );
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_delete_attendancedetail( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendancedetail/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceDetailFileImport.js"></script>
<script>
$(document).ready(function() {
$('#checkData').click(function() {
checkData( $('#file_id').val() );
});
$('#importData').click(function() {
importData( $('#file_id').val() );
});
$('#testImport').click(function() {
testImport();
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>file_id:</td>
<td><input type="text" id="file_id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceDetailFileImport
</td>
</tr>
<tr>
<td colspan="2">
<button id="checkData">CheckDataFile</button>
<button id="importData">ImportDataFile</button>
<button id="testImport">testImportData</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function checkData( file_id ) {
if( file_id == null || file_id == undefined || file_id == "" ){
alert("请输入file_id");
return false;
}
var query_url = '../jaxrs/fileimport/check/' + file_id;
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function importData( file_id ) {
if( file_id == null || file_id == undefined || file_id == "" ){
alert("请输入file_id");
return false;
}
var query_url = '../jaxrs/fileimport/import/' + file_id;
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function testImport( ) {
var query_url = '../jaxrs/fileimport/import/test';
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./ajaxfileupload.js"></script>
<script src="./entity_AttendanceImportFileInfo.js"></script>
<script>
$(document).ready(function() {
$('#upload').click(function() {
upload_attendanceimportfileinfo();
});
$('#download').click(function() {
download_attendanceimportfileinfo($('#id').val());
});
$('#get').click(function() {
data_get_attendanceimportfileinfo($('#id').val());
});
$('#delete').click(function() {
data_delete_attendanceimportfileinfo( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>file:</td>
<td><input type="file" id="file" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceSetting
</td>
</tr>
<tr>
<td colspan="2">
<button id="upload">Upload</button>
<button id="download">Download</button>
<button id="get">GET</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function upload_attendanceimportfileinfo() {
//开始上传具体的文件
$.ajaxFileUpload({
//处理文件上传操作的服务器端地址(可以传参数,已亲测可用)
url: '../servlet/upload/',
data:{},
secureuri:false, //是否启用安全提交,默认为false
fileElementId:'file', //文件选择框的id属性
dataType:'text', //服务器返回的格式,可以是json或xml等
success:function( data, status){ //服务器响应成功时的处理函数
$('#result').html("数据导入成功!");
},
error:function(data, status, e){ //服务器响应失败时的处理函数
console.log(e);
console.log(data);
$('#result').html('上传失败,请重试!!');
}
});
}
function download_attendanceimportfileinfo( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
window.open( '../servlet/download/'+id+'/stream' );
}
function data_get_attendanceimportfileinfo( id ) {
var query_url = '../jaxrs/attendanceimportfileinfo/' + id;
//如果未输入ID,那么就查询所有的应用信息
if( id == null || id == undefined || id == "" ){
query_url = '../jaxrs/attendanceimportfileinfo/list/all';
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_delete_attendanceimportfileinfo( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceimportfileinfo/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceScheduleSetting.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendanceschedulesetting($('#id').val());
});
$('#post').click(function() {
data_post_attendanceschedulesetting();
});
$('#delete').click(function() {
data_delete_attendanceschedulesetting( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceScheduleSetting
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function data_get_attendanceschedulesetting( id ) {
var query_url = '../jaxrs/attendanceschedulesetting/' + id;
//如果未输入ID,那么就查询所有的应用信息
if( id == null || id == undefined || id == "" ){
query_url = '../jaxrs/attendanceschedulesetting/list/all';
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_post_attendanceschedulesetting( id ) {
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceschedulesetting' ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_delete_attendanceschedulesetting( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceschedulesetting/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceSelfHoliday.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendanceselfholiday($('#id').val());
});
$('#post').click(function() {
data_post_attendanceselfholiday();
});
$('#delete').click(function() {
data_delete_attendanceselfholiday( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceAdmin
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function data_get_attendanceselfholiday( id ) {
var query_url = '../jaxrs/attendanceselfholiday/' + id;
//如果未输入ID,那么就查询所有的应用信息
if( id == null || id == undefined || id == "" ){
query_url = '../jaxrs/attendanceselfholiday/list/all';
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_post_attendanceselfholiday( id ) {
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceselfholiday' ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_delete_attendanceselfholiday( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceselfholiday/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceSetting.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendancesetting($('#id').val());
});
$('#post').click(function() {
data_post_attendancesetting();
});
$('#delete').click(function() {
data_delete_attendancesetting( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceSetting
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function data_get_attendancesetting( id ) {
var query_url = '../jaxrs/attendancesetting/' + id;
//如果未输入ID,那么就查询所有的应用信息
if( id == null || id == undefined || id == "" ){
query_url = '../jaxrs/attendancesetting/list/all';
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_post_attendancesetting( id ) {
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendancesetting' ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_delete_attendancesetting( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendancesetting/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./entity_AttendanceWorkDayConfig.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
data_get_attendanceworkdayconfig($('#id').val());
});
$('#post').click(function() {
data_post_attendanceworkdayconfig();
});
$('#delete').click(function() {
data_delete_attendanceworkdayconfig( $('#id').val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>id:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
AttendanceWorkDayConfig
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function data_get_attendanceworkdayconfig( id ) {
var query_url = '../jaxrs/attendanceworkdayconfig/' + id;
//如果未输入ID,那么就查询所有的应用信息
if( id == null || id == undefined || id == "" ){
query_url = '../jaxrs/attendanceworkdayconfig/list/all';
}
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function data_post_attendanceworkdayconfig( id ) {
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceworkdayconfig' ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function data_delete_attendanceworkdayconfig( id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : '../jaxrs/attendanceworkdayconfig/' + id ,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
......@@ -5,6 +5,68 @@
<meta http-equiv="pragma" content="no-cache" />
<script src="./jquery.min.js"></script>
<script src="./clipboard.min.js"></script>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
background:#fff;
text-align:left;
}
a {
color:#1E7ACE;
text-decoration:none;
}
a:hover {
color:#000;
text-decoration:underline;
}
h3 {
font-size:14px;
font-weight:bold;
}
pre,p {
color:#1E7ACE;
margin:4px;
}
input, select,textarea {
padding:1px;
margin:2px;
font-size:11px;
}
fieldset {
padding:10px;
margin-top:10px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset legend {
color:#1E7ACE;
font-weight:bold;
padding:3px 20px 3px 20px;
border:1px solid #A4CDF2;
background:#fff;
}
input {
border:1px solid #A4CDF2;
}
button {
border:1px solid #A4CDF2;
background-color : #FFFFFF;
height:25px;
margin-top:10px;
font-weight:bold;
color:#1E7ACE;
}
-->
</style>
<script>
$.getScript('./describe.js?rd=' + Math.random()).then(function() {
var describe = new Describe();
......@@ -14,7 +76,7 @@
});
$(document).ready(function(){
var clipboard = new Clipboard("#btn");
var clipboard = new Clipboard("#btn_copy");
});
</script>
</head>
......@@ -24,19 +86,19 @@
<tr>
<td style="width: 350px;" valign="top">
<fieldset>
<legend>Menu</legend>
<legend>API Menu</legend>
<div id="menu" style="height: 850px; overflow: auto">&nbsp;</div>
</fieldset>
</td>
<td valign="top">
<fieldset>
<legend>Content</legend>
<legend>API Content</legend>
<div id="content"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word">&nbsp;</div>
</fieldset>
<fieldset>
<legend>
Result&nbsp;<a href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
Result&nbsp;<a id="btn_copy" href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
</legend>
<div id="result"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; width: 1400px">&nbsp;</div>
......
logger_parameter = {};
function logger_init() {
$('#result').html('');
$('#content').html('');
var str = '<table border="1" width="100%">';
str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp<a href="#" id="trace">trace</a>&nbsp;<a href="#" id="debug">debug</a>&nbsp;<a href="#" id="info">info</a>&nbsp;<a href="#" id="warn">warn</a></td></tr>';
str += '<tr><td>debug:</td><td id="level">&nbsp;</td></tr>';
str += '</table>';
$('#content').html(str);
$('#get').click(function() {
logger_get();
});
$('#trace').click(function() {
logger_trace();
});
$('#debug').click(function() {
logger_debug();
});
$('#info').click(function() {
logger_info();
});
$('#warn').click(function() {
logger_warn();
});
}
function logger_get() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#level').html(json.data.value);
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_trace() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/trace',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_debug() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/debug',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_info() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/info',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_warn() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/warn',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./showStatistic.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
var _name = $("#name").val();
var _year = $("#year").val();
var _month = $("#month").val();
var _date = $("#date").val();
getStatistic( _name, _year, _month, _date );
});
$('#put').click(function() {
var _id = $("#last_id").val();
var _count = $("#count").val();
getFilterListForStatistic( _id, _count );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>name:<input type="text" id="name" value="蔡艳红"/></td>
<td>date:<input type="text" id="date" value=""/></td>
</tr>
<tr>
<td>year:<input type="text" id="year" value="2016"/></td>
<td>month:<input type="text" id="month" value="03"/></td>
</tr>
<tr>
<td>last_id:<input type="text" id="last_id" value="(0)"/></td>
<td>count:<input type="text" id="count" value="10"/></td>
</tr>
<tr>
<td>type:SHOW_Statistic</td>
</tr>
<tr>
<td>
<select id="queryUrl">
<option value="person/{name}/{year}/{month}">person/{name}/{year}/{month}</option>
<option value="persons/department/{name}/{year}/{month}">persons/department/{name}/{year}/{month}</option>
<option value="department/{name}/{year}/{month}">department/{name}/{year}/{month}</option>
<option value="department/sum/{name}/{year}/{month}">department/sum/{name}/{year}/{month}</option>
<option value="department/{name}/{date}">department/{name}/{date}</option>
<option value="department/day/{name}/{year}/{month}">department/day/{name}/{year}/{month}</option>
<option value="department/day/{name}/{date}">department/day/{name}/{date}</option>
<option value="company/{name}/{year}/{month}">company/{name}/{year}/{month}</option>
<option value="company/day/{name}/{year}/{month}">company/day/{name}/{year}/{month}</option>
</select>
</td>
<td>
<button id="get">GET</button>
</td>
</tr>
<tr>
<td>
<select id="putUrl">
<option value="filter/personMonth/list/{id}/next/{count}">filter/personMonth/list/{id}/next/{count}</option>
<option value="filter/personMonth/list/{id}/prev/{count}">filter/personMonth/list/{id}/prev/{count}</option>
<option value="filter/departmentMonth/list/{id}/next/{count}">filter/departmentMonth/list/{id}/next/{count}</option>
<option value="filter/departmentMonth/list/{id}/prev/{count}">filter/departmentMonth/list/{id}/prev/{count}</option>
<option value="filter/companyMonth/list/{id}/next/{count}">filter/companyMonth/list/{id}/next/{count}</option>
<option value="filter/companyMonth/list/{id}/prev/{count}">filter/companyMonth/list/{id}/prev/{count}</option>
<option value="filter/departmentDay/list/{id}/next/{count}">filter/departmentDay/list/{id}/next/{count}</option>
<option value="filter/departmentDay/list/{id}/prev/{count}">filter/departmentDay/list/{id}/prev/{count}</option>
<option value="filter/companyDay/list/{id}/next/{count}">filter/companyDay/list/{id}/next/{count}</option>
<option value="filter/companyDay/list/{id}/prev/{count}">filter/companyDay/list/{id}/prev/{count}</option>
</select>
</td>
<td>
<button id="put">PUT</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px"></textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
var service_base_path = '../jaxrs/statisticshow/';
function getStatistic( name, year, month, date ) {
var query_url = service_base_path + $("#queryUrl").val();
if( name != null && name != undefined && name != "(0)"){
query_url = query_url.replace( "{name}", encodeURIComponent(name) );
}
if( date != null && date != undefined && date != "(0)"){
query_url = query_url.replace( "{date}", encodeURIComponent(date) );
}
if( year != null && year != undefined && year != "(0)"){
query_url = query_url.replace( "{year}", year );
}
if( month != null && month != undefined && month != "(0)"){
query_url = query_url.replace( "{month}", month );
}
alert(query_url);
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function getFilterListForStatistic( last_id, _count ){
var service_url = $("#putUrl").val();
var query_url = service_base_path + "/" + service_url;
if( last_id == null || last_id == undefined ){
last_id="(0)";
}
if( _count == null || _count == undefined ){
_count=20;
}
//根据参数组织URL
query_url = query_url.replace( "{id}",last_id );
query_url = query_url.replace( "{count}",_count );
alert( "PUT:"+query_url );
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : query_url,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script src="./test.js"></script>
<script>
$(document).ready(function() {
$('#get').click(function() {
doget();
});
$('#put').click(function() {
doput();
});
$('#post').click(function() {
dopost();
});
$('#delete').click(function() {
dodelete();
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>URL:</td>
<td>/jaxrs/<input type="text" id="url" style="width:95%"/></td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="put">PUT</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr><td colspan="2"><textarea id="content" style="width:97%;height:300px">{}</textarea></td></tr>
<tr><td colspan="2"><textarea id="result" style="width:97%;height:400px"></textarea></td></tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function doget() {
var url = '../jaxrs/'+$("#url").val();
alert(url);
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function dopost() {
var url = '../jaxrs/'+$("#url").val();
alert(url);
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function doput() {
var url = '../jaxrs/'+$("#url").val();
alert(url);
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON($('#content').val())),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function dodelete() {
var url = '../jaxrs/'+$("#url").val();
alert(url);
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>main_entiity</title>
<script>
$(document).ready(function() {
$('#get_uuid').click(function() {
$('#data', '#result').val('');
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/uuid/random',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify( json, null, 4));
});
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" width="100%">
<tr>
<td colspan="2">
<button id="get_uuid">GET UUID</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:600px"/>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -51,7 +51,7 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
}
public void persist(JpaObject o) throws Exception {
//o.onPersist();
// o.onPersist();
this.get(o.getClass()).persist(o);
}
......@@ -523,6 +523,20 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
return em.createQuery(cq).getSingleResult();
}
public <T extends JpaObject> Long countEqualAndEqualAndEqual(Class<T> cls, String oneEuqalAttribute,
Object oneEqualValue, String twoEqualAttribute, Object twoEqualValue, String threeEqualAttribute,
Object threeEqualValue) throws Exception {
EntityManager em = this.get(cls);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<T> root = cq.from(cls);
cq.select(cb.count(root))
.where(cb.and(cb.equal(root.get(oneEuqalAttribute), oneEqualValue),
cb.equal(root.get(twoEqualAttribute), twoEqualValue),
cb.equal(root.get(threeEqualAttribute), threeEqualValue)));
return em.createQuery(cq).getSingleResult();
}
public <T extends JpaObject> Long countEqualAndEqualAndNotEqual(Class<T> cls, String euqalAttribute,
Object equalValue, String otherEqualAttribute, Object otherEqualValue, String notEqualAttribute,
Object notEqualValue) throws Exception {
......@@ -1345,6 +1359,24 @@ public class EntityManagerContainer extends EntityManagerContainerBasic {
return list;
}
public <T extends JpaObject> List<T> listEqualAndEqualAndSequenceAfter(Class<T> clz, String oneEqualAttribute,
Object oneEqualValue, String twoEqualAttribute, Object twoEqualValue, Integer count, String sequence)
throws Exception {
EntityManager em = this.get(clz);
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<T> cq = cb.createQuery(clz);
Root<T> root = cq.from(clz);
Predicate p = cb.equal(root.get(oneEqualAttribute), oneEqualValue);
p = cb.and(p, cb.equal(root.get(twoEqualAttribute), twoEqualValue));
if (StringUtils.isNotEmpty(sequence)) {
p = cb.and(p, cb.greaterThan(root.get(JpaObject_.sequence), sequence));
}
cq.select(root).where(p).orderBy(cb.asc(root.get(JpaObject_.sequence)));
List<T> os = em.createQuery(cq).setMaxResults((count != null && count > 0) ? count : 100).getResultList();
List<T> list = new ArrayList<>(os);
return list;
}
/* 仅在单一数据库可用 */
public <T extends JpaObject, W extends GsonPropertyObject> List<W> fetchEqualDescPaging(Class<T> clz,
WrapCopier<T, W> copier, String equalAttribute, Object equalValue, Integer page, Integer count,
......
......@@ -24,6 +24,39 @@ import com.x.base.core.project.tools.ListTools;
public class PersistenceXmlHelper {
public static List<String> directWrite(String path, List<String> classNames) throws Exception {
try {
Document document = DocumentHelper.createDocument();
Element persistence = document.addElement("persistence", "http://java.sun.com/xml/ns/persistence");
persistence.addAttribute(QName.get("schemaLocation", "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
"http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd");
persistence.addAttribute("version", "2.0");
for (String className : classNames) {
Element unit = persistence.addElement("persistence-unit");
unit.addAttribute("name", className);
unit.addAttribute("transaction-type", "RESOURCE_LOCAL");
Element provider = unit.addElement("provider");
provider.addText(PersistenceProviderImpl.class.getName());
Element mapped_element = unit.addElement("class");
mapped_element.addText(className);
Element sliceJpaObject_element = unit.addElement("class");
sliceJpaObject_element.addText("com.x.base.core.entity.SliceJpaObject");
Element jpaObject_element = unit.addElement("class");
jpaObject_element.addText("com.x.base.core.entity.JpaObject");
}
OutputFormat format = OutputFormat.createPrettyPrint();
format.setEncoding("UTF-8");
File file = new File(path);
FileUtils.touch(file);
XMLWriter writer = new XMLWriter(new FileWriter(file), format);
writer.write(document);
writer.close();
return classNames;
} catch (Exception e) {
throw new Exception("registContainerEntity error.className:" + ListTools.toStringJoin(classNames), e);
}
}
public static List<String> write(String path, List<String> entities) throws Exception {
List<String> names = new ArrayList<>();
String name = "";
......
......@@ -134,8 +134,7 @@ public class Applications extends ConcurrentHashMap<String, CopyOnWriteArrayList
public ActionResponse postQuery(Boolean xdebugger, Application application, String uri, Object body)
throws Exception {
return CipherConnectionAction.post(xdebugger, application.getUrlRoot() + CipherConnectionAction.trim(uri),
body);
return CipherConnectionAction.post(xdebugger, application.getUrlRoot() + CipherConnectionAction.trim(uri), body);
}
public ActionResponse postQuery(String applicationName, String uri, Object body) throws Exception {
......
......@@ -337,7 +337,12 @@ public class Describe {
jaxrsField.setIsBaseType(true);
}
} else {
jaxrsField.setIsCollection(false);
//O2LEE,String[]未被判断为collection导致组织的JSON格式不符合wrapIn要求
if( StringUtils.equalsAnyIgnoreCase( "String[]", jaxrsField.getType() )) {
jaxrsField.setIsCollection(true);
}else {
jaxrsField.setIsCollection(false);
}
if (StringUtils.startsWithAny(jaxrsField.getType(), "String", "Boolean", "Date", "Integer",
"Double", "Long", "Float")) {
jaxrsField.setIsBaseType(true);
......
......@@ -8,7 +8,6 @@ import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.gson.XGsonBuilder;
import com.x.base.core.project.tools.DefaultCharset;
......@@ -16,6 +15,7 @@ public class CenterServer extends ConfigObject {
private static final Integer default_port = 20030;
private static final Integer default_scanInterval = 0;
private static final Boolean default_configApiEnable = true;
public static CenterServer defaultInstance() {
return new CenterServer();
......@@ -30,6 +30,7 @@ public class CenterServer extends ConfigObject {
this.proxyHost = "";
this.proxyPort = default_port;
this.scanInterval = default_scanInterval;
this.configApiEnable = default_configApiEnable;
}
@FieldDescribe("是否启用")
......@@ -50,6 +51,12 @@ public class CenterServer extends ConfigObject {
private Integer scanInterval;
@FieldDescribe("其他参数")
private LinkedHashMap<String, Object> config;
@FieldDescribe("允许通过Api修改config")
private Boolean configApiEnable;
public Boolean getConfigApiEnable() {
return configApiEnable == null ? default_configApiEnable : this.configApiEnable;
}
public String getHttpProtocol() {
return StringUtils.equals("https", this.httpProtocol) ? "https" : "http";
......@@ -123,10 +130,6 @@ public class CenterServer extends ConfigObject {
this.config = config;
}
// public void setHost(String host) {
// this.host = host;
// }
public void setHttpProtocol(String httpProtocol) {
this.httpProtocol = httpProtocol;
}
......@@ -136,4 +139,8 @@ public class CenterServer extends ConfigObject {
FileUtils.write(file, XGsonBuilder.toJson(this), DefaultCharset.charset);
}
public void setConfigApiEnable(Boolean configApiEnable) {
this.configApiEnable = configApiEnable;
}
}
......@@ -2,6 +2,7 @@ package com.x.base.core.project.config;
import java.io.File;
import java.io.FileFilter;
import java.util.concurrent.ConcurrentHashMap;
import javax.naming.InitialContext;
import javax.ws.rs.core.MediaType;
......@@ -101,7 +102,9 @@ public class Config {
public static final String RESOUCE_AUDITLOGPRINTSTREAM = "auditLogPrintStream";
public static final String RESOUCE_CONFIG = "config";
// public static final String RESOUCE_CONFIG = "config";
public static final String RESOUCE_NODE = "node";
private static final String DEFAULT_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCWcVZIS57VeOUzi8c01WKvwJK9uRe6hrGTUYmF6J/pI6/UvCbdBWCoErbzsBZOElOH8Sqal3vsNMVLjPYClfoDyYDaUlakP3ldfnXJzAFJVVubF53KadG+fwnh9ZMvxdh7VXVqRL3IQBDwGgzX4rmSK+qkUJjc3OkrNJPB7LLD8QIDAQAB";
private static final String DEFAULT_PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAJZxVkhLntV45TOLxzTVYq/Akr25F7qGsZNRiYXon+kjr9S8Jt0FYKgStvOwFk4SU4fxKpqXe+w0xUuM9gKV+gPJgNpSVqQ/eV1+dcnMAUlVW5sXncpp0b5/CeH1ky/F2HtVdWpEvchAEPAaDNfiuZIr6qRQmNzc6Ss0k8HsssPxAgMBAAECgYAWtRy05NUgm5Lc6Og0jVDL/mEnydxPBy2ectwzHh2k7wIHNi8XhUxFki2TMqzrM9Dv3/LySpMl4AE3mhs34LNPy6F+MwyF5X7j+2Y6MflJyeb9HNyT++viysQneoOEiOk3ghxF2/GPjpiEF79wSp+1YKTxRAyq7ypV3t35fGOOEQJBANLDPWl8b5c3lrcz/dTamMjHbVamEyX43yzQOphzkhYsz4pruATzTxU+z8/zPdEqHcWWV39CP3xu3EYNcAhxJW8CQQC2u7PF5Xb1xYRCsmIPssFxil64vvdUadSxl7GLAgjQ9ULyYWB24KObCEzLnPcT8Pf2Q0YQOixxa/78FuzmgbyfAkA7ZFFV/H7lugB6t+f7p24OhkRFep9CwBMD6dnZRBgSr6X8d8ZvfrD2Z7DgBMeSva+OEoOtlNmXExZ3lynO9zN5AkAVczEmIMp3DSl6XtAuAZC9kD2QODJ2QToLYsAfjiyUwsWKCC43piTuVOoW2KUUPSwOR1VZIEsJQWEcHGDQqhgHAkAeZ7a6dVRZFdBwKA0ADjYCufAW2cIYiVDQBJpgB+kiLQflusNOCBK0FT3lg8BdUSy2D253Ih6l3lbaM/4M7DFQ";
......@@ -1031,4 +1034,13 @@ public class Config {
return initialContext().lookup(RESOUCE_JDBC_PREFIX + name);
}
@SuppressWarnings("unchecked")
public static ConcurrentHashMap<String, Object> resource_node() throws Exception {
return (ConcurrentHashMap<String, Object>) initialContext().lookup(RESOUCE_NODE);
}
public static void registWebServer() {
}
}
\ No newline at end of file
package com.x.base.core.project.exception;
public class ExceptionUnknowValue extends PromptException {
private static final long serialVersionUID = -7354813827434276962L;
public ExceptionUnknowValue(Object value) {
super("未知的值:{}.", value);
}
}
......@@ -75,6 +75,8 @@ abstract class AbstractJaxrsAction {
DefaultCharset.charset);
fileName = FilenameUtils.getName(fileName);
return fileName;
}
}
\ No newline at end of file
package com.x.base.core.project.jaxrs;
import java.net.URI;
import java.util.Objects;
import javax.ws.rs.core.CacheControl;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import com.x.base.core.project.exception.CallbackPromptException;
......@@ -37,6 +39,22 @@ public class ResponseFactory {
.build();
} else if ((null != result.getData()) && (result.getData() instanceof WoCallback)) {
return Response.ok(callback((WoCallback) result.getData())).cacheControl(defaultCacheControl).build();
} else if ((null != result.getData()) && (result.getData() instanceof WoSeeOther)) {
WoSeeOther wo = (WoSeeOther) result.getData();
try {
return Response.seeOther(new URI(wo.getUrl())).build();
} catch (Exception e) {
return Response.serverError().entity(Objects.toString(wo.getUrl(), ""))
.cacheControl(defaultCacheControl).build();
}
} else if ((null != result.getData()) && (result.getData() instanceof WoTemporaryRedirect)) {
WoTemporaryRedirect wo = (WoTemporaryRedirect) result.getData();
try {
return Response.temporaryRedirect(new URI(wo.getUrl())).build();
} catch (Exception e) {
return Response.serverError().entity(Objects.toString(wo.getUrl(), ""))
.cacheControl(defaultCacheControl).build();
}
} else {
return Response.ok(result.toJson()).cacheControl(defaultCacheControl).build();
}
......@@ -63,8 +81,24 @@ public class ResponseFactory {
.build();
} else if ((null != result.getData()) && (result.getData() instanceof WoCallback)) {
return Response.ok(callback((WoCallback) result.getData())).cacheControl(maxAgeCacheControl).build();
} else if ((null != result.getData()) && (result.getData() instanceof WoSeeOther)) {
WoSeeOther wo = (WoSeeOther) result.getData();
try {
return Response.seeOther(new URI(wo.getUrl())).build();
} catch (Exception e) {
return Response.serverError().entity(Objects.toString(wo.getUrl(), ""))
.cacheControl(defaultCacheControl).build();
}
} else if ((null != result.getData()) && (result.getData() instanceof WoTemporaryRedirect)) {
WoTemporaryRedirect wo = (WoTemporaryRedirect) result.getData();
try {
return Response.temporaryRedirect(new URI(wo.getUrl())).build();
} catch (Exception e) {
return Response.serverError().entity(Objects.toString(wo.getUrl(), ""))
.cacheControl(defaultCacheControl).build();
}
} else {
return Response.ok(result.toJson()).cacheControl(maxAgeCacheControl).build();
return Response.ok(result.toJson()).cacheControl(defaultCacheControl).build();
}
}
}
......
package com.x.base.core.project.jaxrs;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
public class WoSeeOther extends GsonPropertyObject {
public WoSeeOther() {
}
public WoSeeOther(String url) throws Exception {
this.url = url;
}
@FieldDescribe("地址")
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
package com.x.base.core.project.jaxrs;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.gson.GsonPropertyObject;
public class WoTemporaryRedirect extends GsonPropertyObject {
public WoTemporaryRedirect() {
}
public WoTemporaryRedirect(String url) throws Exception {
this.url = url;
}
@FieldDescribe("地址")
private String url;
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
......@@ -95,6 +95,16 @@ public class MessageConnector {
public static final String TYPE_CALENDAR_ALARM = "calendar_alarm";
public static final String TYPE_CUSTOM_CREATE = "custom_create";
public static final String TYPE_TEAMWORK_TASKCREATE = "teamwork_taskCreate";
public static final String TYPE_TEAMWORK_TASKUPDATE = "teamwork_taskUpdate";
public static final String TYPE_TEAMWORK_TASKDELETE = "teamwork_taskDelelte";
public static final String TYPE_TEAMWORK_TASKOVERTIME = "teamwork_taskOvertime";
public static final String TYPE_TEAMWORK_CHAT = "teamwork_taskChat";
public static final String CONSUME_WS = "ws";
......
package com.x.base.core.project.message;
import com.google.gson.JsonElement;
import com.x.base.core.project.annotation.FieldDescribe;
public class WsMessage extends Message {
public WsMessage() {
}
@FieldDescribe("Ws消息类别.")
private String type;
@FieldDescribe("Ws消息接收人.")
private String person;
@FieldDescribe("Ws消息标题.")
private String title;
@FieldDescribe("Ws消息内容.")
private JsonElement body;
public String getPerson() {
......
......@@ -64,6 +64,9 @@ public class OrganizationDefinition {
public final static String MessageManager = "MessageManager";
public final static String MessageManager_discription = "消息管理员(系统角色),可以对系统中产生的消息进行管理。";
public final static String HotPictureManager = "HotPictureManager";
public final static String HotPictureManager_discription = "热点图片控制权限(系统角色),可以对系统中产生的系统图片进行管理。";
public final static String SearchPrivilege = "SearchPrivilege";
public final static String SearchPrivilege_discription = "搜索管理员(系统角色),可以跨权限对系统内容进行搜索。";
......
......@@ -45,6 +45,10 @@ public class StringTools {
public static final Pattern UUID_REGEX = Pattern
.compile("^[a-zA-Z_0-9]{8}-[a-zA-Z_0-9]{4}-[a-zA-Z_0-9]{4}-[a-zA-Z_0-9]{4}-[a-zA-Z_0-9]{12}$");
public static final String[] SQL_LIKE = new String[] { "_", "%" };
public static final String[] SQL_LIKE_SHIFT = new String[] { "\\\\_", "\\\\%" };
private static final Random random = new Random();
public static int utf8Length(String str) {
......@@ -373,4 +377,12 @@ public class StringTools {
return ListUtils.subtract(in, ex);
}
}
public static String escapeSqlLikeKey(String str) {
if (StringUtils.isEmpty(str)) {
return str;
} else {
return StringUtils.trim(StringUtils.replaceEach(str, SQL_LIKE, SQL_LIKE_SHIFT));
}
}
}
\ No newline at end of file
......@@ -25,9 +25,9 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.processplatform.core.entity.element.End", "com.x.processplatform.core.entity.element.ApplicationDict",
"com.x.processplatform.core.entity.element.ApplicationDictItem",
"com.x.processplatform.core.entity.element.QueryView", "com.x.processplatform.core.entity.element.QueryStat",
"com.x.processplatform.core.entity.element.Projection", "com.x.query.core.entity.Item",
"com.x.query.dynamic.entity.*" }, storeJars = { "x_organization_core_entity", "x_organization_core_express",
"x_processplatform_core_entity", "x_query_core_entity" }, dynamicJars = {
"com.x.processplatform.core.entity.element.Projection", "com.x.processplatform.core.entity.element.Mapping",
"com.x.query.core.entity.Item", "com.x.query.dynamic.entity.*" }, storeJars = { "x_organization_core_entity",
"x_organization_core_express", "x_processplatform_core_entity", "x_query_core_entity" }, dynamicJars = {
"x_query_dynamic_entity" }, storageTypes = { StorageType.processPlatform })
public class x_processplatform_assemble_designer extends Deployable {
......
......@@ -26,9 +26,9 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.processplatform.core.entity.element.Script", "com.x.processplatform.core.entity.element.Service",
"com.x.processplatform.core.entity.element.Split", "com.x.processplatform.core.entity.element.QueryView",
"com.x.processplatform.core.entity.element.QueryStat", "com.x.processplatform.core.entity.element.Projection",
"com.x.query.core.entity.Item" }, storageTypes = { StorageType.processPlatform }, storeJars = {
"x_organization_core_entity", "x_organization_core_express", "x_processplatform_core_entity",
"x_query_core_entity" })
"com.x.processplatform.core.entity.element.Mapping", "com.x.query.core.entity.Item" }, storageTypes = {
StorageType.processPlatform }, storeJars = { "x_organization_core_entity",
"x_organization_core_express", "x_processplatform_core_entity", "x_query_core_entity" })
public class x_processplatform_assemble_surface extends Deployable {
// public x_processplatform_assemble_surface() {
......
......@@ -26,7 +26,8 @@ import com.x.base.core.project.annotation.ModuleType;
"com.x.processplatform.core.entity.element.Delay", "com.x.processplatform.core.entity.element.File",
"com.x.processplatform.core.entity.element.Form", "com.x.processplatform.core.entity.element.FormField",
"com.x.processplatform.core.entity.element.Embed", "com.x.processplatform.core.entity.element.Projection",
"com.x.processplatform.core.entity.log.ProcessingError", "com.x.query.core.entity.Item",
"com.x.processplatform.core.entity.element.Mapping", "com.x.processplatform.core.entity.log.ProcessingError",
"com.x.query.core.entity.Item",
"com.x.query.dynamic.entity.*" }, storageTypes = { StorageType.processPlatform }, storeJars = {
"x_organization_core_entity", "x_organization_core_express", "x_processplatform_core_entity",
"x_query_core_entity" }, dynamicJars = { "x_query_dynamic_entity" })
......
......@@ -22,36 +22,4 @@ import com.x.base.core.project.annotation.ModuleType;
"x_organization_core_express", "x_processplatform_core_entity", "x_cms_core_entity" })
public class x_query_service_processing extends Deployable {
// public x_query_service_processing() {
// super();
// dependency.containerEntities.add("com.x.query.core.entity.Item");
// dependency.containerEntities.add("com.x.query.core.entity.Query");
// dependency.containerEntities.add("com.x.query.core.entity.View");
// dependency.containerEntities.add("com.x.query.core.entity.Stat");
// dependency.containerEntities.add("com.x.query.core.entity.Reveal");
// dependency.containerEntities.add("com.x.query.core.entity.segment.Word");
// dependency.containerEntities.add("com.x.query.core.entity.segment.Entry");
// dependency.containerEntities.add("com.x.query.core.entity.neural.Entry");
// dependency.containerEntities.add("com.x.query.core.entity.neural.InText");
// dependency.containerEntities.add("com.x.query.core.entity.neural.OutText");
// dependency.containerEntities.add("com.x.query.core.entity.neural.InValue");
// dependency.containerEntities.add("com.x.query.core.entity.neural.OutValue");
// dependency.containerEntities.add("com.x.query.core.entity.neural.Model");
// dependency.containerEntities.add("com.x.query.core.entity.schema.*");
// dependency.containerEntities.add("com.x.processplatform.core.entity.content.Review");
// dependency.containerEntities.add("com.x.processplatform.core.entity.content.Work");
// dependency.containerEntities.add("com.x.processplatform.core.entity.content.WorkCompleted");
// dependency.containerEntities.add("com.x.processplatform.core.entity.content.Attachment");
// dependency.containerEntities.add("com.x.cms.core.entity.Document");
// dependency.containerEntities.add("com.x.cms.core.entity.FileInfo");
// dependency.containerEntities.add("com.x.cms.core.entity.AppInfo");
// dependency.containerEntities.add("com.x.cms.core.entity.CategoryInfo");
// dependency.storageTypes.add(StorageType.processPlatform.toString());
// dependency.storageTypes.add(StorageType.cms.toString());
// dependency.storeJars.add(x_query_core_entity.class.getSimpleName());
// dependency.storeJars.add(x_organization_core_entity.class.getSimpleName());
// dependency.storeJars.add(x_organization_core_express.class.getSimpleName());
// dependency.storeJars.add(x_processplatform_core_entity.class.getSimpleName());
// dependency.storeJars.add(x_cms_core_entity.class.getSimpleName());
// }
}
......@@ -139,14 +139,6 @@ public class CryptoClass {
String value = rsaEncrypt(Base64.encodeBase64String(ss), TEST_PUBLIC_KEY);
byte[] ds = Base64.decodeBase64(rsaDecrypt(value, TEST_PRIVATE_KEY));
FileUtils.writeByteArrayToFile(new File("e:/2.war"), ds);
System.out.println(ds.length + "<>" + ss.length);
for (int i = 0; i < ss.length; i++) {
if (ss[i] != ds[i]) {
System.out.println("!!!!!!!!@##");
System.out.println(i);
System.out.println("!!!!!!!!@##");
}
}
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script lang="text/javascript">
//根据ID获取论坛信息对象
function query_by_id( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var query_url = '../jaxrs/'+serviceName+'/' + id;
send_get_request( query_url );
}
//保存论坛信息对象
function saveEntity(serviceName) {
var url = '../jaxrs/' + serviceName;
send_post_request( url );
}
//根据ID删除论坛信息对象
function deleteEntity( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var url = '../jaxrs/' + serviceName ;
send_delete_request( url, id );
}
/////////////////////////////////////////////////////////////////////////////////////////////////
var serviceName = "forum";
$(document).ready(function() {
$('#get').click(function() {
query_by_id($('#id').val(), serviceName);
});
$('#post').click(function() {
saveEntity(serviceName);
});
$('#delete').click(function() {
deleteEntity( $('#id').val(), serviceName );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>ID:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
论坛信息(BBSFORUMINFO)
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px">{}</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script lang="text/javascript">
//根据ID获取论坛信息对象
function query_by_id( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var query_url = '../jaxrs/'+serviceName+'/' + id;
send_get_request( query_url );
}
//保存论坛信息对象
function saveEntity(serviceName) {
var url = '../jaxrs/' + serviceName;
send_post_request( url );
}
//根据ID删除论坛信息对象
function deleteEntity( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var url = '../jaxrs/' + serviceName ;
send_delete_request( url, id );
}
/////////////////////////////////////////////////////////////////////////////////////////////////
var serviceName = "permission";
$(document).ready(function() {
$('#all').click(function() {
send_get_request( '../jaxrs/' + serviceName + "/all" );
});
$('#get').click(function() {
query_by_id($('#id').val(), serviceName);
});
$('#post').click(function() {
saveEntity(serviceName);
});
$('#delete').click(function() {
deleteEntity( $('#id').val(), serviceName );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>ID:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
权限信息(BBSPERMISSIONINFO)
</td>
</tr>
<tr>
<td colspan="2">
<button id="all">ALL</button>
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px">{}</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script lang="text/javascript">
//根据ID获取论坛信息对象
function query_by_id( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var query_url = '../jaxrs/'+serviceName+'/' + id;
send_get_request( query_url );
}
//保存论坛信息对象
function saveEntity(serviceName) {
var url = '../jaxrs/' + serviceName;
send_post_request( url );
}
//根据ID删除论坛信息对象
function deleteEntity( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var url = '../jaxrs/' + serviceName ;
send_delete_request( url, id );
}
/////////////////////////////////////////////////////////////////////////////////////////////////
var serviceName = "role";
$(document).ready(function() {
$('#all').click(function() {
send_get_request( '../jaxrs/' + serviceName + "/all" );
});
$('#get').click(function() {
query_by_id($('#id').val(), serviceName);
});
$('#post').click(function() {
saveEntity(serviceName);
});
$('#delete').click(function() {
deleteEntity( $('#id').val(), serviceName );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>ID:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
角色信息(BBSROLEINFO)
</td>
</tr>
<tr>
<td colspan="2">
<button id="all">ALL</button>
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px">{}</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script lang="text/javascript">
//根据ID获取论坛信息对象
function query_by_id( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var query_url = '../jaxrs/'+serviceName+'/' + id;
send_get_request( query_url );
}
//保存论坛信息对象
function saveEntity(serviceName) {
var url = '../jaxrs/' + serviceName;
send_post_request( url );
}
//根据ID删除论坛信息对象
function deleteEntity( id, serviceName ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
var url = '../jaxrs/' + serviceName ;
send_delete_request( url, id );
}
/////////////////////////////////////////////////////////////////////////////////////////////////
var serviceName = "subject";
$(document).ready(function() {
$('#get').click(function() {
query_by_id($('#id').val(), serviceName);
});
$('#post').click(function() {
saveEntity(serviceName);
});
$('#delete').click(function() {
deleteEntity( $('#id').val(), serviceName );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>ID:</td>
<td><input type="text" id="id" style="width:95%"/></td>
</tr>
<tr>
<td>type:</td>
<td>
主题信息(BBSSUBJECTINFO)
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px">{}</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
function failure(data) {
console.log(data);
alert(data.message);
}
function splitValue(str) {
if (str) {
if (str.length > 0) {
return str.split(',');
}
}
return [];
}
function joinValue(o, split) {
var s = ',';
if (split) {
s = '' + split;
}
if (o) {
if (toString.apply(o) === '[object Array]') {
return o.join(s);
}
}
return o;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script lang="text/javascript">
//GET
function m_get( url ) {
send_get_request( url );
}
//POST
function m_post() {
send_post_request( url );
}
//PUT
function m_post() {
send_put_request( url );
}
//DELETE
function m_delete() {
send_delete_request_as_url( url );
}
/////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
$('#get').click(function() {
common_get( $("#url").val() );
});
$('#post').click(function() {
common_post( $("#url").val() );
});
$('#put').click(function() {
common_put( $("#url").val() );
});
$('#delete').click(function() {
common_delete( $("#url").val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>URL:</td>
<td><input type="text" id="url" style="width:95%" placeholder="../jaxrs/forum/"/></td>
</tr>
<tr>
<td>type:</td>
<td>
通用REST服务调用
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="put">PUT</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px">{}</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
debug_parameter = {};
function debug_init() {
$('#result').html('');
$('#content').html('');
var str = '<table border="1" width="100%">';
str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp<a href="#" id="on">on</a>&nbsp;<a href="#" id="off">off</a></td></tr>';
str += '<tr><td>debug:</td><td id="status">&nbsp;</td></tr>';
str += '</table>';
$('#content').html(str);
$('#get').click(function() {
debug_get();
});
$('#on').click(function() {
debug_on();
});
$('#off').click(function() {
debug_off();
});
}
function debug_get() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function debug_on() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug/true',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function debug_off() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug/false',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
\ No newline at end of file
......@@ -200,20 +200,20 @@ Describe.prototype = {
switch (p.name) {
case 'flag':
case 'id':
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid" value="(0)"/></td><td>' + p.name
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; " value="(0)"/></td><td>' + p.name
+ ':' + p.description + '</td></tr>';
break;
case 'count':
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid" value="20"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; " value="20"/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
break;
default:
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
break
}
} else {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
}
});
......@@ -225,10 +225,10 @@ Describe.prototype = {
txt += '<table >';
$.each(m.formParameters, function(pi, p) {
if (p.type == "File") {
txt += '<tr><td><input type="file" name="' + p.name + '" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>'
txt += '<tr><td><input type="file" name="' + p.name + '" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>'
+ p.name + ':' + p.description + '</td></tr>';
} else {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
}
});
......@@ -239,7 +239,7 @@ Describe.prototype = {
txt += '<fieldset id="queryParameters"><legend>Query Parameter</legend>';
txt += '<table >';
$.each(m.queryParameters, function(pi, p) {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':' + p.description
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':' + p.description
+ '</td></tr>';
});
txt += '</table>';
......@@ -250,10 +250,10 @@ Describe.prototype = {
txt += '<table>';
$.each(m.ins, function(ii, i) {
if (i.isCollection) {
txt += '<tr><td><textarea id="' + i.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + i.name + ':' + i.description
txt += '<tr><td><textarea id="' + i.name + '" style="width:600px; padding:1px; "/></td><td>' + i.name + ':' + i.description
'</td></tr>';
} else {
txt += '<tr><td><input type="text" id="' + i.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + i.name + ':'
txt += '<tr><td><input type="text" id="' + i.name + '" style="width:600px; padding:1px; "/></td><td>' + i.name + ':'
+ i.description
'</td></tr>';
}
......@@ -264,7 +264,7 @@ Describe.prototype = {
if (m.useJsonElementParameter) {
txt += '<fieldset><legend>JsonElement</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="jsonElement" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '<textarea id="jsonElement" style="height:300px; width:600px; padding:1px; "/>';
txt += '</td><td>json</td></tr>';
txt += '</table>';
txt += '</fieldset>';
......@@ -272,7 +272,7 @@ Describe.prototype = {
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; "/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
......@@ -308,6 +308,7 @@ Describe.prototype = {
if (m.contentType.indexOf('application/json') > -1) {
switch (m.type) {
case 'POST':
debugger;
var data = {};
if (m.ins && m.ins.length > 0) {
$.each(m.ins, function(ii, i) {
......@@ -320,11 +321,21 @@ Describe.prototype = {
data[i.name] = $('#' + i.name, '#ins').val();
}
} else {
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
if (i.isCollection) {
data[i.name] = Describe.splitValue($('#' + i.name, '#ins').val());
} else {
if( $('#' + i.name, '#ins').val() == null || typeof($('#' + i.name, '#ins').val()) == "undefind" || $('#' + i.name, '#ins').val() == "" ){
$('#' + i.name, '#ins').val("{}");
}
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
}
}
}
});
} else if (m.useJsonElementParameter) {
if( $('#jsonElement').val() == null || typeof($('#jsonElement').val()) == "undefind" || $('#jsonElement').val() == "" ){
$('#jsonElement').val("{}");
}
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
......@@ -344,11 +355,21 @@ Describe.prototype = {
data[i.name] = $('#' + i.name, '#ins').val();
}
} else {
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
if (i.isCollection) {
data[i.name] = Describe.splitValue($('#' + i.name, '#ins').val());
} else {
if( $('#' + i.name, '#ins').val() == null || typeof($('#' + i.name, '#ins').val()) == "undefind" || $('#' + i.name, '#ins').val() == "" ){
$('#' + i.name, '#ins').val("{}");
}
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
}
}
}
});
} else if (m.useJsonElementParameter) {
if( $('#jsonElement').val() == null || typeof($('#jsonElement').val()) == "undefind" || $('#jsonElement').val() == "" ){
$('#jsonElement').val("{}");
}
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
......
......@@ -5,6 +5,68 @@
<meta http-equiv="pragma" content="no-cache" />
<script src="./jquery.min.js"></script>
<script src="./clipboard.min.js"></script>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
background:#fff;
text-align:left;
}
a {
color:#1E7ACE;
text-decoration:none;
}
a:hover {
color:#000;
text-decoration:underline;
}
h3 {
font-size:14px;
font-weight:bold;
}
pre,p {
color:#1E7ACE;
margin:4px;
}
input, select,textarea {
padding:1px;
margin:2px;
font-size:11px;
}
fieldset {
padding:10px;
margin-top:10px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset legend {
color:#1E7ACE;
font-weight:bold;
padding:3px 20px 3px 20px;
border:1px solid #A4CDF2;
background:#fff;
}
input {
border:1px solid #A4CDF2;
}
button {
border:1px solid #A4CDF2;
background-color : #FFFFFF;
height:25px;
margin-top:10px;
font-weight:bold;
color:#1E7ACE;
}
-->
</style>
<script>
$.getScript('./describe.js?rd=' + Math.random()).then(function() {
var describe = new Describe();
......@@ -14,7 +76,7 @@
});
$(document).ready(function(){
var clipboard = new Clipboard("#btn");
var clipboard = new Clipboard("#btn_copy");
});
</script>
</head>
......@@ -24,19 +86,19 @@
<tr>
<td style="width: 350px;" valign="top">
<fieldset>
<legend>Menu</legend>
<legend>API Menu</legend>
<div id="menu" style="height: 850px; overflow: auto">&nbsp;</div>
</fieldset>
</td>
<td valign="top">
<fieldset>
<legend>Content</legend>
<legend>API Content</legend>
<div id="content"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word">&nbsp;</div>
</fieldset>
<fieldset>
<legend>
Result&nbsp;<a href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
Result&nbsp;<a id="btn_copy" href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
</legend>
<div id="result"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; width: 1400px">&nbsp;</div>
......
jQuery.extend({
createUploadIframe: function(id, uri)
{
//create frame
var frameId = 'jUploadFrame' + id;
var iframeHtml = '<iframe id="' + frameId + '" name="' + frameId + '" style="position:absolute; top:-9999px; left:-9999px"';
if(window.ActiveXObject)
{
if(typeof uri== 'boolean'){
iframeHtml += ' src="' + 'javascript:false' + '"';
}
else if(typeof uri== 'string'){
iframeHtml += ' src="' + uri + '"';
}
}
iframeHtml += ' />';
jQuery(iframeHtml).appendTo(document.body);
return jQuery('#' + frameId).get(0);
},
createUploadForm: function(id, fileElementId)
{
//create form
var formId = 'jUploadForm' + id;
var fileId = 'jUploadFile' + id;
var form = jQuery('<form action="" method="POST" name="' + formId + '" id="' + formId + '" enctype="multipart/form-data"></form>');
var oldElement = jQuery('#' + fileElementId);
var newElement = jQuery(oldElement).clone();
jQuery(oldElement).attr('id', fileId);
jQuery(oldElement).before(newElement);
jQuery(oldElement).appendTo(form);
//set attributes
jQuery(form).css('position', 'absolute');
jQuery(form).css('top', '-1200px');
jQuery(form).css('left', '-1200px');
jQuery(form).appendTo('body');
return form;
},
ajaxFileUpload: function(s) {
// TODO introduce global settings, allowing the client to modify them for all requests, not only timeout
s = jQuery.extend({}, jQuery.ajaxSettings, s);
var id = new Date().getTime()
var form = jQuery.createUploadForm(id, s.fileElementId);
var io = jQuery.createUploadIframe(id, s.secureuri);
var frameId = 'jUploadFrame' + id;
var formId = 'jUploadForm' + id;
// Watch for a new set of requests
if ( s.global && ! jQuery.active++ )
{
jQuery.event.trigger( "ajaxStart" );
}
var requestDone = false;
// Create the request object
var xml = {}
if ( s.global )
jQuery.event.trigger("ajaxSend", [xml, s]);
// Wait for a response to come back
var uploadCallback = function(isTimeout)
{
var io = document.getElementById(frameId);
try
{
if(io.contentWindow)
{
xml.responseText = io.contentWindow.document.body?io.contentWindow.document.body.innerHTML:null;
xml.responseXML = io.contentWindow.document.XMLDocument?io.contentWindow.document.XMLDocument:io.contentWindow.document;
}else if(io.contentDocument)
{
xml.responseText = io.contentDocument.document.body?io.contentDocument.document.body.innerHTML:null;
xml.responseXML = io.contentDocument.document.XMLDocument?io.contentDocument.document.XMLDocument:io.contentDocument.document;
}
}catch(e)
{
jQuery.handleError(s, xml, null, e);
}
if ( xml || isTimeout == "timeout")
{
requestDone = true;
var status;
try {
status = isTimeout != "timeout" ? "success" : "error";
// Make sure that the request was successful or notmodified
if ( status != "error" )
{
// process the data (runs the xml through httpData regardless of callback)
var data = jQuery.uploadHttpData( xml, s.dataType );
// If a local callback was specified, fire it and pass it the data
if ( s.success )
s.success( data, status );
// Fire the global callback
if( s.global )
jQuery.event.trigger( "ajaxSuccess", [xml, s] );
} else
jQuery.handleError(s, xml, status);
} catch(e)
{
status = "error";
jQuery.handleError(s, xml, status, e);
}
// The request was completed
if( s.global )
jQuery.event.trigger( "ajaxComplete", [xml, s] );
// Handle the global AJAX counter
if ( s.global && ! --jQuery.active )
jQuery.event.trigger( "ajaxStop" );
// Process result
if ( s.complete )
s.complete(xml, status);
jQuery(io).unbind()
setTimeout(function()
{ try
{
jQuery(io).remove();
jQuery(form).remove();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
}, 100)
xml = null
}
}
// Timeout checker
if ( s.timeout > 0 )
{
setTimeout(function(){
// Check to see if the request is still happening
if( !requestDone ) uploadCallback( "timeout" );
}, s.timeout);
}
try
{
var form = jQuery('#' + formId);
jQuery(form).attr('action', s.url);
jQuery(form).attr('method', 'POST');
jQuery(form).attr('target', frameId);
if(form.encoding)
{
jQuery(form).attr('encoding', 'multipart/form-data');
}
else
{
jQuery(form).attr('enctype', 'multipart/form-data');
}
jQuery(form).submit();
} catch(e)
{
jQuery.handleError(s, xml, null, e);
}
jQuery('#' + frameId).load(uploadCallback );
return {abort: function () {}};
},
uploadHttpData: function( r, type ) {
var data = !type;
data = type == "xml" || data ? r.responseXML : r.responseText;
// If the type is "script", eval it in global context
if ( type == "script" )
jQuery.globalEval( data );
// Get the JavaScript object, if JSON is used.
if ( type == "json" )
eval( "data = " + data );
// evaluate scripts within html
if ( type == "html" )
jQuery("<div>").html(data).evalScripts();
return data;
}
})
function failure(data) {
console.log(data);
alert(data.message);
}
function splitValue(str) {
if (str) {
if (str.length > 0) {
return str.split(',');
}
}
return [];
}
function joinValue(o, split) {
var s = ',';
if (split) {
s = '' + split;
}
if (o) {
if (toString.apply(o) === '[object Array]') {
return o.join(s);
}
}
return o;
}
function send_get_request( url ){
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function send_post_request( url ){
var content = $('#content').val();
if( content == null || content == undefined || content == "" ){
alert("请输入content");
return false;
}
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON( content )),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function send_put_request( url ){
var content = $('#content').val();
if( content == null || content == undefined || content == "" ){
alert("请输入content");
return false;
}
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON( content )),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function send_delete_request( url, id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url + '/' + id ,
xhrFields : { 'withCredentials' : true },
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify( json.data, null, 4 ));
});
}
function send_delete_request_as_url( url ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url + '/' ,
xhrFields : { 'withCredentials' : true },
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify( json.data, null, 4 ));
});
}
\ No newline at end of file
{
"id":"b74ca04a-be1f-4dc2-af3d-c68fa1d16cf3",
"title": "中国电信2016年度重点工作部署",
"deployYear": "2016",
"deployMonth": "05",
"deployerName": "蔡艳红",
"auditLeaderName": "胡起",
"creatorName": "蔡艳红",
"defaultWorkType": "政策改革",
"defaultWorkLevel": "公司重点工作",
"defaultLeader": "周睿",
"isNeedAudit": true
}
\ No newline at end of file
logger_parameter = {};
function logger_init() {
$('#result').html('');
$('#content').html('');
var str = '<table border="1" width="100%">';
str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp<a href="#" id="trace">trace</a>&nbsp;<a href="#" id="debug">debug</a>&nbsp;<a href="#" id="info">info</a>&nbsp;<a href="#" id="warn">warn</a></td></tr>';
str += '<tr><td>debug:</td><td id="level">&nbsp;</td></tr>';
str += '</table>';
$('#content').html(str);
$('#get').click(function() {
logger_get();
});
$('#trace').click(function() {
logger_trace();
});
$('#debug').click(function() {
logger_debug();
});
$('#info').click(function() {
logger_info();
});
$('#warn').click(function() {
logger_warn();
});
}
function logger_get() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#level').html(json.data.value);
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_trace() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/trace',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_debug() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/debug',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_info() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/info',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_warn() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/warn',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
\ No newline at end of file
......@@ -3,6 +3,7 @@ package com.x.calendar.assemble.control.factory;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.message.MessageConnector;
import com.x.base.core.project.tools.ListTools;
import com.x.calendar.core.entity.Calendar_Event;
import com.x.calendar.core.tools.LogUtil;
......@@ -10,7 +11,12 @@ public class MessageFactory {
public static void send_alarm( EntityManagerContainer emc, Calendar_Event event ) throws Exception {
LogUtil.INFO( "send calendar alarm message", event.getTitle() + ", StartTime: " + event.getStartTimeStr() );
MessageConnector.send( MessageConnector.TYPE_CALENDAR_ALARM, event.getValarm_Summary(), event.getCreatePerson(), event );
if( ListTools.isNotEmpty( event.getParticipants() )) {
for( String participant : event.getParticipants() ) {
MessageConnector.send( MessageConnector.TYPE_CALENDAR_ALARM, event.getValarm_Summary(), participant, event );
}
}
event = emc.find( event.getId(), Calendar_Event.class );
emc.beginTransaction( Calendar_Event.class );
event.setAlarmAlready( true );
......
......@@ -34,7 +34,7 @@ public class ActionDestroyAfterEventId extends BaseAction {
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id ) throws Exception {
LogUtil.INFO( ">>>>>>ActionDestroyAfterEventId.execute......" );
//LogUtil.INFO( ">>>>>>ActionDestroyAfterEventId.execute......" );
ActionResult<Wo> result = new ActionResult<>();
Integer count = 0;
Wo wo = new Wo();
......
......@@ -21,7 +21,7 @@ public class ActionDestroySingleEventWithId extends BaseAction {
private Logger logger = LoggerFactory.getLogger( ActionDestroySingleEventWithId.class );
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String id ) throws Exception {
LogUtil.INFO( ">>>>>>ActionDestroySingleEventWithId.execute......" );
//LogUtil.INFO( ">>>>>>ActionDestroySingleEventWithId.execute......" );
ActionResult<Wo> result = new ActionResult<>();
Calendar calendar = null;
Calendar_Event calendar_event = null;
......
......@@ -21,7 +21,7 @@ public class ActionDestroyWithMaster extends BaseAction {
private Logger logger = LoggerFactory.getLogger( ActionDestroyWithMaster.class );
protected ActionResult<Wo> execute( HttpServletRequest request, EffectivePerson effectivePerson, String eventId ) throws Exception {
LogUtil.INFO( ">>>>>>ActionDestroyWithMaster.execute......" );
//LogUtil.INFO( ">>>>>>ActionDestroyWithMaster.execute......" );
ActionResult<Wo> result = new ActionResult<>();
Calendar calendar = null;
Calendar_Event calendar_event = null;
......
......@@ -75,8 +75,7 @@ public class Calendar_EventService {
* @return
* @throws Exception
*/
public Calendar_Event create( EntityManagerContainer emc,
Calendar_Event calendar_record,
public Calendar_Event create( EntityManagerContainer emc, Calendar_Event calendar_record,
Boolean autoTransaction ) throws Exception {
if( autoTransaction == null ) {
autoTransaction = true;
......@@ -89,7 +88,7 @@ public class Calendar_EventService {
if( autoTransaction ) {
emc.beginTransaction( Calendar_Event.class );
}
emc.persist( calendar_record, CheckPersistType.all);
emc.persist( calendar_record, CheckPersistType.all);
if( autoTransaction ) {
emc.commit();
}
......@@ -195,8 +194,6 @@ public class Calendar_EventService {
calendarEvents = eventRepeatMaster.getRecurringDatesInPeriod( startTime, endTime );
}
if( ListTools.isNotEmpty( calendarEvents )) {
emc.beginTransaction( Calendar_Event.class );
emc.beginTransaction( Calendar_EventRepeatMaster.class );
for( Calendar_Event calendar_Event : calendarEvents ) {
//判断该事件是否已经存在,如果不存在,则进行数据添加
if ( !business.calendar_EventFactory().eventExists( calendar_Event ) ) {
......@@ -228,9 +225,9 @@ public class Calendar_EventService {
}
event_ids.add( calendar_Event.getId() );
System.out.println(">>>>>>生成新事件开始时间:" + calendar_Event.getStartTime() );
System.out.println(">>>>>>生成新事件结束时间:" + calendar_Event.getEndTime() );
emc.beginTransaction( Calendar_Event.class );
emc.persist( calendar_Event, CheckPersistType.all );
emc.commit();
}
}
......@@ -240,6 +237,7 @@ public class Calendar_EventService {
}
}
emc.beginTransaction( Calendar_EventRepeatMaster.class );
emc.check( eventRepeatMaster, CheckPersistType.all );
emc.commit();
}
......
function failure(data) {
console.log(data);
alert(data.message);
}
function splitValue(str) {
if (str) {
if (str.length > 0) {
return str.split(',');
}
}
return [];
}
function joinValue(o, split) {
var s = ',';
if (split) {
s = '' + split;
}
if (o) {
if (toString.apply(o) === '[object Array]') {
return o.join(s);
}
}
return o;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<script lang="text/javascript">
//GET
function m_get( url ) {
send_get_request( url );
}
//POST
function m_post() {
send_post_request( url );
}
//PUT
function m_post() {
send_put_request( url );
}
//DELETE
function m_delete() {
send_delete_request_as_url( url );
}
/////////////////////////////////////////////////////////////////////////////////////////////////
$(document).ready(function() {
$('#get').click(function() {
send_get_request( $("#url").val() );
});
$('#post').click(function() {
send_post_request( $("#url").val() );
});
$('#put').click(function() {
send_put_request( $("#url").val() );
});
$('#delete').click(function() {
send_delete_request( $("#url").val() );
});
});
</script>
</head>
<body>
<div style="float: left; width: 720px;">
<div style="width: 100%;">
<table border="1" style="width:100%">
<tr>
<td>URL:</td>
<td><input type="text" id="url" style="width:95%" placeholder="../jaxrs/forum/"/></td>
</tr>
<tr>
<td>type:</td>
<td>
通用REST服务调用
</td>
</tr>
<tr>
<td colspan="2">
<button id="get">GET</button>
<button id="post">POST</button>
<button id="put">PUT</button>
<button id="delete">DELETE</button>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="content" style="width:97%;height:300px">{}</textarea>
</td>
</tr>
<tr>
<td colspan="2">
<textarea id="result" style="width:97%;height:400px"></textarea>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
\ No newline at end of file
debug_parameter = {};
function debug_init() {
$('#result').html('');
$('#content').html('');
var str = '<table border="1" width="100%">';
str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp<a href="#" id="on">on</a>&nbsp;<a href="#" id="off">off</a></td></tr>';
str += '<tr><td>debug:</td><td id="status">&nbsp;</td></tr>';
str += '</table>';
$('#content').html(str);
$('#get').click(function() {
debug_get();
});
$('#on').click(function() {
debug_on();
});
$('#off').click(function() {
debug_off();
});
}
function debug_get() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function debug_on() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug/true',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function debug_off() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/debug/false',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#status').html(json.data.value + '');
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
\ No newline at end of file
......@@ -200,20 +200,20 @@ Describe.prototype = {
switch (p.name) {
case 'flag':
case 'id':
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid" value="(0)"/></td><td>' + p.name
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; " value="(0)"/></td><td>' + p.name
+ ':' + p.description + '</td></tr>';
break;
case 'count':
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid" value="20"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; " value="20"/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
break;
default:
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
break
}
} else {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
}
});
......@@ -225,10 +225,10 @@ Describe.prototype = {
txt += '<table >';
$.each(m.formParameters, function(pi, p) {
if (p.type == "File") {
txt += '<tr><td><input type="file" name="' + p.name + '" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>'
txt += '<tr><td><input type="file" name="' + p.name + '" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>'
+ p.name + ':' + p.description + '</td></tr>';
} else {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':'
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':'
+ p.description + '</td></tr>';
}
});
......@@ -239,7 +239,7 @@ Describe.prototype = {
txt += '<fieldset id="queryParameters"><legend>Query Parameter</legend>';
txt += '<table >';
$.each(m.queryParameters, function(pi, p) {
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + p.name + ':' + p.description
txt += '<tr><td><input type="text" id="' + p.name + '" style="width:600px; padding:1px; "/></td><td>' + p.name + ':' + p.description
+ '</td></tr>';
});
txt += '</table>';
......@@ -250,10 +250,10 @@ Describe.prototype = {
txt += '<table>';
$.each(m.ins, function(ii, i) {
if (i.isCollection) {
txt += '<tr><td><textarea id="' + i.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + i.name + ':' + i.description
txt += '<tr><td><textarea id="' + i.name + '" style="width:600px; padding:1px; "/></td><td>' + i.name + ':' + i.description
'</td></tr>';
} else {
txt += '<tr><td><input type="text" id="' + i.name + '" style="width:600px; padding:1px; border:1px #000000 solid"/></td><td>' + i.name + ':'
txt += '<tr><td><input type="text" id="' + i.name + '" style="width:600px; padding:1px; "/></td><td>' + i.name + ':'
+ i.description
'</td></tr>';
}
......@@ -264,7 +264,7 @@ Describe.prototype = {
if (m.useJsonElementParameter) {
txt += '<fieldset><legend>JsonElement</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="jsonElement" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '<textarea id="jsonElement" style="height:300px; width:600px; padding:1px; "/>';
txt += '</td><td>json</td></tr>';
txt += '</table>';
txt += '</fieldset>';
......@@ -272,7 +272,7 @@ Describe.prototype = {
if (m.useStringParameter) {
txt += '<fieldset><legend>String</legend>';
txt += '<table><tr><td>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; border:1px #000000 solid"/>';
txt += '<textarea id="string" style="height:300px; width:600px; padding:1px; "/>';
txt += '</td><td>string</td></tr>';
txt += '</table>';
txt += '</fieldset>';
......@@ -308,6 +308,7 @@ Describe.prototype = {
if (m.contentType.indexOf('application/json') > -1) {
switch (m.type) {
case 'POST':
debugger;
var data = {};
if (m.ins && m.ins.length > 0) {
$.each(m.ins, function(ii, i) {
......@@ -320,11 +321,21 @@ Describe.prototype = {
data[i.name] = $('#' + i.name, '#ins').val();
}
} else {
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
if (i.isCollection) {
data[i.name] = Describe.splitValue($('#' + i.name, '#ins').val());
} else {
if( $('#' + i.name, '#ins').val() == null || typeof($('#' + i.name, '#ins').val()) == "undefind" || $('#' + i.name, '#ins').val() == "" ){
$('#' + i.name, '#ins').val("{}");
}
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
}
}
}
});
} else if (m.useJsonElementParameter) {
if( $('#jsonElement').val() == null || typeof($('#jsonElement').val()) == "undefind" || $('#jsonElement').val() == "" ){
$('#jsonElement').val("{}");
}
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
......@@ -344,11 +355,21 @@ Describe.prototype = {
data[i.name] = $('#' + i.name, '#ins').val();
}
} else {
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
if (i.isCollection) {
data[i.name] = Describe.splitValue($('#' + i.name, '#ins').val());
} else {
if( $('#' + i.name, '#ins').val() == null || typeof($('#' + i.name, '#ins').val()) == "undefind" || $('#' + i.name, '#ins').val() == "" ){
$('#' + i.name, '#ins').val("{}");
}
data[i.name] = $.parseJSON($('#' + i.name, '#ins').val());
}
}
}
});
} else if (m.useJsonElementParameter) {
if( $('#jsonElement').val() == null || typeof($('#jsonElement').val()) == "undefind" || $('#jsonElement').val() == "" ){
$('#jsonElement').val("{}");
}
data = $.parseJSON($('#jsonElement').val());
} else if (m.useStringParameter) {
data = $('#string').val();
......
......@@ -5,6 +5,68 @@
<meta http-equiv="pragma" content="no-cache" />
<script src="./jquery.min.js"></script>
<script src="./clipboard.min.js"></script>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size:12px;
color:#666666;
background:#fff;
text-align:left;
}
a {
color:#1E7ACE;
text-decoration:none;
}
a:hover {
color:#000;
text-decoration:underline;
}
h3 {
font-size:14px;
font-weight:bold;
}
pre,p {
color:#1E7ACE;
margin:4px;
}
input, select,textarea {
padding:1px;
margin:2px;
font-size:11px;
}
fieldset {
padding:10px;
margin-top:10px;
border:1px solid #A4CDF2;
background:#fff;
}
fieldset legend {
color:#1E7ACE;
font-weight:bold;
padding:3px 20px 3px 20px;
border:1px solid #A4CDF2;
background:#fff;
}
input {
border:1px solid #A4CDF2;
}
button {
border:1px solid #A4CDF2;
background-color : #FFFFFF;
height:25px;
margin-top:10px;
font-weight:bold;
color:#1E7ACE;
}
-->
</style>
<script>
$.getScript('./describe.js?rd=' + Math.random()).then(function() {
var describe = new Describe();
......@@ -14,7 +76,7 @@
});
$(document).ready(function(){
var clipboard = new Clipboard("#btn");
var clipboard = new Clipboard("#btn_copy");
});
</script>
</head>
......@@ -24,19 +86,19 @@
<tr>
<td style="width: 350px;" valign="top">
<fieldset>
<legend>Menu</legend>
<legend>API Menu</legend>
<div id="menu" style="height: 850px; overflow: auto">&nbsp;</div>
</fieldset>
</td>
<td valign="top">
<fieldset>
<legend>Content</legend>
<legend>API Content</legend>
<div id="content"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word">&nbsp;</div>
</fieldset>
<fieldset>
<legend>
Result&nbsp;<a href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
Result&nbsp;<a id="btn_copy" href="javascript:" data-clipboard-target="#result">copy</a>&nbsp;
</legend>
<div id="result"
style="white-space: pre; font-size: 12px; word-break: break-all; word-wrap: break-word; width: 1400px">&nbsp;</div>
......
function failure(data) {
console.log(data);
alert(data.message);
}
function splitValue(str) {
if (str) {
if (str.length > 0) {
return str.split(',');
}
}
return [];
}
function joinValue(o, split) {
var s = ',';
if (split) {
s = '' + split;
}
if (o) {
if (toString.apply(o) === '[object Array]') {
return o.join(s);
}
}
return o;
}
function send_get_request( url ){
$.ajax({
type : 'get',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url,
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
$('#result').html( JSON.stringify( json, null, 4) );
}).fail(function(json) {
failure(json);
});
}
function send_post_request( url ){
var content = $('#content').val();
if( content == null || content == undefined || content == "" ){
alert("请输入content");
return false;
}
$.ajax({
type : 'post',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON( content )),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function send_put_request( url ){
var content = $('#content').val();
if( content == null || content == undefined || content == "" ){
alert("请输入content");
return false;
}
$.ajax({
type : 'put',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url ,
xhrFields : {
'withCredentials' : true
},
data : JSON.stringify($.parseJSON( content )),
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify(json.data, null, 4));
});
}
function send_delete_request( url, id ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url + '/' + id ,
xhrFields : { 'withCredentials' : true },
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify( json.data, null, 4 ));
});
}
function send_delete_request_as_url( url ) {
if( id == null || id == undefined || id == "" ){
alert("请输入ID");
return false;
}
$.ajax({
type : 'delete',
dataType : 'json',
contentType : 'application/json; charset=utf-8',
url : url + '/' ,
xhrFields : { 'withCredentials' : true },
crossDomain : true
}).done(function(json) {
$('#result').html(JSON.stringify( json.data, null, 4 ));
});
}
\ No newline at end of file
logger_parameter = {};
function logger_init() {
$('#result').html('');
$('#content').html('');
var str = '<table border="1" width="100%">';
str += '<tr><td colspan="2"><a href="#" id="get">get</a>&nbsp<a href="#" id="trace">trace</a>&nbsp;<a href="#" id="debug">debug</a>&nbsp;<a href="#" id="info">info</a>&nbsp;<a href="#" id="warn">warn</a></td></tr>';
str += '<tr><td>debug:</td><td id="level">&nbsp;</td></tr>';
str += '</table>';
$('#content').html(str);
$('#get').click(function() {
logger_get();
});
$('#trace').click(function() {
logger_trace();
});
$('#debug').click(function() {
logger_debug();
});
$('#info').click(function() {
logger_info();
});
$('#warn').click(function() {
logger_warn();
});
}
function logger_get() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).done(function(json) {
if (json.type == 'success') {
$('#level').html(json.data.value);
}
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_trace() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/trace',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_debug() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/debug',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_info() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/info',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
function logger_warn() {
$.ajax({
type : 'get',
dataType : 'json',
url : '../jaxrs/logger/warn',
contentType : 'application/json; charset=utf-8',
xhrFields : {
'withCredentials' : true
},
crossDomain : true
}).always(function(json) {
$('#result').html(JSON.stringify(json, null, 4));
});
}
\ No newline at end of file
......@@ -45,7 +45,7 @@ public class AppInfoFactory extends AbstractFactory {
CriteriaQuery<String> cq = cb.createQuery(String.class);
Root<AppInfo> root = cq.from(AppInfo.class);
cq.select(root.get(AppInfo_.id));
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
Predicate p = cb.equal(root.get(AppInfo_.documentType), documentType);
return em.createQuery(cq.where(p)).getResultList();
}
......@@ -58,7 +58,7 @@ public class AppInfoFactory extends AbstractFactory {
CriteriaQuery<AppInfo> cq = cb.createQuery(AppInfo.class);
Root<AppInfo> root = cq.from(AppInfo.class);
Predicate p = null;
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = CriteriaBuilderTools.predicate_and(cb, p, cb.equal(root.get(AppInfo_.documentType), documentType) );
}
if (StringUtils.isNotEmpty(appType) &&!StringUtils.equals( "未分类",appType )) {
......@@ -68,7 +68,11 @@ public class AppInfoFactory extends AbstractFactory {
p = CriteriaBuilderTools.predicate_and(cb, p,
CriteriaBuilderTools.predicate_or(
cb, cb.isNull(root.get(AppInfo_.appType)),
cb.equal(root.get(AppInfo_.appType), ""))
CriteriaBuilderTools.predicate_or(
cb, cb.equal(root.get(AppInfo_.appType), ""),
cb.equal(root.get(AppInfo_.appType), "未分类")
)
)
);
}
return em.createQuery(cq.where(p)).getResultList();
......@@ -95,7 +99,7 @@ public class AppInfoFactory extends AbstractFactory {
Root<AppInfo> root = cq.from(AppInfo.class);
cq.select(root.get(AppInfo_.id));
Predicate p = cb.isTrue(root.get(AppInfo_.allPeoplePublish));
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and(p, cb.equal(root.get(AppInfo_.documentType), documentType));
}
return em.createQuery(cq.where(p)).getResultList();
......@@ -116,7 +120,7 @@ public class AppInfoFactory extends AbstractFactory {
cq.select(root.get(AppInfo_.id));
Predicate p = cb.isTrue(root.get(AppInfo_.allPeopleView));
p = cb.or(p, cb.isTrue(root.get(AppInfo_.allPeoplePublish)));
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and(p, cb.equal(root.get(AppInfo_.documentType), documentType));
}
return em.createQuery(cq.where(p)).getResultList();
......@@ -186,7 +190,7 @@ public class AppInfoFactory extends AbstractFactory {
if (ListTools.isNotEmpty(groupNames)) {
p_permission = cb.or(p_permission, root.get(AppInfo_.manageableGroupList).in(groupNames));
}
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p_permission = cb.equal(p_permission, cb.equal(root.get(AppInfo_.documentType), documentType));
}
cq.select(root.get(AppInfo_.id));
......@@ -257,7 +261,7 @@ public class AppInfoFactory extends AbstractFactory {
p = p_permission;
}
}
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and(p, cb.equal(root.get(AppInfo_.documentType), documentType));
}
cq.select(root.get(AppInfo_.id));
......@@ -326,7 +330,7 @@ public class AppInfoFactory extends AbstractFactory {
p = p_permission;
}
}
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and(p, cb.equal(root.get(AppInfo_.documentType), documentType));
}
cq.select(root.get(AppInfo_.id));
......@@ -398,7 +402,7 @@ public class AppInfoFactory extends AbstractFactory {
p = p_permission;
}
}
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and(p, cb.equal(root.get(AppInfo_.documentType), documentType));
}
cq.select(root.get(AppInfo_.id));
......@@ -468,7 +472,7 @@ public class AppInfoFactory extends AbstractFactory {
p = p_permission;
}
}
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType)) {
if (StringUtils.isNotEmpty(documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and(p, cb.equal(root.get(AppInfo_.documentType), documentType));
}
cq.select(root.get(AppInfo_.id));
......@@ -510,6 +514,7 @@ public class AppInfoFactory extends AbstractFactory {
Root<AppInfo> root = cq.from(AppInfo.class);
Predicate p = cb.isNull( root.get(AppInfo_.appType) );
p = cb.or( p, cb.equal( root.get(AppInfo_.appType), ""));
p = cb.or( p, cb.equal( root.get(AppInfo_.appType), "未分类"));
cq.select(cb.count(root));
return em.createQuery(cq.where(p)).getSingleResult();
}
......
......@@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
......@@ -79,33 +80,37 @@ public class CategoryInfoFactory extends AbstractFactory {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<String> cq = cb.createQuery( String.class );
Root<CategoryInfo> root = cq.from( CategoryInfo.class );
cq.select(root.get( CategoryInfo_.id));
cq.select(root.get( CategoryInfo_.id));
TypedQuery<String> query = null;
if( manager ) {
if( ListTools.isEmpty( appIds )) {
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType )) {
Predicate p = cb.equal( root.get( CategoryInfo_.documentType ), documentType );
return em.createQuery( cq.where( p ) ).setMaxResults(maxCount).getResultList();
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
Predicate p = cb.equal( root.get( CategoryInfo_.documentType ), documentType );
query = em.createQuery( cq.where( p ) ).setMaxResults(maxCount);
}else {
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
query = em.createQuery( cq ).setMaxResults(maxCount);
}
}else {
Predicate p = root.get( CategoryInfo_.appId ).in(appIds);
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType ) ) {
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType) ) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType ), documentType ));
}
return em.createQuery( cq.where(p) ).setMaxResults(maxCount).getResultList();
query = em.createQuery( cq.where(p) ).setMaxResults(maxCount);
}
}else {
if( ListTools.isEmpty( appIds )) {
return new ArrayList<>();
}else {
Predicate p = root.get( CategoryInfo_.appId ).in(appIds);
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType )) {
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType ), documentType ));
}
return em.createQuery( cq.where(p) ).setMaxResults(maxCount).getResultList();
query = em.createQuery( cq.where(p) ).setMaxResults(maxCount);
}
}
//System.out.println(">>>>>>>>>>>listByAppIds SQL:" +query.toString() );
return query.getResultList();
}
public List<CategoryInfo> listCategoryByAppId( String appId, String documentType, Integer maxCount ) throws Exception {
......@@ -114,7 +119,7 @@ public class CategoryInfoFactory extends AbstractFactory {
CriteriaQuery<CategoryInfo> cq = cb.createQuery( CategoryInfo.class );
Root<CategoryInfo> root = cq.from( CategoryInfo.class );
Predicate p = cb.equal(root.get( CategoryInfo_.appId ), appId );
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType )) {
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType ), documentType ));
}
return em.createQuery( cq.where(p) ).setMaxResults(maxCount).getResultList();
......@@ -127,7 +132,7 @@ public class CategoryInfoFactory extends AbstractFactory {
CriteriaQuery<Long> cq = cb.createQuery(Long.class);
Root<CategoryInfo> root = cq.from(CategoryInfo.class);
Predicate p = cb.equal( root.get(CategoryInfo_.appId), appId );
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType )) {
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType ), documentType ));
}
cq.select(cb.count(root));
......@@ -156,15 +161,13 @@ public class CategoryInfoFactory extends AbstractFactory {
Root<CategoryInfo> root = cq.from( CategoryInfo.class);
Predicate p = cb.like(root.get( CategoryInfo_.categoryName ), "%" + str + "%", '\\');
p = cb.or(p, cb.like(root.get( CategoryInfo_.categoryAlias ), str + "%", '\\'));
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType )) {
if( StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType ), documentType ));
}
cq.select(root.get( CategoryInfo_.id));
return em.createQuery(cq.where(p)).setMaxResults(200).getResultList();
}
public List<String> listMyCategoryWithAppId( List<String> myCategoryIds, String documentType, String appId ) throws Exception {
EntityManager em = this.entityManagerContainer().get( CategoryInfo.class );
CriteriaBuilder cb = em.getCriteriaBuilder();
......@@ -175,7 +178,7 @@ public class CategoryInfoFactory extends AbstractFactory {
if( myCategoryIds != null && !myCategoryIds.isEmpty() ){
p = cb.and( p, root.get( CategoryInfo_.id ).in( myCategoryIds ) );
}
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType), documentType));
}
return em.createQuery(cq.where( p )).getResultList();
......@@ -239,7 +242,7 @@ public class CategoryInfoFactory extends AbstractFactory {
}else {
p_filter = cb.and( p_filter, root.get( CategoryInfo_.id ).in( inCategoryIds ));
}
}
}
//排除指定的ID列表
if( ListTools.isNotEmpty( excludCategoryIds )) {
if( p_filter == null ) {
......@@ -247,8 +250,7 @@ public class CategoryInfoFactory extends AbstractFactory {
}else {
p_filter = cb.and( p_filter, cb.not( root.get( CategoryInfo_.id ).in( excludCategoryIds )));
}
}
}
Predicate p_permission = null;
if( StringUtils.isNotEmpty( personName )) {
//可以管理的栏目,肯定可以发布信息
......@@ -283,7 +285,7 @@ public class CategoryInfoFactory extends AbstractFactory {
p = p_permission;
}
}
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType), documentType));
}
cq.select(root.get( CategoryInfo_.id ));
......@@ -371,7 +373,7 @@ public class CategoryInfoFactory extends AbstractFactory {
p = p_permission;
}
}
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType), documentType));
}
cq.select(root.get( CategoryInfo_.id ));
......@@ -403,7 +405,7 @@ public class CategoryInfoFactory extends AbstractFactory {
if( ListTools.isNotEmpty( excludCategoryIds )) {
p = cb.and( p, cb.not( root.get( CategoryInfo_.id ).in( excludCategoryIds )));
}
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType), documentType));
}
return em.createQuery(cq.where( p )).setMaxResults(maxCount).getResultList();
......@@ -439,7 +441,7 @@ public class CategoryInfoFactory extends AbstractFactory {
p = cb.and( p, cb.not( root.get( CategoryInfo_.id ).in( excludCategoryIds )));
}
p = cb.and( p, p_all );
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType), documentType));
}
return em.createQuery(cq.where( p )).setMaxResults(maxCount).getResultList();
......@@ -472,7 +474,7 @@ public class CategoryInfoFactory extends AbstractFactory {
p = cb.or( p, root.get( CategoryInfo_.manageableGroupList).in(groupNames));
}
cq.select(root.get( CategoryInfo_.id ));
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType) && !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( CategoryInfo_.documentType), documentType));
}
return em.createQuery( cq.where( p ) ).setMaxResults(maxCount).getResultList();
......
......@@ -64,7 +64,7 @@ public class DocumentFactory extends AbstractFactory {
Root<Document> root = cq.from( Document.class );
Predicate p = cb.equal(root.get( Document_.appId ), appId );
cq.select( root.get( Document_.id) ).where(p);
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)) {
if( StringUtils.isNotEmpty( documentType) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( Document_.documentType), documentType));
}
return em.createQuery( cq ).setMaxResults(maxCount).getResultList();
......@@ -332,7 +332,7 @@ public class DocumentFactory extends AbstractFactory {
if(ListTools.isNotEmpty( categoryIdList )) {
p = cb.and( p, root.get( Document_.categoryId ).in( categoryIdList ));
}
if(StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)) {
if(StringUtils.isNotEmpty( documentType ) && !"全部".equals(documentType)&& !"all".equalsIgnoreCase(documentType)) {
p = cb.and( p, cb.equal( root.get( Document_.documentType ), documentType));
}
return em.createQuery(cq.where(p)).getResultList();
......
......@@ -46,7 +46,7 @@ public class ActionGetPublishableAppInfo extends BaseAction {
if (check) {
if ( isXAdmin ) { // 如果用户管理系统管理,则获取所有的栏目和分类信息
try {
wos = listPublishAbleAppInfoByPermission( personName, isAnonymous, null, "全部", isXAdmin, 1000 );
wos = listPublishAbleAppInfoByPermission( personName, isAnonymous, null, "all", "全部", isXAdmin, 1000 );
} catch (Exception e) {
check = false;
Exception exception = new ExceptionAppInfoProcess(e,
......@@ -56,7 +56,7 @@ public class ActionGetPublishableAppInfo extends BaseAction {
}
} else {
try {
wos_out = listPublishAbleAppInfoByPermission( personName, isAnonymous, null, "全部", isXAdmin, 1000 );
wos_out = listPublishAbleAppInfoByPermission( personName, isAnonymous, null, "all", "全部", isXAdmin, 1000 );
for( Wo wo : wos_out ) {
if( ListTools.isNotEmpty( wo.getWrapOutCategoryList() )) {
wos.add( wo );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册