From d621854a4c0db29ada05b4189a5071307b716464 Mon Sep 17 00:00:00 2001 From: 10295 <1029559041@qq.com> Date: Mon, 4 Jun 2018 01:28:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E5=B9=95=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/pom.xml | 14 + core/src/main/java/core/thrift/QryResult.java | 496 --- core/src/main/java/core/thrift/QueryImp.java | 18 - core/src/main/java/core/thrift/TestQry.java | 971 ------ .../java/core/thrift/ThriftClientDemo.java | 53 +- .../java/core/thrift/ThriftServerDemo.java | 3 +- .../core/thrift/comment/QueryComment.java | 2996 +++++++++++++++++ core/src/main/resources/TestQry.thrift | 23 - db/src/main/java/db/form/PageResult.java | 4 + .../java/web/controller/BaseController.java | 38 +- .../java/web/controller/DataController.java | 68 +- .../java/web/controller/TableController.java | 33 +- web/src/main/java/web/html/OtherResult.java | 5 + web/src/main/java/web/html/Table.java | 69 + web/src/main/java/web/html/TableResult.java | 29 + .../main/java/web/html/data/DataTable.java | 62 + .../java/web/html/data/OtherDataResult.java | 7 + .../main/java/web/model/DataModelForm.java | 24 +- .../webapp/WEB-INF/jsp/{ => data}/form.jsp | 21 +- .../webapp/WEB-INF/jsp/data/otherData.jsp | 56 + web/src/main/webapp/WEB-INF/jsp/table.jsp | 96 +- web/src/main/webapp/WEB-INF/jsp/test.jsp | 2 +- web/src/test/java/SpringTest.java | 7 +- 23 files changed, 3514 insertions(+), 1581 deletions(-) delete mode 100644 core/src/main/java/core/thrift/QryResult.java delete mode 100644 core/src/main/java/core/thrift/QueryImp.java delete mode 100644 core/src/main/java/core/thrift/TestQry.java create mode 100644 core/src/main/java/core/thrift/comment/QueryComment.java delete mode 100644 core/src/main/resources/TestQry.thrift create mode 100644 web/src/main/java/web/html/OtherResult.java create mode 100644 web/src/main/java/web/html/Table.java create mode 100644 web/src/main/java/web/html/TableResult.java create mode 100644 web/src/main/java/web/html/data/DataTable.java create mode 100644 web/src/main/java/web/html/data/OtherDataResult.java rename web/src/main/webapp/WEB-INF/jsp/{ => data}/form.jsp (83%) create mode 100644 web/src/main/webapp/WEB-INF/jsp/data/otherData.jsp diff --git a/core/pom.xml b/core/pom.xml index 0be9455..bcb98ac 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -38,6 +38,20 @@ fastjson + + org.apache.logging.log4j + log4j-api + + + + org.apache.logging.log4j + log4j-core + + + + org.apache.logging.log4j + log4j-web + org.apache.thrift diff --git a/core/src/main/java/core/thrift/QryResult.java b/core/src/main/java/core/thrift/QryResult.java deleted file mode 100644 index fffed76..0000000 --- a/core/src/main/java/core/thrift/QryResult.java +++ /dev/null @@ -1,496 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.11.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package core.thrift; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-04-28") -public class QryResult implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("QryResult"); - - private static final org.apache.thrift.protocol.TField CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("code", org.apache.thrift.protocol.TType.I32, (short)1); - private static final org.apache.thrift.protocol.TField MSG_FIELD_DESC = new org.apache.thrift.protocol.TField("msg", org.apache.thrift.protocol.TType.STRING, (short)2); - - private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new QryResultStandardSchemeFactory(); - private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new QryResultTupleSchemeFactory(); - - /** - * 返回码, 1成功,0失败 - */ - public int code; // required - /** - * 响应信息 - */ - public java.lang.String msg; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - /** - * 返回码, 1成功,0失败 - */ - CODE((short)1, "code"), - /** - * 响应信息 - */ - MSG((short)2, "msg"); - - private static final java.util.Map byName = new java.util.HashMap(); - - static { - for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // CODE - return CODE; - case 2: // MSG - return MSG; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(java.lang.String name) { - return byName.get(name); - } - - private final short _thriftId; - private final java.lang.String _fieldName; - - _Fields(short thriftId, java.lang.String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public java.lang.String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __CODE_ISSET_ID = 0; - private byte __isset_bitfield = 0; - public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.CODE, new org.apache.thrift.meta_data.FieldMetaData("code", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - tmpMap.put(_Fields.MSG, new org.apache.thrift.meta_data.FieldMetaData("msg", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); - metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(QryResult.class, metaDataMap); - } - - public QryResult() { - } - - public QryResult( - int code, - java.lang.String msg) - { - this(); - this.code = code; - setCodeIsSet(true); - this.msg = msg; - } - - /** - * Performs a deep copy on other. - */ - public QryResult(QryResult other) { - __isset_bitfield = other.__isset_bitfield; - this.code = other.code; - if (other.isSetMsg()) { - this.msg = other.msg; - } - } - - public QryResult deepCopy() { - return new QryResult(this); - } - - @Override - public void clear() { - setCodeIsSet(false); - this.code = 0; - this.msg = null; - } - - /** - * 返回码, 1成功,0失败 - */ - public int getCode() { - return this.code; - } - - /** - * 返回码, 1成功,0失败 - */ - public QryResult setCode(int code) { - this.code = code; - setCodeIsSet(true); - return this; - } - - public void unsetCode() { - __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CODE_ISSET_ID); - } - - /** Returns true if field code is set (has been assigned a value) and false otherwise */ - public boolean isSetCode() { - return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CODE_ISSET_ID); - } - - public void setCodeIsSet(boolean value) { - __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CODE_ISSET_ID, value); - } - - /** - * 响应信息 - */ - public java.lang.String getMsg() { - return this.msg; - } - - /** - * 响应信息 - */ - public QryResult setMsg(java.lang.String msg) { - this.msg = msg; - return this; - } - - public void unsetMsg() { - this.msg = null; - } - - /** Returns true if field msg is set (has been assigned a value) and false otherwise */ - public boolean isSetMsg() { - return this.msg != null; - } - - public void setMsgIsSet(boolean value) { - if (!value) { - this.msg = null; - } - } - - public void setFieldValue(_Fields field, java.lang.Object value) { - switch (field) { - case CODE: - if (value == null) { - unsetCode(); - } else { - setCode((java.lang.Integer)value); - } - break; - - case MSG: - if (value == null) { - unsetMsg(); - } else { - setMsg((java.lang.String)value); - } - break; - - } - } - - public java.lang.Object getFieldValue(_Fields field) { - switch (field) { - case CODE: - return getCode(); - - case MSG: - return getMsg(); - - } - throw new java.lang.IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new java.lang.IllegalArgumentException(); - } - - switch (field) { - case CODE: - return isSetCode(); - case MSG: - return isSetMsg(); - } - throw new java.lang.IllegalStateException(); - } - - @Override - public boolean equals(java.lang.Object that) { - if (that == null) - return false; - if (that instanceof QryResult) - return this.equals((QryResult)that); - return false; - } - - public boolean equals(QryResult that) { - if (that == null) - return false; - if (this == that) - return true; - - boolean this_present_code = true; - boolean that_present_code = true; - if (this_present_code || that_present_code) { - if (!(this_present_code && that_present_code)) - return false; - if (this.code != that.code) - return false; - } - - boolean this_present_msg = true && this.isSetMsg(); - boolean that_present_msg = true && that.isSetMsg(); - if (this_present_msg || that_present_msg) { - if (!(this_present_msg && that_present_msg)) - return false; - if (!this.msg.equals(that.msg)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - int hashCode = 1; - - hashCode = hashCode * 8191 + code; - - hashCode = hashCode * 8191 + ((isSetMsg()) ? 131071 : 524287); - if (isSetMsg()) - hashCode = hashCode * 8191 + msg.hashCode(); - - return hashCode; - } - - @Override - public int compareTo(QryResult other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = java.lang.Boolean.valueOf(isSetCode()).compareTo(other.isSetCode()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetCode()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.code, other.code); - if (lastComparison != 0) { - return lastComparison; - } - } - lastComparison = java.lang.Boolean.valueOf(isSetMsg()).compareTo(other.isSetMsg()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetMsg()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.msg, other.msg); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - scheme(iprot).read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - scheme(oprot).write(oprot, this); - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder sb = new java.lang.StringBuilder("QryResult("); - boolean first = true; - - sb.append("code:"); - sb.append(this.code); - first = false; - if (!first) sb.append(", "); - sb.append("msg:"); - if (this.msg == null) { - sb.append("null"); - } else { - sb.append(this.msg); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class QryResultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { - public QryResultStandardScheme getScheme() { - return new QryResultStandardScheme(); - } - } - - private static class QryResultStandardScheme extends org.apache.thrift.scheme.StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, QryResult struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // CODE - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.code = iprot.readI32(); - struct.setCodeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - case 2: // MSG - if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { - struct.msg = iprot.readString(); - struct.setMsgIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, QryResult struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(CODE_FIELD_DESC); - oprot.writeI32(struct.code); - oprot.writeFieldEnd(); - if (struct.msg != null) { - oprot.writeFieldBegin(MSG_FIELD_DESC); - oprot.writeString(struct.msg); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class QryResultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { - public QryResultTupleScheme getScheme() { - return new QryResultTupleScheme(); - } - } - - private static class QryResultTupleScheme extends org.apache.thrift.scheme.TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, QryResult struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet optionals = new java.util.BitSet(); - if (struct.isSetCode()) { - optionals.set(0); - } - if (struct.isSetMsg()) { - optionals.set(1); - } - oprot.writeBitSet(optionals, 2); - if (struct.isSetCode()) { - oprot.writeI32(struct.code); - } - if (struct.isSetMsg()) { - oprot.writeString(struct.msg); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, QryResult struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(2); - if (incoming.get(0)) { - struct.code = iprot.readI32(); - struct.setCodeIsSet(true); - } - if (incoming.get(1)) { - struct.msg = iprot.readString(); - struct.setMsgIsSet(true); - } - } - } - - private static S scheme(org.apache.thrift.protocol.TProtocol proto) { - return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); - } -} - diff --git a/core/src/main/java/core/thrift/QueryImp.java b/core/src/main/java/core/thrift/QueryImp.java deleted file mode 100644 index d8a22f5..0000000 --- a/core/src/main/java/core/thrift/QueryImp.java +++ /dev/null @@ -1,18 +0,0 @@ -package core.thrift; - -import org.apache.thrift.TException; - -public class QueryImp implements TestQry.Iface { - @Override - public QryResult qryTest(int qryCode) throws TException { - QryResult result = new QryResult(); - if(qryCode==1){ - result.code = 1; - result.msg = "success"; - }else{ - result.code = 0; - result.msg = "fail"; - } - return result; - } -} diff --git a/core/src/main/java/core/thrift/TestQry.java b/core/src/main/java/core/thrift/TestQry.java deleted file mode 100644 index c5d2402..0000000 --- a/core/src/main/java/core/thrift/TestQry.java +++ /dev/null @@ -1,971 +0,0 @@ -/** - * Autogenerated by Thrift Compiler (0.11.0) - * - * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - * @generated - */ -package core.thrift; - -@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) -@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-04-28") -public class TestQry { - - public interface Iface { - - /** - * 测试查询接口,当qryCode值为1时返回"成功"的响应信息,qryCode值为其他值时返回"失败"的响应信息 - * @param qryCode测试参数 - * - * @param qryCode - */ - public QryResult qryTest(int qryCode) throws org.apache.thrift.TException; - - } - - public interface AsyncIface { - - public void qryTest(int qryCode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; - - } - - public static class Client extends org.apache.thrift.TServiceClient implements Iface { - public static class Factory implements org.apache.thrift.TServiceClientFactory { - public Factory() {} - public Client getClient(org.apache.thrift.protocol.TProtocol prot) { - return new Client(prot); - } - public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { - return new Client(iprot, oprot); - } - } - - public Client(org.apache.thrift.protocol.TProtocol prot) - { - super(prot, prot); - } - - public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { - super(iprot, oprot); - } - - public QryResult qryTest(int qryCode) throws org.apache.thrift.TException - { - send_qryTest(qryCode); - return recv_qryTest(); - } - - public void send_qryTest(int qryCode) throws org.apache.thrift.TException - { - qryTest_args args = new qryTest_args(); - args.setQryCode(qryCode); - sendBase("qryTest", args); - } - - public QryResult recv_qryTest() throws org.apache.thrift.TException - { - qryTest_result result = new qryTest_result(); - receiveBase(result, "qryTest"); - if (result.isSetSuccess()) { - return result.success; - } - throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "qryTest failed: unknown result"); - } - - } - public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { - public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { - private org.apache.thrift.async.TAsyncClientManager clientManager; - private org.apache.thrift.protocol.TProtocolFactory protocolFactory; - public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { - this.clientManager = clientManager; - this.protocolFactory = protocolFactory; - } - public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { - return new AsyncClient(protocolFactory, clientManager, transport); - } - } - - public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { - super(protocolFactory, clientManager, transport); - } - - public void qryTest(int qryCode, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - checkReady(); - qryTest_call method_call = new qryTest_call(qryCode, resultHandler, this, ___protocolFactory, ___transport); - this.___currentMethod = method_call; - ___manager.call(method_call); - } - - public static class qryTest_call extends org.apache.thrift.async.TAsyncMethodCall { - private int qryCode; - public qryTest_call(int qryCode, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { - super(client, protocolFactory, transport, resultHandler, false); - this.qryCode = qryCode; - } - - public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { - prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("qryTest", org.apache.thrift.protocol.TMessageType.CALL, 0)); - qryTest_args args = new qryTest_args(); - args.setQryCode(qryCode); - args.write(prot); - prot.writeMessageEnd(); - } - - public QryResult getResult() throws org.apache.thrift.TException { - if (getState() != org.apache.thrift.async.TAsyncMethodCall.State.RESPONSE_READ) { - throw new java.lang.IllegalStateException("Method call not finished!"); - } - org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); - org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); - return (new Client(prot)).recv_qryTest(); - } - } - - } - - public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { - private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); - public Processor(I iface) { - super(iface, getProcessMap(new java.util.HashMap>())); - } - - protected Processor(I iface, java.util.Map> processMap) { - super(iface, getProcessMap(processMap)); - } - - private static java.util.Map> getProcessMap(java.util.Map> processMap) { - processMap.put("qryTest", new qryTest()); - return processMap; - } - - public static class qryTest extends org.apache.thrift.ProcessFunction { - public qryTest() { - super("qryTest"); - } - - public qryTest_args getEmptyArgsInstance() { - return new qryTest_args(); - } - - protected boolean isOneway() { - return false; - } - - @Override - protected boolean handleRuntimeExceptions() { - return false; - } - - public qryTest_result getResult(I iface, qryTest_args args) throws org.apache.thrift.TException { - qryTest_result result = new qryTest_result(); - result.success = iface.qryTest(args.qryCode); - return result; - } - } - - } - - public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { - private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); - public AsyncProcessor(I iface) { - super(iface, getProcessMap(new java.util.HashMap>())); - } - - protected AsyncProcessor(I iface, java.util.Map> processMap) { - super(iface, getProcessMap(processMap)); - } - - private static java.util.Map> getProcessMap(java.util.Map> processMap) { - processMap.put("qryTest", new qryTest()); - return processMap; - } - - public static class qryTest extends org.apache.thrift.AsyncProcessFunction { - public qryTest() { - super("qryTest"); - } - - public qryTest_args getEmptyArgsInstance() { - return new qryTest_args(); - } - - public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { - final org.apache.thrift.AsyncProcessFunction fcall = this; - return new org.apache.thrift.async.AsyncMethodCallback() { - public void onComplete(QryResult o) { - qryTest_result result = new qryTest_result(); - result.success = o; - try { - fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); - } catch (org.apache.thrift.transport.TTransportException e) { - _LOGGER.error("TTransportException writing to internal frame buffer", e); - fb.close(); - } catch (java.lang.Exception e) { - _LOGGER.error("Exception writing to internal frame buffer", e); - onError(e); - } - } - public void onError(java.lang.Exception e) { - byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; - org.apache.thrift.TSerializable msg; - qryTest_result result = new qryTest_result(); - if (e instanceof org.apache.thrift.transport.TTransportException) { - _LOGGER.error("TTransportException inside handler", e); - fb.close(); - return; - } else if (e instanceof org.apache.thrift.TApplicationException) { - _LOGGER.error("TApplicationException inside handler", e); - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = (org.apache.thrift.TApplicationException)e; - } else { - _LOGGER.error("Exception inside handler", e); - msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; - msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); - } - try { - fcall.sendResponse(fb,msg,msgType,seqid); - } catch (java.lang.Exception ex) { - _LOGGER.error("Exception writing to internal frame buffer", ex); - fb.close(); - } - } - }; - } - - protected boolean isOneway() { - return false; - } - - public void start(I iface, qryTest_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { - iface.qryTest(args.qryCode,resultHandler); - } - } - - } - - public static class qryTest_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("qryTest_args"); - - private static final org.apache.thrift.protocol.TField QRY_CODE_FIELD_DESC = new org.apache.thrift.protocol.TField("qryCode", org.apache.thrift.protocol.TType.I32, (short)1); - - private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new qryTest_argsStandardSchemeFactory(); - private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new qryTest_argsTupleSchemeFactory(); - - public int qryCode; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - QRY_CODE((short)1, "qryCode"); - - private static final java.util.Map byName = new java.util.HashMap(); - - static { - for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 1: // QRY_CODE - return QRY_CODE; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(java.lang.String name) { - return byName.get(name); - } - - private final short _thriftId; - private final java.lang.String _fieldName; - - _Fields(short thriftId, java.lang.String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public java.lang.String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - private static final int __QRYCODE_ISSET_ID = 0; - private byte __isset_bitfield = 0; - public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.QRY_CODE, new org.apache.thrift.meta_data.FieldMetaData("qryCode", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); - metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(qryTest_args.class, metaDataMap); - } - - public qryTest_args() { - } - - public qryTest_args( - int qryCode) - { - this(); - this.qryCode = qryCode; - setQryCodeIsSet(true); - } - - /** - * Performs a deep copy on other. - */ - public qryTest_args(qryTest_args other) { - __isset_bitfield = other.__isset_bitfield; - this.qryCode = other.qryCode; - } - - public qryTest_args deepCopy() { - return new qryTest_args(this); - } - - @Override - public void clear() { - setQryCodeIsSet(false); - this.qryCode = 0; - } - - public int getQryCode() { - return this.qryCode; - } - - public qryTest_args setQryCode(int qryCode) { - this.qryCode = qryCode; - setQryCodeIsSet(true); - return this; - } - - public void unsetQryCode() { - __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __QRYCODE_ISSET_ID); - } - - /** Returns true if field qryCode is set (has been assigned a value) and false otherwise */ - public boolean isSetQryCode() { - return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __QRYCODE_ISSET_ID); - } - - public void setQryCodeIsSet(boolean value) { - __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __QRYCODE_ISSET_ID, value); - } - - public void setFieldValue(_Fields field, java.lang.Object value) { - switch (field) { - case QRY_CODE: - if (value == null) { - unsetQryCode(); - } else { - setQryCode((java.lang.Integer)value); - } - break; - - } - } - - public java.lang.Object getFieldValue(_Fields field) { - switch (field) { - case QRY_CODE: - return getQryCode(); - - } - throw new java.lang.IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new java.lang.IllegalArgumentException(); - } - - switch (field) { - case QRY_CODE: - return isSetQryCode(); - } - throw new java.lang.IllegalStateException(); - } - - @Override - public boolean equals(java.lang.Object that) { - if (that == null) - return false; - if (that instanceof qryTest_args) - return this.equals((qryTest_args)that); - return false; - } - - public boolean equals(qryTest_args that) { - if (that == null) - return false; - if (this == that) - return true; - - boolean this_present_qryCode = true; - boolean that_present_qryCode = true; - if (this_present_qryCode || that_present_qryCode) { - if (!(this_present_qryCode && that_present_qryCode)) - return false; - if (this.qryCode != that.qryCode) - return false; - } - - return true; - } - - @Override - public int hashCode() { - int hashCode = 1; - - hashCode = hashCode * 8191 + qryCode; - - return hashCode; - } - - @Override - public int compareTo(qryTest_args other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = java.lang.Boolean.valueOf(isSetQryCode()).compareTo(other.isSetQryCode()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetQryCode()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.qryCode, other.qryCode); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - scheme(iprot).read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - scheme(oprot).write(oprot, this); - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder sb = new java.lang.StringBuilder("qryTest_args("); - boolean first = true; - - sb.append("qryCode:"); - sb.append(this.qryCode); - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { - try { - // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. - __isset_bitfield = 0; - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class qryTest_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { - public qryTest_argsStandardScheme getScheme() { - return new qryTest_argsStandardScheme(); - } - } - - private static class qryTest_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, qryTest_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 1: // QRY_CODE - if (schemeField.type == org.apache.thrift.protocol.TType.I32) { - struct.qryCode = iprot.readI32(); - struct.setQryCodeIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, qryTest_args struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - oprot.writeFieldBegin(QRY_CODE_FIELD_DESC); - oprot.writeI32(struct.qryCode); - oprot.writeFieldEnd(); - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class qryTest_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { - public qryTest_argsTupleScheme getScheme() { - return new qryTest_argsTupleScheme(); - } - } - - private static class qryTest_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, qryTest_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet optionals = new java.util.BitSet(); - if (struct.isSetQryCode()) { - optionals.set(0); - } - oprot.writeBitSet(optionals, 1); - if (struct.isSetQryCode()) { - oprot.writeI32(struct.qryCode); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, qryTest_args struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(1); - if (incoming.get(0)) { - struct.qryCode = iprot.readI32(); - struct.setQryCodeIsSet(true); - } - } - } - - private static S scheme(org.apache.thrift.protocol.TProtocol proto) { - return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); - } - } - - public static class qryTest_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { - private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("qryTest_result"); - - private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRUCT, (short)0); - - private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new qryTest_resultStandardSchemeFactory(); - private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new qryTest_resultTupleSchemeFactory(); - - public QryResult success; // required - - /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ - public enum _Fields implements org.apache.thrift.TFieldIdEnum { - SUCCESS((short)0, "success"); - - private static final java.util.Map byName = new java.util.HashMap(); - - static { - for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { - byName.put(field.getFieldName(), field); - } - } - - /** - * Find the _Fields constant that matches fieldId, or null if its not found. - */ - public static _Fields findByThriftId(int fieldId) { - switch(fieldId) { - case 0: // SUCCESS - return SUCCESS; - default: - return null; - } - } - - /** - * Find the _Fields constant that matches fieldId, throwing an exception - * if it is not found. - */ - public static _Fields findByThriftIdOrThrow(int fieldId) { - _Fields fields = findByThriftId(fieldId); - if (fields == null) throw new java.lang.IllegalArgumentException("Field " + fieldId + " doesn't exist!"); - return fields; - } - - /** - * Find the _Fields constant that matches name, or null if its not found. - */ - public static _Fields findByName(java.lang.String name) { - return byName.get(name); - } - - private final short _thriftId; - private final java.lang.String _fieldName; - - _Fields(short thriftId, java.lang.String fieldName) { - _thriftId = thriftId; - _fieldName = fieldName; - } - - public short getThriftFieldId() { - return _thriftId; - } - - public java.lang.String getFieldName() { - return _fieldName; - } - } - - // isset id assignments - public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; - static { - java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); - tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, - new org.apache.thrift.meta_data.StructMetaData(org.apache.thrift.protocol.TType.STRUCT, QryResult.class))); - metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); - org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(qryTest_result.class, metaDataMap); - } - - public qryTest_result() { - } - - public qryTest_result( - QryResult success) - { - this(); - this.success = success; - } - - /** - * Performs a deep copy on other. - */ - public qryTest_result(qryTest_result other) { - if (other.isSetSuccess()) { - this.success = new QryResult(other.success); - } - } - - public qryTest_result deepCopy() { - return new qryTest_result(this); - } - - @Override - public void clear() { - this.success = null; - } - - public QryResult getSuccess() { - return this.success; - } - - public qryTest_result setSuccess(QryResult success) { - this.success = success; - return this; - } - - public void unsetSuccess() { - this.success = null; - } - - /** Returns true if field success is set (has been assigned a value) and false otherwise */ - public boolean isSetSuccess() { - return this.success != null; - } - - public void setSuccessIsSet(boolean value) { - if (!value) { - this.success = null; - } - } - - public void setFieldValue(_Fields field, java.lang.Object value) { - switch (field) { - case SUCCESS: - if (value == null) { - unsetSuccess(); - } else { - setSuccess((QryResult)value); - } - break; - - } - } - - public java.lang.Object getFieldValue(_Fields field) { - switch (field) { - case SUCCESS: - return getSuccess(); - - } - throw new java.lang.IllegalStateException(); - } - - /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ - public boolean isSet(_Fields field) { - if (field == null) { - throw new java.lang.IllegalArgumentException(); - } - - switch (field) { - case SUCCESS: - return isSetSuccess(); - } - throw new java.lang.IllegalStateException(); - } - - @Override - public boolean equals(java.lang.Object that) { - if (that == null) - return false; - if (that instanceof qryTest_result) - return this.equals((qryTest_result)that); - return false; - } - - public boolean equals(qryTest_result that) { - if (that == null) - return false; - if (this == that) - return true; - - boolean this_present_success = true && this.isSetSuccess(); - boolean that_present_success = true && that.isSetSuccess(); - if (this_present_success || that_present_success) { - if (!(this_present_success && that_present_success)) - return false; - if (!this.success.equals(that.success)) - return false; - } - - return true; - } - - @Override - public int hashCode() { - int hashCode = 1; - - hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); - if (isSetSuccess()) - hashCode = hashCode * 8191 + success.hashCode(); - - return hashCode; - } - - @Override - public int compareTo(qryTest_result other) { - if (!getClass().equals(other.getClass())) { - return getClass().getName().compareTo(other.getClass().getName()); - } - - int lastComparison = 0; - - lastComparison = java.lang.Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); - if (lastComparison != 0) { - return lastComparison; - } - if (isSetSuccess()) { - lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); - if (lastComparison != 0) { - return lastComparison; - } - } - return 0; - } - - public _Fields fieldForId(int fieldId) { - return _Fields.findByThriftId(fieldId); - } - - public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { - scheme(iprot).read(iprot, this); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { - scheme(oprot).write(oprot, this); - } - - @Override - public java.lang.String toString() { - java.lang.StringBuilder sb = new java.lang.StringBuilder("qryTest_result("); - boolean first = true; - - sb.append("success:"); - if (this.success == null) { - sb.append("null"); - } else { - sb.append(this.success); - } - first = false; - sb.append(")"); - return sb.toString(); - } - - public void validate() throws org.apache.thrift.TException { - // check for required fields - // check for sub-struct validity - if (success != null) { - success.validate(); - } - } - - private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { - try { - write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException { - try { - read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); - } catch (org.apache.thrift.TException te) { - throw new java.io.IOException(te); - } - } - - private static class qryTest_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { - public qryTest_resultStandardScheme getScheme() { - return new qryTest_resultStandardScheme(); - } - } - - private static class qryTest_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { - - public void read(org.apache.thrift.protocol.TProtocol iprot, qryTest_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TField schemeField; - iprot.readStructBegin(); - while (true) - { - schemeField = iprot.readFieldBegin(); - if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { - break; - } - switch (schemeField.id) { - case 0: // SUCCESS - if (schemeField.type == org.apache.thrift.protocol.TType.STRUCT) { - struct.success = new QryResult(); - struct.success.read(iprot); - struct.setSuccessIsSet(true); - } else { - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - break; - default: - org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); - } - iprot.readFieldEnd(); - } - iprot.readStructEnd(); - - // check for required fields of primitive type, which can't be checked in the validate method - struct.validate(); - } - - public void write(org.apache.thrift.protocol.TProtocol oprot, qryTest_result struct) throws org.apache.thrift.TException { - struct.validate(); - - oprot.writeStructBegin(STRUCT_DESC); - if (struct.success != null) { - oprot.writeFieldBegin(SUCCESS_FIELD_DESC); - struct.success.write(oprot); - oprot.writeFieldEnd(); - } - oprot.writeFieldStop(); - oprot.writeStructEnd(); - } - - } - - private static class qryTest_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { - public qryTest_resultTupleScheme getScheme() { - return new qryTest_resultTupleScheme(); - } - } - - private static class qryTest_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { - - @Override - public void write(org.apache.thrift.protocol.TProtocol prot, qryTest_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet optionals = new java.util.BitSet(); - if (struct.isSetSuccess()) { - optionals.set(0); - } - oprot.writeBitSet(optionals, 1); - if (struct.isSetSuccess()) { - struct.success.write(oprot); - } - } - - @Override - public void read(org.apache.thrift.protocol.TProtocol prot, qryTest_result struct) throws org.apache.thrift.TException { - org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; - java.util.BitSet incoming = iprot.readBitSet(1); - if (incoming.get(0)) { - struct.success = new QryResult(); - struct.success.read(iprot); - struct.setSuccessIsSet(true); - } - } - } - - private static S scheme(org.apache.thrift.protocol.TProtocol proto) { - return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); - } - } - -} diff --git a/core/src/main/java/core/thrift/ThriftClientDemo.java b/core/src/main/java/core/thrift/ThriftClientDemo.java index bd2f56b..57192c0 100644 --- a/core/src/main/java/core/thrift/ThriftClientDemo.java +++ b/core/src/main/java/core/thrift/ThriftClientDemo.java @@ -1,27 +1,56 @@ package core.thrift; +import core.thrift.comment.QueryComment; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.protocol.TProtocol; import org.apache.thrift.transport.TFramedTransport; import org.apache.thrift.transport.TSocket; import org.apache.thrift.transport.TTransport; +import java.util.ArrayList; +import java.util.List; + public class ThriftClientDemo { - private final static int DEFAULT_QRY_CODE = 1; - public static void main(String[] args){ - try { - TTransport tTransport = getTTransport(); - TProtocol protocol = new TBinaryProtocol(tTransport); - TestQry.Client client = new TestQry.Client(protocol); - QryResult result = client.qryTest(DEFAULT_QRY_CODE); - System.out.println("code="+result.code+" msg="+result.msg); - }catch (Exception e) { - e.printStackTrace(); - } + + private static final String host="127.0.0.1"; + private static final int port=2233; + private static Logger log=LogManager.getLogger(); + + public static void main(String[] args) throws Exception { + downloadXml(new ArrayList(){{ + add(12026697); + }},"测试弹幕"); + } + + public static List commentSumList(List cids) throws Exception { + List result= client().commentSumList(cids); + log.info("查询结果:"+result); + return result; } + + public static int commentSum(int cid) throws Exception { + int result=client().commentSum(cid); + log.info("查询结果:"+result); + return result; + } + + public static String downloadXml(List cids,String fileName) throws Exception { + String result=client().download(cids,fileName); + log.info("查询结果:"+result); + return result; + } + + private static QueryComment.Client client() throws Exception { + TTransport tTransport = getTTransport(); + TProtocol protocol = new TBinaryProtocol(tTransport); + return new QueryComment.Client(protocol); + } + private static TTransport getTTransport() throws Exception{ try{ - TTransport tTransport = getTTransport("sukura.top", 2233, 5000); + TTransport tTransport = getTTransport(host, port, 5000); if(!tTransport.isOpen()){ tTransport.open(); } diff --git a/core/src/main/java/core/thrift/ThriftServerDemo.java b/core/src/main/java/core/thrift/ThriftServerDemo.java index 45ec5a0..dab3012 100644 --- a/core/src/main/java/core/thrift/ThriftServerDemo.java +++ b/core/src/main/java/core/thrift/ThriftServerDemo.java @@ -1,5 +1,6 @@ package core.thrift; +import core.thrift.comment.QueryComment; import org.apache.thrift.TProcessorFactory; import org.apache.thrift.protocol.TBinaryProtocol; import org.apache.thrift.server.TNonblockingServer; @@ -13,7 +14,7 @@ public class ThriftServerDemo { try { TNonblockingServerSocket socket = new TNonblockingServerSocket(2233); - TestQry.Processor processor = new TestQry.Processor(new QueryImp()); + QueryComment.Processor processor = new QueryComment.Processor(new QueryComment.QueryImpl()); TNonblockingServer.Args arg = new TNonblockingServer.Args(socket); arg.protocolFactory(new TBinaryProtocol.Factory()); arg.transportFactory(new TFramedTransport.Factory()); diff --git a/core/src/main/java/core/thrift/comment/QueryComment.java b/core/src/main/java/core/thrift/comment/QueryComment.java new file mode 100644 index 0000000..35fcb39 --- /dev/null +++ b/core/src/main/java/core/thrift/comment/QueryComment.java @@ -0,0 +1,2996 @@ +/** + * Autogenerated by Thrift Compiler (0.11.0) + * + * DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + * @generated + */ +package core.thrift.comment; + +import org.apache.thrift.TException; + +import java.util.List; + +@SuppressWarnings({"cast", "rawtypes", "serial", "unchecked", "unused"}) +@javax.annotation.Generated(value = "Autogenerated by Thrift Compiler (0.11.0)", date = "2018-06-03") +public class QueryComment { + + public interface Iface { + + /** + * 查询单个cid弹幕数 + * + * + * @param cid + */ + public int commentSum(int cid) throws org.apache.thrift.TException; + + /** + * * 批量查询多个cid弹幕数 + * * + * + * @param cids + */ + public java.util.List commentSumList(java.util.List cids) throws org.apache.thrift.TException; + + /** + * * 批量下载弹幕 + * * + * + * @param cids + * @param fileName + */ + public String download(java.util.List cids, String fileName) throws org.apache.thrift.TException; + + } + + public interface AsyncIface { + + public void commentSum(int cid, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + public void commentSumList(java.util.List cids, org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException; + + public void download(java.util.List cids, String fileName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException; + + } + + public static class Client extends org.apache.thrift.TServiceClient implements Iface { + public static class Factory implements org.apache.thrift.TServiceClientFactory { + public Factory() {} + public Client getClient(org.apache.thrift.protocol.TProtocol prot) { + return new Client(prot); + } + public Client getClient(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + return new Client(iprot, oprot); + } + } + + public Client(org.apache.thrift.protocol.TProtocol prot) + { + super(prot, prot); + } + + public Client(org.apache.thrift.protocol.TProtocol iprot, org.apache.thrift.protocol.TProtocol oprot) { + super(iprot, oprot); + } + + public int commentSum(int cid) throws org.apache.thrift.TException + { + send_commentSum(cid); + return recv_commentSum(); + } + + public void send_commentSum(int cid) throws org.apache.thrift.TException + { + commentSum_args args = new commentSum_args(); + args.setCid(cid); + sendBase("commentSum", args); + } + + public int recv_commentSum() throws org.apache.thrift.TException + { + commentSum_result result = new commentSum_result(); + receiveBase(result, "commentSum"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "commentSum failed: unknown result"); + } + + public java.util.List commentSumList(java.util.List cids) throws org.apache.thrift.TException + { + send_commentSumList(cids); + return recv_commentSumList(); + } + + public void send_commentSumList(java.util.List cids) throws org.apache.thrift.TException + { + commentSumList_args args = new commentSumList_args(); + args.setCids(cids); + sendBase("commentSumList", args); + } + + public java.util.List recv_commentSumList() throws org.apache.thrift.TException + { + commentSumList_result result = new commentSumList_result(); + receiveBase(result, "commentSumList"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "commentSumList failed: unknown result"); + } + + public String download(java.util.List cids, String fileName) throws org.apache.thrift.TException + { + send_download(cids, fileName); + return recv_download(); + } + + public void send_download(java.util.List cids, String fileName) throws org.apache.thrift.TException + { + download_args args = new download_args(); + args.setCids(cids); + args.setFileName(fileName); + sendBase("download", args); + } + + public String recv_download() throws org.apache.thrift.TException + { + download_result result = new download_result(); + receiveBase(result, "download"); + if (result.isSetSuccess()) { + return result.success; + } + throw new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.MISSING_RESULT, "download failed: unknown result"); + } + + } + public static class AsyncClient extends org.apache.thrift.async.TAsyncClient implements AsyncIface { + public static class Factory implements org.apache.thrift.async.TAsyncClientFactory { + private org.apache.thrift.async.TAsyncClientManager clientManager; + private org.apache.thrift.protocol.TProtocolFactory protocolFactory; + public Factory(org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.protocol.TProtocolFactory protocolFactory) { + this.clientManager = clientManager; + this.protocolFactory = protocolFactory; + } + public AsyncClient getAsyncClient(org.apache.thrift.transport.TNonblockingTransport transport) { + return new AsyncClient(protocolFactory, clientManager, transport); + } + } + + public AsyncClient(org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.async.TAsyncClientManager clientManager, org.apache.thrift.transport.TNonblockingTransport transport) { + super(protocolFactory, clientManager, transport); + } + + public void commentSum(int cid, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + commentSum_call method_call = new commentSum_call(cid, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class commentSum_call extends org.apache.thrift.async.TAsyncMethodCall { + private int cid; + public commentSum_call(int cid, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.cid = cid; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("commentSum", org.apache.thrift.protocol.TMessageType.CALL, 0)); + commentSum_args args = new commentSum_args(); + args.setCid(cid); + args.write(prot); + prot.writeMessageEnd(); + } + + public Integer getResult() throws org.apache.thrift.TException { + if (getState() != State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_commentSum(); + } + } + + public void commentSumList(java.util.List cids, org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException { + checkReady(); + commentSumList_call method_call = new commentSumList_call(cids, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class commentSumList_call extends org.apache.thrift.async.TAsyncMethodCall> { + private java.util.List cids; + public commentSumList_call(java.util.List cids, org.apache.thrift.async.AsyncMethodCallback> resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.cids = cids; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("commentSumList", org.apache.thrift.protocol.TMessageType.CALL, 0)); + commentSumList_args args = new commentSumList_args(); + args.setCids(cids); + args.write(prot); + prot.writeMessageEnd(); + } + + public java.util.List getResult() throws org.apache.thrift.TException { + if (getState() != State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_commentSumList(); + } + } + + public void download(java.util.List cids, String fileName, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + checkReady(); + download_call method_call = new download_call(cids, fileName, resultHandler, this, ___protocolFactory, ___transport); + this.___currentMethod = method_call; + ___manager.call(method_call); + } + + public static class download_call extends org.apache.thrift.async.TAsyncMethodCall { + private java.util.List cids; + private String fileName; + public download_call(java.util.List cids, String fileName, org.apache.thrift.async.AsyncMethodCallback resultHandler, org.apache.thrift.async.TAsyncClient client, org.apache.thrift.protocol.TProtocolFactory protocolFactory, org.apache.thrift.transport.TNonblockingTransport transport) throws org.apache.thrift.TException { + super(client, protocolFactory, transport, resultHandler, false); + this.cids = cids; + this.fileName = fileName; + } + + public void write_args(org.apache.thrift.protocol.TProtocol prot) throws org.apache.thrift.TException { + prot.writeMessageBegin(new org.apache.thrift.protocol.TMessage("download", org.apache.thrift.protocol.TMessageType.CALL, 0)); + download_args args = new download_args(); + args.setCids(cids); + args.setFileName(fileName); + args.write(prot); + prot.writeMessageEnd(); + } + + public String getResult() throws org.apache.thrift.TException { + if (getState() != State.RESPONSE_READ) { + throw new IllegalStateException("Method call not finished!"); + } + org.apache.thrift.transport.TMemoryInputTransport memoryTransport = new org.apache.thrift.transport.TMemoryInputTransport(getFrameBuffer().array()); + org.apache.thrift.protocol.TProtocol prot = client.getProtocolFactory().getProtocol(memoryTransport); + return (new Client(prot)).recv_download(); + } + } + + } + + public static class Processor extends org.apache.thrift.TBaseProcessor implements org.apache.thrift.TProcessor { + private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(Processor.class.getName()); + public Processor(I iface) { + super(iface, getProcessMap(new java.util.HashMap>())); + } + + protected Processor(I iface, java.util.Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static java.util.Map> getProcessMap(java.util.Map> processMap) { + processMap.put("commentSum", new commentSum()); + processMap.put("commentSumList", new commentSumList()); + processMap.put("download", new download()); + return processMap; + } + + public static class commentSum extends org.apache.thrift.ProcessFunction { + public commentSum() { + super("commentSum"); + } + + public commentSum_args getEmptyArgsInstance() { + return new commentSum_args(); + } + + protected boolean isOneway() { + return false; + } + + @Override + protected boolean handleRuntimeExceptions() { + return false; + } + + public commentSum_result getResult(I iface, commentSum_args args) throws org.apache.thrift.TException { + commentSum_result result = new commentSum_result(); + result.success = iface.commentSum(args.cid); + result.setSuccessIsSet(true); + return result; + } + } + + public static class commentSumList extends org.apache.thrift.ProcessFunction { + public commentSumList() { + super("commentSumList"); + } + + public commentSumList_args getEmptyArgsInstance() { + return new commentSumList_args(); + } + + protected boolean isOneway() { + return false; + } + + @Override + protected boolean handleRuntimeExceptions() { + return false; + } + + public commentSumList_result getResult(I iface, commentSumList_args args) throws org.apache.thrift.TException { + commentSumList_result result = new commentSumList_result(); + result.success = iface.commentSumList(args.cids); + return result; + } + } + + public static class download extends org.apache.thrift.ProcessFunction { + public download() { + super("download"); + } + + public download_args getEmptyArgsInstance() { + return new download_args(); + } + + protected boolean isOneway() { + return false; + } + + @Override + protected boolean handleRuntimeExceptions() { + return false; + } + + public download_result getResult(I iface, download_args args) throws org.apache.thrift.TException { + download_result result = new download_result(); + result.success = iface.download(args.cids, args.fileName); + return result; + } + } + + } + + public static class AsyncProcessor extends org.apache.thrift.TBaseAsyncProcessor { + private static final org.slf4j.Logger _LOGGER = org.slf4j.LoggerFactory.getLogger(AsyncProcessor.class.getName()); + public AsyncProcessor(I iface) { + super(iface, getProcessMap(new java.util.HashMap>())); + } + + protected AsyncProcessor(I iface, java.util.Map> processMap) { + super(iface, getProcessMap(processMap)); + } + + private static java.util.Map> getProcessMap(java.util.Map> processMap) { + processMap.put("commentSum", new commentSum()); + processMap.put("commentSumList", new commentSumList()); + processMap.put("download", new download()); + return processMap; + } + + public static class commentSum extends org.apache.thrift.AsyncProcessFunction { + public commentSum() { + super("commentSum"); + } + + public commentSum_args getEmptyArgsInstance() { + return new commentSum_args(); + } + + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + public void onComplete(Integer o) { + commentSum_result result = new commentSum_result(); + result.success = o; + result.setSuccessIsSet(true); + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + commentSum_result result = new commentSum_result(); + if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, commentSum_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.commentSum(args.cid,resultHandler); + } + } + + public static class commentSumList extends org.apache.thrift.AsyncProcessFunction> { + public commentSumList() { + super("commentSumList"); + } + + public commentSumList_args getEmptyArgsInstance() { + return new commentSumList_args(); + } + + public org.apache.thrift.async.AsyncMethodCallback> getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback>() { + public void onComplete(java.util.List o) { + commentSumList_result result = new commentSumList_result(); + result.success = o; + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + commentSumList_result result = new commentSumList_result(); + if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, commentSumList_args args, org.apache.thrift.async.AsyncMethodCallback> resultHandler) throws org.apache.thrift.TException { + iface.commentSumList(args.cids,resultHandler); + } + } + + public static class download extends org.apache.thrift.AsyncProcessFunction { + public download() { + super("download"); + } + + public download_args getEmptyArgsInstance() { + return new download_args(); + } + + public org.apache.thrift.async.AsyncMethodCallback getResultHandler(final org.apache.thrift.server.AbstractNonblockingServer.AsyncFrameBuffer fb, final int seqid) { + final org.apache.thrift.AsyncProcessFunction fcall = this; + return new org.apache.thrift.async.AsyncMethodCallback() { + public void onComplete(String o) { + download_result result = new download_result(); + result.success = o; + try { + fcall.sendResponse(fb, result, org.apache.thrift.protocol.TMessageType.REPLY,seqid); + } catch (org.apache.thrift.transport.TTransportException e) { + _LOGGER.error("TTransportException writing to internal frame buffer", e); + fb.close(); + } catch (Exception e) { + _LOGGER.error("Exception writing to internal frame buffer", e); + onError(e); + } + } + public void onError(Exception e) { + byte msgType = org.apache.thrift.protocol.TMessageType.REPLY; + org.apache.thrift.TSerializable msg; + download_result result = new download_result(); + if (e instanceof org.apache.thrift.transport.TTransportException) { + _LOGGER.error("TTransportException inside handler", e); + fb.close(); + return; + } else if (e instanceof org.apache.thrift.TApplicationException) { + _LOGGER.error("TApplicationException inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = (org.apache.thrift.TApplicationException)e; + } else { + _LOGGER.error("Exception inside handler", e); + msgType = org.apache.thrift.protocol.TMessageType.EXCEPTION; + msg = new org.apache.thrift.TApplicationException(org.apache.thrift.TApplicationException.INTERNAL_ERROR, e.getMessage()); + } + try { + fcall.sendResponse(fb,msg,msgType,seqid); + } catch (Exception ex) { + _LOGGER.error("Exception writing to internal frame buffer", ex); + fb.close(); + } + } + }; + } + + protected boolean isOneway() { + return false; + } + + public void start(I iface, download_args args, org.apache.thrift.async.AsyncMethodCallback resultHandler) throws org.apache.thrift.TException { + iface.download(args.cids, args.fileName,resultHandler); + } + } + + } + + public static class commentSum_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("commentSum_args"); + + private static final org.apache.thrift.protocol.TField CID_FIELD_DESC = new org.apache.thrift.protocol.TField("cid", org.apache.thrift.protocol.TType.I32, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new commentSum_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new commentSum_argsTupleSchemeFactory(); + + public int cid; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CID((short)1, "cid"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CID + return CID; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __CID_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CID, new org.apache.thrift.meta_data.FieldMetaData("cid", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(commentSum_args.class, metaDataMap); + } + + public commentSum_args() { + } + + public commentSum_args( + int cid) + { + this(); + this.cid = cid; + setCidIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public commentSum_args(commentSum_args other) { + __isset_bitfield = other.__isset_bitfield; + this.cid = other.cid; + } + + public commentSum_args deepCopy() { + return new commentSum_args(this); + } + + @Override + public void clear() { + setCidIsSet(false); + this.cid = 0; + } + + public int getCid() { + return this.cid; + } + + public commentSum_args setCid(int cid) { + this.cid = cid; + setCidIsSet(true); + return this; + } + + public void unsetCid() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __CID_ISSET_ID); + } + + /** Returns true if field cid is set (has been assigned a value) and false otherwise */ + public boolean isSetCid() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __CID_ISSET_ID); + } + + public void setCidIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __CID_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CID: + if (value == null) { + unsetCid(); + } else { + setCid((Integer)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CID: + return getCid(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CID: + return isSetCid(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof commentSum_args) + return this.equals((commentSum_args)that); + return false; + } + + public boolean equals(commentSum_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_cid = true; + boolean that_present_cid = true; + if (this_present_cid || that_present_cid) { + if (!(this_present_cid && that_present_cid)) + return false; + if (this.cid != that.cid) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + cid; + + return hashCode; + } + + @Override + public int compareTo(commentSum_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetCid()).compareTo(other.isSetCid()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCid()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cid, other.cid); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("commentSum_args("); + boolean first = true; + + sb.append("cid:"); + sb.append(this.cid); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class commentSum_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSum_argsStandardScheme getScheme() { + return new commentSum_argsStandardScheme(); + } + } + + private static class commentSum_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, commentSum_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CID + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.cid = iprot.readI32(); + struct.setCidIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, commentSum_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + oprot.writeFieldBegin(CID_FIELD_DESC); + oprot.writeI32(struct.cid); + oprot.writeFieldEnd(); + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class commentSum_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSum_argsTupleScheme getScheme() { + return new commentSum_argsTupleScheme(); + } + } + + private static class commentSum_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, commentSum_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetCid()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetCid()) { + oprot.writeI32(struct.cid); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, commentSum_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.cid = iprot.readI32(); + struct.setCidIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class commentSum_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("commentSum_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.I32, (short)0); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new commentSum_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new commentSum_resultTupleSchemeFactory(); + + public int success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + private static final int __SUCCESS_ISSET_ID = 0; + private byte __isset_bitfield = 0; + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(commentSum_result.class, metaDataMap); + } + + public commentSum_result() { + } + + public commentSum_result( + int success) + { + this(); + this.success = success; + setSuccessIsSet(true); + } + + /** + * Performs a deep copy on other. + */ + public commentSum_result(commentSum_result other) { + __isset_bitfield = other.__isset_bitfield; + this.success = other.success; + } + + public commentSum_result deepCopy() { + return new commentSum_result(this); + } + + @Override + public void clear() { + setSuccessIsSet(false); + this.success = 0; + } + + public int getSuccess() { + return this.success; + } + + public commentSum_result setSuccess(int success) { + this.success = success; + setSuccessIsSet(true); + return this; + } + + public void unsetSuccess() { + __isset_bitfield = org.apache.thrift.EncodingUtils.clearBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return org.apache.thrift.EncodingUtils.testBit(__isset_bitfield, __SUCCESS_ISSET_ID); + } + + public void setSuccessIsSet(boolean value) { + __isset_bitfield = org.apache.thrift.EncodingUtils.setBit(__isset_bitfield, __SUCCESS_ISSET_ID, value); + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((Integer)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof commentSum_result) + return this.equals((commentSum_result)that); + return false; + } + + public boolean equals(commentSum_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true; + boolean that_present_success = true; + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (this.success != that.success) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + success; + + return hashCode; + } + + @Override + public int compareTo(commentSum_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("commentSum_result("); + boolean first = true; + + sb.append("success:"); + sb.append(this.success); + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + // it doesn't seem like you should have to do this, but java serialization is wacky, and doesn't call the default constructor. + __isset_bitfield = 0; + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class commentSum_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSum_resultStandardScheme getScheme() { + return new commentSum_resultStandardScheme(); + } + } + + private static class commentSum_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, commentSum_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.I32) { + struct.success = iprot.readI32(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, commentSum_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.isSetSuccess()) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeI32(struct.success); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class commentSum_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSum_resultTupleScheme getScheme() { + return new commentSum_resultTupleScheme(); + } + } + + private static class commentSum_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, commentSum_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + oprot.writeI32(struct.success); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, commentSum_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = iprot.readI32(); + struct.setSuccessIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class commentSumList_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("commentSumList_args"); + + private static final org.apache.thrift.protocol.TField CIDS_FIELD_DESC = new org.apache.thrift.protocol.TField("cids", org.apache.thrift.protocol.TType.LIST, (short)1); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new commentSumList_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new commentSumList_argsTupleSchemeFactory(); + + public java.util.List cids; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CIDS((short)1, "cids"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CIDS + return CIDS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CIDS, new org.apache.thrift.meta_data.FieldMetaData("cids", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(commentSumList_args.class, metaDataMap); + } + + public commentSumList_args() { + } + + public commentSumList_args( + java.util.List cids) + { + this(); + this.cids = cids; + } + + /** + * Performs a deep copy on other. + */ + public commentSumList_args(commentSumList_args other) { + if (other.isSetCids()) { + java.util.List __this__cids = new java.util.ArrayList(other.cids); + this.cids = __this__cids; + } + } + + public commentSumList_args deepCopy() { + return new commentSumList_args(this); + } + + @Override + public void clear() { + this.cids = null; + } + + public int getCidsSize() { + return (this.cids == null) ? 0 : this.cids.size(); + } + + public java.util.Iterator getCidsIterator() { + return (this.cids == null) ? null : this.cids.iterator(); + } + + public void addToCids(int elem) { + if (this.cids == null) { + this.cids = new java.util.ArrayList(); + } + this.cids.add(elem); + } + + public java.util.List getCids() { + return this.cids; + } + + public commentSumList_args setCids(java.util.List cids) { + this.cids = cids; + return this; + } + + public void unsetCids() { + this.cids = null; + } + + /** Returns true if field cids is set (has been assigned a value) and false otherwise */ + public boolean isSetCids() { + return this.cids != null; + } + + public void setCidsIsSet(boolean value) { + if (!value) { + this.cids = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CIDS: + if (value == null) { + unsetCids(); + } else { + setCids((java.util.List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CIDS: + return getCids(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CIDS: + return isSetCids(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof commentSumList_args) + return this.equals((commentSumList_args)that); + return false; + } + + public boolean equals(commentSumList_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_cids = true && this.isSetCids(); + boolean that_present_cids = true && that.isSetCids(); + if (this_present_cids || that_present_cids) { + if (!(this_present_cids && that_present_cids)) + return false; + if (!this.cids.equals(that.cids)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetCids()) ? 131071 : 524287); + if (isSetCids()) + hashCode = hashCode * 8191 + cids.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(commentSumList_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetCids()).compareTo(other.isSetCids()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCids()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cids, other.cids); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("commentSumList_args("); + boolean first = true; + + sb.append("cids:"); + if (this.cids == null) { + sb.append("null"); + } else { + sb.append(this.cids); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class commentSumList_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSumList_argsStandardScheme getScheme() { + return new commentSumList_argsStandardScheme(); + } + } + + private static class commentSumList_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, commentSumList_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CIDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list0 = iprot.readListBegin(); + struct.cids = new java.util.ArrayList(_list0.size); + int _elem1; + for (int _i2 = 0; _i2 < _list0.size; ++_i2) + { + _elem1 = iprot.readI32(); + struct.cids.add(_elem1); + } + iprot.readListEnd(); + } + struct.setCidsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, commentSumList_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.cids != null) { + oprot.writeFieldBegin(CIDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.cids.size())); + for (int _iter3 : struct.cids) + { + oprot.writeI32(_iter3); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class commentSumList_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSumList_argsTupleScheme getScheme() { + return new commentSumList_argsTupleScheme(); + } + } + + private static class commentSumList_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, commentSumList_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetCids()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetCids()) { + { + oprot.writeI32(struct.cids.size()); + for (int _iter4 : struct.cids) + { + oprot.writeI32(_iter4); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, commentSumList_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list5 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.cids = new java.util.ArrayList(_list5.size); + int _elem6; + for (int _i7 = 0; _i7 < _list5.size; ++_i7) + { + _elem6 = iprot.readI32(); + struct.cids.add(_elem6); + } + } + struct.setCidsIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class commentSumList_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("commentSumList_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.LIST, (short)0); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new commentSumList_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new commentSumList_resultTupleSchemeFactory(); + + public java.util.List success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(commentSumList_result.class, metaDataMap); + } + + public commentSumList_result() { + } + + public commentSumList_result( + java.util.List success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public commentSumList_result(commentSumList_result other) { + if (other.isSetSuccess()) { + java.util.List __this__success = new java.util.ArrayList(other.success); + this.success = __this__success; + } + } + + public commentSumList_result deepCopy() { + return new commentSumList_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public int getSuccessSize() { + return (this.success == null) ? 0 : this.success.size(); + } + + public java.util.Iterator getSuccessIterator() { + return (this.success == null) ? null : this.success.iterator(); + } + + public void addToSuccess(int elem) { + if (this.success == null) { + this.success = new java.util.ArrayList(); + } + this.success.add(elem); + } + + public java.util.List getSuccess() { + return this.success; + } + + public commentSumList_result setSuccess(java.util.List success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((java.util.List)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof commentSumList_result) + return this.equals((commentSumList_result)that); + return false; + } + + public boolean equals(commentSumList_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); + if (isSetSuccess()) + hashCode = hashCode * 8191 + success.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(commentSumList_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("commentSumList_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class commentSumList_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSumList_resultStandardScheme getScheme() { + return new commentSumList_resultStandardScheme(); + } + } + + private static class commentSumList_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, commentSumList_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list8 = iprot.readListBegin(); + struct.success = new java.util.ArrayList(_list8.size); + int _elem9; + for (int _i10 = 0; _i10 < _list8.size; ++_i10) + { + _elem9 = iprot.readI32(); + struct.success.add(_elem9); + } + iprot.readListEnd(); + } + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, commentSumList_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.success.size())); + for (int _iter11 : struct.success) + { + oprot.writeI32(_iter11); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class commentSumList_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public commentSumList_resultTupleScheme getScheme() { + return new commentSumList_resultTupleScheme(); + } + } + + private static class commentSumList_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, commentSumList_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + { + oprot.writeI32(struct.success.size()); + for (int _iter12 : struct.success) + { + oprot.writeI32(_iter12); + } + } + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, commentSumList_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list13 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.success = new java.util.ArrayList(_list13.size); + int _elem14; + for (int _i15 = 0; _i15 < _list13.size; ++_i15) + { + _elem14 = iprot.readI32(); + struct.success.add(_elem14); + } + } + struct.setSuccessIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class download_args implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("download_args"); + + private static final org.apache.thrift.protocol.TField CIDS_FIELD_DESC = new org.apache.thrift.protocol.TField("cids", org.apache.thrift.protocol.TType.LIST, (short)1); + private static final org.apache.thrift.protocol.TField FILE_NAME_FIELD_DESC = new org.apache.thrift.protocol.TField("fileName", org.apache.thrift.protocol.TType.STRING, (short)2); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new download_argsStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new download_argsTupleSchemeFactory(); + + public java.util.List cids; // required + public String fileName; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + CIDS((short)1, "cids"), + FILE_NAME((short)2, "fileName"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 1: // CIDS + return CIDS; + case 2: // FILE_NAME + return FILE_NAME; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.CIDS, new org.apache.thrift.meta_data.FieldMetaData("cids", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.ListMetaData(org.apache.thrift.protocol.TType.LIST, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.I32)))); + tmpMap.put(_Fields.FILE_NAME, new org.apache.thrift.meta_data.FieldMetaData("fileName", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(download_args.class, metaDataMap); + } + + public download_args() { + } + + public download_args( + java.util.List cids, + String fileName) + { + this(); + this.cids = cids; + this.fileName = fileName; + } + + /** + * Performs a deep copy on other. + */ + public download_args(download_args other) { + if (other.isSetCids()) { + java.util.List __this__cids = new java.util.ArrayList(other.cids); + this.cids = __this__cids; + } + if (other.isSetFileName()) { + this.fileName = other.fileName; + } + } + + public download_args deepCopy() { + return new download_args(this); + } + + @Override + public void clear() { + this.cids = null; + this.fileName = null; + } + + public int getCidsSize() { + return (this.cids == null) ? 0 : this.cids.size(); + } + + public java.util.Iterator getCidsIterator() { + return (this.cids == null) ? null : this.cids.iterator(); + } + + public void addToCids(int elem) { + if (this.cids == null) { + this.cids = new java.util.ArrayList(); + } + this.cids.add(elem); + } + + public java.util.List getCids() { + return this.cids; + } + + public download_args setCids(java.util.List cids) { + this.cids = cids; + return this; + } + + public void unsetCids() { + this.cids = null; + } + + /** Returns true if field cids is set (has been assigned a value) and false otherwise */ + public boolean isSetCids() { + return this.cids != null; + } + + public void setCidsIsSet(boolean value) { + if (!value) { + this.cids = null; + } + } + + public String getFileName() { + return this.fileName; + } + + public download_args setFileName(String fileName) { + this.fileName = fileName; + return this; + } + + public void unsetFileName() { + this.fileName = null; + } + + /** Returns true if field fileName is set (has been assigned a value) and false otherwise */ + public boolean isSetFileName() { + return this.fileName != null; + } + + public void setFileNameIsSet(boolean value) { + if (!value) { + this.fileName = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case CIDS: + if (value == null) { + unsetCids(); + } else { + setCids((java.util.List)value); + } + break; + + case FILE_NAME: + if (value == null) { + unsetFileName(); + } else { + setFileName((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case CIDS: + return getCids(); + + case FILE_NAME: + return getFileName(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case CIDS: + return isSetCids(); + case FILE_NAME: + return isSetFileName(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof download_args) + return this.equals((download_args)that); + return false; + } + + public boolean equals(download_args that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_cids = true && this.isSetCids(); + boolean that_present_cids = true && that.isSetCids(); + if (this_present_cids || that_present_cids) { + if (!(this_present_cids && that_present_cids)) + return false; + if (!this.cids.equals(that.cids)) + return false; + } + + boolean this_present_fileName = true && this.isSetFileName(); + boolean that_present_fileName = true && that.isSetFileName(); + if (this_present_fileName || that_present_fileName) { + if (!(this_present_fileName && that_present_fileName)) + return false; + if (!this.fileName.equals(that.fileName)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetCids()) ? 131071 : 524287); + if (isSetCids()) + hashCode = hashCode * 8191 + cids.hashCode(); + + hashCode = hashCode * 8191 + ((isSetFileName()) ? 131071 : 524287); + if (isSetFileName()) + hashCode = hashCode * 8191 + fileName.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(download_args other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetCids()).compareTo(other.isSetCids()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetCids()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.cids, other.cids); + if (lastComparison != 0) { + return lastComparison; + } + } + lastComparison = Boolean.valueOf(isSetFileName()).compareTo(other.isSetFileName()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetFileName()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.fileName, other.fileName); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("download_args("); + boolean first = true; + + sb.append("cids:"); + if (this.cids == null) { + sb.append("null"); + } else { + sb.append(this.cids); + } + first = false; + if (!first) sb.append(", "); + sb.append("fileName:"); + if (this.fileName == null) { + sb.append("null"); + } else { + sb.append(this.fileName); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class download_argsStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public download_argsStandardScheme getScheme() { + return new download_argsStandardScheme(); + } + } + + private static class download_argsStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, download_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 1: // CIDS + if (schemeField.type == org.apache.thrift.protocol.TType.LIST) { + { + org.apache.thrift.protocol.TList _list16 = iprot.readListBegin(); + struct.cids = new java.util.ArrayList(_list16.size); + int _elem17; + for (int _i18 = 0; _i18 < _list16.size; ++_i18) + { + _elem17 = iprot.readI32(); + struct.cids.add(_elem17); + } + iprot.readListEnd(); + } + struct.setCidsIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + case 2: // FILE_NAME + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.fileName = iprot.readString(); + struct.setFileNameIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, download_args struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.cids != null) { + oprot.writeFieldBegin(CIDS_FIELD_DESC); + { + oprot.writeListBegin(new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, struct.cids.size())); + for (int _iter19 : struct.cids) + { + oprot.writeI32(_iter19); + } + oprot.writeListEnd(); + } + oprot.writeFieldEnd(); + } + if (struct.fileName != null) { + oprot.writeFieldBegin(FILE_NAME_FIELD_DESC); + oprot.writeString(struct.fileName); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class download_argsTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public download_argsTupleScheme getScheme() { + return new download_argsTupleScheme(); + } + } + + private static class download_argsTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, download_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetCids()) { + optionals.set(0); + } + if (struct.isSetFileName()) { + optionals.set(1); + } + oprot.writeBitSet(optionals, 2); + if (struct.isSetCids()) { + { + oprot.writeI32(struct.cids.size()); + for (int _iter20 : struct.cids) + { + oprot.writeI32(_iter20); + } + } + } + if (struct.isSetFileName()) { + oprot.writeString(struct.fileName); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, download_args struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(2); + if (incoming.get(0)) { + { + org.apache.thrift.protocol.TList _list21 = new org.apache.thrift.protocol.TList(org.apache.thrift.protocol.TType.I32, iprot.readI32()); + struct.cids = new java.util.ArrayList(_list21.size); + int _elem22; + for (int _i23 = 0; _i23 < _list21.size; ++_i23) + { + _elem22 = iprot.readI32(); + struct.cids.add(_elem22); + } + } + struct.setCidsIsSet(true); + } + if (incoming.get(1)) { + struct.fileName = iprot.readString(); + struct.setFileNameIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class download_result implements org.apache.thrift.TBase, java.io.Serializable, Cloneable, Comparable { + private static final org.apache.thrift.protocol.TStruct STRUCT_DESC = new org.apache.thrift.protocol.TStruct("download_result"); + + private static final org.apache.thrift.protocol.TField SUCCESS_FIELD_DESC = new org.apache.thrift.protocol.TField("success", org.apache.thrift.protocol.TType.STRING, (short)0); + + private static final org.apache.thrift.scheme.SchemeFactory STANDARD_SCHEME_FACTORY = new download_resultStandardSchemeFactory(); + private static final org.apache.thrift.scheme.SchemeFactory TUPLE_SCHEME_FACTORY = new download_resultTupleSchemeFactory(); + + public String success; // required + + /** The set of fields this struct contains, along with convenience methods for finding and manipulating them. */ + public enum _Fields implements org.apache.thrift.TFieldIdEnum { + SUCCESS((short)0, "success"); + + private static final java.util.Map byName = new java.util.HashMap(); + + static { + for (_Fields field : java.util.EnumSet.allOf(_Fields.class)) { + byName.put(field.getFieldName(), field); + } + } + + /** + * Find the _Fields constant that matches fieldId, or null if its not found. + */ + public static _Fields findByThriftId(int fieldId) { + switch(fieldId) { + case 0: // SUCCESS + return SUCCESS; + default: + return null; + } + } + + /** + * Find the _Fields constant that matches fieldId, throwing an exception + * if it is not found. + */ + public static _Fields findByThriftIdOrThrow(int fieldId) { + _Fields fields = findByThriftId(fieldId); + if (fields == null) throw new IllegalArgumentException("Field " + fieldId + " doesn't exist!"); + return fields; + } + + /** + * Find the _Fields constant that matches name, or null if its not found. + */ + public static _Fields findByName(String name) { + return byName.get(name); + } + + private final short _thriftId; + private final String _fieldName; + + _Fields(short thriftId, String fieldName) { + _thriftId = thriftId; + _fieldName = fieldName; + } + + public short getThriftFieldId() { + return _thriftId; + } + + public String getFieldName() { + return _fieldName; + } + } + + // isset id assignments + public static final java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> metaDataMap; + static { + java.util.Map<_Fields, org.apache.thrift.meta_data.FieldMetaData> tmpMap = new java.util.EnumMap<_Fields, org.apache.thrift.meta_data.FieldMetaData>(_Fields.class); + tmpMap.put(_Fields.SUCCESS, new org.apache.thrift.meta_data.FieldMetaData("success", org.apache.thrift.TFieldRequirementType.DEFAULT, + new org.apache.thrift.meta_data.FieldValueMetaData(org.apache.thrift.protocol.TType.STRING))); + metaDataMap = java.util.Collections.unmodifiableMap(tmpMap); + org.apache.thrift.meta_data.FieldMetaData.addStructMetaDataMap(download_result.class, metaDataMap); + } + + public download_result() { + } + + public download_result( + String success) + { + this(); + this.success = success; + } + + /** + * Performs a deep copy on other. + */ + public download_result(download_result other) { + if (other.isSetSuccess()) { + this.success = other.success; + } + } + + public download_result deepCopy() { + return new download_result(this); + } + + @Override + public void clear() { + this.success = null; + } + + public String getSuccess() { + return this.success; + } + + public download_result setSuccess(String success) { + this.success = success; + return this; + } + + public void unsetSuccess() { + this.success = null; + } + + /** Returns true if field success is set (has been assigned a value) and false otherwise */ + public boolean isSetSuccess() { + return this.success != null; + } + + public void setSuccessIsSet(boolean value) { + if (!value) { + this.success = null; + } + } + + public void setFieldValue(_Fields field, Object value) { + switch (field) { + case SUCCESS: + if (value == null) { + unsetSuccess(); + } else { + setSuccess((String)value); + } + break; + + } + } + + public Object getFieldValue(_Fields field) { + switch (field) { + case SUCCESS: + return getSuccess(); + + } + throw new IllegalStateException(); + } + + /** Returns true if field corresponding to fieldID is set (has been assigned a value) and false otherwise */ + public boolean isSet(_Fields field) { + if (field == null) { + throw new IllegalArgumentException(); + } + + switch (field) { + case SUCCESS: + return isSetSuccess(); + } + throw new IllegalStateException(); + } + + @Override + public boolean equals(Object that) { + if (that == null) + return false; + if (that instanceof download_result) + return this.equals((download_result)that); + return false; + } + + public boolean equals(download_result that) { + if (that == null) + return false; + if (this == that) + return true; + + boolean this_present_success = true && this.isSetSuccess(); + boolean that_present_success = true && that.isSetSuccess(); + if (this_present_success || that_present_success) { + if (!(this_present_success && that_present_success)) + return false; + if (!this.success.equals(that.success)) + return false; + } + + return true; + } + + @Override + public int hashCode() { + int hashCode = 1; + + hashCode = hashCode * 8191 + ((isSetSuccess()) ? 131071 : 524287); + if (isSetSuccess()) + hashCode = hashCode * 8191 + success.hashCode(); + + return hashCode; + } + + @Override + public int compareTo(download_result other) { + if (!getClass().equals(other.getClass())) { + return getClass().getName().compareTo(other.getClass().getName()); + } + + int lastComparison = 0; + + lastComparison = Boolean.valueOf(isSetSuccess()).compareTo(other.isSetSuccess()); + if (lastComparison != 0) { + return lastComparison; + } + if (isSetSuccess()) { + lastComparison = org.apache.thrift.TBaseHelper.compareTo(this.success, other.success); + if (lastComparison != 0) { + return lastComparison; + } + } + return 0; + } + + public _Fields fieldForId(int fieldId) { + return _Fields.findByThriftId(fieldId); + } + + public void read(org.apache.thrift.protocol.TProtocol iprot) throws org.apache.thrift.TException { + scheme(iprot).read(iprot, this); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot) throws org.apache.thrift.TException { + scheme(oprot).write(oprot, this); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("download_result("); + boolean first = true; + + sb.append("success:"); + if (this.success == null) { + sb.append("null"); + } else { + sb.append(this.success); + } + first = false; + sb.append(")"); + return sb.toString(); + } + + public void validate() throws org.apache.thrift.TException { + // check for required fields + // check for sub-struct validity + } + + private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException { + try { + write(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(out))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, ClassNotFoundException { + try { + read(new org.apache.thrift.protocol.TCompactProtocol(new org.apache.thrift.transport.TIOStreamTransport(in))); + } catch (org.apache.thrift.TException te) { + throw new java.io.IOException(te); + } + } + + private static class download_resultStandardSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public download_resultStandardScheme getScheme() { + return new download_resultStandardScheme(); + } + } + + private static class download_resultStandardScheme extends org.apache.thrift.scheme.StandardScheme { + + public void read(org.apache.thrift.protocol.TProtocol iprot, download_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TField schemeField; + iprot.readStructBegin(); + while (true) + { + schemeField = iprot.readFieldBegin(); + if (schemeField.type == org.apache.thrift.protocol.TType.STOP) { + break; + } + switch (schemeField.id) { + case 0: // SUCCESS + if (schemeField.type == org.apache.thrift.protocol.TType.STRING) { + struct.success = iprot.readString(); + struct.setSuccessIsSet(true); + } else { + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + break; + default: + org.apache.thrift.protocol.TProtocolUtil.skip(iprot, schemeField.type); + } + iprot.readFieldEnd(); + } + iprot.readStructEnd(); + + // check for required fields of primitive type, which can't be checked in the validate method + struct.validate(); + } + + public void write(org.apache.thrift.protocol.TProtocol oprot, download_result struct) throws org.apache.thrift.TException { + struct.validate(); + + oprot.writeStructBegin(STRUCT_DESC); + if (struct.success != null) { + oprot.writeFieldBegin(SUCCESS_FIELD_DESC); + oprot.writeString(struct.success); + oprot.writeFieldEnd(); + } + oprot.writeFieldStop(); + oprot.writeStructEnd(); + } + + } + + private static class download_resultTupleSchemeFactory implements org.apache.thrift.scheme.SchemeFactory { + public download_resultTupleScheme getScheme() { + return new download_resultTupleScheme(); + } + } + + private static class download_resultTupleScheme extends org.apache.thrift.scheme.TupleScheme { + + @Override + public void write(org.apache.thrift.protocol.TProtocol prot, download_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol oprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet optionals = new java.util.BitSet(); + if (struct.isSetSuccess()) { + optionals.set(0); + } + oprot.writeBitSet(optionals, 1); + if (struct.isSetSuccess()) { + oprot.writeString(struct.success); + } + } + + @Override + public void read(org.apache.thrift.protocol.TProtocol prot, download_result struct) throws org.apache.thrift.TException { + org.apache.thrift.protocol.TTupleProtocol iprot = (org.apache.thrift.protocol.TTupleProtocol) prot; + java.util.BitSet incoming = iprot.readBitSet(1); + if (incoming.get(0)) { + struct.success = iprot.readString(); + struct.setSuccessIsSet(true); + } + } + } + + private static S scheme(org.apache.thrift.protocol.TProtocol proto) { + return (org.apache.thrift.scheme.StandardScheme.class.equals(proto.getScheme()) ? STANDARD_SCHEME_FACTORY : TUPLE_SCHEME_FACTORY).getScheme(); + } + } + + public static class QueryImpl implements Iface { + @Override + public int commentSum(int cid) throws TException { + return 0; + } + + @Override + public List commentSumList(List cids) throws TException { + return null; + } + + @Override + public String download(List cids, String fileName) throws TException { + return null; + } + } +} diff --git a/core/src/main/resources/TestQry.thrift b/core/src/main/resources/TestQry.thrift deleted file mode 100644 index 778b237..0000000 --- a/core/src/main/resources/TestQry.thrift +++ /dev/null @@ -1,23 +0,0 @@ -/** -* 文件名为TestQry.thrift -* 实现功能:创建一个查询结果struct和一个服务接口service -* 基于:thrift-0.9.2 -**/ -namespace java com.thrift -struct QryResult { - /** - *返回码, 1成功,0失败 - */ - 1:i32 code; - /** - *响应信息 - */ - 2:string msg; -} -service TestQry{ - /** - * 测试查询接口,当qryCode值为1时返回"成功"的响应信息,qryCode值为其他值时返回"失败"的响应信息 - * @param qryCode测试参数 - */ - QryResult qryTest(1:i32 qryCode) -} \ No newline at end of file diff --git a/db/src/main/java/db/form/PageResult.java b/db/src/main/java/db/form/PageResult.java index 516ab12..4e4f52f 100644 --- a/db/src/main/java/db/form/PageResult.java +++ b/db/src/main/java/db/form/PageResult.java @@ -4,6 +4,10 @@ import db.model.AbstractModel; import java.util.List; +/** + * 分页数据实体 + * @param + */ public class PageResult { private long count; diff --git a/web/src/main/java/web/controller/BaseController.java b/web/src/main/java/web/controller/BaseController.java index c3cfa5a..9013bb1 100644 --- a/web/src/main/java/web/controller/BaseController.java +++ b/web/src/main/java/web/controller/BaseController.java @@ -11,16 +11,16 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.hibernate.criterion.DetachedCriteria; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.core.ResolvableType; import org.springframework.dao.DataAccessException; import org.springframework.http.MediaType; +import org.springframework.util.ClassUtils; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import web.service.BaseService; -import java.lang.reflect.ParameterizedType; - /** * Created by reborn on 2017/9/14. */ @@ -30,17 +30,21 @@ public abstract class BaseController tClass; + private ResolvableType resolvableType=ResolvableType.forClass(ClassUtils.getUserClass(this.getClass())); protected final String tableName; public BaseController() { - TableInfo tableInfo=HibernateConfig.getTableNote(getCommandClass()); - if(tableInfo!=null&&StringUtils.isNotEmpty(tableInfo.comment())){ - tableName=tableInfo.comment(); - }else { - tableName=getCommandClass().getName(); + if(getResolvableType()!=AbstractModel.class){ + TableInfo tableInfo=HibernateConfig.getTableNote(getResolvableType()); + if(tableInfo!=null&&StringUtils.isNotEmpty(tableInfo.comment())){ + tableName=tableInfo.comment(); + }else { + tableName=getResolvableType().getName(); + } + }else{ + tableName=null; } } @@ -79,20 +83,16 @@ public abstract class BaseController getCommandClass(){ -// log.info(ResolvableType.forField(ReflectionUtils.findField(this.getClass(),"service"))); - if(tClass==null){ - if(this.getClass().getGenericSuperclass() instanceof ParameterizedType){ - tClass=(Class) ((ParameterizedType)this.getClass().getGenericSuperclass()).getActualTypeArguments()[0]; - }else{ - tClass= (Class) AbstractModel.class; - } - } - return tClass; + public Class getResolvableType() { + return getResolvableType(0); + } + + public Class getResolvableType(int index) { + return resolvableType.getSuperType().getGeneric(index).resolve(); } protected DetachedCriteria getDetachedCriteria(A queryCommand){ - return DetachedCriteria.forClass(getCommandClass()); + return DetachedCriteria.forClass(getResolvableType()); } protected abstract boolean checkAction(DBAction action); diff --git a/web/src/main/java/web/controller/DataController.java b/web/src/main/java/web/controller/DataController.java index ad256db..42858be 100644 --- a/web/src/main/java/web/controller/DataController.java +++ b/web/src/main/java/web/controller/DataController.java @@ -1,50 +1,89 @@ package web.controller; +import core.thrift.ThriftClientDemo; import db.form.DBAction; -import db.form.PageResult; import db.model.bilibili.DataModel; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.MatchMode; import org.hibernate.criterion.Property; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import web.html.data.DataTable; +import web.html.data.OtherDataResult; import web.model.DataModelForm; import web.service.DataService; import javax.servlet.http.HttpSession; +import java.io.File; import java.io.IOException; +import java.lang.reflect.InvocationTargetException; import java.nio.charset.Charset; +import java.util.ArrayList; import java.util.EnumSet; import java.util.List; @Controller @RequestMapping("/data") -public class DataController extends TableController { +public class DataController extends TableController> { - private final String regionJson=IOUtils.toString(DataController.class.getResourceAsStream("/region.json"), Charset.forName("UTF-8")); + private final String regionJson = IOUtils.toString(DataController.class.getResourceAsStream("/region.json"), Charset.forName("UTF-8")); public DataController() throws IOException { } @RequestMapping - public String find(HttpSession session,Model model) { - session.setAttribute("regionJson",regionJson); - return super.find(model,new DataModelForm(),new PageResult(0,10)); + public String find(HttpSession session, Model model) throws InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException { + session.setAttribute("regionJson", regionJson); + return super.find(model, new DataModelForm(), new DataTable<>(0, 10)); } @RequestMapping("start/{size}") - public void start(@PathVariable Integer size){ + public void start(@PathVariable Integer size) { stop(); service.start(size); } + @ResponseBody + @RequestMapping(value = "count/{cid}") + public Integer count(@PathVariable int cid) { +// try { +// return ThriftClientDemo.commentSum(cid); +// }catch (Exception e){ +// log.error(e); +// } + return null; + } + + @RequestMapping("download") + public ResponseEntity export(DataModelForm form) throws Exception { + if(StringUtils.isNotEmpty(form.getFileName())&&form.getCids()!=null&&!form.getCids().isEmpty()) { + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); + headers.setContentDispositionFormData("attachment", form.getFileName()+".zip"); + String filePath=ThriftClientDemo.downloadXml(form.getCids(),form.getFileName()); + if(filePath!=null) { + return new ResponseEntity<>(FileUtils.readFileToByteArray(new File(filePath)), headers, HttpStatus.CREATED); + }else{ + return new ResponseEntity<>("弹幕下载失败", HttpStatus.INTERNAL_SERVER_ERROR); + } + }else{ + return new ResponseEntity("参数异常",HttpStatus.BAD_REQUEST); + } + } + @RequestMapping("stop") - public void stop(){ + public void stop() { service.stop(); } @@ -55,9 +94,9 @@ public class DataController extends TableController otherDatas(DataModelForm command) { + return new ArrayList(){{ + add(new OtherDataResult()); + }}; + } } diff --git a/web/src/main/java/web/controller/TableController.java b/web/src/main/java/web/controller/TableController.java index 6bfad19..e3bf01a 100644 --- a/web/src/main/java/web/controller/TableController.java +++ b/web/src/main/java/web/controller/TableController.java @@ -1,40 +1,48 @@ package web.controller; import db.form.DBAction; -import db.form.PageResult; import db.form.Type; import db.model.AbstractModel; import org.springframework.dao.DataAccessException; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.RequestMapping; +import web.html.OtherResult; +import web.html.Table; import web.service.BaseService; +import java.lang.reflect.InvocationTargetException; import java.util.List; -public abstract class TableController extends BaseController { +public abstract class TableController> extends BaseController { + private static final String otherColumns="otherColumns"; + + private static final int typeIndex=4; @RequestMapping("table") - public String find(Model model,@ModelAttribute("command") A command,PageResult pageResult){ + public String find(Model model,@ModelAttribute("command") A command,B pageResult) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + + DBAction action=DBAction.R; log.info(tableName+ "进行批量" + action.getCh() + "操作请求"); - PageResult result; + B result; if(checkAction(action)) { try { Long rowCount=rowCount(command); if(rowCount>0) { List list = find(command, pageResult.getCurrentPage()*pageResult.getPageSize(), pageResult.getPageSize()); - result=new PageResult(rowCount, pageResult.getCurrentPage(),list,pageResult.getPageSize() , Type.success); + List otherDatas= otherDatas(command); + result= (B) getResolvableType(typeIndex).getConstructor(long.class,int.class,List.class,int.class,Type.class,List.class).newInstance(rowCount, pageResult.getCurrentPage(),list,pageResult.getPageSize() , Type.success,otherDatas); }else{ - result=new PageResult(Type.fail,"没有记录"); + result= (B) getResolvableType(typeIndex).getConstructor(Type.class,String.class).newInstance(Type.fail,"没有记录"); } } catch (DataAccessException e) { log.error(e); - result=new PageResult(Type.fail,"非法操作"); + result= (B) getResolvableType(typeIndex).getConstructor(Type.class,String.class).newInstance(Type.fail,"非法操作"); } }else{ - result=new PageResult(Type.fail,tableName + "不允许" + action.getCh() + "操作"); + result= (B) getResolvableType(typeIndex).getConstructor(Type.class,String.class).newInstance(Type.fail,tableName + "不允许" + action.getCh() + "操作"); } model.addAttribute("datas", result); @@ -54,4 +62,13 @@ public abstract class TableController otherDatas(A command){ + return null; + } + } diff --git a/web/src/main/java/web/html/OtherResult.java b/web/src/main/java/web/html/OtherResult.java new file mode 100644 index 0000000..fd4e364 --- /dev/null +++ b/web/src/main/java/web/html/OtherResult.java @@ -0,0 +1,5 @@ +package web.html; + +public interface OtherResult { + +} diff --git a/web/src/main/java/web/html/Table.java b/web/src/main/java/web/html/Table.java new file mode 100644 index 0000000..e781a57 --- /dev/null +++ b/web/src/main/java/web/html/Table.java @@ -0,0 +1,69 @@ +package web.html; + +import db.form.PageResult; +import db.form.Type; +import db.model.AbstractModel; + +import java.util.List; + +public abstract class Table extends PageResult implements TableResult{ + + + private static String importJspPath; + + private static List titles; + + private static List otherTitles; + + private static List columns; + + private List otherData; + + public Table() { + } + + public Table(int currentPage, int pageSize) { + super(currentPage, pageSize); + } + + public Table(long count, int currentPage, List datas, int pageSize, Type type,List otherData) { + super(count, currentPage, datas, pageSize, type); + this.otherData = otherData; + } + + public Table(Type type, String errorMsg) { + super(type, errorMsg); + } + + public String getImportJspPath() { + if(importJspPath==null){ + importJspPath=importJspPath(); + } + return importJspPath; + } + + public List getTitles() { + if(titles==null){ + titles=titles(); + } + return titles; + } + + public List getOtherTitles() { + if(otherTitles==null){ + otherTitles=otherTitles(); + } + return otherTitles; + } + + public List getColumns() { + if(columns==null){ + columns=columns(); + } + return columns; + } + + public List getOtherData() { + return otherData; + } +} diff --git a/web/src/main/java/web/html/TableResult.java b/web/src/main/java/web/html/TableResult.java new file mode 100644 index 0000000..76f2b9b --- /dev/null +++ b/web/src/main/java/web/html/TableResult.java @@ -0,0 +1,29 @@ +package web.html; + +import java.util.List; + +public interface TableResult { + /** + * jsp路径 + * @return + */ + String importJspPath(); + + /** + * 显示列名 + * @return + */ + List titles(); + + /** + * 显示实体属性 + * @return + */ + List columns(); + + /** + * 显示其他列名 + * @return + */ + List otherTitles(); +} diff --git a/web/src/main/java/web/html/data/DataTable.java b/web/src/main/java/web/html/data/DataTable.java new file mode 100644 index 0000000..85710c4 --- /dev/null +++ b/web/src/main/java/web/html/data/DataTable.java @@ -0,0 +1,62 @@ +package web.html.data; + +import db.form.Type; +import db.model.bilibili.DataModel; +import web.html.Table; + +import java.util.ArrayList; +import java.util.List; + +public class DataTable extends Table { + + + + public DataTable(int currentPage, int pageSize) { + super(currentPage, pageSize); + } + + public DataTable(long count, int currentPage, List datas, int pageSize, Type type, List otherData) { + super(count, currentPage, datas, pageSize, type, otherData); + } + + public DataTable(Type type, String errorMsg) { + super(type, errorMsg); + } + + public DataTable(){ + + } + + @Override + public String importJspPath() { + return "data/"; + } + + @Override + public List titles() { + return new ArrayList() {{ + add("弹幕编号"); + add("AV号"); + add("视频标题"); + add("视频副标题"); + }}; + } + + @Override + public List columns() { + return new ArrayList() {{ + add("cid"); + add("aid"); + add("title"); + add("subtitle"); + }}; + } + + @Override + public List otherTitles() { + return new ArrayList() {{ + add("弹幕数"); + }}; + } + +} diff --git a/web/src/main/java/web/html/data/OtherDataResult.java b/web/src/main/java/web/html/data/OtherDataResult.java new file mode 100644 index 0000000..e0ceab8 --- /dev/null +++ b/web/src/main/java/web/html/data/OtherDataResult.java @@ -0,0 +1,7 @@ +package web.html.data; + +import web.html.OtherResult; + +public class OtherDataResult implements OtherResult { + +} diff --git a/web/src/main/java/web/model/DataModelForm.java b/web/src/main/java/web/model/DataModelForm.java index e57dc45..f1839b1 100644 --- a/web/src/main/java/web/model/DataModelForm.java +++ b/web/src/main/java/web/model/DataModelForm.java @@ -1,10 +1,16 @@ package web.model; +import db.model.bilibili.DataModel; + import java.util.List; -public class DataModelForm extends db.model.bilibili.DataModel { +public class DataModelForm extends DataModel { private List typeIds; + private List cids; + + private String fileName; + public List getTypeIds() { return typeIds; } @@ -12,4 +18,20 @@ public class DataModelForm extends db.model.bilibili.DataModel { public void setTypeIds(List typeIds) { this.typeIds = typeIds; } + + public List getCids() { + return cids; + } + + public void setCids(List cids) { + this.cids = cids; + } + + public String getFileName() { + return fileName; + } + + public void setFileName(String fileName) { + this.fileName = fileName; + } } diff --git a/web/src/main/webapp/WEB-INF/jsp/form.jsp b/web/src/main/webapp/WEB-INF/jsp/data/form.jsp similarity index 83% rename from web/src/main/webapp/WEB-INF/jsp/form.jsp rename to web/src/main/webapp/WEB-INF/jsp/data/form.jsp index 79a3979..2ef1de0 100644 --- a/web/src/main/webapp/WEB-INF/jsp/form.jsp +++ b/web/src/main/webapp/WEB-INF/jsp/data/form.jsp @@ -65,7 +65,10 @@
- + +
+
+
@@ -110,10 +113,22 @@ $(".dropdown-item[data-type="+$(this).data("type")+"]").show(); }); - $(".btn-secondary").click(function () { - + $("#query,#pageButton button").click(function () { $("#pageForm").attr("action","/data/table?currentPage="+($(this).val()==''?0:$(this).val())+"&pageSize=${datas.pageSize}").submit(); + }); + $("#download").click(function(){ + if($("input[name=cids]:not([disabled]):checked").length==0){ + alert("清选中需要下载的弹幕"); + return; + } + var fileNmae; + if($("#query").val()!=''){ + fileNmae=$("#query").val(); + }else{ + fileNmae=new Date().getTime(); + } + $("#pageForm").attr("action","/data/download?fileName="+fileNmae).submit(); }); }); diff --git a/web/src/main/webapp/WEB-INF/jsp/data/otherData.jsp b/web/src/main/webapp/WEB-INF/jsp/data/otherData.jsp new file mode 100644 index 0000000..5810268 --- /dev/null +++ b/web/src/main/webapp/WEB-INF/jsp/data/otherData.jsp @@ -0,0 +1,56 @@ +<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> +<%-- + Created by IntelliJ IDEA. + User: 10295 + Date: 2018/6/3 + Time: 20:55 + To change this template use File | Settings | File Templates. +--%> + +<%@ page pageEncoding="utf-8" %> + + + + + + + + + 获取中 + + + + + diff --git a/web/src/main/webapp/WEB-INF/jsp/table.jsp b/web/src/main/webapp/WEB-INF/jsp/table.jsp index abc1981..91c1909 100644 --- a/web/src/main/webapp/WEB-INF/jsp/table.jsp +++ b/web/src/main/webapp/WEB-INF/jsp/table.jsp @@ -5,6 +5,21 @@ <%@ page pageEncoding="utf-8" %> + + + + @@ -14,30 +29,79 @@ - + - - - - - + + + + + + + + + + + + + + + + + + + 没有设置标题显示 + + + + - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + 没有设置列数据显示 + + +
cidaidtitlesubtitleauthor +
+ + ${datas.titles[0]} + +
+
${title}${title}
${data.cid}${data.aid}${data.title}${data.subtitle}${data.author}
+
+ + +
+
${data[column]}
diff --git a/web/src/main/webapp/WEB-INF/jsp/test.jsp b/web/src/main/webapp/WEB-INF/jsp/test.jsp index b6c1117..740a5e0 100644 --- a/web/src/main/webapp/WEB-INF/jsp/test.jsp +++ b/web/src/main/webapp/WEB-INF/jsp/test.jsp @@ -26,7 +26,7 @@
- +
diff --git a/web/src/test/java/SpringTest.java b/web/src/test/java/SpringTest.java index 17c6dcd..bf138d5 100644 --- a/web/src/test/java/SpringTest.java +++ b/web/src/test/java/SpringTest.java @@ -63,7 +63,7 @@ public class SpringTest { @Test public void test() throws Exception { - ResultActions resultActions = this.mockMvc.perform(MockMvcRequestBuilders.get("/data/table").param("firstResult", "0").param("maxResults", "10").param("typeIds","123").param("typeIds","456")); + ResultActions resultActions = this.mockMvc.perform(MockMvcRequestBuilders.get("/data/table").param("firstResult", "0").param("maxResults", "10").param("cids","49052").param("typeIds","33")); resultActions.andDo(MockMvcResultHandlers.print()).andReturn(); } @@ -98,5 +98,10 @@ public class SpringTest { biliService.getHibernateTemplate(); } + @Test + public void test6() throws Exception { + ResultActions resultActions = this.mockMvc.perform(MockMvcRequestBuilders.get("/data/count").param("cids","49052")); + resultActions.andDo(MockMvcResultHandlers.print()).andReturn(); + } }