<?php

namespace app\controller;

use think\response\Json;

trait ResponseJson
{
    public function JsonSucess($data,$code=1): Json
    {
        return $this->JsonResponse($code,config("ResponseCode.".$code),$data);
    }
    public function JsonError($code=0): Json
    {
        return $this->JsonResponse($code,config("ResponseCode.".$code));
    }
    public function JsonResponse($code,$message,$data=[]): Json
    {
        return json(["code"=>$code,"data"=>$data,"message"=>$message]);
    }
}