Merge branch 'refs/heads/feat-user-sync'
This commit is contained in:
commit
1bb639504d
|
|
@ -377,6 +377,13 @@ 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 {
|
||||||
|
|
@ -388,7 +395,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 := proto.UserSyncResp{}
|
resp := 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为增量同步
|
||||||
|
|
@ -406,7 +413,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": proto.UserSyncResp{}})
|
c.JSON(200, gin.H{"code": proto.ParameterError, "message": "type is error", "data": 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{}})
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ package proto
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
"videoplayer/dao"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type UpdateUserInfoReq struct {
|
type UpdateUserInfoReq struct {
|
||||||
|
|
@ -34,13 +33,6 @@ type CronInfo struct {
|
||||||
Every int `json:"every" form:"every"` //每隔多少秒执行一次,小于等于0表示不执行,时间粒度为10s
|
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 {
|
type UserSync struct {
|
||||||
Update []UserAddOrUpdate `json:"update" form:"update"` //更新用户
|
Update []UserAddOrUpdate `json:"update" form:"update"` //更新用户
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue