1. 程式人生 > 實用技巧 >yb 課堂實戰之視訊列表介面開發+API許可權路徑規劃 《三》

yb 課堂實戰之視訊列表介面開發+API許可權路徑規劃 《三》

開發JsonData工具類

package net.ybclass.online_ybclass.utils;

public class JsonData {
    /**
     * 狀態碼,0表示成功過,1表示處理中,-1表示失敗
     */
    private Integer code;
    /**
     * 業務資料
     */
    private Object data;
    /**
     * 資訊描述
     */
    private String msg;

    public JsonData() {
    }

    public JsonData(Integer code, Object data, String msg) {
        
this.code = code; this.data = data; this.msg = msg; } /** * 成功,不用返回資料 * @return */ public static JsonData buildSuccess() { return new JsonData(0, null, null); } /** * 成功,返回資料 * @param data 返回資料 * @return */ public static
JsonData buildSuccess(Object data) { return new JsonData(0, data, null); } /** * 失敗,返回資訊 * @param msg 返回資訊 * @return */ public static JsonData buildError(String msg) { return new JsonData(-1, null, msg); } /** * 失敗,返回資訊和狀態碼 * @param code 狀態碼 *
@param msg 返回資訊 * @return */ public static JsonData buildError(Integer code, String msg) { return new JsonData(code, null, msg); } public Integer getCode() { return code; } public void setCode(Integer code) { this.code = code; } public Object getData() { return data; } public void setData(Object data) { this.data = data; } public String getMsg() { return msg; } public void setMsg(String msg) { this.msg = msg; } }

修改Controller層

規劃api許可權路徑

  • api/v1/pub/video/xxx 這個是不需要登陸
  • api/v1/pri/video/xxx 這個是需要登陸