All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.luues.util.datawrap.ResultDataWrap Maven / Gradle / Ivy

There is a newer version: 1.3.0.5.RELEASE
Show newest version
package com.luues.util.datawrap;

import java.io.Serializable;
import java.lang.reflect.Field;

/**
 * 功能:公共返回结果
 * 作者:Mr-Wu
 * 日期:01-12-2016
 */
public class ResultDataWrap extends DataWrap implements Serializable{

	public ResultDataWrap() {
		super();
	}

	public ResultDataWrap(int resultCode) {
		this.resultCode = resultCode;
		resh();
	}

	public ResultDataWrap(int resultCode, String resultMsg) {
		this.resultCode = resultCode;
		this.resultMsg = resultMsg;
		resh();
	}

	public int getResultCode() {
		return this.resultCode;
	}

	public void setResultCode(int resultCode) {
		this.resultCode = resultCode;
		resh();
	}

	public String getResultMsg() {
		return this.resultMsg;
	}

	public void setResultMsg(String resultMsg) {
		this.resultMsg = resultMsg;
		resh();
	}

	public Object getData() {
		return this.get("rows");
	}

	public void putData(Object value){
		this.put("rows", value);
	}

	/*public String toString(){
		JSONObject obj = new JSONObject();
		obj.put(ResultCode.code_key, this.resultCode);
		obj.put("total", this.total);
		if(this.total > 0){
			obj.put("currPage", ResultCode.getCurrPage());
			obj.put("pageSize", ResultCode.getPageSize());
			obj.put("pageCount", this.total == 0 ? 1 : this.total % ResultCode.getPageSize() == 0 ? this.total / ResultCode.getPageSize() : this.total / ResultCode.getPageSize() + 1);
		}
		obj.put("message", this.resultMsg);
		obj.put("msg", this.resultMsg);
		obj.put("data", this.data);
		obj.put("time", new Date().getTime());
		String callback = null;
		if(!TypeConvert.isNull(RequestContextHolder.getRequestAttributes())){
			try{
				callback = TypeConvert.StringToTrim(((ServletRequestAttributes)RequestContextHolder.getRequestAttributes()).getRequest().getParameter("callback"));
			}catch (Exception e){}
		}
		if(!TypeConvert.isNull(callback)){
			return callback + "(" + ResultCode.chinaToUnicode(obj.toString()) + ")";
		}
		return ResultCode.chinaToUnicode(obj.toString());
	}*/

	private void resh(){
		Field[] fields = this.getClass().getDeclaredFields();
		for(int i=0;i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy