更改RetrieveDicts接口参数为int

This commit is contained in:
Argo-Lenovo 2016-11-03 21:28:19 +08:00
parent cb3b178059
commit be81d04f33
3 changed files with 223 additions and 223 deletions

View File

@ -20,7 +20,7 @@ namespace Bootstrap.Admin.Models
/// <returns></returns>
public QueryData<Dict> RetrieveData()
{
var data = DictHelper.RetrieveDicts(string.Empty);
var data = DictHelper.RetrieveDicts();
if (!string.IsNullOrEmpty(Name))
{
data = data.Where(t => t.Name.Contains(Name));

View File

@ -19,11 +19,11 @@ namespace Bootstrap.DataAccess
/// </summary>
/// <param name="tId"></param>
/// <returns></returns>
public static IEnumerable<Dict> RetrieveDicts(string tId = null)
public static IEnumerable<Dict> RetrieveDicts(int id = 0)
{
string sql = "select * from Dicts";
var ret = CacheManager.GetOrAdd(DictDataKey, CacheSection.RetrieveIntervalByKey(DictDataKey), key =>
{
string sql = "select * from Dicts";
List<Dict> Dicts = new List<Dict>();
DbCommand cmd = DBAccessManager.SqlDBAccess.CreateCommand(CommandType.Text, sql);
try
@ -46,7 +46,7 @@ namespace Bootstrap.DataAccess
catch (Exception ex) { ExceptionManager.Publish(ex); }
return Dicts;
}, CacheSection.RetrieveDescByKey(DictDataKey));
return string.IsNullOrEmpty(tId) ? ret : ret.Where(t => tId.Equals(t.ID.ToString(), StringComparison.OrdinalIgnoreCase));
return id == 0 ? ret : ret.Where(t => id == t.ID);
}
/// <summary>

View File

@ -44,7 +44,7 @@ namespace Bootstrap.DataAccess.Tests
var dict = dicts.FirstOrDefault(d => d.Category == Dict.Category);
dict.Name = "__测试子菜单2__";
Assert.IsTrue(DictHelper.SaveDict(dict), string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.ID));
var dest = DictHelper.RetrieveDicts(dict.ID.ToString());
var dest = DictHelper.RetrieveDicts(dict.ID);
Assert.IsTrue(dest.Count() == 1, "带参数的DictHelper.RetrieveDicts方法调用失败");
Assert.AreEqual(dict.Name, dest.First().Name, string.Format("更新字典记录ID = {0} 操作失败,请检查 DictHelper.SaveDict 方法", dict.ID));
}