Merge branch 'refs/heads/feat-user-sync'

This commit is contained in:
junleea 2024-12-15 15:06:20 +08:00
commit 1bb639504d
2 changed files with 9 additions and 10 deletions

View File

@ -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{}})

View File

@ -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"` //更新用户