From c9db9531537c3387709e7fc5ee8b2bd6580c89bd Mon Sep 17 00:00:00 2001 From: tanglong Date: Fri, 6 Jun 2025 17:17:18 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/School/S_SchoolService.cs | 33 +++++++++++++------ .../School/Request/SchoolPageListParam.cs | 2 +- 2 files changed, 24 insertions(+), 11 deletions(-) diff --git a/VOL.Business/Services/School/S_SchoolService.cs b/VOL.Business/Services/School/S_SchoolService.cs index 40aaa7c..95ac544 100644 --- a/VOL.Business/Services/School/S_SchoolService.cs +++ b/VOL.Business/Services/School/S_SchoolService.cs @@ -139,22 +139,35 @@ namespace VOL.Business.Services.School school_Entity.CreateDate = DateTime.Now; school_Entity.Creator = UserContext.Current.UserId; - var natureList = await _natureAssocGradeRepository.FindAsync(x => x.NatureId == paramDto.SchoolNatureId); - if (natureList == null || natureList.Count == 0) - throw new Exception($"未找到学校性质:{paramDto.SchoolNatureId}"); - - var user = await _userRepository.FindAsyncFirst(x => x.UserName == paramDto.UserName && x.Role_Id == 2); - if (user != null) - throw new Exception($"用户名为{paramDto.UserName}的学校已存在"); var gradeEntityList = new List(); - - foreach (var nature in natureList) + + if (paramDto.SchoolType == SchoolType.School) { + var natureList = await _natureAssocGradeRepository.FindAsync(x => x.NatureId == paramDto.SchoolNatureId); + if (natureList == null || natureList.Count == 0) + throw new Exception($"未找到学校性质:{paramDto.SchoolNatureId}"); + + var user = await _userRepository.FindAsyncFirst(x => x.UserName == paramDto.UserName && x.Role_Id == 2); + if (user != null) + throw new Exception($"用户名为{paramDto.UserName}的学校已存在"); + + foreach (var nature in natureList) + { + gradeEntityList.Add(new S_SchoolAssocGrade() + { + SchoolCode = nextSchoolCode, + GradeId = nature.GradeId + }); + } + } + else + { + var grade = await _gradeRepository.FindAsIQueryable(x => x.GradeName == "运动馆").FirstOrDefaultAsync(); gradeEntityList.Add(new S_SchoolAssocGrade() { SchoolCode = nextSchoolCode, - GradeId = nature.GradeId + GradeId = grade?.Id ?? 0 }); } diff --git a/VOL.Model/School/Request/SchoolPageListParam.cs b/VOL.Model/School/Request/SchoolPageListParam.cs index 0cdef9a..956242e 100644 --- a/VOL.Model/School/Request/SchoolPageListParam.cs +++ b/VOL.Model/School/Request/SchoolPageListParam.cs @@ -62,7 +62,7 @@ namespace VOL.Model.School.Request /// ///学校性质Id /// - public int SchoolNatureId { get; set; } + public int? SchoolNatureId { get; set; } /// ///学校编号