Compare commits
2 Commits
a621cb5ad2
...
a05d3b3c7f
| Author | SHA1 | Date |
|---|---|---|
|
|
a05d3b3c7f | |
|
|
f10e46761b |
|
|
@ -142,3 +142,10 @@ func GetAllUser() []User {
|
|||
DB.Find(&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"`
|
||||
}
|
||||
|
||||
// 用户数据同步
|
||||
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) {
|
||||
var req_data SyncUserReq
|
||||
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 req_data.Types == 1 { //1为全量同步
|
||||
add_users := dao.GetAllUser()
|
||||
resp := UserSyncResp{}
|
||||
resp := dao.UserSyncResp{}
|
||||
resp.Add = add_users
|
||||
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": resp})
|
||||
} 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"})
|
||||
}
|
||||
} 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 {
|
||||
c.JSON(200, gin.H{"code": proto.NoPermission, "message": "no permission,server is not master", "data": proto.UserSync{}})
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
"videoplayer/dao"
|
||||
"videoplayer/handler"
|
||||
"videoplayer/proto"
|
||||
"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"
|
||||
add_temp_key := device + "_sync_user_ids_add_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.SetRedisSetUnionAndStore(delete_temp_key, 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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue