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

namespace YBDevice.Api.Controllers
{
    /// <summary>
    /// 家庭成员管理
    /// </summary>
    public class FamilyController : BaseController
    {
        /// <summary>
        /// 家庭成员列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> GetListAsync()
        {
            return await new FamilyApp().GetListAsync();
        }

        /// <summary>
        /// 家庭成员信息修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> SubmitAsync([FromBody] FamilySubmitModel model)
        {
            return await new FamilyApp().SubmitAsync(model);
        }
        /// <summary>
        /// 删除家庭成员
        /// </summary>
        /// <param name="id">家庭成员ID</param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> DeleteAsync(int id)
        {
            return await new FamilyApp().DeleteAsync(id);
        }
        /// <summary>
        /// 家庭成员详情
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ResultInfo> DetailAsync(int id)
        {
            return await new FamilyApp().DetailAsync(id);
        }
        /// <summary>
        /// 设置目标体重
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> SetTargetAsync([FromBody] YB_FamilyTarget model)
        {
            return await new FamilyApp().SetTargetAsync(model);
        }
        /// <summary>
        /// 获取指定家庭成员的历史记录
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultInfo> GetHistoryListAsync([FromBody] ParamQuery model)
        {
            var data= await new ResultApp().GetHistoryListAsync(model);
            return new ResultInfo(ResultState.SUCCESS, "success", data);
        }
    }
}
