using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Bowin.Common.ServiceToken.Permission; using Bowin.Common.WebModels; using YLShipBuildLandMap.Entity; using YLShipBuildLandMap.Entity.ViewModel; using YLShipBuildLandMap.Services.SystemSetting; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Newtonsoft.Json.Linq; namespace YLShipBuildLandMap.Web.Controllers.SystemSetting { [Route("api/systemsetting/[controller]/[action]")] [ApiController] [Authorize] public class DictionaryController : ControllerBase { private IDictionaryService DictionaryService { get; set; } public DictionaryController(IDictionaryService dictionaryService) { DictionaryService = dictionaryService; } [HttpPost] [FunctionCode("9904")] public async Task GetList([FromBody] dynamic inputObject) { try { int? pageIndex = inputObject.pageIndex; int? pageSize = inputObject.pageSize; string dictionaryName = inputObject.dictionaryName; string dictionaryCode = inputObject.dictionaryCode; string name = inputObject.name; var dictionaryItemList = await DictionaryService.GetDictionaryItemList(pageIndex, pageSize, dictionaryName, dictionaryCode, name); return ResultMessage.Success(dictionaryItemList); } catch (Exception ex) { return ResultMessage.GetError(ex.Message); } } [HttpPost] public async Task GetDicList([FromBody] dynamic inputObject) { string code = inputObject.code; var list = await DictionaryService.GetDictionaryItemsbyCache(code); //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3)); // var a = ResultMessage.Success(list); return ResultMessage.Success(list); } [HttpPost] public async Task GetTugboatTitleDicList([FromBody] dynamic inputObject) { string code = "TugboatTitle"; var list = await DictionaryService.GetTugboatTitleDictionary(code); //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3)); return ResultMessage.Success(list); } [HttpPost] public async Task GetDepartmentTitleDicList([FromBody] dynamic inputObject) { string code = "TugboatTitle"; var list = await DictionaryService.GetDepartmentTitleDictionary(code); //System.Threading.Thread.Sleep(TimeSpan.FromSeconds(3)); return ResultMessage.Success(list); } [HttpPost] public async Task GetDicListForSelect([FromBody] dynamic inputObject) { try { int? pageIndex = inputObject.pageindex; int? pageSize = inputObject.pagesize; string dictionaryName = inputObject.name; string dictionaryCode = inputObject.code; var dicList = await DictionaryService.GetDictionaryList(pageIndex, pageSize, dictionaryName, dictionaryCode); return ResultMessage.Success(dicList); } catch (Exception ex) { return ResultMessage.GetError(ex.Message); } } [HttpPost] [FunctionCode("990401")] public ResultMessage GetDicItem([FromBody] dynamic inputObject) { Guid? dicItemID = inputObject.dicItemID; return ResultMessage.Success(DictionaryService.GetDicItem(dicItemID)); } [HttpPost] [FunctionCode("990402")] public async Task EditDicItem([FromBody] dynamic inputObject) { SysDictionaryItem dicItem = inputObject.dicItem.ToObject(); await DictionaryService.Save(dicItem, LoginUser.Current.UserID); return ResultMessage.Success(); } [HttpPost] [FunctionCode("990403")] public async Task Delete([FromBody] dynamic inputObj) { try { List dicItemIDList = inputObj.dicItemIDs.ToObject>(); ; await DictionaryService.Delete(dicItemIDList); return ResultMessage.Success(); } catch (Exception ex) { return ResultMessage.GetError(ex.Message); } } } }