Commit 58716f5a authored by liudong1993's avatar liudong1993

1

parent a96fb421
...@@ -13,7 +13,7 @@ namespace EduSpider.Model.Entity ...@@ -13,7 +13,7 @@ namespace EduSpider.Model.Entity
public class RB_Account public class RB_Account
{ {
/// <summary> /// <summary>
/// 对应Uid /// 对应id
/// </summary> /// </summary>
public int Id { get; set; } public int Id { get; set; }
...@@ -33,7 +33,7 @@ namespace EduSpider.Model.Entity ...@@ -33,7 +33,7 @@ namespace EduSpider.Model.Entity
public AccountTypeEnum AccountType { get; set; } public AccountTypeEnum AccountType { get; set; }
/// <summary> /// <summary>
/// 对应 老师/学生ID /// 对应 老师/学生UID
/// </summary> /// </summary>
public int AccountId { get; set; } public int AccountId { get; set; }
......
...@@ -60,10 +60,10 @@ namespace EduSpider.Repository ...@@ -60,10 +60,10 @@ namespace EduSpider.Repository
string sql = $@" string sql = $@"
select * from( select * from(
SELECT a.Id,a.Account,a.`Password`,a.AccountType,a.AccountId,t.TeacherName AS AccountName,t.Logo as UserIcon,a.Status FROM rb_account a SELECT a.Id,a.Account,a.`Password`,a.AccountType,a.AccountId,t.TeacherName AS AccountName,t.Logo as UserIcon,a.Status FROM rb_account a
INNER JOIN rb_teacher t on a.AccountId =t.TeacherId and a.AccountType =1 INNER JOIN rb_teacher t on a.Id =t.TeacherId and a.AccountType =1
UNION UNION
SELECT a.Id,a.Account,a.`Password`,a.AccountType,a.AccountId,s.StudentName AS AccountName,'' as UserIcon,a.Status FROM rb_account a SELECT a.Id,a.Account,a.`Password`,a.AccountType,a.AccountId,s.StudentName AS AccountName,'' as UserIcon,a.Status FROM rb_account a
INNER JOIN rb_student s on a.AccountId =s.StudId and a.AccountType =2 INNER JOIN rb_student s on a.Id =s.StudId and a.AccountType =2
) t where {where} ) t where {where}
"; ";
return Get<RB_Account_Extend>(sql).ToList(); return Get<RB_Account_Extend>(sql).ToList();
...@@ -76,7 +76,7 @@ INNER JOIN rb_student s on a.AccountId =s.StudId and a.AccountType =2 ...@@ -76,7 +76,7 @@ INNER JOIN rb_student s on a.AccountId =s.StudId and a.AccountType =2
/// <returns></returns> /// <returns></returns>
public int GetMaxStuTeaId(int type) public int GetMaxStuTeaId(int type)
{ {
string sql = $" select max(AccountId) from RB_Account where AccountType ={type}"; string sql = $" select max(Id) from RB_Account where AccountType ={type}";
var obj = ExecuteScalar(sql); var obj = ExecuteScalar(sql);
return obj == null ? 0 : Convert.ToInt32(obj); return obj == null ? 0 : Convert.ToInt32(obj);
} }
......
...@@ -44,7 +44,7 @@ namespace EduSpider.Repository ...@@ -44,7 +44,7 @@ namespace EduSpider.Repository
LEFT JOIN ( LEFT JOIN (
SELECT e.ExamId,COUNT(0) as StuNum,SUM(e.TScore) as TScore FROM rb_exam_score e GROUP BY e.ExamId SELECT e.ExamId,COUNT(0) as StuNum,SUM(e.TScore) as TScore FROM rb_exam_score e GROUP BY e.ExamId
) es on e.ExamId = es.ExamId ) es on e.ExamId = es.ExamId
where {where} order by e.EcamId desc"; where {where} order by e.ExamId desc";
return GetPage<RB_Exam_Extend>(pageIndex, pageSize, out count, sql, parameters).ToList(); return GetPage<RB_Exam_Extend>(pageIndex, pageSize, out count, sql, parameters).ToList();
} }
} }
......
...@@ -79,9 +79,9 @@ namespace EduSpider.Services ...@@ -79,9 +79,9 @@ namespace EduSpider.Services
public object GetExamStuScoreInfo(int examId, int stuId, int stuUId) public object GetExamStuScoreInfo(int examId, int stuId, int stuUId)
{ {
if (stuUId > 0) { if (stuUId > 0) {
var accountModel = AccountRepository.GetAccountList(new RB_Account_Extend() { Id = stuUId, AccountType = Utility.Enum.AccountTypeEnum.Student }).FirstOrDefault(); var accountModel = AccountRepository.GetAccountList(new RB_Account_Extend() { AccountId = stuUId, AccountType = Utility.Enum.AccountTypeEnum.Student }).FirstOrDefault();
if (accountModel == null) { return ""; } if (accountModel == null) { return ""; }
stuId = accountModel.AccountId; stuId = accountModel.Id;
} }
var stuModel = StudentRepository.GetEntity(stuId); var stuModel = StudentRepository.GetEntity(stuId);
if (stuModel == null) { return ""; } if (stuModel == null) { return ""; }
...@@ -131,13 +131,13 @@ namespace EduSpider.Services ...@@ -131,13 +131,13 @@ namespace EduSpider.Services
}), }),
DifficultyList = sExamModel?.ScoreList.GroupBy(x => new { x.Difficulty }).Select(x => new DifficultyList = sExamModel?.ScoreList.GroupBy(x => new { x.Difficulty }).Select(x => new
{ {
x.Key.Difficulty, Difficulty = x.Key.Difficulty == "易" ? "简单题" : x.Key.Difficulty == "中" ? "中档题" : "难题",
Count = x.Count(), Count = x.Count(),
Score = x.Sum(x => x.QScore) Score = x.Sum(x => x.QScore)
}), }),
DifficultyRateList = sExamModel?.ScoreList.GroupBy(x => new { x.Difficulty }).Select(x => new DifficultyRateList = sExamModel?.ScoreList.GroupBy(x => new { x.Difficulty }).Select(x => new
{ {
x.Key.Difficulty, Difficulty = x.Key.Difficulty == "易" ? "简单题" : x.Key.Difficulty == "中" ? "中档题" : "难题",
ScoreRate = Math.Round(x.Sum(y => y.Score) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero), ScoreRate = Math.Round(x.Sum(y => y.Score) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
AvgScoreRate = Math.Round(x.Sum(y => y.AvgScore) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero), AvgScoreRate = Math.Round(x.Sum(y => y.AvgScore) / x.Sum(y => y.QScore), 2, MidpointRounding.AwayFromZero),
}) })
......
...@@ -163,7 +163,7 @@ namespace EduSpider.Utility ...@@ -163,7 +163,7 @@ namespace EduSpider.Utility
/// </summary> /// </summary>
public static string AppID public static string AppID
{ {
get { return "wx38e054ee42b054f4"; } get { return "wx10655d8e5b0a67c5"; }
} }
/// <summary> /// <summary>
...@@ -171,7 +171,7 @@ namespace EduSpider.Utility ...@@ -171,7 +171,7 @@ namespace EduSpider.Utility
/// </summary> /// </summary>
public static string AppSecret public static string AppSecret
{ {
get { return "d3ad4699265ba885ae2c8b65bf574ea5"; } get { return "ba2b81857e4b9c20d3860fb84eca1d79"; }
} }
/// <summary> /// <summary>
......
using EduSpider.Cache.User; using Edu.WebApi.Filter;
using EduSpider.Cache.User;
using EduSpider.Model.Cache; using EduSpider.Model.Cache;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using System; using System;
using VTX.FW.Filter;
using VTX.FW.Helper; using VTX.FW.Helper;
using VTX.FW.VtController; using VTX.FW.VtController;
...@@ -11,6 +13,8 @@ namespace EduSpider.WebApi.Controllers.Base ...@@ -11,6 +13,8 @@ namespace EduSpider.WebApi.Controllers.Base
[EnableCors("AllowCors")] [EnableCors("AllowCors")]
[Route("api/[controller]/[action]")] [Route("api/[controller]/[action]")]
[ApiController] [ApiController]
[ActionFilter]
[ApiExceptionFilter]
public class BaseController : ApiBaseController public class BaseController : ApiBaseController
{ {
/// <summary> /// <summary>
......
...@@ -38,6 +38,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -38,6 +38,7 @@ namespace EduSpider.WebApi.Controllers
{ {
x.ExamId, x.ExamId,
x.ExamName, x.ExamName,
x.CourseId,
x.StuNum, x.StuNum,
x.TScore, x.TScore,
AvgScore = x.StuNum > 0 ? Math.Round(x.TScore / x.StuNum, 2, MidpointRounding.AwayFromZero) : 0, AvgScore = x.StuNum > 0 ? Math.Round(x.TScore / x.StuNum, 2, MidpointRounding.AwayFromZero) : 0,
......
...@@ -17,6 +17,7 @@ using JWT.Algorithms; ...@@ -17,6 +17,7 @@ using JWT.Algorithms;
using JWT.Serializers; using JWT.Serializers;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Http;
namespace EduSpider.WebApi.Controllers namespace EduSpider.WebApi.Controllers
{ {
...@@ -56,7 +57,7 @@ namespace EduSpider.WebApi.Controllers ...@@ -56,7 +57,7 @@ namespace EduSpider.WebApi.Controllers
string ExamName = json["ExamName"] != null ? json["ExamName"].ToString() : ""; string ExamName = json["ExamName"] != null ? json["ExamName"].ToString() : "";
string filename = files[0].FileName; string filename = files[0].FileName;
string fileExtention = System.IO.Path.GetExtension(files[0].FileName); string fileExtention = Path.GetExtension(files[0].FileName);
//验证文件格式 //验证文件格式
List<string> ExtList = new() { List<string> ExtList = new() {
".xls", ".xls",
...@@ -78,7 +79,6 @@ namespace EduSpider.WebApi.Controllers ...@@ -78,7 +79,6 @@ namespace EduSpider.WebApi.Controllers
string dateStr = DateTime.Now.ToString("yyyyMMdd"); string dateStr = DateTime.Now.ToString("yyyyMMdd");
string tempPath = basepath + "upfile\\temporary\\" + dateStr + "\\"; string tempPath = basepath + "upfile\\temporary\\" + dateStr + "\\";
string path_server = tempPath + path; string path_server = tempPath + path;
//string httpPath = "/upfile/temporary/" + dateStr + "/" + path;
if (!Directory.Exists(tempPath)) if (!Directory.Exists(tempPath))
{ {
Directory.CreateDirectory(tempPath); Directory.CreateDirectory(tempPath);
......
...@@ -4,6 +4,10 @@ ...@@ -4,6 +4,10 @@
<TargetFramework>net5.0</TargetFramework> <TargetFramework>net5.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<PropertyGroup>
<AspNetCoreHostingModel>OutOfProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Autofac" Version="6.3.0" /> <PackageReference Include="Autofac" Version="6.3.0" />
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" /> <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="7.2.0" />
......
...@@ -37,11 +37,11 @@ namespace EduSpider.WebApi ...@@ -37,11 +37,11 @@ namespace EduSpider.WebApi
List<string> corsArray = GetCorsArray(); List<string> corsArray = GetCorsArray();
services.AddCors(options => options.AddPolicy("AllowCors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins(corsArray.ToArray()))); services.AddCors(options => options.AddPolicy("AllowCors", policy => policy.AllowAnyHeader().AllowAnyMethod().AllowCredentials().WithOrigins(corsArray.ToArray())));
services.AddControllers(); services.AddControllers();
services.AddMvc(options => //services.AddMvc(options =>
{ //{
options.Filters.Add<ApiExceptionFilterAttribute>(); // options.Filters.Add<ApiExceptionFilterAttribute>();
options.Filters.Add<ActionFilterAttribute>(); // options.Filters.Add<ActionFilterAttribute>();
}); //});
//处理josn格式 //处理josn格式
services.AddMvc().AddJsonOptions(options => services.AddMvc().AddJsonOptions(options =>
...@@ -49,7 +49,6 @@ namespace EduSpider.WebApi ...@@ -49,7 +49,6 @@ namespace EduSpider.WebApi
options.JsonSerializerOptions.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.Create(System.Text.Unicode.UnicodeRanges.All); options.JsonSerializerOptions.Encoder = System.Text.Encodings.Web.JavaScriptEncoder.Create(System.Text.Unicode.UnicodeRanges.All);
options.JsonSerializerOptions.PropertyNamingPolicy = null; options.JsonSerializerOptions.PropertyNamingPolicy = null;
}); });
} }
/// <summary> /// <summary>
......
...@@ -84,9 +84,9 @@ namespace EduSpider.Spiders.ClassInRule ...@@ -84,9 +84,9 @@ namespace EduSpider.Spiders.ClassInRule
{ {
accountList.Add(new RB_Account() accountList.Add(new RB_Account()
{ {
Id = item.StudentUid, Id = item.StudId,
Account = item.StudentAccount, Account = item.StudentAccount,
AccountId = item.StudId, AccountId = item.StudentUid,
AccountType = Utility.Enum.AccountTypeEnum.Student, AccountType = Utility.Enum.AccountTypeEnum.Student,
OpenId = "", OpenId = "",
Password = DESHepler.Encrypt(item.StudentAccount[^6..]), Password = DESHepler.Encrypt(item.StudentAccount[^6..]),
......
...@@ -83,9 +83,9 @@ namespace EduSpider.Spiders.ClassInRule ...@@ -83,9 +83,9 @@ namespace EduSpider.Spiders.ClassInRule
{ {
accountList.Add(new RB_Account() accountList.Add(new RB_Account()
{ {
Id = item.TeacherUid, Id = item.TeacherId,
Account = item.TeacherAccount, Account = item.TeacherAccount,
AccountId = item.TeacherId, AccountId = item.TeacherUid,
AccountType = AccountTypeEnum.Teacher, AccountType = AccountTypeEnum.Teacher,
OpenId = "", OpenId = "",
Password = DESHepler.Encrypt(item.TeacherAccount[^6..]), Password = DESHepler.Encrypt(item.TeacherAccount[^6..]),
......
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