SJA APS后端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.4 KiB

  1. // Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
  2. package db
  3. import (
  4. "context"
  5. "go.mongodb.org/mongo-driver/bson/primitive"
  6. "leit.com/leit_seat_aps/glog"
  7. )
  8. /******************************************************************************
  9. *
  10. * @Function Name :
  11. *-----------------------------------------------------------------------------
  12. *
  13. * @Description :
  14. *
  15. * @Function Parameters:
  16. *
  17. * @Return Value :
  18. *
  19. * @Author : Lou Wenzhi
  20. *
  21. * @Date : 2021/3/22 9:17
  22. *
  23. ******************************************************************************/
  24. type TableDataInfoLog struct {
  25. Servername string `bson:"servername" json:"servername"` //服务名称
  26. Tablename string `bson:"tablename" json:"tablename"` //表名称
  27. Pkname string `bson:"pkname" json:"pkname"` //主键名称
  28. Message string `bson:"message" json:"message"` //json信息
  29. Createtime string `bson:"createtime" json:"createtime"` //出错函数
  30. }
  31. func (t *TableDataInfoLog) InsertRecord() (insertID primitive.ObjectID) {
  32. //1.初始化链接
  33. client := MgoDb()
  34. //2.选择数据库,数据表
  35. collect := client.Database("logDb").Collection("tabledatainfolog")
  36. insertRest, err := collect.InsertOne(context.TODO(), t)
  37. if err != nil {
  38. glog.InfoExtln("mongodb err is", err)
  39. return
  40. }
  41. insertID = insertRest.InsertedID.(primitive.ObjectID)
  42. return insertID
  43. }