处理国家多语言数据
This commit is contained in:
@@ -101,6 +101,49 @@ namespace Atomx.Admin.Controllers
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过ID获取数据
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IActionResult Get(long id)
|
||||
{
|
||||
var result = new ApiResult<Area>();
|
||||
var data = _dbContext.Areas.SingleOrDefault(p => p.Id == id);
|
||||
if (data == null)
|
||||
{
|
||||
return new JsonResult(new ApiResult<string>().IsFail("数据不存在", null));
|
||||
}
|
||||
|
||||
result = result.IsSuccess(data);
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 通过ID获取详情,含多语言
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("detail")]
|
||||
public IActionResult Detail(long id)
|
||||
{
|
||||
var result = new ApiResult<AreaLocalizedModel>();
|
||||
var data = _dbContext.Areas.SingleOrDefault(p => p.Id == id);
|
||||
if (data == null)
|
||||
{
|
||||
return new JsonResult(new ApiResult<string>().IsFail("数据不存在", null));
|
||||
}
|
||||
var localizedList = _dbContext.LocalizedProperties.Where(p => p.EntityId == id).ToList();
|
||||
var model = _mapper.Map<AreaLocalizedModel>(data);
|
||||
model.Locales = localizedList;
|
||||
|
||||
result = result.IsSuccess(model);
|
||||
|
||||
return new JsonResult(result);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增编辑数据
|
||||
|
||||
Reference in New Issue
Block a user