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; } /// ///学校编号