新增媒体文件上传、下载结果类 & 精简函数上的@link注释

This commit is contained in:
jinyu
2015-07-25 22:48:34 +08:00
parent 9e982ca3f7
commit 30b64dc54a
26 changed files with 442 additions and 158 deletions
@@ -178,7 +178,7 @@ public class Pay3Api {
* 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY
* @param opUserId
* 操作员帐号, 默认为商户号
* @see {@link com.foxinmy.weixin4j.api.Pay3Api#refundApply(InputStream, IdQuery, String, double, double, String, Map)}
* @see {@link #refundApply(InputStream, IdQuery, String, double, double, String, Map)}
*/
public RefundResult refundApply(InputStream ca, IdQuery idQuery,
String outRefundNo, double totalFee, double refundFee,
@@ -0,0 +1,58 @@
package com.foxinmy.weixin4j.model;
import java.io.Serializable;
import java.util.Arrays;
import com.foxinmy.weixin4j.http.ContentType;
/**
* 媒体文件下载结果
*
* @className MediaDownloadResult
* @author jy
* @date 2015年7月25日
* @since JDK 1.7
* @see
*/
public class MediaDownloadResult implements Serializable {
private static final long serialVersionUID = -7090523911701729058L;
/**
* 内容
*/
private byte[] content;
/**
* 类型
*/
private ContentType contentType;
/**
* 文件名
*/
private String fileName;
public byte[] getContent() {
return content;
}
public ContentType getContentType() {
return contentType;
}
public String getFileName() {
return fileName;
}
public MediaDownloadResult(byte[] content, ContentType contentType,
String fileName) {
this.content = content;
this.contentType = contentType;
this.fileName = fileName;
}
@Override
public String toString() {
return "MediaDownloadResult [content=" + Arrays.toString(content)
+ ", contentType=" + contentType + ", fileName=" + fileName
+ "]";
}
}
@@ -0,0 +1,52 @@
package com.foxinmy.weixin4j.model;
import java.io.Serializable;
import java.util.Date;
import com.alibaba.fastjson.annotation.JSONCreator;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.MediaType;
/**
* 媒体文件上传结果
*
* @className MediaUploadResult
* @author jy
* @date 2015年7月25日
* @since JDK 1.7
* @see
*/
public class MediaUploadResult implements Serializable {
private static final long serialVersionUID = -620630472640999536L;
private String mediaId;
private MediaType mediaType;
private Date createdAt;
@JSONCreator
public MediaUploadResult(@JSONField(name = "media_id") String mediaId,
@JSONField(name = "type") MediaType mediaType,
@JSONField(name = "created_at") Date createdAt) {
this.mediaId = mediaId;
this.mediaType = mediaType;
this.createdAt = createdAt;
}
public String getMediaId() {
return mediaId;
}
public MediaType getMediaType() {
return mediaType;
}
public Date getCreatedAt() {
return createdAt;
}
@Override
public String toString() {
return "MediaUploadResult [mediaId=" + mediaId + ", mediaType=" + mediaType
+ ", createdAt=" + createdAt + "]";
}
}
@@ -267,7 +267,7 @@ public class PayUtil {
* @param weixinAccount
* 商户信息
* @return 支付的订单信息
* @see {@link com.foxinmy.weixin4j.payment.PayUtil#createMicroPay(MicroPayPackage, WeixinPayAccount)}
* @see {@link #createMicroPay(MicroPayPackage, WeixinPayAccount)}
* @throws WeixinException
*/
public static Order createMicroPay(String authCode, String body,
@@ -146,7 +146,7 @@ public class WeixinPayProxy {
*
* @throws IOException
*
* @see {@link com.foxinmy.weixin4j.payment.WeixinPayProxy#refund(InputStream, IdQuery, String, double, double,CurrencyType, String)}
* @see {@link #refundApply(InputStream, IdQuery, String, double, double,CurrencyType, String)}
*/
public com.foxinmy.weixin4j.payment.mch.RefundResult refundApply(
IdQuery idQuery, String outRefundNo, double totalFee,
@@ -233,7 +233,7 @@ public class WeixinPayProxy {
* @param idQuery
* transaction_id、out_trade_no 二选一
* @return 撤销结果
* @see {@link com.foxinmy.weixin4j.mp.WeixinProxy#reverse(InputStream, IdQuery)}
* @see {@link #reverseOrder(InputStream, IdQuery)}
* @throws WeixinException
* @throws IOException
*/
@@ -124,4 +124,22 @@ public class FileUtil {
}
return fileType;
}
/**
* 获取文件后缀
*
* @param fileName
* @return
*/
public static String getFileExtension(String fileName) {
int extensionPos = fileName.lastIndexOf(".");
if (extensionPos < 0) {
return "";
}
int lastUnixPos = fileName.lastIndexOf("/");
int lastWindowsPos = fileName.lastIndexOf("\\");
int lastSeparator = Math.max(lastUnixPos, lastWindowsPos);
return lastSeparator > extensionPos ? "" : fileName
.substring(extensionPos + 1);
}
}
@@ -68,16 +68,4 @@ public class IOUtil {
}
return count;
}
public static String getExtension(String filename) {
int extensionPos = filename.lastIndexOf(".");
if (extensionPos < 0) {
return "";
}
int lastUnixPos = filename.lastIndexOf("/");
int lastWindowsPos = filename.lastIndexOf("\\");
int lastSeparator = Math.max(lastUnixPos, lastWindowsPos);
return lastSeparator > extensionPos ? "" : filename
.substring(extensionPos + 1);
}
}