增加新增专家功能

This commit is contained in:
范露尧
2023-09-14 21:16:41 +08:00
parent deba0675d7
commit 93e9ae19f8
6 changed files with 104 additions and 2 deletions

View File

@@ -7,11 +7,14 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Vote.Services.Dto;
using Vote.Services.Entities;
using static Vote.Services.Dto.ProjectsList2Output;
namespace Vote.Services.ApiController
{
@@ -177,7 +180,9 @@ namespace Vote.Services.ApiController
{
var list = await rep_Experts.DetachedEntities.GroupJoin(rep_VoteRecords.DetachedEntities, a => a.login_code, a => a.expert_login_code, (a, b) => new { a, b })
.SelectMany(a => a.b.DefaultIfEmpty(), (a, b) => new { a.a.Id, a.a.login_code, is_vote = b != null })
.Distinct().ToListAsync();
.Distinct()
.OrderBy(a => a.Id)
.ToListAsync();
return list;
//var query = from a in rep_Experts.DetachedEntities
// join b in rep_VoteRecords.DetachedEntities on a.login_code equals b.expert_login_code into temp
@@ -193,5 +198,28 @@ namespace Vote.Services.ApiController
}
/// <summary>
/// 新增专家
/// </summary>
/// <returns></returns>
[HttpPost]
public async Task AddExpert(AddExpertInput args)
{
if (args == null || args.expertnum <= 0)
throw Oops.Oh("参数异常");
var list = new List<Experts>();
for (int i = 0; i < args.expertnum; i++)
{
var newid = Ulid.NewUlid().ToString();
var newidsimple = newid.ToUpper().Replace("I", "").Replace("L", "").Replace("0", "").Replace("O", "").Replace("1", "");
list.Add(new Experts
{
Id = newid,
login_code = newidsimple.Substring(newidsimple.Length - 6, 6),
CreatedTime = DateTime.Now
});
}
await rep_Experts.InsertAsync(list);
}
}
}