浏览代码

修改update接口

Ohio-HYF 1 年之前
父节点
当前提交
8a1a400d43
共有 4 个文件被更改,包括 126 次插入73 次删除
  1. 26 64
      .idea/workspace.xml
  2. 42 0
      db/selection.go
  3. 7 6
      model/http_model/UpdateSelectionRequest.go
  4. 51 3
      service/selection.go

+ 26 - 64
.idea/workspace.xml

@@ -5,76 +5,17 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="8dde75a1-d1c1-4fc1-81a0-4db9a43a6250" name="更改" comment="">
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409143823.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409145238.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409154616.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409154618.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409154646.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409154651.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409154652.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/Settle_20230409160253.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/number_info_20230408160507.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/number_info_20230408223420.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/db/number_info_20230408223440.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/SpecialTaskDataList_20230408160507.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/SpecialTaskDataList_20230409142026.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/SpecialTaskDataList_20230409142031.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/SpecialTaskDataList_20230409142144.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/SpecialTaskDataList_20230409142154.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/SpecialTaskDataList_20230409142300.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/getSpecialSettleNumber_20230408221028.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/getSpecialSettleNumber_20230408221059.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/getSpecialSettleNumber_20230408221432.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/getSpecialSettleNumber_20230408221554.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/specialTaskSettleList_20230409141710.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/handler/specialTaskSettleList_20230409153734.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/common_model/talent_condition_20230408160507.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/common_model/talent_condition_20230409150405.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409142613.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409142759.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409142857.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409142918.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409142920.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409150325.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/SpecialTaskSettleList_20230409150554.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/getSpecialSettleNumber_20230408221230.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/getSpecialSettleNumber_20230408221426.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/model/http_model/getSpecialSettleNumber_20230408221548.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/pack/special_task_settle_list_20230409153856.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/pack/special_task_settle_list_20230409154145.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/pack/special_task_settle_list_20230409154146.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/pack/special_task_settle_list_condition_20230409150222.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/pack/special_task_settle_list_condition_20230409150439.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/route/init_20230408160508.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/route/init_20230409135907.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/route/init_20230409140943.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/route/init_20230409141000.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/route/init_20230409141016.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/route/init_20230409153621.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/SpecialTask_20230408160508.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/SpecialTask_20230409143447.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/SpecialTask_20230409155535.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/auto_task_20230408211730.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/auto_task_20230408215853.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/data_20230408160508.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/data_20230408215043.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/number_info_20230408160508.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.history/service/number_info_20230408223501.go" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/.gitignore" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/go.imports.xml" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/vcs.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/.idea/watcherTasks.xml" beforeDir="false" />
-      <change beforePath="$PROJECT_DIR$/model/http_model/CreateSelectionRequest.go" beforeDir="false" afterPath="$PROJECT_DIR$/model/http_model/CreateSelectionRequest.go" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/model/http_model/FindAllSelectionRequest.go" beforeDir="false" afterPath="$PROJECT_DIR$/model/http_model/FindAllSelectionRequest.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/db/selection.go" beforeDir="false" afterPath="$PROJECT_DIR$/db/selection.go" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/model/http_model/UpdateSelectionRequest.go" beforeDir="false" afterPath="$PROJECT_DIR$/model/http_model/UpdateSelectionRequest.go" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/service/auto_task.go" beforeDir="false" afterPath="$PROJECT_DIR$/service/auto_task.go" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/service/selection.go" beforeDir="false" afterPath="$PROJECT_DIR$/service/selection.go" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
     <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
     <option name="LAST_RESOLUTION" value="IGNORE" />
   </component>
-  <component name="GOROOT" url="file://$PROJECT_DIR$/../../../Application/Go" />
+  <component name="GOROOT" url="file://$PROJECT_DIR$/../../../develop_tools/Go" />
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
@@ -93,11 +34,32 @@
     "WebServerToolWindowFactoryState": "false",
     "go.import.settings.migrated": "true",
     "go.sdk.automatically.set": "true",
-    "last_opened_file_path": "C:/Users/ls",
+    "last_opened_file_path": "C:/Users/24678",
     "node.js.detected.package.eslint": "true",
     "node.js.selected.package.eslint": "(autodetect)"
   }
 }]]></component>
+  <component name="RunManager">
+    <configuration default="true" type="GoApplicationRunConfiguration" factoryName="Go Application">
+      <module name="youngee_m_api" />
+      <working_directory value="$PROJECT_DIR$" />
+      <go_parameters value="-i" />
+      <kind value="FILE" />
+      <directory value="$PROJECT_DIR$" />
+      <filePath value="$PROJECT_DIR$" />
+      <method v="2" />
+    </configuration>
+    <configuration default="true" type="GoTestRunConfiguration" factoryName="Go Test">
+      <module name="youngee_m_api" />
+      <working_directory value="$PROJECT_DIR$" />
+      <go_parameters value="-i" />
+      <kind value="DIRECTORY" />
+      <directory value="$PROJECT_DIR$" />
+      <filePath value="$PROJECT_DIR$" />
+      <framework value="gotest" />
+      <method v="2" />
+    </configuration>
+  </component>
   <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="应用程序级" UseSingleDictionary="true" transferred="true" />
   <component name="TypeScriptGeneratedFilesManager">
     <option name="version" value="3" />

+ 42 - 0
db/selection.go

@@ -240,3 +240,45 @@ func PaySelection(ctx context.Context, enterpriseId string, payMoney float64, se
 	}
 	return nil
 }
+
+func CreateSecBrief(ctx context.Context, briefInfo gorm_model.YounggeeSecBrief) error {
+	db := GetWriteDB(ctx)
+	err := db.Create(&briefInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteSecBriefBySelectionId(ctx context.Context, selectionId string) error {
+	db := GetWriteDB(ctx)
+	deleteCondition := gorm_model.YounggeeSecBrief{
+		SelectionID: selectionId,
+	}
+	err := db.Where(deleteCondition).Delete(gorm_model.YounggeeSecBrief{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func CreateSecExample(ctx context.Context, ExampleInfo gorm_model.YounggeeSecExample) error {
+	db := GetWriteDB(ctx)
+	err := db.Create(&ExampleInfo).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}
+
+func DeleteSecExampleBySelectionId(ctx context.Context, selectionId string) error {
+	db := GetWriteDB(ctx)
+	deleteCondition := gorm_model.YounggeeSecExample{
+		SelectionID: selectionId,
+	}
+	err := db.Where(deleteCondition).Delete(gorm_model.YounggeeSecExample{}).Error
+	if err != nil {
+		return err
+	}
+	return nil
+}

+ 7 - 6
model/http_model/UpdateSelectionRequest.go

@@ -3,6 +3,7 @@ package http_model
 type UpdateSelectionRequest struct {
 	EnterpriseId     string            `json:"enterprise_id"`
 	SelectionID      string            `json:"selection_id"` // 选品项目id
+	SelectionStatus  int               `json:"selection_status"`
 	Platform         int               `json:"platform"`
 	ProductId        string            `json:"product_id"`
 	ContentType      int               `json:"content_type"`
@@ -23,15 +24,15 @@ type UpdateSelectionRequest struct {
 }
 
 type SecBriefInfo struct {
-	FileUrl  string `json:"file_url"`
-	FileUid  string `json:"file_uid"`
-	FileName string `json:"file_name"`
+	PhotoUrl string `json:"photo_url"`
+	PhotoUid string `json:"photo_uid"`
+	Name     string `json:"name"`
 }
 
 type SecExampleInfo struct {
-	FileUrl  string `json:"file_url"`
-	FileUid  string `json:"file_uid"`
-	FileName string `json:"file_name"`
+	PhotoUrl string `json:"photo_url"`
+	PhotoUid string `json:"photo_uid"`
+	Name     string `json:"name"`
 }
 
 type UpdateSelectionData struct {

+ 51 - 3
service/selection.go

@@ -83,7 +83,7 @@ func (*selection) Create(ctx context.Context, request http_model.CreateSelection
 
 func (*selection) Update(ctx context.Context, request http_model.UpdateSelectionRequest, enterpriseId string) (*http_model.UpdateSelectionData, error) {
 	// 1. 检查该企业id和商品id有无选品
-	selectionInfo, err := db.GetSelectionByEnterpiseIdAndProductId(ctx, enterpriseId, conv.MustInt(request.ProductId, 0))
+	selectionInfo, err := db.GetSelectionById(ctx, request.SelectionID)
 	if err != nil {
 		return nil, err
 	}
@@ -110,16 +110,19 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 	estimatedCostToString, _ := conv.String(estimatedCost)
 	// d) 任务截止时间
 	taskDdl := time.Time{} //赋零值
-
 	taskDdl, _ = time.ParseInLocation("2006-01-02 15:04:05", request.TaskDdl, time.Local)
+	// f) 更新选品状态
+	if request.SelectionStatus != 2 {
+		request.SelectionStatus = 1
+	}
 
 	updateSelection := gorm_model.YounggeeSelectionInfo{
 		SelectionID:      request.SelectionID,
+		SelectionStatus:  request.SelectionStatus,
 		SelectionName:    selectionName,
 		EnterpriseID:     enterpriseId,
 		ProductID:        conv.MustInt(request.ProductId, 0),
 		ContentType:      conv.MustInt(request.ContentType, 0),
-		SelectionStatus:  1,
 		TaskMode:         conv.MustInt(request.TaskMode, 0),
 		Platform:         conv.MustInt(request.Platform, 0),
 		SampleMode:       conv.MustInt(request.SampleMode, 0),
@@ -155,6 +158,51 @@ func (*selection) Update(ctx context.Context, request http_model.UpdateSelection
 		return nil, err
 	}
 
+	// 4. 更新选品brief和示例
+	if request.SecBrief != nil {
+		// 删除已有brief
+		err = db.DeleteSecBriefBySelectionId(ctx, selectionInfo.SelectionID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的brief
+		for _, v := range request.SecBrief {
+			brief := gorm_model.YounggeeSecBrief{
+				SelectionID: selectionInfo.SelectionID,
+				FileUid:     v.PhotoUid,
+				FileName:    v.Name,
+				FileUrl:     v.PhotoUrl,
+				CreatedAt:   time.Now(),
+			}
+			err = db.CreateSecBrief(ctx, brief)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
+	if request.SecExample != nil {
+		// 删除已有示例
+		err = db.DeleteSecExampleBySelectionId(ctx, selectionInfo.SelectionID)
+		if err != nil {
+			return nil, err
+		}
+		// 插入新的示例
+		for _, v := range request.SecExample {
+			Example := gorm_model.YounggeeSecExample{
+				SelectionID: selectionInfo.SelectionID,
+				FileUid:     v.PhotoUid,
+				FileName:    v.Name,
+				FileUrl:     v.PhotoUrl,
+				CreatedAt:   time.Now(),
+			}
+			err = db.CreateSecExample(ctx, Example)
+			if err != nil {
+				return nil, err
+			}
+		}
+	}
+
 	res := &http_model.UpdateSelectionData{
 		SelectionId: updateSelection.SelectionID,
 	}