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

// Copyright (c) Shenyang Leading Edge Intelligent Technology Co., Ltd. All rights reserved.
package db
import (
"context"
"go.mongodb.org/mongo-driver/bson/primitive"
"leit.com/leit_seat_aps/glog"
)
/******************************************************************************
*
* @Function Name :
*-----------------------------------------------------------------------------
*
* @Description :
*
* @Function Parameters:
*
* @Return Value :
*
* @Author : Lou Wenzhi
*
* @Date : 2021/3/22 9:17
*
******************************************************************************/
type TableDataInfoLog struct {
Servername string `bson:"servername" json:"servername"` //服务名称
Tablename string `bson:"tablename" json:"tablename"` //表名称
Pkname string `bson:"pkname" json:"pkname"` //主键名称
Message string `bson:"message" json:"message"` //json信息
Createtime string `bson:"createtime" json:"createtime"` //出错函数
}
func (t *TableDataInfoLog) InsertRecord() (insertID primitive.ObjectID) {
//1.初始化链接
client := MgoDb()
//2.选择数据库,数据表
collect := client.Database("logDb").Collection("tabledatainfolog")
insertRest, err := collect.InsertOne(context.TODO(), t)
if err != nil {
glog.InfoExtln("mongodb err is", err)
return
}
insertID = insertRest.InsertedID.(primitive.ObjectID)
return insertID
}