Compare commits
No commits in common. "a05d3b3c7f034ce99aac34e093c9fe5df2055bdc" and "a621cb5ad20743aa31248c91ef1ac76e01b90d66" have entirely different histories.
a05d3b3c7f
...
a621cb5ad2
|
|
@ -142,10 +142,3 @@ 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,6 +377,13 @@ 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 {
|
||||
|
|
@ -388,7 +395,7 @@ func GetSyncUserInfo(c *gin.Context) {
|
|||
if proto.Config.SERVER_USER_TYPE == "master" {
|
||||
if req_data.Types == 1 { //1为全量同步
|
||||
add_users := dao.GetAllUser()
|
||||
resp := dao.UserSyncResp{}
|
||||
resp := UserSyncResp{}
|
||||
resp.Add = add_users
|
||||
c.JSON(200, gin.H{"code": proto.SuccessCode, "message": "success", "data": resp})
|
||||
} else if req_data.Types == 2 { //2为增量同步
|
||||
|
|
@ -406,7 +413,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": dao.UserSyncResp{}})
|
||||
c.JSON(200, gin.H{"code": proto.ParameterError, "message": "type is error", "data": UserSyncResp{}})
|
||||
}
|
||||
} else {
|
||||
c.JSON(200, gin.H{"code": proto.NoPermission, "message": "no permission,server is not master", "data": proto.UserSync{}})
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import (
|
|||
"strconv"
|
||||
"time"
|
||||
"videoplayer/dao"
|
||||
"videoplayer/handler"
|
||||
"videoplayer/proto"
|
||||
"videoplayer/worker"
|
||||
)
|
||||
|
|
@ -129,7 +130,7 @@ func UserSyncDataFromMaster() {
|
|||
}
|
||||
|
||||
// 同步数据到主服务器-增删改数据
|
||||
func GetUserSyncData(device string) dao.UserSyncResp {
|
||||
func GetUserSyncData(device string) handler.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"
|
||||
|
|
@ -164,7 +165,7 @@ func GetUserSyncData(device string) dao.UserSyncResp {
|
|||
worker.ClearRedisSet(key + "_update")
|
||||
worker.SetRedisSetUnionAndStore(delete_temp_key, key+"_delete")
|
||||
worker.ClearRedisSet(key + "_delete")
|
||||
return dao.UserSyncResp{Add: add_users, Update: update_users, Delete: delete_users}
|
||||
return handler.UserSyncResp{Add: add_users, Update: update_users, Delete: delete_users}
|
||||
}
|
||||
|
||||
func setSyncUserDataSet(t string, id int) error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue