finish
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
|
||||
// BackArticle article struct
|
||||
type BackArticle struct {
|
||||
ID int `gorm:"primaryKey;column:id" json:"-"` // 文章id
|
||||
ID int `gorm:"primaryKey;column:id" json:"id"` // 文章id
|
||||
CreateTime time.Time `gorm:"column:create_time" json:"createTime"` // 文章新建时间
|
||||
CreateUser int `gorm:"column:create_user" json:"createUser"` // 文章创建者id
|
||||
ModifyTime time.Time `gorm:"column:modify_time" json:"modifyTime"` // 文章最后更新时间
|
||||
@@ -21,7 +21,7 @@ type BackArticle struct {
|
||||
}
|
||||
|
||||
type ListArticle struct {
|
||||
ID int `json:"-"`
|
||||
ID int `json:"id"`
|
||||
Username string `json:"username"`
|
||||
CreateTime time.Time `json:"createTime"`
|
||||
ModifyTime time.Time `json:"modifyTime"`
|
||||
@@ -34,13 +34,3 @@ type ListArticle struct {
|
||||
func init() {
|
||||
initJcMap[BackArticle]()
|
||||
}
|
||||
|
||||
//func ArticleMapJ2c(jsonMap map[string]interface{}, ignoreNil bool) map[string]interface{} {
|
||||
// colMap := make(map[string]interface{})
|
||||
// for k, v := range jsonMap {
|
||||
// if colKey := colKey != "" && (!ignoreNil && v == nil) {
|
||||
// colMap[colKey] = v
|
||||
// }
|
||||
// }
|
||||
// return colMap
|
||||
//}
|
||||
|
||||
1
models/kafka.go
Normal file
1
models/kafka.go
Normal file
@@ -0,0 +1 @@
|
||||
package models
|
||||
@@ -63,7 +63,7 @@ type BackSituationRecord struct {
|
||||
IsDelete int `gorm:"column:is_delete" json:"isDelete"` // 删除标志
|
||||
}
|
||||
|
||||
type ListObeservation struct {
|
||||
type ListObservation struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"` // 姓名
|
||||
Age int `json:"age"` // 年龄
|
||||
@@ -81,10 +81,31 @@ type ListObeservation struct {
|
||||
CreateTime time.Time `json:"createTime"` // 创建时间
|
||||
ModifyUser int `json:"modifyUser"` // 修改者
|
||||
ModifyTime time.Time `json:"modifyTime"` // 修改时间
|
||||
PcrTime time.Time `json:"pcrTime"` //核酸时间
|
||||
PcrResult int `json:"pcrResult"` //核酸结果
|
||||
RecordTime time.Time `json:"recordTime"` //状态转换时间
|
||||
Record string `json:"record"` //状态转换内容
|
||||
PcrTime time.Time `json:"pcrTime"` // 核酸时间
|
||||
PcrResult int `json:"pcrResult"` // 核酸结果:0-未检测,1-阴性,2-阳性
|
||||
RecordTime time.Time `json:"recordTime"` // 状态转换时间
|
||||
Record string `json:"record"` // 状态转换内容
|
||||
}
|
||||
|
||||
type TreeObservation struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"` // 姓名
|
||||
Age int `json:"age"` // 年龄
|
||||
Sex int `json:"sex"` // 性别
|
||||
Phone string `json:"phone"` // 手机号码
|
||||
Identification string `json:"identification"` // 身份证号
|
||||
ContactPerson int `json:"contactPerson"` // 接触者id
|
||||
Region string `json:"region"` // 受观察者所在区域
|
||||
Address string `json:"address"` // 受观察者所在具体地点
|
||||
HealthSituation int `json:"healthSituation"` // 被观察者的疫情状况:0- 其他,1-患者,2-密接,3-次密接
|
||||
HealthChangeTime time.Time `json:"healthChangeTime"` // 患者健康状况转化时间
|
||||
MeasureSituation int `json:"measureSituation"` // 受观察者被采取措施状况 :0-未采取措施,1-解除风险,2-正在治疗,3-集中隔离,4-居家隔离
|
||||
Trajectory string `json:"trajectory"` // 行程轨迹
|
||||
CreateUser int `json:"createUser"` // 创建者
|
||||
CreateTime time.Time `json:"createTime"` // 创建时间
|
||||
ModifyUser int `json:"modifyUser"` // 修改者
|
||||
ModifyTime time.Time `json:"modifyTime"` // 修改时间
|
||||
Children []*TreeObservation `json:"children"` // 子结点
|
||||
}
|
||||
|
||||
type QueryObservation struct {
|
||||
|
||||
@@ -4,6 +4,12 @@ import "time"
|
||||
|
||||
type BackNotification struct {
|
||||
Time time.Time `json:"time"`
|
||||
Kind int `json:"kind"`
|
||||
Kind string `json:"kind"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type SendInfo struct {
|
||||
Region []string `json:"region"`
|
||||
Channel []int `json:"channel"`
|
||||
Notification BackNotification `json:"notification"`
|
||||
}
|
||||
|
||||
@@ -2,11 +2,13 @@ package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"nCovTrack-Backend/global"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var colNameReg, _ = regexp.Compile(".*column:(.*);?")
|
||||
@@ -124,7 +126,7 @@ func BeforeBatchSave(colMaps *[]map[string]interface{}, user int) {
|
||||
|
||||
func Upsert[T any](colMap map[string]interface{}) (ok bool, rowsAffected int64) {
|
||||
var tx *gorm.DB
|
||||
if colMap["id"] == nil || int(colMap["id"].(float64)) == 0 {
|
||||
if colMap["id"] == nil || getMapId(colMap["id"]) == 0 {
|
||||
tx = global.Db.Model(new(T)).Create(colMap)
|
||||
} else {
|
||||
tx = global.Db.Model(new(T)).Where("id = ?", colMap["id"]).Updates(colMap)
|
||||
@@ -169,7 +171,7 @@ func DeleteById[T any](id int) (ok bool, rowsAffected int64) {
|
||||
if tx.Error != nil {
|
||||
return false, 0
|
||||
}
|
||||
return true, rowsAffected
|
||||
return true, tx.RowsAffected
|
||||
}
|
||||
|
||||
func DropById[T any](id int) {
|
||||
@@ -253,3 +255,17 @@ func CountByOrm(tx *gorm.DB) int64 {
|
||||
tx.Count(&count)
|
||||
return count
|
||||
}
|
||||
|
||||
func getMapId(id interface{}) int {
|
||||
switch id.(type) {
|
||||
case int:
|
||||
return id.(int)
|
||||
case string:
|
||||
id, _ := strconv.Atoi(id.(string))
|
||||
return id
|
||||
case float64:
|
||||
return int(id.(float64))
|
||||
default:
|
||||
return -1
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user