| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- package com.goafanti.common.bo;
- import org.apache.shiro.SecurityUtils;
- import java.io.Serializable;
- import java.util.ArrayList;
- import java.util.List;
- /**
- *
- * @param <T> 在Controller里面设置返回对象就可以用apipost读取到
- */
- public class Result<T> {
- private T data;
- private List<Error> error = new ArrayList<Error>();
- private String token;
- public Result() {
- this.token = (String) SecurityUtils.getSubject().getSession().getId();
- }
- public Result(T data) {
- this.data = data;
- }
- /**
- * @return the data
- */
- public T getData() {
- return data;
- }
- /**
- * @param data
- * the data to set
- */
- public void setData(T data) {
- this.data = data;
- }
- /**
- * @return the error
- */
- public List<Error> getError() {
- return error;
- }
- /**
- * @param error
- * the error to set
- */
- public void setError(List<Error> error) {
- this.error = error;
- }
- public Result<T> error(Error e) {
- if (e != null) {
- this.error.add(e);
- }
- return this;
- }
- public Result<T> data(T o) {
- this.data = o;
- return this;
- }
- public Serializable getToken() {
- return token;
- }
- public void setToken(String token) {
- this.token = token;
- }
- }
|