1.0.0版本更新

This commit is contained in:
zenghao
2016-09-11 21:37:13 +08:00
parent 7ea3d29b60
commit d0ac51a059
5 changed files with 421 additions and 0 deletions
@@ -0,0 +1,85 @@
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.roncoo.pay.common.core.entity;
import com.alibaba.fastjson.JSONObject;
/**
* api请求正常返回结果,该实体作为API请求时,按照规范返回的实体. code 为返回码 msg 为返回描述 data 为返回的具体结果 Created
* 龙果学院:www.roncoo.com
* @author zenghao
*/
public class ApiCommonResultVo {
public ApiCommonResultVo(int code, String msg, Object data) {
this.code = code;
this.msg = msg;
if (data != null) {
this.data = data;
}
}
public ApiCommonResultVo(Object data) {
this.code = 0;
this.msg = "";
if (data != null) {
this.data = data;
}
}
/**
* 返回码
*/
private int code;
/**
* 返回描述
*/
private String msg = "";
/**
* 返回数据
*/
private Object data = new Object();
public void setCode(int code) {
this.code = code;
}
public void setMsg(String msg) {
this.msg = msg;
}
public void setData(Object data) {
this.data = data;
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
public Object getData() {
return data;
}
public static void main(String[] args) {
System.out.println(JSONObject.toJSONString(new ApiCommonResultVo(-1, "", null)));
}
}
@@ -0,0 +1,83 @@
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.roncoo.pay.common.core.entity;
import com.alibaba.fastjson.JSONObject;
import java.util.ArrayList;
/**
* API请求,返回分页数据时,统一实体类,将返回的数据统一封装到该实体中,返回给客户端
* 龙果学院:www.roncoo.com
* @author zenghao
*/
public class ApiPageListResultVo {
/**
* 返回码
*/
private int code;
/**
* 返回描述
*/
private String msg = "";
/**
* 返回分页数据,默认为0页0条
*/
private PageListVO data = new PageListVO(0,0,0,new ArrayList<rpObject>());
public void setCode(int code) {
this.code = code;
}
public void setMsg(String msg) {
this.msg = msg;
}
public void setData(PageListVO data) {
this.data = data;
}
public int getCode() {
return code;
}
public String getMsg() {
return msg;
}
public PageListVO getData() {
return data;
}
public static void main(String [] args ){
ApiPageListResultVo apiPageListResultVo = new ApiPageListResultVo();
apiPageListResultVo.setCode(-1);
apiPageListResultVo.setMsg("测试数据");
PageListVO pageListVO = new PageListVO(0,2,33,new ArrayList<Object>());
apiPageListResultVo.setData(pageListVO);
System.out.println(JSONObject.toJSONString(apiPageListResultVo));
}
}
@@ -0,0 +1,107 @@
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.roncoo.pay.common.core.entity;
import java.util.ArrayList;
import java.util.List;
/**
* 返回的分页实体
* 龙果学院:www.roncoo.com
* @author zenghao
*/
public class PageListVO {
/** 总数量 **/
private long total ;
/** 页码 **/
private int page;
/** 每页条数 **/
private int pageSize;
/** 分页数据 **/
private List pageData = new ArrayList();
/**
* 汇总数据
*/
private Object summary;
public PageListVO(long total , int page , int pageSize , List pageData){
this.total = total;
this.page = page;
this.pageSize = pageSize;
if (pageData != null){
this.pageData = pageData;
}
}
public PageListVO(long total , int page , int pageSize , List pageData, Object summary){
this.total = total;
this.page = page;
this.pageSize = pageSize;
this.summary = summary;
if (pageData != null){
this.pageData = pageData;
}
}
public Object getSummary() {
return summary;
}
public void setSummary(Object summary) {
this.summary = summary;
}
public void setTotal(int total) {
this.total = total;
}
public void setPage(int page) {
this.page = page;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public void setPageData(List pageData) {
this.pageData = pageData;
}
public long getTotal() {
return total;
}
public int getPage() {
return page;
}
public int getPageSize() {
return pageSize;
}
public List getPageData() {
return pageData;
}
}
@@ -0,0 +1,25 @@
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.roncoo.pay.common.core.entity;
import java.io.Serializable;
/**
* 龙果学院:www.roncoo.com
* @author zenghao
*/
public class rpObject extends Object implements Serializable {
}
@@ -0,0 +1,121 @@
/*
* Copyright 2015-2102 RonCoo(http://www.roncoo.com) Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.roncoo.pay.common.core.utils;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* 加密工具类
* @company:广州领课网络科技有限公司(龙果学院 www.roncoo.com).
* @author zenghao
*/
public class EncryptUtil {
private static final Log LOG = LogFactory.getLog(EncryptUtil.class);
// 密码盐
public static final String PWDSALT = "PAY";
/**
* 私有构造方法,将该工具类设为单例模式.
*/
private EncryptUtil() {
}
/**
* 用MD5算法进行加密
*
* @param str
* 需要加密的字符串
* @return MD5加密后的结果
*/
public static String encodeMD5String(String str) {
return encode(str, "MD5");
}
/**
* 用SHA算法进行加密
*
* @param str
* 需要加密的字符串
* @return SHA加密后的结果
*/
public static String encodeSHAString(String str) {
return encode(str, "SHA");
}
/**
* 用base64算法进行加密
*
* @param str
* 需要加密的字符串
* @return base64加密后的结果
*/
public static String encodeBase64String(String str) {
BASE64Encoder encoder = new BASE64Encoder();
return encoder.encode(str.getBytes());
}
/**
* 用base64算法进行解密
*
* @param str
* 需要解密的字符串
* @return base64解密后的结果
* @throws IOException
*/
public static String decodeBase64String(String str) throws IOException {
BASE64Decoder encoder = new BASE64Decoder();
return new String(encoder.decodeBuffer(str));
}
private static String encode(String str, String method) {
MessageDigest mdInst = null;
// 把密文转换成十六进制的字符串形式
// 单线程用StringBuilder,速度快 多线程用stringbuffer,安全
StringBuilder dstr = new StringBuilder();
try {
// 获得MD5摘要算法的 MessageDigest对象
mdInst = MessageDigest.getInstance(method);
// 使用指定的字节更新摘要
mdInst.update(str.getBytes());
// 获得密文
byte[] md = mdInst.digest();
for (int i = 0; i < md.length; i++) {
int tmp = md[i];
if (tmp < 0) {
tmp += 256;
}
if (tmp < 16) {
dstr.append("0");
}
dstr.append(Integer.toHexString(tmp));
}
} catch (NoSuchAlgorithmException e) {
LOG.error(e);
}
return dstr.toString();
}
}