作者 tangxuhui

更新模型

package models
//DataLogK3cloud 金蝶k3cloud数据采集记录
type DataLogK3cloud struct {
tableName string `comment:"金蝶k3cloud数据采集记录" pg:"manufacture.data_log_k3cloud,alias:data_log_k3cloud"`
Id int64 `pg:",pk"`
FormId string `comment:"formId" pg:"form_id"`
RequestParam string `comment:"请求参数" pg:"request_param"`
BeginAt int64 `comment:"开始时间" pg:"begin_at"`
EndAt int64 `comment:"结束时间" pg:"begin_at"`
DataVersion int64 `comment:"数据版本" pg:"data_version"`
IsSuccess int `comment:"是否成功" pg:"is_success"`
Error string `comment:"错误信息" pg:"error"`
}
... ...
package models
//MaterialGroupK3cloud 采集自金蝶k3cloud物料分组数据
type MaterialGroupK3cloud struct {
tableName string `comment:"采集自金蝶k3cloud物料数据" pg:"manufacture.material_group_k3cloud,alias:material_group_k3cloud"`
Id int64 `pg:",pk"`
Number string `comment:"分组编码" pg:"number"`
Name string `comment:"分组名称" pg:"name"`
ParentId int64 `comment:"父级id" pg:"parent_id"`
DataVersion int64 `comment:"数据版本" pg:"data_version"`
}
... ...
package models
//MaterialK3cloud 采集自金蝶k3cloud物料数据
type MaterialK3cloud struct {
tableName string `comment:"采集自金蝶k3cloud物料数据" pg:"manufacture.material_k3cloud,alias:material_k3cloud"`
MaterialId int64 `pg:",pk"`
Name string `comment:"物料名称" pg:"name"`
Number string `comment:"物料编码" pg:"number"`
Specification string `comment:"规格型号" pg:"specification"`
ForbidStatus string `comment:"禁用状态,"A":否,"B":是" pg:"forbid_status"`
ErpClsId int `comment:"物料属性" pg:"erp_cls_id"`
BaseUnitId int `comment:"基本单位" pg:"base_unit_id"`
BaseUnitName string `comment:"基本单位名称" pg:"base_unit_name"`
CreateDate string `comment:"创建时间" pg:"create_date"`
ModifyDate string `comment:"修改时间" pg:"modify_date"`
ForbidDate string `comment:"禁用时间" pg:"forbid_date"`
ApproveDate string `comment:"审核时间" pg:"approve_date"`
MaterialGroup int `comment:"物料分组" pg:"material_group"`
MaterialGroupNumber string `comment:"物料分组编码" pg:"material_group_number"`
MaterialGroupName string `comment:"物料分组名称" pg:"material_group_name"`
RefStatus int `comment:"是否使用" pg:"ref_status"`
JoinProductId int64 `comment:"关联的product表id" pg:"join_product_id"`
DataVersion int64 `comment:"数据版本" pg:"data_version"`
}
//批量处理sql脚本样例
// -- 插入或则更新
// INSERT INTO demo_test ("id","name","version") VALUES (9,'xx11','v1001'),(2,'xx22','v1001'),(3,'xx3','v1001'),(4,'x4','v1001')
// ON conflict(id)
// DO UPDATE SET ("id","name")=(EXCLUDED.id,EXCLUDED.name)
// RETURNING "id","name","version"
// --- 插入或则更新
// insert into demo_test_copy1 ("id","name")
// select "id","name"
// from demo_test
// on conflict("id")
// do update set
// ("id","name") = (EXCLUDED."id",EXCLUDED."name")
... ...