/// <summary> /// 修改 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <bool> UpdateAsync(RichtextModel richtextModel, CourseModel model) { return(await MySqlHelper.TransactionAsync(async (conn, t) => { await conn.UpdateAsync(richtextModel); await conn.UpdateAsync(model); return true; })); }
/// <summary> /// 修改富文本model /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <bool> UpdateAsync(RichtextModel model) { using (var conn = MySqlHelper.GetConnection()) { var result = await conn.UpdateAsync(model); return(result == 1); } }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public async Task <bool> AddAsync(RichtextModel richtextModel, CourseModel courseModel) { return(await MySqlHelper.TransactionAsync(async (conn, t) => { await conn.InsertAsync <string, CourseModel>(courseModel); await conn.InsertAsync <string, RichtextModel>(richtextModel); return true; })); }
/// <summary> /// 添加文章 /// </summary> /// <param name="richtextModel"></param> /// <param name="articleModel"></param> /// <returns></returns> public async Task <bool> UpdateAsync(RichtextModel richtextModel, ArticleModel articleModel) { var result = await MySqlHelper.TransactionAsync(async (conn, t) => { await conn.UpdateAsync(richtextModel); await conn.UpdateAsync(articleModel); return(true); }); return(result); }
public async Task <IActionResult> AddArticleAsync([FromBody] AddArticleRequestDto request) { var articleGuid = Guid.NewGuid().ToString("N"); var textGuid = Guid.NewGuid().ToString("N"); RichtextModel richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = articleGuid, TextGuid = textGuid, }; ArticleModel articleModel = new ArticleModel { Abstract = request.Abstract, ArticleGuid = articleGuid, ArticleTypeDic = request.ArticleTypeDic, AuthorGuid = UserID, ContentGuid = textGuid, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, PlatformType = PlatformType.CloudDoctor.ToString(), Sort = 1, Title = request.Title, Visible = request.Visible, PictureGuid = request.PictureGuid, ActcleReleaseStatus = Enum.Parse <ReleaseStatus>(request.ActcleReleaseStatus) }; var response = await new ArticleBiz().AddAsync(richtextModel, articleModel); if (response) { //发布时才添加积分 if (articleModel.ActcleReleaseStatus == ReleaseStatus.Release) { new DoctorActionBiz().AddArticleAsync(this.UserID); } return(Success(articleModel.ArticleGuid, null)); } else { return(Failed(ErrorCode.DataBaseError, "添加失败")); } }
/// <summary> /// 添加文章 /// </summary> /// <param name="richtextModel"></param> /// <param name="articleModel"></param> /// <returns></returns> public async Task <bool> AddAsync(RichtextModel richtextModel, ArticleModel articleModel) { var result = await MySqlHelper.TransactionAsync(async (conn, t) => { await conn.InsertAsync <string, ArticleModel>(articleModel); await conn.InsertAsync <string, RichtextModel>(richtextModel); return(true); }); return(result); }
public async Task <IActionResult> AddArticleAsync([FromBody] AddArticleRequestDto request) { var articleGuid = Guid.NewGuid().ToString("N"); var textGuid = Guid.NewGuid().ToString("N"); RichtextModel richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = articleGuid, TextGuid = textGuid, }; var releaseStatus = Enum.Parse <Models.Utility.ReleaseStatus>(request.ActcleReleaseStatus.ToString()); var sourceType = Enum.Parse <ArticleModel.ArticleSourceTypeEnum>(request.SourceType.ToString()); ArticleModel articleModel = new ArticleModel { Abstract = request.Abstract, ArticleGuid = articleGuid, ArticleTypeDic = request.ArticleTypeDic, AuthorGuid = UserID, ContentGuid = textGuid, CreatedBy = UserID, Enable = request.Enable, LastUpdatedBy = UserID, OrgGuid = string.Empty, PlatformType = PlatformType.CloudDoctor.ToString(), Sort = 1, Title = request.Title, Visible = request.Visible, PictureGuid = request.PictureGuid, ActcleReleaseStatus = releaseStatus, SourceType = sourceType.ToString(), Keyword = JsonConvert.SerializeObject(request.Keyword), ExternalLink = request.ExternalLink ?? string.Empty, }; var response = await new ArticleBiz().AddAsync(richtextModel, articleModel); if (response) { return(Success(response)); } else { return(Failed(ErrorCode.DataBaseError, "添加失败")); } }
public async Task <bool> AddAsync(HospitalModel model, RichtextModel richtextModel, List <OfficeModel> offices) { var result = await MySqlHelper.TransactionAsync(async (conn, t) => { await conn.InsertAsync <string, HospitalModel>(model); await conn.InsertAsync <string, RichtextModel>(richtextModel); foreach (var item in offices) { await conn.InsertAsync <string, OfficeModel>(item); } return(true); }); return(result); }
public async Task <IActionResult> AddCourseAsync([FromBody] AddCourseRequestDto request) { var CourseGuid = Guid.NewGuid().ToString("N"); var textGuid = Guid.NewGuid().ToString("N"); RichtextModel richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = CourseGuid, TextGuid = textGuid, }; CourseModel courseModel = new CourseModel { Summary = request.Abstract, CourseGuid = CourseGuid, AuthorGuid = UserID, ContentGuid = textGuid, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = request.Enable, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, Title = request.Title, Visible = request.Visible, LogoGuid = request.PictureGuid }; var response = await new CourseBiz().AddAsync(richtextModel, courseModel); if (response) { return(Success(response)); } else { return(Failed(ErrorCode.DataBaseError, "添加失败")); } }
public async Task <bool> UpdateAsync(HospitalModel model, RichtextModel richtextModel, bool richtextIsAdd = false) { var result = await MySqlHelper.TransactionAsync(async (conn, t) => { await conn.UpdateAsync(model); if (richtextIsAdd) { await conn.InsertAsync <string, RichtextModel>(richtextModel); } else { await conn.UpdateAsync(richtextModel); } return(true); }); return(result); }
public async Task <IActionResult> AddHospitalAsync([FromBody] AddHospitalRequestDto request) { HospitalBiz hospitalBiz = new HospitalBiz(); if (await hospitalBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } var hospitalGuid = Guid.NewGuid().ToString("N"); var textGuid = Guid.NewGuid().ToString("N"); request.Content = string.IsNullOrWhiteSpace(request.Content) ? "暂无详细" : request.Content; request.HosTag = string.IsNullOrWhiteSpace(request.HosTag) ? "暂无标签" : request.HosTag; var richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = hospitalGuid, TextGuid = textGuid, }; var hospitalModel = new HospitalModel { HosAbstract = request.HosAbstract, HosDetailGuid = textGuid, HosLevel = request.HosLevel, HosName = request.HosName, HosTag = request.HosTag, Location = request.Location, LogoGuid = request.LogoGuid, PlatformType = PlatformType.CloudDoctor.ToString(), RegisteredDate = request.RegisteredDate, Visibility = request.Visibility, HospitalGuid = hospitalGuid, CreatedBy = UserID, LastUpdatedBy = UserID, Enable = request.Enable, OrgGuid = string.Empty, ContactNumber = request.ContactNumber, Sort = request.Sort, GuidanceUrl = request.GuidanceUrl ?? string.Empty, ExternalLink = request.ExternalLink ?? string.Empty, Password = CryptoHelper.AddSalt(hospitalGuid, request.Password), Account = request.Account, IsHospital = request.IsHospital, Longitude = request.Longitude, Latitude = request.Latitude }; var officeAll = await new OfficeBiz().GetAllAsync2(); var offices = officeAll.Select(a => (new { a.OfficeName, ParentName = officeAll.FirstOrDefault(b => b.OfficeGuid == a.ParentOfficeGuid)?.OfficeName, a.Sort, a.Enable, a.PictureGuid })).Distinct(); var offices2 = new List <OfficeModel>(); foreach (var item in offices) { GetOfficeModel(item.ParentName, item.OfficeName, item.Sort, item.Enable, item.PictureGuid, hospitalModel, offices2, offices); } var result = await hospitalBiz.AddAsync(hospitalModel, richtextModel, offices2); if (!result) { return(Failed(ErrorCode.UserData, "添加失败")); } return(Success()); }
public async Task <IActionResult> UpdateHospitalAsync([FromBody] UpdateHospitalRequestDto request) { var hospitalBiz = new HospitalBiz(); var hospitalModel = await hospitalBiz.GetAsync(request.HospitalGuid); if (hospitalModel == null) { return(Failed(ErrorCode.DataBaseError, "数据错误")); } if (request.Account != hospitalModel.Account && await hospitalBiz.AnyAccountAsync(request.Account)) { return(Failed(ErrorCode.UserData, "已经存在相同的账号!")); } var contentBiz = new RichtextBiz(); request.Content = string.IsNullOrWhiteSpace(request.Content) ? "暂无详细" : request.Content; request.HosTag = string.IsNullOrWhiteSpace(request.HosTag) ? "暂无标签" : request.HosTag; var richtextModel = await contentBiz.GetAsync(hospitalModel.HosDetailGuid); var richtextIsAdd = false; if (richtextModel != null) { richtextModel.Content = request.Content; richtextModel.LastUpdatedBy = UserID; richtextModel.LastUpdatedDate = DateTime.Now; richtextModel.OrgGuid = string.Empty; richtextModel.OwnerGuid = request.HospitalGuid; } else { var textGuid = Guid.NewGuid().ToString("N"); richtextModel = new RichtextModel { Content = request.Content, CreatedBy = UserID, CreationDate = DateTime.Now, Enable = true, LastUpdatedBy = UserID, LastUpdatedDate = DateTime.Now, OrgGuid = string.Empty, OwnerGuid = hospitalModel.HospitalGuid, TextGuid = textGuid, }; hospitalModel.HosDetailGuid = textGuid; richtextIsAdd = true; } hospitalModel.HosAbstract = request.HosAbstract; hospitalModel.HosLevel = request.HosLevel; hospitalModel.HosName = request.HosName; hospitalModel.HosTag = request.HosTag; hospitalModel.Location = request.Location; hospitalModel.LogoGuid = request.LogoGuid; hospitalModel.RegisteredDate = request.RegisteredDate; hospitalModel.Visibility = request.Visibility; hospitalModel.LastUpdatedBy = UserID; hospitalModel.LastUpdatedDate = DateTime.Now; hospitalModel.Enable = request.Enable; hospitalModel.ContactNumber = request.ContactNumber; hospitalModel.Sort = request.Sort; hospitalModel.GuidanceUrl = request.GuidanceUrl ?? string.Empty; hospitalModel.ExternalLink = request.ExternalLink ?? string.Empty; hospitalModel.Account = request.Account; hospitalModel.IsHospital = request.IsHospital; hospitalModel.Longitude = request.Longitude; hospitalModel.Latitude = request.Latitude; if (null != request.Password) { hospitalModel.Password = CryptoHelper.AddSalt(hospitalModel.HospitalGuid, request.Password); } var response = await hospitalBiz.UpdateAsync(hospitalModel, richtextModel, richtextIsAdd); if (!response) { return(Failed(ErrorCode.DataBaseError, "修改失败")); } return(Success(response)); }
public async Task <IActionResult> CreatePhysicalProductAsync([FromBody] CreateProductOfDoctorCloudRequestDto requestDto) { if (string.IsNullOrEmpty(requestDto.PictureGuid)) { return(Failed(ErrorCode.Empty, "封面图片未上传")); } requestDto.MerchantGuid = UserID; var merchantModel = await new MerchantBiz().GetModelAsync(requestDto.MerchantGuid); if (merchantModel == null) { return(Failed(ErrorCode.Empty, "未查询到此商铺数据")); } if (!string.IsNullOrEmpty(requestDto.SearchKey?.Trim())) { if (requestDto.SearchKey.Length > 30) { return(Failed(ErrorCode.Empty, "搜索关键词超过最大长度限制")); } } if (!string.IsNullOrEmpty(requestDto.ProductTitle?.Trim())) { if (requestDto.ProductTitle.Length > 255) { return(Failed(ErrorCode.Empty, "商品副标题超过最大长度限制")); } } if (requestDto.ApprovalNumber.Length > 30) { return(Failed(ErrorCode.Empty, "批准文号超过最大长度限制")); } if (requestDto.ProductCode.Length > 50) { return(Failed(ErrorCode.Empty, "商品编码超过最大长度限制")); } if (requestDto.Standerd.Length > 30) { return(Failed(ErrorCode.Empty, "规格超过最大长度限制")); } var productBiz = new ProductBiz(); var checkProductName = await productBiz.CheckProductNameRepeatAsync(requestDto.ProductName, UserID); if (checkProductName) { return(Failed(ErrorCode.UserData, $"已存在“{requestDto.ProductName}”同名产品,请检查")); } var model = await productBiz.GetByCodeAsync(requestDto.MerchantGuid, requestDto.ProductCode); if (model != null) { return(Failed(ErrorCode.UserData, $"商品编码“{requestDto.ProductCode}”被占用")); } var productGuid = Guid.NewGuid().ToString("N"); List <RichtextModel> richtexts = new List <RichtextModel>(); //商品介绍富文本 var introduceTextModel = new RichtextModel { TextGuid = Guid.NewGuid().ToString("N"), OwnerGuid = productGuid, Content = requestDto.Introduce, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }; //商品详情富文本 var detailTextModel = new RichtextModel { TextGuid = Guid.NewGuid().ToString("N"), OwnerGuid = productGuid, Content = requestDto.ProductDetail, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }; richtexts.AddRange(new List <RichtextModel> { introduceTextModel, detailTextModel }); List <BannerModel> banners = new List <BannerModel>(); var sort = 1; foreach (var item in requestDto.Banners) { banners.Add(new BannerModel { BannerGuid = Guid.NewGuid().ToString("N"), OwnerGuid = productGuid, PictureGuid = item.PictureGuid, TargetUrl = item.TargetUrl, Sort = item.Sort ?? (item.Sort = sort++).Value, BannerName = string.IsNullOrWhiteSpace(item.BannerName) ? $"banner{item.Sort}" : item.BannerName, Description = item.Description, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }); } var categoryName = ""; var categoryDicModel = await new DictionaryBiz().GetAsync(requestDto.CategoryGuid); categoryName = categoryDicModel?.ConfigName; var productModel = new ProductModel { ProductGuid = productGuid, ProductCode = requestDto.ProductCode, ProductTitle = requestDto.ProductTitle, MerchantGuid = requestDto.MerchantGuid, CategoryGuid = requestDto.CategoryGuid, CategoryName = categoryName ?? "", PictureGuid = requestDto.PictureGuid, ProductName = requestDto.ProductName, ProductLabel = requestDto.SearchKey, Brand = requestDto.BrandGuid, Standerd = requestDto.Standerd, RetentionPeriod = requestDto.RetentionPeriod, Manufacture = requestDto.Manufacture, ApprovalNumber = requestDto.ApprovalNumber, Price = requestDto.Price, CostPrice = requestDto.CostPrice, MarketPrice = requestDto.MarketPrice, Freight = requestDto.Freight, IntroduceGuid = introduceTextModel.TextGuid, ProDetailGuid = detailTextModel.TextGuid, Inventory = requestDto.Inventory, WarningInventory = requestDto.WarningInventory, OnSale = requestDto.OnSale, OperationTime = requestDto.OperationTime, CreatedBy = UserID, LastUpdatedBy = UserID, ProductForm = ProductFormEnum.Physical.ToString(), OrgGuid = "", PlatformType = merchantModel.PlatformType }; var result = await productBiz.CreateProductOfDoctorCloudAsync(productModel, richtexts, banners); return(result ? Success() : Failed(ErrorCode.DataBaseError, "发布商品失败")); }
public async Task <IActionResult> CreateServiceProductAsync([FromBody] CreateServiceProductRequestDto requestDto) { if (string.IsNullOrEmpty(requestDto.PictureGuid)) { return(Failed(ErrorCode.Empty, "封面图片未上传")); } var merchantModel = await new MerchantBiz().GetModelAsync(UserID); if (merchantModel == null) { return(Failed(ErrorCode.Empty, "未查询到此商铺数据")); } var productBiz = new ProductBiz(); var checkProductName = await productBiz.CheckProductNameRepeatAsync(requestDto.ProductName, UserID); if (checkProductName) { return(Failed(ErrorCode.UserData, $"已存在“{requestDto.ProductName}”同名产品,请检查")); } List <ProductModel> productModels = new List <ProductModel>(); List <ProductProjectModel> productProjectModels = new List <ProductProjectModel>(); List <RichtextModel> richtextModels = new List <RichtextModel>(); List <BannerModel> bannerModels = new List <BannerModel>(); var productGuid = Guid.NewGuid().ToString("N"); List <RichtextModel> richtexts = new List <RichtextModel>(); //商品介绍富文本 var introduceTextModel = new RichtextModel { TextGuid = Guid.NewGuid().ToString("N"), OwnerGuid = productGuid, Content = requestDto.Introduce, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }; //商品详情富文本 var detailTextModel = new RichtextModel { TextGuid = Guid.NewGuid().ToString("N"), OwnerGuid = productGuid, Content = requestDto.ProductDetail, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }; richtexts.AddRange(new List <RichtextModel> { introduceTextModel, detailTextModel }); richtextModels.AddRange(richtexts); List <BannerModel> banners = new List <BannerModel>(); var sort = 1; foreach (var item in requestDto.Banners) { banners.Add(new BannerModel { BannerGuid = Guid.NewGuid().ToString("N"), OwnerGuid = productGuid, PictureGuid = item.PictureGuid, TargetUrl = item.TargetUrl, Sort = sort, BannerName = string.IsNullOrWhiteSpace(item.BannerName) ? $"banner{sort}" : item.BannerName, Description = item.Description, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = string.Empty }); sort++; } bannerModels.AddRange(banners); var productModel = new ProductModel { ProductGuid = productGuid, ProductCode = Guid.NewGuid().ToString("N"), ProductTitle = requestDto.ProductTitle, MerchantGuid = UserID, CategoryGuid = requestDto.CategoryGuid, CategoryName = requestDto.CategoryName, PictureGuid = requestDto.PictureGuid, ProductName = requestDto.ProductName, Price = requestDto.Price, IntroduceGuid = introduceTextModel.TextGuid, ProDetailGuid = detailTextModel.TextGuid, OnSale = requestDto.OnSale, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = "", ProductForm = ProductFormEnum.Service.ToString(), PlatformType = merchantModel.PlatformType, EffectiveDays = requestDto.EffectiveDays, ProjectThreshold = requestDto.ProjectThreshold, Recommend = requestDto.Recommend }; #warning 因未开通线上支付,现所有商品均为可预付款,预付款比例为0,即所有商品金额均到店支付 productModels.Add(productModel); List <ProductProjectModel> productProjects = new List <ProductProjectModel>(); if (requestDto.ProjectGuids != null) { productProjects.AddRange(requestDto.ProjectGuids.Select(a => new ProductProjectModel { ProductProjectGuid = Guid.NewGuid().ToString("N"), ProductGuid = productModel.ProductGuid, ProjectGuid = a.ProjectGuid, ProjectTimes = a.Infinite ? 999 : a.ProjectTimes, PlatformType = merchantModel.PlatformType, CreatedBy = UserID, LastUpdatedBy = UserID, OrgGuid = "" }).ToList()); } productProjectModels.AddRange(productProjects); var result = await productBiz.CreateProductAsync(productModels, richtextModels, bannerModels, productProjectModels); return(result ? Success() : Failed(ErrorCode.DataBaseError, "创建产品失败")); }