Ejemplo n.º 1
0
        public async Task <ApiResult <BlogArticleWebModel> > GetById(int id)
        {
            var r = new ApiResult <BlogArticleWebModel>();

            try
            {
                var entity = await _blogArticleServices.GetById(id);

                if (entity != null)
                {
                    r.msg  = "查询成功";
                    r.data = _mapper.Map <BlogArticleWebModel>(entity);
                }
                else
                {
                    r.status = 404;
                    r.msg    = "未匹配到数据";
                }
            }
            catch (Exception ex)
            {
                r.status = 500;
                r.msg    = ex.Message;
            }
            return(r);
        }