diff --git a/Bootstrap.Admin/Controllers/Api/CategoryController.cs b/Bootstrap.Admin/Controllers/Api/CategoryController.cs index aaaafaa9..4bf04241 100644 --- a/Bootstrap.Admin/Controllers/Api/CategoryController.cs +++ b/Bootstrap.Admin/Controllers/Api/CategoryController.cs @@ -1,5 +1,4 @@ using Bootstrap.DataAccess; -using Bootstrap.Security; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using System.Collections.Generic; @@ -15,7 +14,7 @@ namespace Bootstrap.Admin.Controllers.Api /// [HttpGet] [AllowAnonymous] - public IEnumerable Get() + public IEnumerable Get() { return DictHelper.RetrieveCategories(); } diff --git a/Bootstrap.Admin/wwwroot/js/dicts.js b/Bootstrap.Admin/wwwroot/js/dicts.js index 315c26ea..b6f594a8 100644 --- a/Bootstrap.Admin/wwwroot/js/dicts.js +++ b/Bootstrap.Admin/wwwroot/js/dicts.js @@ -26,10 +26,8 @@ $.bc({ url: "api/Category", callback: function (result) { - var data = result.map(function (ele, index) { return ele.Category; }); $('#txt_dict_cate').typeahead({ - source: data, - autoSelect: true + source: result }); } }); diff --git a/Bootstrap.DataAccess/DictHelper.cs b/Bootstrap.DataAccess/DictHelper.cs index 7a55c2c8..89e2764a 100644 --- a/Bootstrap.DataAccess/DictHelper.cs +++ b/Bootstrap.DataAccess/DictHelper.cs @@ -95,18 +95,18 @@ namespace Bootstrap.DataAccess /// 获取字典分类名称 /// /// - public static IEnumerable RetrieveCategories() + public static IEnumerable RetrieveCategories() { return CacheManager.GetOrAdd(RetrieveCategoryDataKey, key => { - var ret = new List(); + var ret = new List(); string sql = "select distinct Category from Dicts"; DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql); using (DbDataReader reader = DBAccessManager.SqlDBAccess.ExecuteReader(cmd)) { while (reader.Read()) { - ret.Add(new BootstrapDict() { Category = (string)reader[0] }); + ret.Add((string)reader[0]); } } return ret;