aadiffupdatetest.go 807 B

12345678910111213141516171819202122232425262728293031323334
  1. package api
  2. import (
  3. "box-cost/db/model"
  4. "box-cost/db/repo"
  5. "box-cost/log"
  6. "errors"
  7. "fmt"
  8. "time"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // 更新生产计划
  12. func DiffUpdatePlanTest(c *gin.Context, apictx *ApiSession) (interface{}, error) {
  13. var plan model.ProductPlan
  14. err := c.ShouldBindJSON(&plan)
  15. if err != nil {
  16. fmt.Println(err)
  17. log.Error(err)
  18. return nil, errors.New("参数错误")
  19. }
  20. if plan.Id.Hex() == "" {
  21. return nil, errors.New("id的为空")
  22. }
  23. plan.UpdateTime = time.Now()
  24. // 查询更新前数据
  25. // oldPlan := &model.ProductPlan{}
  26. // repo.RepoSeachDoc(apictx.CreateRepoCtx(),&repo.DocSearchOptions{},oldPlan)
  27. return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), "product-plan_copy1", plan.Id.Hex(), &plan)
  28. // 查询更新后数据
  29. // 差异比较
  30. // 记录到数据库中
  31. }