Ver código fonte

Merge branch 'develop5.0-tmd' of http://106.12.23.251:10000/TEAMMODEL/TEAMModelOS into develop5.0-tmd

liqk 4 anos atrás
pai
commit
993a214940

+ 1 - 1
TEAMModelOS/ClientApp/src/api/openMgmt.js

@@ -20,7 +20,7 @@ export default{
      * @param {} data
      */
     getApiList: function (data) {
-        return post('/open-api/get', data)
+        return post('/open-api/get-api', data)
     },
     /**
      * 新增/编辑

+ 5 - 0
TEAMModelOS/ClientApp/src/locale/lang/en-US/settings.js

@@ -56,6 +56,11 @@ export default {
 	openStatus: '状态',
 	enable: '启用',
 	disable: '禁用',
+	webhook: "webhook",
+	domainName: "域名",
+	subNews: "订阅通知",
+	apiType1: "数据写入接口",
+	apiType2: "数据读取接口",
 	apiName: '接口名称',
 	apiAddress: '接口地址',
 	apiMethod: '请求方法',

+ 5 - 0
TEAMModelOS/ClientApp/src/locale/lang/zh-CN/settings.js

@@ -56,6 +56,11 @@ export default {
 	openStatus: '状态',
 	enable: '启用',
 	disable: '禁用',
+	webhook: "webhook",
+	domainName: "域名",
+	subNews: "订阅通知",
+	apiType1: "数据写入接口",
+	apiType2: "数据读取接口",
 	apiName: '接口名称',
 	apiAddress: '接口地址',
 	apiMethod: '请求方法',

+ 6 - 1
TEAMModelOS/ClientApp/src/locale/lang/zh-TW/settings.js

@@ -56,10 +56,15 @@ export default {
     openStatus: '狀態',
     enable: '啟用',
     disable: '禁用',
+    webhook: "webhook",
+    domainName: "域名",
+	subNews: "訂閱通知",
+	apiType1: "數據寫入接口",
+	apiType2: "數據讀取接口",
     apiName: '接口名稱',
     apiAddress: '接口地址',
     apiMethod: '請求方法',
-    apiParams: '参数示例',
+    apiParams: '參數示例',
     openKeep: '儲存平臺',
     edit: "編輯應用",
     unedit: '取消編輯',

+ 32 - 1
TEAMModelOS/ClientApp/src/view/settings/OpenMgmt2.css

@@ -68,11 +68,26 @@
                 } */
 }
 .open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info {
-  padding: 20px;
+  padding: 20px 20px 0 20px;
   /* .ivu-radio-inner{
                         background-color: #F3F3F3;
                     } */
 }
+.open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info + p {
+  color: #949494;
+  height: 40px;
+  line-height: 40px;
+  padding-left: 20px;
+  border-top: 1px solid #424242;
+  border-bottom: 1px solid #424242;
+}
+.open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info .ivu-checkbox {
+  margin-right: 0;
+}
+.open-mgmt .open-mgmt-right .open-right-info .open-info .open-mgmt-info .ivu-checkbox-wrapper {
+  margin-left: 0;
+  margin-right: 30px;
+}
 .open-mgmt .open-mgmt-right .open-right-info .open-info .ivu-form-item:not(:first-child) {
   margin-top: 30px;
 }
@@ -97,9 +112,25 @@
 .open-mgmt .open-mgmt-right .open-right-info .open-api {
   width: 70%;
 }
+.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav {
+  color: #a5a5a5;
+}
+.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav .ivu-tabs-ink-bar {
+  border-bottom: 2px solid #1cc0f3;
+}
+.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav .ivu-tabs-tab-active {
+  font-size: 14px;
+  color: #fff;
+}
+.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-nav .ivu-tabs-tab:hover {
+  color: #fff;
+}
 .open-mgmt .open-mgmt-right .open-right-info .open-api .open-api-header {
   height: 40px;
 }
+.open-mgmt .open-mgmt-right .open-right-info .open-api .ivu-tabs-tab {
+  height: 40px;
+}
 .open-mgmt .open-mgmt-right .open-right-info .open-api .open-api-table {
   padding: 20px;
   /* .ivu-table-wrapper{

+ 40 - 1
TEAMModelOS/ClientApp/src/view/settings/OpenMgmt2.less

@@ -77,7 +77,25 @@
                 font-size: 16px;
 
                 .open-mgmt-info {
-                    padding: 20px;
+                    padding: 20px 20px 0 20px;
+
+                    & + p{
+                        color: #949494;
+                        height: 40px;
+                        line-height: 40px;
+                        padding-left: 20px;
+                        border-top: 1px solid #424242;
+                        border-bottom: 1px solid #424242;
+                    }
+
+                    .ivu-checkbox{
+                        margin-right: 0;
+                    }
+
+                    .ivu-checkbox-wrapper{
+                        margin-left: 0;
+                        margin-right: 30px;
+                    }
 
                     /* .ivu-radio-inner{
                         background-color: #F3F3F3;
@@ -126,10 +144,31 @@
             .open-api{
                 width: 70%;
 
+                .ivu-tabs-nav{
+                    color: #a5a5a5;
+
+                    .ivu-tabs-ink-bar{
+                        border-bottom: 2px solid #1cc0f3;
+                    }
+
+                    .ivu-tabs-tab-active{
+                        font-size: 14px;
+                        color: #fff;
+                    }
+
+                    .ivu-tabs-tab:hover{
+                        color: #fff;
+                    }
+                }
+
                 .open-api-header{
                     height: 40px;
                 }
 
+                .ivu-tabs-tab{
+                    height: 40px;
+                }
+
                 .open-api-table{
                     padding: 20px;
 

+ 129 - 45
TEAMModelOS/ClientApp/src/view/settings/OpenMgmt2.vue

@@ -48,63 +48,141 @@
             <div class="open-right-info">
                 <div class="open-info">
                     <vuescroll>
-                        <div class="open-mgmt-info dark-iview-form disabled-iview-input">
+                        <div class=" dark-iview-form disabled-iview-input">
                             <!-- <div class="open-mgmt-info"> -->
                                 <Form :model="openMgInfo" label-position="top">
-                                    <FormItem :label="$t('settings.openName')">
-                                        <Input v-model="openMgInfo.name"
-                                            :class="isEdit ? '' : 'open-info-disabled'"
-                                            :readonly="isEdit ? false : true"></Input>
-                                    </FormItem>
-                                    <FormItem :label="$t('settings.token')" class="api-token" v-show="!isEdit">
-                                        <div class="api-icon">
-                                            <!-- 隐藏 -->
-                                            <Icon :type="isTokenShow ? 'md-eye' : 'md-eye-off'" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="isTokenShow = !isTokenShow" />
-                                            <!-- 刷新 -->
-                                            <Icon type="md-refresh" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="refresh" />
-                                            <!-- 复制 -->
-                                            <Icon type="ios-copy" size="18" color="rgb(115 115 115)" @click="copyToken" />
-                                        </div>
-                                        <Input
-                                            v-model="openMgInfo.token"
-                                            type="textarea"
-                                            :autosize="{ minRows: 10 }"
-                                            class="open-info-disabled"
-                                            readonly
-                                            v-show="isTokenShow"
-                                        ></Input>
-                                    </FormItem>
-                                    <FormItem :label="$t('settings.des')">
-                                        <Input v-model="openMgInfo.descr"
-                                            type="textarea"
-                                            :autosize="{ minRows: 2 }"
-                                            :class="isEdit ? '' : 'open-info-disabled'"
-                                            :readonly="isEdit ? false : true"></Input>
-                                    </FormItem>
-                                    <FormItem :label="$t('settings.openStatus')">
-                                        <RadioGroup v-model="openMgInfo.status">
-                                            <Radio :label="1" :disabled="isEdit ? false : true">{{ $t("settings.enable") }}</Radio>
-                                            <Radio :label="0" :disabled="isEdit ? false : true">{{ $t("settings.disable") }}</Radio>
-                                        </RadioGroup>
-                                    </FormItem>
+                                    <div class="open-mgmt-info">
+                                        <FormItem :label="$t('settings.openName')">
+                                            <Input v-model="openMgInfo.name"
+                                                :class="isEdit ? '' : 'open-info-disabled'"
+                                                :readonly="isEdit ? false : true"></Input>
+                                        </FormItem>
+                                        <FormItem :label="$t('settings.token')" class="api-token" v-show="!isEdit">
+                                            <div class="api-icon">
+                                                <!-- 隐藏 -->
+                                                <Icon :type="isTokenShow ? 'md-eye' : 'md-eye-off'" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="isTokenShow = !isTokenShow" />
+                                                <!-- 刷新 -->
+                                                <Icon type="md-refresh" size="18" style="margin-right: 10px" color="rgb(115 115 115)" @click="refresh" />
+                                                <!-- 复制 -->
+                                                <Icon type="ios-copy" size="18" color="rgb(115 115 115)" @click="copyToken" />
+                                            </div>
+                                            <Input
+                                                v-model="openMgInfo.token"
+                                                type="textarea"
+                                                :autosize="{ minRows: 10 }"
+                                                class="open-info-disabled"
+                                                readonly
+                                                v-show="isTokenShow"
+                                            ></Input>
+                                        </FormItem>
+                                        <FormItem :label="$t('settings.des')">
+                                            <Input v-model="openMgInfo.descr"
+                                                type="textarea"
+                                                :autosize="{ minRows: 2 }"
+                                                :class="isEdit ? '' : 'open-info-disabled'"
+                                                :readonly="isEdit ? false : true"></Input>
+                                        </FormItem>
+                                        <FormItem :label="$t('settings.openStatus')">
+                                            <RadioGroup v-model="openMgInfo.status">
+                                                <Radio :label="1" :disabled="isEdit ? false : true">{{ $t("settings.enable") }}</Radio>
+                                                <Radio :label="0" :disabled="isEdit ? false : true">{{ $t("settings.disable") }}</Radio>
+                                            </RadioGroup>
+                                        </FormItem>
+                                    </div>
+                                    <p>{{ $t('settings.webhook') }}</p>
+                                    <div class="open-mgmt-info">
+                                        <FormItem :label="$t('settings.domainName')">
+                                            <Input v-model="openMgInfo.domain"
+                                                :class="isEdit ? '' : 'open-info-disabled'"
+                                                :readonly="isEdit ? false : true"></Input>
+                                        </FormItem>
+                                        <FormItem :label="$t('settings.subNews')">
+                                            <CheckboxGroup v-model="openMgInfo.news">
+                                                <Checkbox label="hhhh" :disabled="isEdit ? false : true">
+                                                    <span>订阅通知1</span>
+                                                </Checkbox>
+                                                <Checkbox label="www" :disabled="isEdit ? false : true">
+                                                    <span>订阅通知2</span>
+                                                </Checkbox>
+                                                <Checkbox label="mmm" :disabled="isEdit ? false : true">
+                                                    <span>订阅通知3</span>
+                                                </Checkbox>
+                                                <Checkbox label="wwwww" :disabled="isEdit ? false : true">
+                                                    <span>订阅通知4</span>
+                                                </Checkbox>
+                                            </CheckboxGroup>
+                                        </FormItem>
+                                    </div>
                                 </Form>
                             </div>
                         <!-- </div> -->
                     </vuescroll>
                 </div>
-                <div class="open-api dark-iview-table dark-iview-page">
+                <div class="open-api dark-iview-table dark-iview-page dark-iview-tabs-card">
                 <!-- <div class="open-api"> -->
-                    <vuescroll>
-                        <div class="open-api-table">
+                    <!-- <vuescroll> -->
+                        <!-- <div class="open-api-table">
+                            <p>数据写入接口</p>
                             <Table ref="selection"
                                    :loading="isLoadList"
                                    :columns="apiListCol"
                                    :data="isEdit ? apiListSelect : apiListNow"
                                    @on-selection-change="selectionChange"
                             ></Table>
-                            <!-- <Page :total="pageTotal" :page-size-opts="pageSizeOpts" size="small" show-sizer show-total /> -->
-                        </div>
-                    </vuescroll>
+                            <Page :total="pageTotal" :page-size-opts="pageSizeOpts" size="small" show-sizer show-total />
+                        </div> -->
+                    <!-- </vuescroll> -->
+                    <!-- <vuescroll> -->
+                        <!-- <div class="open-api-table">
+                            <p>数据读取接口</p>
+                            <Table ref="selection"
+                                   :loading="isLoadList"
+                                   :columns="apiListCol"
+                                   :data="isEdit ? apiListSelect : apiListNow"
+                                   @on-selection-change="selectionChange"
+                            ></Table>
+                            <Page :total="pageTotal" :page-size-opts="pageSizeOpts" size="small" show-sizer show-total />
+                        </div> -->
+                    <!-- </vuescroll> -->
+
+                    <Tabs value="1">
+                        <TabPane :label="$t('settings.apiType1')" name="1">
+                            <div class="open-api-table">
+                                <Table ref="selection"
+                                       :loading="isLoadList"
+                                       :columns="apiListCol"
+                                       :data="isEdit ? apiListSelect : apiListNow"
+                                       @on-selection-change="selectionChange"
+                                >
+                                    <template slot-scope="{ row }" slot="name">
+                                        <span>{{ row.name }}</span>
+                                        <Poptip trigger="hover" :content="row.descr" placement="right">
+                                            <!-- <Icon type="ios-alert" /> -->
+                                            <Icon type="ios-alert-outline" />
+                                        </Poptip>
+                                    </template>
+                                </Table>
+                            </div>
+                        </TabPane>
+                        <TabPane :label="$t('settings.apiType2')" name="2">
+                            <div class="open-api-table">
+                                <Table ref="selection"
+                                       :loading="isLoadList"
+                                       :columns="apiListCol"
+                                       :data="isEdit ? apiListSelect : apiListNow"
+                                       @on-selection-change="selectionChange"
+                                >
+                                    <template slot-scope="{ row }" slot="name">
+                                        <span>{{ row.name }}</span>
+                                        <Poptip trigger="hover" :content="row.descr" placement="right">
+                                            <!-- <Icon type="ios-alert" /> -->
+                                            <Icon type="ios-alert-outline" />
+                                        </Poptip>
+                                    </template>
+                                </Table>
+                            </div>
+                        </TabPane>
+                    </Tabs>
                 </div>
             </div>
         </div>
@@ -122,6 +200,7 @@ export default {
             schoolCode: this.$store.state.userInfo.schoolCode,
             openList: [], //开放平台列表
             openMgInfo: {}, //平台信息
+            apiType: 1,
             apiListCol: [ //api表头
                 /* {
                     type: 'selection',
@@ -131,6 +210,7 @@ export default {
                 {
                     title: this.$t("settings.apiName"),
                     key: "name",
+                    slot: "name"
                 },
                 {
                     title: this.$t("settings.apiAddress"),
@@ -141,7 +221,7 @@ export default {
                     key: "method",
                 },
                 {
-                    title: this.$t("settings.apiParams"),
+                    title: this.$t("settings.des"),
                     key: "descr",
                 },
             ],
@@ -406,7 +486,11 @@ export default {
         selectionChange(selection) {
             this.apiListNow = selection
             console.log(selection);
-        }
+        },
+        selectMenu(name) {
+            console.log(name);
+            this.apiType = name
+        },
     }
 }
 </script>

+ 3 - 3
TEAMModelOS/Controllers/Item/ItemController.cs

@@ -122,12 +122,12 @@ namespace TEAMModelOS.Controllers
                     {
                         if (itemInfo.scope.Equals("private"))
                         {
-                            itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            itemInfo = await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
                         }
                         else
                         {
-                          // itemInfo.periodId
-                            itemInfo = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
+                            // itemInfo.periodId
+                            itemInfo = await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync(itemInfo, new PartitionKey($"{itemInfo.code}"));
                             ItemCond itemCond = null;
                             try {
 

+ 4 - 28
TEAMModelOS/Controllers/Pager/PaperController.cs

@@ -220,24 +220,15 @@ namespace TEAMModelOS.Controllers
             paper.code = "Paper-" + paper.code;
             if (option.ToString().Equals("insert"))
             {               
-                var response = await client.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(paper.id, new PartitionKey($"{paper.code}"));
-                if (response.Status == 200)
+                if (paper.scope.Equals("private"))
                 {
-                    return Ok(new { error = ResponseCode.DATA_EXIST, V = "试卷已经存在!" });
+                    paper = await client.GetContainer("TEAMModelOS", "Teacher").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
                 }
                 else
                 {
-                    if (paper.scope.Equals("private"))
-                    {
-                        //paper.JsonRemove("periodId");
-                        paper = await client.GetContainer("TEAMModelOS", "Teacher").CreateItemAsync(paper, new PartitionKey($"{paper.code}"));
-                    }
-                    else
-                    {
-                        //paper.JsonRemove("periodId");
-                        paper = await client.GetContainer("TEAMModelOS", "School").CreateItemAsync(paper, new PartitionKey($"{paper.code}"));
-                    }
+                    paper = await client.GetContainer("TEAMModelOS", "School").UpsertItemAsync(paper, new PartitionKey($"{paper.code}"));
                 }
+                
             }
             else
             {
@@ -251,21 +242,6 @@ namespace TEAMModelOS.Controllers
                 }
             }
             return Ok(new { paper });
-            /*ResponseBuilder builder = ResponseBuilder.custom();
-            if (string.IsNullOrEmpty(request.id))
-            {
-                request.id = _snowflakeId.NextId() + ""; 
-                request.createTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
-                await _azureCosmos.SaveOrUpdate(request);
-            }
-            else
-            {
-                await _azureCosmos.SaveOrUpdate(request);
-            }
-            
-            return builder.Data(request).build();*/
-            //return Ok();
         }
-
     }
 }

+ 49 - 30
TEAMModelOS/Controllers/Syllabus/ShareController.cs

@@ -260,34 +260,7 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("opt", out JsonElement opt)) { return BadRequest(); }
                 var client = _azureCosmos.GetCosmosClient();
                 Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
-                Syllabus syllabus = null;
-                if (share.scope == "school")
-                {
-                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
-                }
-                else if (share.scope == "private")
-                {
-                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
-                }
-                if (syllabus.auth.IsNotEmpty())
-                {
-                    syllabus.auth.ForEach(x =>
-                    {
-                        if (x.tmdid == $"{code}" && x.type == $"{type}")
-                        {
-                            if ($"{opt}".Equals("ignore"))
-                            {
-                                x.agree = 0;
-                            }
-                            else if ($"{opt}".Equals("ignore")) {
-                                x.agree = 1;
-                            }
-
-                        }
-                    });
-                }
-
-                if ($"{opt}".Equals("ignore"))
+                if ($"{opt}".Equals("agree"))
                 {
                     share.agree = 1;
                     await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, $"{id}", new PartitionKey($"Share-{type}-{code}"));
@@ -296,13 +269,53 @@ namespace TEAMModelOS.Controllers
                 {
                     await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemAsync<Share>($"{id}", new PartitionKey($"Share-{type}-{code}"));
                 }
+
+                Syllabus syllabus = null;
                 if (share.scope == "school")
                 {
-                    syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    try 
+                    { 
+                        syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    } catch {
+                        //仅处理差不到数据的情况
+                    }
                 }
                 else if (share.scope == "private")
                 {
-                    syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    try 
+                    {
+                        syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>($"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    } catch 
+                    {
+                    }
+                }
+                if (syllabus != null) {
+                    if (syllabus.auth.IsNotEmpty())
+                    {
+                        syllabus.auth.ForEach(x =>
+                        {
+                            if (x.tmdid == $"{code}" && x.type == $"{type}")
+                            {
+                                if ($"{opt}".Equals("ignore"))
+                                {
+                                    x.agree = 0;
+                                }
+                                else if ($"{opt}".Equals("ignore"))
+                                {
+                                    x.agree = 1;
+                                }
+
+                            }
+                        });
+                    }
+                    if (share.scope == "school")
+                    {
+                        syllabus = await client.GetContainer("TEAMModelOS", "School").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    }
+                    else if (share.scope == "private")
+                    {
+                        syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Syllabus>(syllabus, $"{id}", new PartitionKey($"Syllabus-{share.volumeId}"));
+                    }
                 }
                 return Ok(new { status = 200 });
             } catch (Exception ex) {
@@ -310,6 +323,12 @@ namespace TEAMModelOS.Controllers
                 return Ok(new { status = 500 });
             }
         }
+        /// <summary>
+        /// 删除共享记录
+        /// {"id":"章节id","type:"coedit/share","code":"教师tmdid"}
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
         [ProducesDefaultResponseType]
         [HttpPost("del-share")]
         public async Task<IActionResult> DelShare(JsonElement request) {

+ 33 - 0
TEAMModelOS/Controllers/Syllabus/SyllabusController.cs

@@ -240,11 +240,44 @@ namespace TEAMModelOS.Controllers
                 var client = _azureCosmos.GetCosmosClient();
                 if (scope.ToString().Equals("school"))
                 {
+                    Syllabus syllabus = await client.GetContainer("TEAMModelOS", "School").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    if (syllabus.auth.IsNotEmpty()) {
+                        foreach (var a in syllabus.auth)
+                        {
+                            try
+                            {
+                                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                share.agree = -1;
+                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                            }
+                            catch (Exception ex)
+                            {
+                                ///仅用于处理查不到该数据的问题
+                            }
+                        }
+                    }
                     var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
+                    Syllabus syllabus = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Syllabus>(id.ToString(), new PartitionKey($"Syllabus-{code}"));
+                    if (syllabus.auth.IsNotEmpty())
+                    {
+                        foreach (var a in syllabus.auth)
+                        {
+                            try
+                            {
+                                Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                share.agree = -1;
+                                await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, syllabus.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                            }
+                            catch (Exception ex)
+                            {
+                                ///仅用于处理查不到该数据的问题
+                            }
+                        }
+                    }
                     var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Syllabus-{code}"));
                     return Ok(new { code = response.Status });
                 }

+ 51 - 1
TEAMModelOS/Controllers/Syllabus/VolumeController.cs

@@ -61,19 +61,69 @@ namespace TEAMModelOS.Controllers
                 if (!request.TryGetProperty("code", out JsonElement code)) return BadRequest();
                 if (!request.TryGetProperty("scope", out JsonElement scope)) return BadRequest();
                 var client = _azureCosmos.GetCosmosClient();
+                string sql = "select value(c) from c ";
+                List<Syllabus> syllabus = new List<Syllabus>();
                 if (scope.ToString().Equals("school"))
                 {
                     var response = await client.GetContainer("TEAMModelOS", "School").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{id}") })) {
+                        syllabus.Add(item);
+                    }
+                    if (syllabus.IsNotEmpty())
+                    {
+                        foreach (var s in syllabus) {
+                            if (s.auth.IsNotEmpty()) {
+                                foreach (var a in s.auth) {
+                                    try {
+                                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        share.agree = -1;
+                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share,s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                    } catch (Exception ex) {
+                                        ///仅用于处理查不到该数据的问题
+                                    }
+                                }
+                            }
+                        }
+                        var sresponse = await client.GetContainer("TEAMModelOS", "School").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{id}");
+                    }
                     return Ok(new { code = response.Status });
                 }
                 else
                 {
                     var response = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemStreamAsync(id.ToString(), new PartitionKey($"Volume-{code}"));
+                    await foreach (var item in client.GetContainer("TEAMModelOS", "Teacher").GetItemQueryIterator<Syllabus>(queryText: sql, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Syllabus-{id}") }))
+                    {
+                        syllabus.Add(item);
+                    }
+                    if (syllabus.IsNotEmpty())
+                    {
+                        foreach (var s in syllabus)
+                        {
+                            if (s.auth.IsNotEmpty())
+                            {
+                                foreach (var a in s.auth)
+                                {
+                                    try
+                                    {
+                                        Share share = await client.GetContainer("TEAMModelOS", "Teacher").ReadItemAsync<Share>(s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                        share.agree = -1;
+                                        await client.GetContainer("TEAMModelOS", "Teacher").ReplaceItemAsync<Share>(share, s.id, new PartitionKey($"Share-{a.type}-{a.tmdid}"));
+                                    }
+                                    catch (Exception ex)
+                                    {
+                                        ///仅用于处理查不到该数据的问题
+                                    }
+                                }
+                            }
+                        }
+                        var sresponse = await client.GetContainer("TEAMModelOS", "Teacher").DeleteItemsStreamAsync(syllabus.Select(x => x.id).ToList(), $"Syllabus-{id}");
+                    }
                     return Ok(new { code = response.Status });
                 }
             }
-            catch (Exception e)
+            catch (Exception ex)
             {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},VolumeController:Delete\n{ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
                 return BadRequest();
             }
         }