217 lines
8.2 KiB
C#
217 lines
8.2 KiB
C#
using Admin.NET.Core;
|
|
using Admin.NET.Core.Service;
|
|
using Furion.DatabaseAccessor;
|
|
|
|
using Furion.DependencyInjection;
|
|
using Furion.DynamicApiController;
|
|
using Furion.FriendlyException;
|
|
using Mapster;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Linq.Dynamic.Core;
|
|
using Microsoft.Extensions.Caching.Distributed;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Serialization;
|
|
using System.Threading.Tasks;
|
|
using Flurl.Http;
|
|
|
|
namespace Admin.NET.Application
|
|
{
|
|
/// <summary>
|
|
/// 专家团队服务
|
|
/// </summary>
|
|
[ApiDescriptionSettings("测评服务", Name = "BusSpecialistGroup", Order = 100)]
|
|
public class BusSpecialistGroupService : IDynamicApiController, ITransient
|
|
{
|
|
private readonly SqlSugarRepository<BusSpecialistGroup> _busSpecialistGroupRep;
|
|
private readonly SysDictDataService _sysDictDataService;
|
|
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="busSpecialistGroupRep"></param>
|
|
/// <param name="sysDictDataService"></param>
|
|
public BusSpecialistGroupService(
|
|
SqlSugarRepository<BusSpecialistGroup> busSpecialistGroupRep,
|
|
SysDictDataService sysDictDataService
|
|
)
|
|
{
|
|
_busSpecialistGroupRep = busSpecialistGroupRep;
|
|
_sysDictDataService = sysDictDataService;
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取专业咨询类型
|
|
/// </summary>
|
|
/// <param name="requestDTO">340820674089029</param>
|
|
/// <returns></returns>
|
|
[HttpGet("GetType")]
|
|
public async Task<List<SpecialTypeResponseDTO>> GetType([FromQuery] SpecialTypeRequestDTO requestDTO)
|
|
{
|
|
var result = await _sysDictDataService.GetDictDataListByDictTypeId(requestDTO.TypeId);
|
|
return result.Select(s => new SpecialTypeResponseDTO()
|
|
{
|
|
Name = s.Value,
|
|
Code = s.Code
|
|
}).ToList();
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 分页查询专家团队
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("page")]
|
|
public async Task<SqlSugarPagedList<BusSpecialistGroupOutput>> Page([FromQuery] BusSpecialistGroupInput input)
|
|
{
|
|
var busSpecialistGroups = await _busSpecialistGroupRep.AsQueryable()
|
|
.WhereIF(input.MajorType.HasValue, u => u.MajorType == input.MajorType)
|
|
.WhereIF(!string.IsNullOrEmpty(input.Name), u => u.Name == input.Name)
|
|
//.Where(u => u.Gander == input.Gander)
|
|
//.Where(!string.IsNullOrEmpty(input.Pic), u => u.Pic == input.Pic)
|
|
.WhereIF(!string.IsNullOrEmpty(input.Phone), u => u.Phone == input.Phone)
|
|
.WhereIF(!string.IsNullOrEmpty(input.ServiceExpres), u => u.ServiceExpres == input.ServiceExpres)
|
|
.WhereIF(!string.IsNullOrEmpty(input.MajorTag), u => u.MajorTag == input.MajorTag)
|
|
.WhereIF(!string.IsNullOrEmpty(input.Summery), u => u.Summery == input.Summery)
|
|
.WhereIF(!string.IsNullOrEmpty(input.BusinessScope), u => u.BusinessScope == input.BusinessScope)
|
|
.Where(u => u.IsDelete == false)
|
|
.OrderBy(u => u.CreateTime, OrderByType.Desc)
|
|
.OrderBuilder(input)
|
|
.Select(s => new BusSpecialistGroupOutput()
|
|
{
|
|
MajorType = s.MajorType,
|
|
Name = s.Name,
|
|
Gander = s.Gander,
|
|
Pic = s.Pic,
|
|
Phone = s.Phone,
|
|
ServiceExpres = s.ServiceExpres,
|
|
MajorTag = s.MajorTag,
|
|
Summery = s.Summery,
|
|
BusinessScope = s.BusinessScope,
|
|
Sort = s.Sort,
|
|
Id = s.Id
|
|
|
|
})
|
|
.ToPagedListAsync(input.Page, input.PageSize);
|
|
|
|
return busSpecialistGroups;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 增加专家团队
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("add")]
|
|
public async Task Add(AddBusSpecialistGroupInput input)
|
|
{
|
|
var busSpecialistGroup = input.Adapt<BusSpecialistGroup>();
|
|
await _busSpecialistGroupRep.InsertAsync(busSpecialistGroup);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 删除专家团队
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("delete")]
|
|
public async Task Delete(DeleteBusSpecialistGroupInput input)
|
|
{
|
|
var busSpecialistGroup = await _busSpecialistGroupRep.AsQueryable().FirstAsync(u => u.Id == input.Id);
|
|
await _busSpecialistGroupRep.FakeDeleteAsync(busSpecialistGroup);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 更新专家团队
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("edit")]
|
|
public async Task Update(UpdateBusSpecialistGroupInput input)
|
|
{
|
|
var isExist = await _busSpecialistGroupRep.AsQueryable().AnyAsync(u => u.Id == input.Id);
|
|
if (!isExist) throw Oops.Oh(ErrorCodeEnum.D3000);
|
|
|
|
var busSpecialistGroup = input.Adapt<BusSpecialistGroup>();
|
|
await _busSpecialistGroupRep.UpdateAsync(busSpecialistGroup);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取专家团队
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[HttpGet("detail")]
|
|
public async Task<BusSpecialistGroupOutput> Get([FromQuery] QueryeBusSpecialistGroupInput input)
|
|
{
|
|
return (await _busSpecialistGroupRep.AsQueryable().FirstAsync(u => u.Id == input.Id)).Adapt<BusSpecialistGroupOutput>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取专家团队列表
|
|
/// </summary>
|
|
/// <param name="input"></param>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpGet("list")]
|
|
public async Task<List<BusSpeciaItemslistGroupOutput>> List([FromQuery] QueryBusSpecaillistRequestDto input)
|
|
{
|
|
var query = await _busSpecialistGroupRep.AsQueryable()
|
|
.Where(e => e.IsDelete == false)
|
|
.WhereIF(input.Code.HasValue, w => w.MajorType == input.Code)
|
|
.Select(s => new BusSpeciaItemslistGroupOutput()
|
|
{
|
|
Name = s.Name,
|
|
MajorTag = s.MajorTag,
|
|
Gander = s.Gander,
|
|
Pic = s.Pic,
|
|
Phone = s.Phone,
|
|
ServiceExpres = s.ServiceExpres,
|
|
Sort = s.Sort,
|
|
Id = s.Id,
|
|
BusinessScope = s.BusinessScope,
|
|
Summary = s.Summery
|
|
}).ToListAsync();
|
|
query.ForEach(s =>
|
|
{
|
|
s.MajorTags = s.MajorTag.Split("|").ToList();
|
|
});
|
|
|
|
return query;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 获取H5产品列表
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[AllowAnonymous]
|
|
[HttpGet("speciallist")]
|
|
public async Task<List<Datum>> GetSpecialList()
|
|
{
|
|
var replist = new List<Datum>();
|
|
var list = await "https://kp.ycymedu.com/web/special/get_special_list?cate_id=0&subject_id=0&page=1&limit=16&type=&is_pay=&salesOrder=&scoreOrder=&search=".GetJsonAsync<SpecialObjectDto>();
|
|
replist = list.data.data;
|
|
replist.ForEach(a =>
|
|
{
|
|
|
|
a.url = string.Format("https://kp.ycymedu.com/web/special/details.html?from=special_cate&id={0}", a.id);
|
|
});
|
|
return replist;
|
|
}
|
|
|
|
|
|
}
|
|
}
|