using Furion;
using Mapster;
using Nirvana.Common;
using YBDevice.Entity;
using YBDevice.NApi.Application.UserInfo;

namespace YBDevice.Application
{
    public class Mapper : IRegister
    {
        private static string APICDNURL = App.Configuration["APICDNURL"];//API图片CDN地址
        /// <summary>
        /// 自定义映射
        /// </summary>
        /// <param name="config"></param>
        public void Register(TypeAdapterConfig config)
        {
            //config.ForType<Entity, Dto>()
            //   .Map(dest => dest.FullName, src => src.FirstName + src.LastName)
            //   .Map(dest => dest.IdCard, src => src.IdCard.Replace("1234", "****"));
            config.ForType<BodyMeasureHisList, BodyMeasureHisListDto>()
               .Map(dest => dest.time, src => src.time.ToYearDateTime())
               .Map(dest=>dest.age,src=>$"{src.age}岁")
               ;
            //用户使用过的设备类型
            config.ForType<YB_DeviceTypeExt, UserDevTypeS2CDto>()
               .Map(dest => dest.HeadImg, src => $"{APICDNURL}{src.HeadImg}")
               ;
        }
    }
}
