using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Nirvana.Common.ApiBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace YBDevice.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [ApiAuthorizeFilter]
    public class BaseController : ControllerBase
    {
        protected virtual ResultInfo ResultJson(int code, string message, object data)
        {
            return new ResultInfo(code, message, data);
        }

        protected virtual ResultInfo SuccessMessage(string message)
        {
            return new ResultInfo(ResultState.SUCCESS, message);
        }

        protected virtual ResultInfo Success(object data, string message = "success")
        {
            return new ResultInfo(ResultState.SUCCESS, message, data);
        }

        protected virtual ResultInfo Fail(string message = "fail")
        {
            return new ResultInfo(ResultState.FAIL, message);
        }
    }
}
