Commit 90ecb151 by xin.yang

some update

parent 0aa7939e
...@@ -22,13 +22,15 @@ namespace Siger.ApiACC.Controllers ...@@ -22,13 +22,15 @@ namespace Siger.ApiACC.Controllers
private readonly IUnitOfWork _unitOfWork; private readonly IUnitOfWork _unitOfWork;
private readonly IAutomationFixtureToolsCategoryRepository _toolsCategoryRepository; private readonly IAutomationFixtureToolsCategoryRepository _toolsCategoryRepository;
private readonly IAutomationFixtureToolsAssemblyRepository _toolsAssemblyRepository; private readonly IAutomationFixtureToolsAssemblyRepository _toolsAssemblyRepository;
private readonly IAutomationFixtureToolsRepository _toolsRepository;
public FixtureToolsController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository, public FixtureToolsController(IUnitOfWork unitOfWork, IAutomationFixtureToolsCategoryRepository toolsCategoryRepository,
IAutomationFixtureToolsAssemblyRepository toolsAssemblyRepository) IAutomationFixtureToolsAssemblyRepository toolsAssemblyRepository, IAutomationFixtureToolsRepository toolsRepository)
{ {
_unitOfWork = unitOfWork; _unitOfWork = unitOfWork;
_toolsCategoryRepository = toolsCategoryRepository; _toolsCategoryRepository = toolsCategoryRepository;
_toolsAssemblyRepository = toolsAssemblyRepository; _toolsAssemblyRepository = toolsAssemblyRepository;
_toolsRepository = toolsRepository;
} }
[HttpGet] [HttpGet]
...@@ -163,5 +165,34 @@ namespace Siger.ApiACC.Controllers ...@@ -163,5 +165,34 @@ namespace Siger.ApiACC.Controllers
return new ObjectResult(CommonEnum.Succefull); return new ObjectResult(CommonEnum.Succefull);
throw new BadRequestException(CommonEnum.Fail); throw new BadRequestException(CommonEnum.Fail);
} }
[HttpGet]
public IActionResult GetCategoryList()
{
var list = _toolsCategoryRepository.GetList(q => q.projectId == ProjectId && q.status == (int)RowState.Valid).ToList();
var res = GetChildren("", list);
return new ObjectResult(res);
}
private List<FixtureToolsCategoryTree> GetChildren(string parentid, List<siger_automation_fixture_tools_category> sectionDatas)
{
var resp = new List<FixtureToolsCategoryTree>();
var query = sectionDatas.Where(f => f.parent == parentid);
if (!query.Any())
{
return null;
}
foreach (var section in query)
{
var data = new FixtureToolsCategoryTree
{
value = section.id,
label = section.name
};
data.children = GetChildren(section.guid, sectionDatas);
resp.Add(data);
}
return resp;
}
} }
} }
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
......
using System;
using System.Collections.Generic;
using System.Text;
namespace Siger.Middlelayer.AccRepository.Response
{
public class FixtureToolsCategoryTree
{
public int value { get; set; }
public string label { get; set; }
public List<FixtureToolsCategoryTree> children = new List<FixtureToolsCategoryTree>();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment