|
@@ -11,7 +11,9 @@ using Hotline.Share.Dtos.Order;
|
|
|
using Hotline.Share.Requests;
|
|
|
using Hotline.Tools;
|
|
|
using MapsterMapper;
|
|
|
+using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using NPOI.POIFS.Properties;
|
|
|
using SqlSugar;
|
|
|
using XF.Domain.Authentications;
|
|
|
using XF.Domain.Exceptions;
|
|
@@ -19,6 +21,9 @@ using XF.Domain.Repository;
|
|
|
|
|
|
namespace Hotline.Api.Controllers
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ /// 行业管理
|
|
|
+ /// </summary>
|
|
|
public class IndustrialManagementController : BaseController
|
|
|
{
|
|
|
private readonly IMapper _mapper;
|
|
@@ -49,6 +54,27 @@ namespace Hotline.Api.Controllers
|
|
|
_industryClassificationApplication = industryClassificationApplication;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// 获取部门
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpGet("getorglist")]
|
|
|
+ public async Task<List<IndustrialOrgs>> GetOrgList()
|
|
|
+ {
|
|
|
+ var list = await _systemOrganizeRepository.Queryable()
|
|
|
+ .Select(p => new IndustrialOrgs
|
|
|
+ {
|
|
|
+ OrgId = p.Id,
|
|
|
+ OrgName = p.Name,
|
|
|
+ ParentId = p.ParentId,
|
|
|
+ ParentName = p.ParentId,
|
|
|
+ IsDisable = SqlFunc.Subqueryable<IndustryAssociations>().Where(d => d.OrganizeId == p.Id).Any()
|
|
|
+ })
|
|
|
+ .ToTreeAsync(d => d.Children, it => it.ParentId, null);
|
|
|
+
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 新增行业
|
|
|
/// </summary>
|
|
@@ -69,6 +95,12 @@ namespace Hotline.Api.Controllers
|
|
|
if (isHas)
|
|
|
throw UserFriendlyException.SameMessage("存在此行业名称");
|
|
|
|
|
|
+ var hasDat = await _industrialManagementRepository.Queryable()
|
|
|
+ .Includes(d => d.Orgs)
|
|
|
+ .AnyAsync(d => d.Orgs.Any(p => dto.OrgsIds.Contains(p.Id)));
|
|
|
+ if (hasDat)
|
|
|
+ throw UserFriendlyException.SameMessage("部门已关联行业!");
|
|
|
+
|
|
|
IndustrialManagement industrialManagement = new()
|
|
|
{
|
|
|
IndustrialName = dto.IndustryName,
|
|
@@ -100,6 +132,12 @@ namespace Hotline.Api.Controllers
|
|
|
if (isHas)
|
|
|
throw UserFriendlyException.SameMessage("存在此行业名称");
|
|
|
|
|
|
+ var hasDat = await _industrialManagementRepository.Queryable()
|
|
|
+ .Includes(d => d.Orgs)
|
|
|
+ .AnyAsync(d => d.Id != dto.Id && d.Orgs.Any(p => dto.OrgsIds.Contains(p.Id)));
|
|
|
+ if (hasDat)
|
|
|
+ throw UserFriendlyException.SameMessage("部门已关联行业!");
|
|
|
+
|
|
|
var data = await _industrialManagementRepository.GetAsync(p => p.Id == dto.Id, HttpContext.RequestAborted);
|
|
|
if (data == null)
|
|
|
throw UserFriendlyException.SameMessage("数据查询失败");
|