|
@@ -1,8 +1,10 @@
|
|
|
-using HiTeachCE.Models;
|
|
|
+using HiTeachCE.Helpers;
|
|
|
+using HiTeachCE.Models;
|
|
|
using HiTeachCE.Services;
|
|
|
using IdentityModel;
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
+using OpenXmlPowerTools;
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
@@ -122,10 +124,52 @@ namespace HiTeachCE.Controllers
|
|
|
public BaseJosnRPCResponse Add(JosnRPCRequest<OrgDto> request)
|
|
|
{
|
|
|
JsonRPCResponseBuilder builder = JsonRPCResponseBuilder.custom();
|
|
|
- string adminCellphone = "";
|
|
|
- lecturerService.GetList();
|
|
|
-
|
|
|
|
|
|
+ Expression<Func<Lecturer, bool>> linq = null;
|
|
|
+ linq = m => m.cellphone == request.@params.adminCellphone;
|
|
|
+ List<Lecturer> lecturers = lecturerService.GetList(linq);
|
|
|
+ Lecturer lecturer = null;
|
|
|
+ if (lecturers.IsNullOrEmpty())
|
|
|
+ {
|
|
|
+ Random random = new Random();
|
|
|
+ string seed = new string(Constant.az09);
|
|
|
+ string pfx = "";
|
|
|
+ for (int i = 0; i < 4; i++)
|
|
|
+ {
|
|
|
+ string c = seed.ToCharArray()[random.Next(0, seed.Length)] + "";
|
|
|
+ seed.Replace(c, "");
|
|
|
+ pfx = pfx + c;
|
|
|
+ }
|
|
|
+ lecturer = new Lecturer
|
|
|
+ {
|
|
|
+ id = Guid.NewGuid().ToString(),
|
|
|
+ unionid = Guid.NewGuid().ToString("N"),
|
|
|
+ username = request.@params.adminCellphone + "手机用户",
|
|
|
+ password = "",
|
|
|
+ account = "hitmd-" + request.@params.adminCellphone.Substring(request.@params.adminCellphone.Length - 4, 4) + "#" + pfx,
|
|
|
+ areaCode = "86",
|
|
|
+ registerTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(),
|
|
|
+ status = 1,
|
|
|
+ setaccount = 0,
|
|
|
+ cellphone = request.@params.adminCellphone
|
|
|
+ };
|
|
|
+ lecturerService.Insert(lecturer);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ lecturer = lecturers[0];
|
|
|
+ }
|
|
|
+ Expression<Func<Member, bool>> mlinq = null;
|
|
|
+ mlinq = m => m.unionid == lecturer.unionid;
|
|
|
+ List<Member> members= memberService.GetList(mlinq);
|
|
|
+ if (members.IsNotEmpty())
|
|
|
+ {
|
|
|
+ foreach (Member member in members) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+
|
|
|
+ }
|
|
|
return builder.Data(null).build();
|
|
|
}
|
|
|
|