修复循环引用问题
This commit is contained in:
parent
f720eb509b
commit
f10e46761b
|
|
@ -142,3 +142,10 @@ func GetAllUser() []User {
|
||||||
DB.Find(&users)
|
DB.Find(&users)
|
||||||
return users
|
return users
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 用户数据同步
|
||||||
|
type UserSyncResp struct {
|
||||||
|
Update []User `json:"update" form:"update"` //更新用户
|
||||||
|
Add []User `json:"add" form:"add"` //添加用户
|
||||||
|
Delete []proto.UserDelID `json:"delete" form:"delete"` //删除用户
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -377,13 +377,6 @@ type SyncUserReq struct {
|
||||||
Confirm proto.UserSyncConfirm `json:"confirm" form:"confirm"`
|
Confirm proto.UserSyncConfirm `json:"confirm" form:"confirm"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// 用户数据同步
|
|
||||||
type UserSyncResp struct {
|
|
||||||
Update []dao.User `json:"update" form:"update"` //更新用户
|
|
||||||
Add []dao.User `json:"add" form:"add"` //添加用户
|
|
||||||
Delete []proto.UserDelID `json:"delete" form:"delete"` //删除用户
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetSyncUserInfo(c *gin.Context) {
|
func GetSyncUserInfo(c *gin.Context) {
|
||||||
var req_data SyncUserReq
|
var req_data SyncUserReq
|
||||||
if err := c.ShouldBind(&req_data); err == nil {
|
if err := c.ShouldBind(&req_data); err == nil {
|
||||||
|
|
@ -395,7 +388,7 @@ func GetSyncUserInfo(c *gin.Context) {
|
||||||
if proto.Config.SERVER_USER_TYPE == "master" {
|
if proto.Config.SERVER_USER_TYPE == "master" {
|
||||||
if req_data.Types == 1 { //1为全量同步
|
if req_data.Types == 1 { //1为全量同步
|
||||||
add_users := dao.GetAllUser()
|
add_users := dao.GetAllUser()
|
||||||
resp := UserSyncResp{}
|
resp := dao.UserSyncResp{}
|
||||||
resp.Add = add_users
|
resp.Add = add_users
|
||||||
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": resp})
|
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": resp})
|
||||||
} else if req_data.Types == 2 { //2为增量同步
|
} else if req_data.Types == 2 { //2为增量同步
|
||||||
|
|
@ -413,7 +406,7 @@ func GetSyncUserInfo(c *gin.Context) {
|
||||||
c.JSON(200, gin.H{"code": proto.OperationFailed, "message": "failed", "data": "failed"})
|
c.JSON(200, gin.H{"code": proto.OperationFailed, "message": "failed", "data": "failed"})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.JSON(200, gin.H{"code": proto.ParameterError, "message": "type is error", "data": UserSyncResp{}})
|
c.JSON(200, gin.H{"code": proto.ParameterError, "message": "type is error", "data": dao.UserSyncResp{}})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
c.JSON(200, gin.H{"code": proto.NoPermission, "message": "no permission,server is not master", "data": proto.UserSync{}})
|
c.JSON(200, gin.H{"code": proto.NoPermission, "message": "no permission,server is not master", "data": proto.UserSync{}})
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
"videoplayer/handler"
|
|
||||||
"videoplayer/proto"
|
"videoplayer/proto"
|
||||||
"videoplayer/worker"
|
"videoplayer/worker"
|
||||||
)
|
)
|
||||||
|
|
@ -130,7 +129,7 @@ func UserSyncDataFromMaster() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 同步数据到主服务器-增删改数据
|
// 同步数据到主服务器-增删改数据
|
||||||
func GetUserSyncData(device string) handler.UserSyncResp {
|
func GetUserSyncData(device string) dao.UserSyncResp {
|
||||||
key := device + "_sync_user_ids"
|
key := device + "_sync_user_ids"
|
||||||
add_temp_key := device + "_sync_user_ids_add_confirm_temp"
|
add_temp_key := device + "_sync_user_ids_add_confirm_temp"
|
||||||
update_temp_key := device + "_sync_user_ids_update_confirm_temp"
|
update_temp_key := device + "_sync_user_ids_update_confirm_temp"
|
||||||
|
|
@ -165,7 +164,7 @@ func GetUserSyncData(device string) handler.UserSyncResp {
|
||||||
worker.ClearRedisSet(key + "_update")
|
worker.ClearRedisSet(key + "_update")
|
||||||
worker.SetRedisSetUnionAndStore(delete_temp_key, key+"_delete")
|
worker.SetRedisSetUnionAndStore(delete_temp_key, key+"_delete")
|
||||||
worker.ClearRedisSet(key + "_delete")
|
worker.ClearRedisSet(key + "_delete")
|
||||||
return handler.UserSyncResp{Add: add_users, Update: update_users, Delete: delete_users}
|
return dao.UserSyncResp{Add: add_users, Update: update_users, Delete: delete_users}
|
||||||
}
|
}
|
||||||
|
|
||||||
func setSyncUserDataSet(t string, id int) error {
|
func setSyncUserDataSet(t string, id int) error {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue