Переглянути джерело

替换plan和bill add接口

sun-pc-linux 7 місяців тому
батько
коміт
940e74b5c0

+ 8 - 1
boxcost/api/bill-produce.go

@@ -128,15 +128,22 @@ func CreateProduceBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	// 制单人数据
 	userId, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
 	fmt.Println("userId:", apictx.User.Parent)
+	userInfo := &model.UserSmaple{}
 	if !userId.IsZero() {
 		user, err := getUserById(apictx, userId)
+		userInfo = user
 		if err == nil {
 			bill.UserName = user.Name
 			bill.UserId = userId
 		}
 	}
 
-	result, err := repo.RepoAddDoc(ctx, repo.CollectionBillProduce, &bill)
+	result, err := repo.RepoAddDoc1(ctx, repo.CollectionBillProduce, &bill, &repo.RecordLogReq{
+		Path:     c.Request.URL.Path,
+		UserInfo: userInfo,
+		TargetId: "",
+		Type:     "created",
+	})
 	return result, err
 }
 

+ 8 - 1
boxcost/api/bill-product.go

@@ -129,15 +129,22 @@ func CreateProductBill(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	// 制单人数据
 	userId, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
 	fmt.Println("userId:", apictx.User.Parent)
+	userInfo := &model.UserSmaple{}
 	if !userId.IsZero() {
 		user, err := getUserById(apictx, userId)
+		userInfo = user
 		if err == nil {
 			bill.UserName = user.Name
 			bill.UserId = userId
 		}
 	}
 
-	result, err := repo.RepoAddDoc(ctx, repo.CollectionBillProduct, &bill)
+	result, err := repo.RepoAddDoc1(ctx, repo.CollectionBillProduct, &bill, &repo.RecordLogReq{
+		Path:     c.Request.URL.Path,
+		UserInfo: userInfo,
+		TargetId: "",
+		Type:     "created",
+	})
 	return result, err
 }
 

+ 8 - 1
boxcost/api/bill.go

@@ -179,15 +179,22 @@ func CreateBill(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	// 制单人数据
 	userId, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
 	fmt.Println("userId:", apictx.User.Parent)
+	userInfo := &model.UserSmaple{}
 	if !userId.IsZero() {
 		user, err := getUserById(apictx, userId)
+		userInfo = user
 		if err == nil {
 			bill.UserName = user.Name
 			bill.UserId = userId
 		}
 	}
 
-	return repo.RepoAddDoc(ctx, repo.CollectionBillPurchase, &bill)
+	return repo.RepoAddDoc1(ctx, repo.CollectionBillPurchase, &bill, &repo.RecordLogReq{
+		Path:     c.Request.URL.Path,
+		UserInfo: userInfo,
+		TargetId: "",
+		Type:     "created",
+	})
 }
 
 // 获取单据信息

+ 8 - 1
boxcost/api/plan.go

@@ -1255,8 +1255,15 @@ func CreateProductPlan(c *gin.Context, apictx *ApiSession) (interface{}, error)
 	plan.Status = "process" // 进行中
 	plan.CreateTime = time.Now()
 	plan.UpdateTime = time.Now()
+	userId, _ := primitive.ObjectIDFromHex(apictx.User.ID)
+	userInfo, _ := getUserById(apictx, userId)
 
-	result, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionProductPlan, &plan)
+	result, err := repo.RepoAddDoc1(apictx.CreateRepoCtx(), repo.CollectionProductPlan, &plan, &repo.RecordLogReq{
+		Path:     c.Request.URL.Path,
+		UserInfo: userInfo,
+		TargetId: "",
+		Type:     "created",
+	})
 	return result, err
 }
 

+ 2 - 2
boxcost/db/repo/repo.go

@@ -112,10 +112,10 @@ func RepoAddDoc1(ctx *RepoSession, collectName string, doc interface{}, recordLo
 			}
 			history := &dm.History{
 				Userinfo:   recordLogReq.UserInfo,
-				TargetId:   recordLogReq.TargetId,
+				TargetId:   insertId,
 				Path:       recordLogReq.Path,
 				Collection: collectName,
-				Type:       "create",
+				Type:       recordLogReq.Type,
 				Content:    string(newObjByte),
 				CreateTime: time.Now(),
 			}