diff --git a/handler/user.go b/handler/user.go index eb06568..f37993b 100644 --- a/handler/user.go +++ b/handler/user.go @@ -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 := proto.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": proto.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{}}) diff --git a/proto/user_req.go b/proto/user_req.go index 6711302..f3b9435 100644 --- a/proto/user_req.go +++ b/proto/user_req.go @@ -2,7 +2,6 @@ package proto import ( "time" - "videoplayer/dao" ) type UpdateUserInfoReq struct { @@ -34,13 +33,6 @@ type CronInfo struct { Every int `json:"every" form:"every"` //每隔多少秒执行一次,小于等于0表示不执行,时间粒度为10s } -// 用户数据同步 -type UserSyncResp struct { - Update []dao.User `json:"update" form:"update"` //更新用户 - Add []dao.User `json:"add" form:"add"` //添加用户 - Delete []UserDelID `json:"delete" form:"delete"` //删除用户 -} - // 用户数据同步 type UserSync struct { Update []UserAddOrUpdate `json:"update" form:"update"` //更新用户