Ver Fonte

1、新增教室、教室学生关联关系、教师打分评论、学生打分评论增删改查gpc接口。

李思淳 há 5 anos atrás
pai
commit
68567a8ae3

+ 15 - 0
TEAMModelGrpc/Models/StringDto.cs

@@ -0,0 +1,15 @@
+using ProtoBuf;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace TEAMModelGrpc.Models
+{
+    [ProtoContract]
+    public class StringDto
+    {
+        [ProtoMember(1)]
+        public string name { get; set; }
+    }
+}

+ 4 - 2
TEAMModelGrpc/Protos/BlobSASService.proto

@@ -1,7 +1,7 @@
 syntax = "proto3";
 option csharp_namespace = "TMDGrpc.BlobSASService";
 option java_package = "TMDGrpc.BlobSASService";
-package math;
+package TMDGrpc;
 
 
 service BlobSASService {
@@ -19,6 +19,8 @@ message Empty {
 message BlobSASDto {
    //Blob的URL地址
    string Url = 1;
+   //容器名
+   string Container = 2;
    //Blob的SAS签名
-   string SAS = 2;
+   string SAS = 3;
 }

+ 162 - 0
TEAMModelGrpc/Protos/ClassroomService.proto

@@ -0,0 +1,162 @@
+syntax = "proto3";
+option csharp_namespace = "TMDGrpc.ClassroomService";
+option java_package = "TMDGrpc.ClassroomService";
+package TMDGrpc;
+
+
+service ClassroomService {
+   //保存教室
+   rpc SaveOrUpdateVolume(stream Classroom) returns(stream Classroom);
+
+   //查询教室
+   rpc FindVolume(Dict) returns(stream Classroom);
+
+   //删除教室
+   rpc Delete(ListPid) returns(ListPid);
+
+}
+
+
+
+message Classroom {
+   //classroomCode
+   string id = 1;
+   string scopeCode = 2;
+   string classroomCode = 3;
+   Point point = 4;
+   string classroomName = 5;
+   string headMaster = 6;
+   string periodCode = 7;
+   string gradeCode = 8;
+   string hiteach = 9;
+   int32 studentCount = 10;
+   string classroomType = 11;
+   int32 status = 12;
+}
+
+message Point {
+   float x = 1;
+   float y = 2;
+}
+
+//请求参数Dict
+message Dict {
+   //数字Dict
+   map<string,double> NMap = 1;
+   //字符串Dict
+   map<string,string> SMap = 2;
+   //布尔Dict
+   map<string,bool> BMap = 3;
+   //字符串ListMap
+   repeated LSMap LSMap = 4;
+   //数字ListMap
+   repeated LNMap LNMap = 5;
+   //Byte ListMap
+   repeated LBMap LBMap = 6;
+}
+
+//Byte[] Map
+message LBMap {
+   //Key
+   string Key = 1;
+   //byte数组
+   bytes Value = 2;
+}
+
+//数字ListMap
+message LNMap {
+   //Key
+   string Key = 1;
+   //数字数组
+   repeated double Value = 2 [packed = false];
+}
+
+//字符串ListMap
+message LSMap {
+   //数字Dict
+   string Key = 1;
+   //字符串数组
+   repeated string Value = 2;
+}
+
+enum HttpStatusCode {
+   option allow_alias = true;
+   ZERO = 0; // proto3 requires a zero value as the first item (it can be named anything)
+   Continue = 100;
+   SwitchingProtocols = 101;
+   Processing = 102;
+   EarlyHints = 103;
+   OK = 200;
+   Created = 201;
+   Accepted = 202;
+   NonAuthoritativeInformation = 203;
+   NoContent = 204;
+   ResetContent = 205;
+   PartialContent = 206;
+   MultiStatus = 207;
+   AlreadyReported = 208;
+   IMUsed = 226;
+   Ambiguous = 300;
+   MultipleChoices = 300;
+   MovedPermanently = 301;
+   Moved = 301;
+   Found = 302;
+   Redirect = 302;
+   SeeOther = 303;
+   RedirectMethod = 303;
+   NotModified = 304;
+   UseProxy = 305;
+   Unused = 306;
+   TemporaryRedirect = 307;
+   RedirectKeepVerb = 307;
+   PermanentRedirect = 308;
+   BadRequest = 400;
+   Unauthorized = 401;
+   PaymentRequired = 402;
+   Forbidden = 403;
+   NotFound = 404;
+   MethodNotAllowed = 405;
+   NotAcceptable = 406;
+   ProxyAuthenticationRequired = 407;
+   RequestTimeout = 408;
+   Conflict = 409;
+   Gone = 410;
+   LengthRequired = 411;
+   PreconditionFailed = 412;
+   RequestEntityTooLarge = 413;
+   RequestUriTooLong = 414;
+   UnsupportedMediaType = 415;
+   RequestedRangeNotSatisfiable = 416;
+   ExpectationFailed = 417;
+   MisdirectedRequest = 421;
+   UnprocessableEntity = 422;
+   Locked = 423;
+   FailedDependency = 424;
+   UpgradeRequired = 426;
+   PreconditionRequired = 428;
+   TooManyRequests = 429;
+   RequestHeaderFieldsTooLarge = 431;
+   UnavailableForLegalReasons = 451;
+   InternalServerError = 500;
+   NotImplemented = 501;
+   BadGateway = 502;
+   ServiceUnavailable = 503;
+   GatewayTimeout = 504;
+   HttpVersionNotSupported = 505;
+   VariantAlsoNegotiates = 506;
+   InsufficientStorage = 507;
+   LoopDetected = 508;
+   NotExtended = 510;
+   NetworkAuthenticationRequired = 511;
+}
+
+message IdPk {
+   string id = 1;
+   string pk = 2;
+   HttpStatusCode StatusCode = 3;
+}
+
+message ListPid {
+   //list IdPk
+   repeated IdPk idPks = 1;
+}

+ 33 - 0
TEAMModelGrpc/Protos/ClassroomStudentService.proto

@@ -0,0 +1,33 @@
+syntax = "proto3";
+option csharp_namespace = "TMDGrpc.ClassroomStudentService";
+option java_package = "TMDGrpc.ClassroomStudentService";
+package TMDGrpc;
+
+
+service ClassroomStudentService {
+   //保存 或 修改 教室学生关联
+   rpc SaveOrUpdateClassroomStudent(stream ClassroomStudent) returns(stream ClassroomStudent);
+
+   //学生加入教室 或者 修改座位号
+   rpc AddClassroomAsync(stream ClassroomStudent) returns(stream ClassroomStudent);
+
+   //学生退出教室
+   rpc DelClassroom(stream ClassroomStudent) returns(stream ClassroomStudent);
+
+   //查询学生在哪些教室
+   rpc FindStudents(StringDto) returns(stream ClassroomStudent);
+
+}
+
+
+
+message ClassroomStudent {
+   //classroomCode
+   string id = 1;
+   string scopeCode = 2;
+   repeated string studentId = 3;
+}
+
+message StringDto {
+   string name = 1;
+}

+ 2 - 2
TEAMModelGrpc/Protos/CourseService.proto

@@ -1,7 +1,7 @@
 syntax = "proto3";
 option csharp_namespace = "TMDGrpc.CourseService";
 option java_package = "TMDGrpc.CourseService";
-package math;
+package TMDGrpc;
 
 
 service CourseService {
@@ -103,7 +103,7 @@ message CourseTime {
    //上课班级/教室
    string classroomCode = 4;
    //临时课程
-   string frequencyName = 5;
+   repeated string frequencyName = 5;
 }
 
 enum HttpStatusCode {

+ 84 - 0
TEAMModelGrpc/Protos/HomeWorkService.proto

@@ -0,0 +1,84 @@
+syntax = "proto3";
+option csharp_namespace = "TMDGrpc.HomeWorkService";
+option java_package = "TMDGrpc.HomeWorkService";
+package TMDGrpc;
+
+
+service HomeWorkService {
+   //学生作业打分评论
+   rpc StudentScoring(HomeWorkCommentDto) returns(HomeWorkStudent);
+
+   //教师作业打分评论
+   rpc TeacherScoring(HomeWorkScoringDto) returns(HomeWorkStudent);
+
+   //查询教师评语罐头
+   rpc FindTeacherComments(Dict) returns(stream TeacherComments);
+
+}
+
+
+
+message HomeWorkCommentDto {
+}
+
+message HomeWorkScoringDto {
+}
+
+//请求参数Dict
+message Dict {
+   //数字Dict
+   map<string,double> NMap = 1;
+   //字符串Dict
+   map<string,string> SMap = 2;
+   //布尔Dict
+   map<string,bool> BMap = 3;
+   //字符串ListMap
+   repeated LSMap LSMap = 4;
+   //数字ListMap
+   repeated LNMap LNMap = 5;
+   //Byte ListMap
+   repeated LBMap LBMap = 6;
+}
+
+//Byte[] Map
+message LBMap {
+   //Key
+   string Key = 1;
+   //byte数组
+   bytes Value = 2;
+}
+
+//数字ListMap
+message LNMap {
+   //Key
+   string Key = 1;
+   //数字数组
+   repeated double Value = 2 [packed = false];
+}
+
+//字符串ListMap
+message LSMap {
+   //数字Dict
+   string Key = 1;
+   //字符串数组
+   repeated string Value = 2;
+}
+
+//作业数据
+message HomeWorkStudent {
+}
+
+message Comment {
+   string comment = 1;
+   int64 createTime = 2;
+   string id = 3;
+   int32 order = 4;
+}
+
+message TeacherComments {
+   string id = 1;
+   //评语
+   repeated Comment comment = 2;
+   //醍摩豆id 或者学生id
+   string TEAMModelId = 3;
+}

+ 1 - 1
TEAMModelGrpc/Protos/KnowledgeService.proto

@@ -1,7 +1,7 @@
 syntax = "proto3";
 option csharp_namespace = "TMDGrpc.KnowledgeService";
 option java_package = "TMDGrpc.KnowledgeService";
-package math;
+package TMDGrpc;
 
 
 service KnowledgeService {

+ 1 - 1
TEAMModelGrpc/Protos/SyllabusService.proto

@@ -1,7 +1,7 @@
 syntax = "proto3";
 option csharp_namespace = "TMDGrpc.SyllabusService";
 option java_package = "TMDGrpc.SyllabusService";
-package math;
+package TMDGrpc;
 
 
 service SyllabusService {

+ 86 - 1
TEAMModelGrpc/Protos/VolumeService.proto

@@ -1,7 +1,7 @@
 syntax = "proto3";
 option csharp_namespace = "TMDGrpc.VolumeService";
 option java_package = "TMDGrpc.VolumeService";
-package math;
+package TMDGrpc;
 
 
 service VolumeService {
@@ -11,6 +11,9 @@ service VolumeService {
    //查询册别
    rpc FindVolume(Dict) returns(stream SyllabusVolume);
 
+   //删除册别
+   rpc Delete(ListPid) returns(ListPid);
+
 }
 
 
@@ -80,4 +83,86 @@ message LSMap {
    string Key = 1;
    //字符串数组
    repeated string Value = 2;
+}
+
+enum HttpStatusCode {
+   option allow_alias = true;
+   ZERO = 0; // proto3 requires a zero value as the first item (it can be named anything)
+   Continue = 100;
+   SwitchingProtocols = 101;
+   Processing = 102;
+   EarlyHints = 103;
+   OK = 200;
+   Created = 201;
+   Accepted = 202;
+   NonAuthoritativeInformation = 203;
+   NoContent = 204;
+   ResetContent = 205;
+   PartialContent = 206;
+   MultiStatus = 207;
+   AlreadyReported = 208;
+   IMUsed = 226;
+   Ambiguous = 300;
+   MultipleChoices = 300;
+   MovedPermanently = 301;
+   Moved = 301;
+   Found = 302;
+   Redirect = 302;
+   SeeOther = 303;
+   RedirectMethod = 303;
+   NotModified = 304;
+   UseProxy = 305;
+   Unused = 306;
+   TemporaryRedirect = 307;
+   RedirectKeepVerb = 307;
+   PermanentRedirect = 308;
+   BadRequest = 400;
+   Unauthorized = 401;
+   PaymentRequired = 402;
+   Forbidden = 403;
+   NotFound = 404;
+   MethodNotAllowed = 405;
+   NotAcceptable = 406;
+   ProxyAuthenticationRequired = 407;
+   RequestTimeout = 408;
+   Conflict = 409;
+   Gone = 410;
+   LengthRequired = 411;
+   PreconditionFailed = 412;
+   RequestEntityTooLarge = 413;
+   RequestUriTooLong = 414;
+   UnsupportedMediaType = 415;
+   RequestedRangeNotSatisfiable = 416;
+   ExpectationFailed = 417;
+   MisdirectedRequest = 421;
+   UnprocessableEntity = 422;
+   Locked = 423;
+   FailedDependency = 424;
+   UpgradeRequired = 426;
+   PreconditionRequired = 428;
+   TooManyRequests = 429;
+   RequestHeaderFieldsTooLarge = 431;
+   UnavailableForLegalReasons = 451;
+   InternalServerError = 500;
+   NotImplemented = 501;
+   BadGateway = 502;
+   ServiceUnavailable = 503;
+   GatewayTimeout = 504;
+   HttpVersionNotSupported = 505;
+   VariantAlsoNegotiates = 506;
+   InsufficientStorage = 507;
+   LoopDetected = 508;
+   NotExtended = 510;
+   NetworkAuthenticationRequired = 511;
+}
+
+message IdPk {
+   string id = 1;
+   string pk = 2;
+   HttpStatusCode StatusCode = 3;
+}
+
+message ListPid {
+   //list IdPk
+   repeated IdPk idPks = 1;
 }

+ 105 - 0
TEAMModelGrpc/Services/ClassroomService.cs

@@ -0,0 +1,105 @@
+using Grpc.Core;
+using Grpc.Extension.Abstract;
+using Microsoft.AspNetCore.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using TEAMModelGrpc.Models;
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
+using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
+using TEAMModelOS.Service.Models.Core;
+
+namespace TEAMModelGrpc.Services
+{
+    public class ClassroomService : IGrpcService
+    {
+        public readonly IAzureCosmosDBV3Repository cosmosrepository;
+
+        public ClassroomService(IAzureCosmosDBV3Repository cosmosrepository)
+        {
+            this.cosmosrepository = cosmosrepository;
+        }
+
+        /// <summary>
+        /// 保存教室
+        /// </summary>
+        /// <param name="requestStream"></param>
+        /// <param name="responseStream"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task SaveOrUpdateVolume(IAsyncStreamReader<Classroom> requestStream, IServerStreamWriter<Classroom> responseStream, ServerCallContext context)
+        {
+
+            List<Classroom> classrooms = new List<Classroom>();
+            await foreach (Classroom classroom in requestStream.ReadAllAsync())
+            {
+                if (classroom.id != null)
+                {
+                    classrooms.Add( await cosmosrepository.SaveOrUpdate(classroom));
+                }
+                else
+                {
+                    classroom.id = Guid.NewGuid().ToString();
+                    ClassroomStudent students = new ClassroomStudent();
+                    students.scopeCode = classroom.scopeCode;
+                    students.id = classroom.classroomCode;
+                    await cosmosrepository.SaveOrUpdate(students);
+                    classrooms.Add(await cosmosrepository.SaveOrUpdate(classroom));
+
+                }
+            }
+            classrooms.ForEach(x => {
+                responseStream.WriteAsync(x);
+            });
+        }
+
+
+        /// <summary>
+        /// 查询教室
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="responseStream"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task FindVolume(Dict request, IServerStreamWriter<Classroom> responseStream, ServerCallContext context)
+        {
+
+            Dictionary<string, object> dict = request.ToDict();
+            List<Classroom> syllabusVolumes = await cosmosrepository.FindByDict<Classroom>(dict);
+            syllabusVolumes.ForEach(x => {
+                responseStream.WriteAsync(x);
+            });
+        }
+
+
+        /// <summary>
+        /// 删除教室
+        /// </summary>
+        /// <param name="listPid"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task<ListPid> Delete(ListPid listPid, ServerCallContext context)
+        {
+            await cosmosrepository.DeleteAll<Classroom>(listPid.idPks);
+            if (listPid.idPks.IsNotEmpty())
+            {
+                List<ClassroomStudent> students = new List<ClassroomStudent>();
+                foreach (IdPk classroom in listPid.idPks)
+                {
+                    List<ClassroomStudent> classroomStudents = await cosmosrepository.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", classroom.id }, { "scopeCode", classroom.pk } });
+                    students.AddRange(classroomStudents);
+                }
+                if (students.Count > 0)
+                {
+                    await cosmosrepository.DeleteAll<ClassroomStudent>(students);
+                }
+                listPid.idPks = await cosmosrepository.DeleteAll<Classroom>(listPid.idPks);
+            }
+            return listPid;
+        }
+    }
+}

+ 127 - 0
TEAMModelGrpc/Services/ClassroomStudentService.cs

@@ -0,0 +1,127 @@
+using Grpc.Core;
+using Grpc.Extension.Abstract;
+using Microsoft.AspNetCore.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using TEAMModelGrpc.Models;
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
+using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
+using TEAMModelOS.Service.Models.Core;
+
+namespace TEAMModelGrpc.Services
+{
+    public class ClassroomStudentService : IGrpcService
+    {
+        private IAzureCosmosDBV3Repository _cosmos;
+        public ClassroomStudentService(IAzureCosmosDBV3Repository cosmos)
+        {
+            _cosmos = cosmos;
+        }
+
+        /// <summary>
+        /// 保存 或 修改 教室学生关联
+        /// </summary>
+        /// <param name="requestStream"></param>
+        /// <param name="responseStream"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task SaveOrUpdateClassroomStudent(IAsyncStreamReader<ClassroomStudent> requestStream, IServerStreamWriter<ClassroomStudent> responseStream, ServerCallContext context)
+        {
+            List<ClassroomStudent> classrooms = new List<ClassroomStudent>();
+            await foreach (ClassroomStudent students in requestStream.ReadAllAsync())
+            {
+                classrooms.Add(await _cosmos.SaveOrUpdate(students));
+            }
+            classrooms.ForEach(x => {
+                responseStream.WriteAsync(x);
+            });
+        }
+
+
+
+        /// <summary>
+        /// 学生加入教室 或者 修改座位号
+        /// </summary>
+        /// <param name="requestStream"></param>
+        /// <param name="responseStream"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task AddClassroomAsync(IAsyncStreamReader<ClassroomStudent> requestStream, IServerStreamWriter<ClassroomStudent> responseStream, ServerCallContext context) {
+            List<ClassroomStudent> classroomStudents1 = new List<ClassroomStudent>();
+            List<ClassroomStudent> students = new List<ClassroomStudent>();
+            await foreach (ClassroomStudent classroom in requestStream.ReadAllAsync()) {
+                students.Add(classroom);
+
+            }
+            foreach (var classroomStudent in students.GroupBy(x => x.id).ToList())
+            {
+                List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", classroomStudent.Key } });
+                foreach (var classroomStudent1 in classroomStudent)
+                {
+                    classroomStudents[0].studentId.UnionWith(classroomStudent1.studentId);
+                }
+                classroomStudents1.AddRange(classroomStudents);
+            }
+            List<ClassroomStudent> students1 = await _cosmos.SaveOrUpdateAll(classroomStudents1);
+            students1.ForEach(x => {
+                responseStream.WriteAsync(x);
+            });
+        }
+
+
+        /// <summary>
+        /// 学生退出教室
+        /// </summary>
+        /// <param name="requestStream"></param>
+        /// <param name="responseStream"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task DelClassroom(IAsyncStreamReader<ClassroomStudent> requestStream, IServerStreamWriter<ClassroomStudent> responseStream, ServerCallContext context) 
+        {
+            List<ClassroomStudent> students = new List<ClassroomStudent>();
+
+            await foreach (ClassroomStudent classroomStudent in requestStream.ReadAllAsync()) {
+                students.Add(classroomStudent);
+            }
+            List<ClassroomStudent> classroomStudents1 = new List<ClassroomStudent>();
+            foreach (ClassroomStudent item1 in students)
+            {
+                List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", item1.id } });
+                foreach (ClassroomStudent item2 in classroomStudents)
+                {
+                    item2.studentId.ExceptWith(item1.studentId);
+                }
+                classroomStudents1.AddRange(classroomStudents);
+            }
+            List<ClassroomStudent> students1 = await _cosmos.SaveOrUpdateAll(classroomStudents1);
+            students1.ForEach(x => {
+                responseStream.WriteAsync(x);
+            });
+        }
+
+
+
+        /// <summary>
+        /// 查询学生在哪些教室
+        /// </summary>
+        /// <param name="request"></param>
+        /// <param name="responseStream"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task FindStudents(StringDto request, IServerStreamWriter<ClassroomStudent> responseStream, ServerCallContext context) 
+        {
+            List<ClassroomStudent> classroomStudents = await _cosmos.FindSQL<ClassroomStudent>("select c.id,c.scopeCode from c join A0  in c.studentId where 1=1  and A0 =  \'" + request + "\'");
+            if (classroomStudents.IsNotEmpty()) {
+                classroomStudents.ForEach(  x => { 
+                responseStream.WriteAsync(x);
+                });
+            }
+        }
+    }
+}

+ 134 - 0
TEAMModelGrpc/Services/HomeWorkService.cs

@@ -0,0 +1,134 @@
+using Grpc.Core;
+using Grpc.Extension.Abstract;
+using Microsoft.AspNetCore.Authorization;
+using System;
+using System.Collections.Generic;
+using System.Threading.Tasks;
+using TEAMModelGrpc.Models;
+using TEAMModelOS;
+using TEAMModelOS.Models;
+using TEAMModelOS.SDK.Context.Exception;
+using TEAMModelOS.SDK.Helper.Common.CollectionHelper;
+using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
+using TEAMModelOS.Service.Models.Learn;
+
+namespace TEAMModelGrpc.Services
+{
+    public class HomeWorkService : IGrpcService
+    {
+        private readonly IAzureCosmosDBV3Repository _cosmos;
+
+        public HomeWorkService(IAzureCosmosDBV3Repository cosmos)
+        {
+            _cosmos = cosmos;
+        }
+
+        /// <summary>
+        /// 学生作业打分评论
+        /// </summary>
+        /// <param name="homeWorkCommentDto"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task<HomeWorkStudent> StudentScoring(HomeWorkCommentDto homeWorkCommentDto, ServerCallContext context) 
+        {
+            List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", homeWorkCommentDto.id }, { "homeWorkId", homeWorkCommentDto.homeWorkId } });
+            List<HomeWork> homeWorks = await _cosmos.FindByDict<HomeWork>(new Dictionary<string, object> { { "id", homeWorkCommentDto.homeWorkId } });
+            HomeWorkStudent data = new HomeWorkStudent();
+
+            if (homeWorks.IsNotEmpty() && homeWorks[0].other.Contains("comment"))
+            {
+                if (homeWorkStudents.IsNotEmpty())
+                {
+                    if (string.IsNullOrEmpty(homeWorkCommentDto.commentid))
+                    {
+                        //评论
+                        StudentComment homeWorkComment = new StudentComment
+                        {
+                            commentid = Guid.NewGuid().ToString(),
+                            comment = homeWorkCommentDto.comment,
+                            createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(),
+                            fromId = homeWorkCommentDto.fromId,
+                            score = homeWorkCommentDto.score
+                        };
+                        homeWorkStudents[0].studentComments.Add(homeWorkComment);
+                    }
+                    else
+                    {
+                        //回复评论
+                        foreach (StudentComment comment in homeWorkStudents[0].studentComments)
+                        {
+                            if (comment.commentid == homeWorkCommentDto.commentid)
+                            {
+                                Reply reply = new Reply();
+                                reply.fromId = homeWorkCommentDto.fromId;
+                                reply.toId = homeWorkCommentDto.toId;
+                                reply.identity = homeWorkCommentDto.identity;
+                                reply.comment = homeWorkCommentDto.comment;
+                                reply.createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
+                                comment.reply.Add(reply);
+                            }
+                        }
+                    }
+                    //homeWorkStudents[0].comments[request.@params.TEAMModelId] = request.@params.comment;
+                    data = await _cosmos.Update(homeWorkStudents[0]);
+                }
+                return data;
+            }
+            else throw new BizException("未开放互评");
+        }
+
+
+        /// <summary>
+        /// 教师作业打分评论
+        /// </summary>
+        /// <param name="homeWorkCommentDto"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        public async Task<HomeWorkStudent> TeacherScoring(HomeWorkScoringDto homeWorkCommentDto, ServerCallContext context)
+        {
+
+            List<HomeWorkStudent> homeWorkStudents = await _cosmos.FindByDict<HomeWorkStudent>(new Dictionary<string, object> { { "id", homeWorkCommentDto.id }, { "homeWorkId", homeWorkCommentDto.homeWorkId } });
+            HomeWorkStudent data = new HomeWorkStudent();
+            if (homeWorkStudents.IsNotEmpty())
+            {
+
+                homeWorkStudents[0].score = homeWorkCommentDto.score ?? homeWorkStudents[0].score;
+                HomeWorkComment homeWorkComment = new HomeWorkComment
+                {
+                    comment = homeWorkCommentDto.comments,
+                    createTime = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeSeconds(),
+                    TEAMModelId = homeWorkCommentDto.TEAMModelId
+                };
+
+                homeWorkStudents[0].teacherComments = homeWorkComment;
+                data = await _cosmos.SaveOrUpdate(homeWorkStudents[0]);
+
+            }
+            return data;
+        }
+
+
+        /// <summary>
+        /// 查询教师评语罐头
+        /// </summary>
+        /// <param name="dict"></param>
+        /// <param name="context"></param>
+        /// <returns></returns>
+        public async Task FindTeacherComments(Dict dict, IServerStreamWriter<TeacherComments> responseStream, ServerCallContext context) 
+        {
+            Dictionary<string, object> keyValuePairs = dict.ToDict();
+            List<TeacherComments> teacherComments = new List<TeacherComments>();
+            if (keyValuePairs.IsNotEmpty()) {
+                teacherComments = await _cosmos.FindByDict<TeacherComments>(keyValuePairs);
+                if (teacherComments.IsNotEmpty()) {
+                    teacherComments.ForEach(x=> { 
+                        responseStream.WriteAsync(x);
+                    });
+                }
+            }
+            
+        }
+
+    }
+}

+ 14 - 0
TEAMModelGrpc/Services/VolumeService.cs

@@ -63,5 +63,19 @@ namespace TEAMModelGrpc.Services
             });
         }
 
+
+        /// <summary>
+        /// 删除册别
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        [Authorize]
+        public async Task<ListPid> Delete(ListPid listPid, ServerCallContext context)
+        {
+            List<IdPk> idPks = await azureCosmosDBRepository.DeleteAll<SyllabusVolume>(listPid.idPks);
+            listPid.idPks = idPks;
+            return listPid;
+        }
+
     }
 }

+ 11 - 0
TEAMModelGrpc/TEAMModelGrpc.csproj

@@ -9,13 +9,23 @@
     <DocumentationFile>TEAMModelOS.GRPC.xml</DocumentationFile>
   </PropertyGroup>
   <ItemGroup>
+    <None Remove="Protos\BlobSASService.proto" />
+    <None Remove="Protos\ClassroomService.proto" />
+    <None Remove="Protos\ClassroomStudentService.proto" />
+    <None Remove="Protos\HomeWorkService.proto" />
     <None Remove="Protos\SyllabusService.proto" />
+    <None Remove="Protos\VolumeService.proto" />
   </ItemGroup>
   <ItemGroup>
+    <Protobuf Include="Protos\BlobSASService.proto" GrpcServices="Server" />
+    <Protobuf Include="Protos\ClassroomService.proto" GrpcServices="Server" />
+    <Protobuf Include="Protos\ClassroomStudentService.proto" GrpcServices="Server" />
     <Protobuf Include="Protos\greet.proto" GrpcServices="Server" />
     <Protobuf Include="Protos\CourseService.proto" GrpcServices="Server" />
+    <Protobuf Include="Protos\HomeWorkService.proto" GrpcServices="Server" />
     <Protobuf Include="Protos\KnowledgeService.proto" GrpcServices="Server" />
     <Protobuf Include="Protos\SyllabusService.proto" GrpcServices="Server" />
+    <Protobuf Include="Protos\VolumeService.proto" GrpcServices="Server" />
   </ItemGroup>
 
   <ItemGroup>
@@ -31,6 +41,7 @@
   <ItemGroup>
     <ProjectReference Include="..\TEAMModelOS.SDK\TEAMModelOS.SDK.csproj" />
     <ProjectReference Include="..\TEAMModelOS.Service\TEAMModelOS.Service.csproj" />
+    <ProjectReference Include="..\TEAMModelOS\TEAMModelOS.csproj" />
   </ItemGroup>
   <ItemGroup>
     <Folder Include="GrpcHealthCheck\" />

Diff do ficheiro suprimidas por serem muito extensas
+ 974 - 41
TEAMModelGrpc/TEAMModelOS.GRPC.xml


+ 6 - 1
TEAMModelOS.Service/Models/Core/ClassRoomStudent.cs

@@ -1,4 +1,5 @@
-using System;
+using ProtoBuf;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Text;
@@ -7,19 +8,23 @@ using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
 
 namespace TEAMModelOS.Service.Models.Core
 {
+    [ProtoContract]
     [CosmosDB(RU = 400, Name = "CoreClassroomStudent",Cache = true)]
     public class ClassroomStudent:ID
     {
         /// <summary>
         /// classroomCode
         /// </summary>
+        [ProtoMember(1)]
         [Required(ErrorMessage = "{0} 必须填写")]
         public string id { get; set; } //classroomCode
 
+        [ProtoMember(2)]
         [Required(ErrorMessage = "{0} 必须填写")]
         [PartitionKey]
         public string scopeCode { get; set; }
 
+        [ProtoMember(3)]
         public HashSet<string> studentId { get; set; }
 
         //public class Stu

+ 20 - 1
TEAMModelOS.Service/Models/Core/Classroom.cs

@@ -1,4 +1,5 @@
-using System;
+using ProtoBuf;
+using System;
 using System.Collections.Generic;
 using System.ComponentModel.DataAnnotations;
 using System.Text;
@@ -8,6 +9,7 @@ using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
 
 namespace TEAMModelOS.Service.Models.Core
 {
+    [ProtoContract]
     [CosmosDB(RU = 400, Name = "CoreClassroom")]
     public class Classroom:ID
     {
@@ -15,23 +17,36 @@ namespace TEAMModelOS.Service.Models.Core
         {
             point = new Point();
         }
+
+        [ProtoMember(1)]
         [Required(ErrorMessage = "{0} 必须填写")]
         [JsonPropertyName("id")]
         public string id { get; set; }
 
+        [ProtoMember(2)]
         [Required(ErrorMessage = "{0} 必须填写")]
         [PartitionKey]
         public string scopeCode { get; set; }
+        [ProtoMember(3)]
         [Required(ErrorMessage = "{0} 必须填写")]
         public string classroomCode { get; set; }
+        [ProtoMember(4)]
         public Point point { get; set; }
+        [ProtoMember(5)]
         public string classroomName { get; set; }
+        [ProtoMember(6)]
         public string headMaster { get; set; }
+        [ProtoMember(7)]
         public string periodCode { get; set; }
+        [ProtoMember(8)]
         public string gradeCode { get; set; }
+        [ProtoMember(9)]
         public string hiteach { get; set; }
+        [ProtoMember(10)]
         public int studentCount { get; set; }
+        [ProtoMember(11)]
         public string classroomType { get; set; }
+        [ProtoMember(12)]
         public int status { get; set; } = 1;
 
 
@@ -39,8 +54,12 @@ namespace TEAMModelOS.Service.Models.Core
         //public string TEAMModelId { get; set; }
   }
 }
+
+[ProtoContract]
 public class Point
 {
+    [ProtoMember(1)]
     public float x { get; set; }
+    [ProtoMember(2)]
     public float y { get; set; }
 }

+ 11 - 2
TEAMModelOS.Service/Models/Learn/TeacherComments.cs

@@ -1,4 +1,5 @@
-using System;
+using ProtoBuf;
+using System;
 using System.Collections.Generic;
 using System.Text;
 using TEAMModelOS.SDK.Context.Attributes.Azure;
@@ -6,6 +7,7 @@ using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
 
 namespace TEAMModelOS.Service.Models.Learn
 {
+    [ProtoContract]
     [CosmosDB(RU = 400, Name = "HomeWorkTeacherComments")]
     public class TeacherComments : ID
     {
@@ -13,34 +15,41 @@ namespace TEAMModelOS.Service.Models.Learn
             comment = new List<Comment>();
         }
 
+        [ProtoMember(1)]
         public string id { get; set; }
 
         /// <summary>
         /// 评语
         /// </summary>
+        [ProtoMember(2)]
         public List<Comment> comment { get; set; }
 
         /// <summary>
         /// 醍摩豆id 或者学生id
         /// </summary>
         [PartitionKey]
+        [ProtoMember(3)]
         public string TEAMModelId { get; set; }
 
-
+        [ProtoContract]
         public class Comment 
         {
             /// <summary>
             /// 评语
             /// </summary>
+            [ProtoMember(1)]
             public string comment { get; set; }
 
             /// <summary>
             /// 评论时间
             /// </summary>
+            [ProtoMember(2)]
             public long createTime { get; set; } = new DateTimeOffset(DateTime.UtcNow).ToUnixTimeMilliseconds();
 
+            [ProtoMember(3)]
             public string id { get; set; }
 
+            [ProtoMember(4)]
             public int order { get; set; }
 
         }

+ 27 - 11
TEAMModelOS/Controllers/Core/ClassroomStudentController.cs

@@ -61,21 +61,25 @@ namespace TEAMModelOS.Controllers.Core
             {
                 List<ClassroomStudent> students = request.@params;
                 List<ClassroomStudent> classroomStudents1 = new List<ClassroomStudent>();
-                foreach (ClassroomStudent item1 in students) { 
-                    List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", item1.id } });
-                    foreach (ClassroomStudent item2 in classroomStudents) {
-                        item2.studentId.UnionWith(item1.studentId);
+                foreach (var classroomStudent in students.GroupBy(x => x.id).ToList()) {
+                    
+                    List<ClassroomStudent> classroomStudents = await _cosmos.FindByDict<ClassroomStudent>(new Dictionary<string, object> { { "id", classroomStudent.Key } });
+                    foreach (var classroomStudent1 in classroomStudent) 
+                    {
+                        classroomStudents[0].studentId.UnionWith(classroomStudent1.studentId);
                     }
                     classroomStudents1.AddRange(classroomStudents);
                 }
-
                 List<ClassroomStudent> students1 = await _cosmos.SaveOrUpdateAll(classroomStudents1);
-                //if (students1.Count > 0) 
-                    builder.Data(students1);
+                builder.Data(students1);
             }
             return builder.build();
         }
-
+        /// <summary>
+        /// 学生退出教室
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         [HttpPost("DelClassroom")]
         public async Task<BaseJosnRPCResponse> DelClassroom(JosnRPCRequest<List<ClassroomStudent>> request)
         {
@@ -100,7 +104,11 @@ namespace TEAMModelOS.Controllers.Core
             }
             return builder.build();
         }
-
+        /// <summary>
+        /// 查询教室学生关联
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         [HttpPost("FindClassroom")]
         public async Task<BaseJosnRPCResponse> DelClassroom(JosnRPCRequest<Dictionary<string, object>> request)
         {
@@ -113,7 +121,11 @@ namespace TEAMModelOS.Controllers.Core
             }
             return builder.build();
         }
-
+        /// <summary>
+        /// 查询教室学生关联 根据id
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         [HttpPost("FindClassroomById")]
         public async Task<BaseJosnRPCResponse> FindClassroomById(JosnRPCRequest<List<string>> request)
         {
@@ -126,7 +138,11 @@ namespace TEAMModelOS.Controllers.Core
             }
             return builder.build();
         }
-
+        /// <summary>
+        /// 查询学生在哪些教室
+        /// </summary>
+        /// <param name="studentId"></param>
+        /// <returns></returns>
         [HttpPost("FindStudents")]
         public async Task<BaseJosnRPCResponse> FindStudents(JosnRPCRequest<string> studentId)
         {

+ 2 - 5
TEAMModelOS/Controllers/Learn/HomeWorkController.cs

@@ -1,10 +1,8 @@
-using System;
+using Microsoft.AspNetCore.Mvc;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using OpenXmlPowerTools;
 using TEAMModelOS.Models;
 using TEAMModelOS.SDK.Context.Exception;
 using TEAMModelOS.SDK.Extension.DataResult.JsonRpcRequest;
@@ -14,7 +12,6 @@ using TEAMModelOS.SDK.Module.AzureCosmosDBV3;
 using TEAMModelOS.Service.Models.Core;
 using TEAMModelOS.Service.Models.Courses;
 using TEAMModelOS.Service.Models.Learn;
-using static TEAMModelOS.Service.Models.Learn.HomeWork;
 
 namespace TEAMModelOS.Controllers.Learn
 {