1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- package xiangyu
- import (
- "eta/eta_bridge/controller/resp"
- "eta/eta_bridge/logic/xiangyu"
- "github.com/gin-gonic/gin"
- "sync"
- )
- // XiangyuController 象屿指标
- type XiangyuController struct{}
- // 同步用户锁,防止重复同步,不管是全量还是增量,都是同一时间只能一个同步
- var lockSyncUser sync.Mutex
- // SyncUser
- // @Description: 全量同步用户
- // @author: Roc
- // @receiver xc
- // @datetime 2024-01-22 15:51:25
- // @param c *gin.Context
- func (xc *XiangyuController) SyncUser(c *gin.Context) {
- lockSyncUser.Lock()
- defer func() {
- lockSyncUser.Unlock()
- }()
- err := xiangyu.SyncUser()
- if err != nil {
- resp.FailData("同步失败", err.Error(), c)
- return
- }
- resp.Ok("同步成功", c)
- return
- }
- // PullUser
- // @Description: 增量同步用户
- // @author: Roc
- // @receiver xc
- // @datetime 2024-01-23 17:13:07
- // @param c *gin.Context
- func (xc *XiangyuController) PullUser(c *gin.Context) {
- lockSyncUser.Lock()
- defer func() {
- lockSyncUser.Unlock()
- }()
- err := xiangyu.PullUser()
- if err != nil {
- resp.FailData("同步失败", err.Error(), c)
- return
- }
- resp.Ok("同步成功", c)
- return
- }
|