using FHT.Agency.CommonTypes; using FHT.Agency.Web.Filters; using FHT.Agency.Web.Models; using FHT.Management.Interfaces.DependentInterfaces.Services; using FHT.Management.Interfaces.InputModels; using FHT.Utilities; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; namespace FHT.Agency.Web.Areas.Manage.Controllers { [Authorize] public class KeyValueController : Controller { private readonly IManagementKeyValueService _managementKeyValueService; public KeyValueController( IManagementKeyValueService managementKeyValueService) { _managementKeyValueService = managementKeyValueService; } //[HttpGet] //[ClaimsAuthorize(FhtUserClaimType.AutoLinkManagement)] //public ActionResult AutoLinkKeywords() //{ // var value = _managementKeyValueService.GetByKey(KeyValueKey.AutoLinkKeywords); // var inputModel = new KeyValueInputModel(); // if (!string.IsNullOrEmpty(value)) // { // var words= JsonConvert.DeserializeObject>(value); // inputModel.Value =string.Join("\r\n", words); // } // return View(inputModel); //} //[HttpPost] //[ValidateAjaxModel] //[ClaimsAuthorize(FhtUserClaimType.AutoLinkManagement)] //public JsonResult CreateOrUpdateAutoLinkKeywords(KeyValueInputModel model) //{ // var words = new List(); // if(!string.IsNullOrEmpty(model.Value)) // { // words = model.Value.Split(new string[] { "\r\n" }, StringSplitOptions.None).Distinct().ToList(); // } // _managementKeyValueService.CreateOrUpdate(KeyValueKey.AutoLinkKeywords, JsonConvert.SerializeObject(words)); // return Json(true, JsonRequestBehavior.AllowGet); //} [HttpGet] [ClaimsAuthorize(FhtUserClaimType.MenuNavManagement)] public ActionResult MenuNav() { return View("~/ReactBuild/UpdateMenuNav.cshtml"); } //[HttpPost] //[ValidateAjaxModel] //[ClaimsAuthorize(FhtUserClaimType.MenuNavManagement)] //public JsonResult CreateOrUpdateMenuNav(KeyValueInputModel model) //{ // _managementKeyValueService.CreateOrUpdate(KeyValueKey.MenuNavs, model.Value); // return Json(true, JsonRequestBehavior.AllowGet); //} //[HttpGet] //[ClaimsAuthorize(FhtUserClaimType.MenuNavManagement)] //public ActionResult SetMenuNavContent() //{ // var strJson = _managementKeyValueService.GetByKey(KeyValueKey.MenuNavs); // var model = new KeyValueInputModel // { // Value = strJson // }; // return View("~/Areas/Manage/Views/KeyValue/MenuNav.cshtml", model); //} //[HttpPost] //[ValidateAjaxModel] //[ClaimsAuthorize(FhtUserClaimType.MenuNavManagement)] //public JsonResult CreateOrUpdateMenuNavContent(KeyValueInputModel model) //{ // MenuNavInputModel menuNav = null; // if (!string.IsNullOrEmpty(model.Value)) // { // JObject json = JObject.Parse(model.Value); // menuNav = json.ToObject(); // } // if (menuNav != null) // { // _managementKeyValueService.CreateOrUpdate(KeyValueKey.MenuNavs, model.Value); // return Json(true, JsonRequestBehavior.AllowGet); // } // return Json(false, JsonRequestBehavior.AllowGet); //} [HttpGet] [ClaimsAuthorize(FhtUserClaimType.FeaturedProductManagement)] public ActionResult FeaturedProduct() { return View("~/ReactBuild/UpdateFeaturedProduct.cshtml"); } //[HttpPost] //[ValidateAjaxModel] //[ClaimsAuthorize(FhtUserClaimType.FeaturedProductManagement)] //public JsonResult CreateOrUpdateFeaturedProduct(KeyValueInputModel model) //{ // _managementKeyValueService.CreateOrUpdate(KeyValueKey.FeaturedProducts, model.Value); // return Json(true, JsonRequestBehavior.AllowGet); //} //[HttpGet] //[ClaimsAuthorize(FhtUserClaimType.FeaturedProductManagement)] //public ActionResult SetFeaturedProductContent() //{ // var strJson = _managementKeyValueService.GetByKey(KeyValueKey.FeaturedProducts); // var model = new KeyValueInputModel // { // Value = strJson // }; // return View("~/Areas/Manage/Views/KeyValue/FeaturedProduct.cshtml", model); //} //[HttpPost] //[ValidateAjaxModel] //[ClaimsAuthorize(FhtUserClaimType.FeaturedProductManagement)] //public JsonResult CreateOrUpdateFeaturedProductContent(KeyValueInputModel model) //{ // FeaturedProductsInputModel featuredProduct = null; // if (!string.IsNullOrEmpty(model.Value)) // { // JObject json = JObject.Parse(model.Value); // featuredProduct = json.ToObject(); // } // if(featuredProduct!= null) // { // _managementKeyValueService.CreateOrUpdate(KeyValueKey.FeaturedProducts, model.Value); // return Json(true, JsonRequestBehavior.AllowGet); // } // return Json(false, JsonRequestBehavior.AllowGet); //} [HttpGet] [ClaimsAuthorize(FhtUserClaimType.HotWordAdverManagement)] public ActionResult HotWordAdver() { return View("~/ReactBuild/UpdateHotWordPromotion.cshtml"); } // [HttpGet] // [ClaimsAuthorize(FhtUserClaimType.HotWordAdverManagement)] // public ActionResult SetHotWordAdverContent() // { // var strJson = _managementKeyValueService.GetByKey(KeyValueKey.HotWordPromotions); // var model = new KeyValueInputModel // { // Value = strJson // }; // return View("~/Areas/Manage/Views/KeyValue/HotWordAdver.cshtml", model); // } // [HttpPost] // [ValidateAjaxModel] // [ClaimsAuthorize(FhtUserClaimType.HotWordAdverManagement)] // public JsonResult CreateOrUpdateHotWordAdverContent(KeyValueInputModel model) // { // //TODO:验证 Value 是否有效 // _managementKeyValueService.CreateOrUpdate(KeyValueKey.HotWordPromotions, model.Value); // return Json(true, JsonRequestBehavior.AllowGet); // } } }