From a8fd8c58bb80045c32e1965d0bb1ed0871f8b31b Mon Sep 17 00:00:00 2001 From: dengbiao Date: Fri, 22 Nov 2024 22:24:09 +0800 Subject: [PATCH 1/3] =?UTF-8?q?update=20=E5=8D=95=E4=BE=8B=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/hdl/hdl_login.go | 14 +++++++------- app/provider/user_info.go | 22 ++++++++++++++++++++++ app/svc/svc_auth.go | 7 ++++++- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 21f1acf..66f2104 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -225,13 +225,13 @@ func Register(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } - data := svc.AliyunSmsBase(c, "") - //校验短信 - err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], req.Mobile, req.Code) - if err != nil { - e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) - return - } + //data := svc.AliyunSmsBase(c, "") + ////校验短信 + //err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], req.Mobile, req.Code) + //if err != nil { + // e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) + // return + //} commReq(c, req) } diff --git a/app/provider/user_info.go b/app/provider/user_info.go index 39f8e64..7099c9c 100644 --- a/app/provider/user_info.go +++ b/app/provider/user_info.go @@ -17,6 +17,7 @@ var ( // UserInfoProvider 定义了一个接口来管理用户信息的获取 type UserInfoProvider interface { GetUserInfo(uid int64) (*model.User, error) + ClearCache() } // userInfoProvider 实现了 UserInfoProvider 接口 @@ -25,6 +26,13 @@ type userInfoProvider struct { mu sync.RWMutex } +// NewUserInfoProvider 创建一个新的 userInfoProvider 实例 +func NewUserInfoProvider() UserInfoProvider { + return &userInfoProvider{ + userCache: make(map[int64]string), + } +} + // GetUserInfoProvider 返回 userInfoProvider 的单例实例 func GetUserInfoProvider() UserInfoProvider { once.Do(func() { @@ -60,6 +68,13 @@ func (p *userInfoProvider) GetUserInfo(uid int64) (*model.User, error) { return userModel, err } + // 将用户信息转换为 JSON 字符串 + userBytes, err := json.Marshal(userModel) + if err != nil { + return nil, fmt.Errorf("failed to marshal user info: %w", err) + } + userStr = string(userBytes) + // 缓存到内存中 p.mu.Lock() //上"写"锁 p.userCache[uid] = string(userStr) @@ -67,3 +82,10 @@ func (p *userInfoProvider) GetUserInfo(uid int64) (*model.User, error) { return userModel, nil } + +// ClearCache 清空缓存 +func (p *userInfoProvider) ClearCache() { + p.mu.Lock() // 上"写"锁 + p.userCache = make(map[int64]string) + p.mu.Unlock() // 释放"写"锁 +} diff --git a/app/svc/svc_auth.go b/app/svc/svc_auth.go index c00aedd..1624316 100644 --- a/app/svc/svc_auth.go +++ b/app/svc/svc_auth.go @@ -60,11 +60,16 @@ func CheckUser(c *gin.Context) (user *model.User, newToken string, err error) { return user, newToken, err } // 3、获取用户信息 - userInfoProvider := provider.GetUserInfoProvider() + //userInfoProvider := provider.GetUserInfoProvider() + userInfoProvider := provider.NewUserInfoProvider() userInfo, err := userInfoProvider.GetUserInfo(mc.Uid) if err != nil { return user, newToken, err } + userInfo, err = userInfoProvider.GetUserInfo(mc.Uid) + if err != nil { + return user, newToken, err + } // 4、检验账号是否未激活或被冻结 if userInfo.State == int(enum.UserStateForFreeze) { From 3a9dbd537ec22895a149f68735ca589223106ace Mon Sep 17 00:00:00 2001 From: dengbiao Date: Fri, 22 Nov 2024 22:36:55 +0800 Subject: [PATCH 2/3] uypdate --- app/hdl/hdl_login.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/hdl/hdl_login.go b/app/hdl/hdl_login.go index 66f2104..21f1acf 100644 --- a/app/hdl/hdl_login.go +++ b/app/hdl/hdl_login.go @@ -225,13 +225,13 @@ func Register(c *gin.Context) { e.OutErr(c, err1.Code, err1.Error()) return } - //data := svc.AliyunSmsBase(c, "") - ////校验短信 - //err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], req.Mobile, req.Code) - //if err != nil { - // e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) - // return - //} + data := svc.AliyunSmsBase(c, "") + //校验短信 + err = aliyun.AliyunCheckSms(data["aliyun_sms_id"], data["aliyun_sms_secret"], req.Mobile, req.Code) + if err != nil { + e.OutErr(c, 400, e.NewErr(400, "验证码错误,请重试")) + return + } commReq(c, req) } From 70a3509150325d9e8af1b505d46fc440818bbb52 Mon Sep 17 00:00:00 2001 From: shenjiachi Date: Sat, 23 Nov 2024 09:25:38 +0800 Subject: [PATCH 3/3] update --- app/hdl/hdl_points_center.go | 4 ++++ app/router/router.go | 1 + go.mod | 4 ++-- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/app/hdl/hdl_points_center.go b/app/hdl/hdl_points_center.go index dd3eff6..2b753b8 100644 --- a/app/hdl/hdl_points_center.go +++ b/app/hdl/hdl_points_center.go @@ -427,3 +427,7 @@ func GetContributionValueFlow(c *gin.Context) { e.OutSuc(c, resp, nil) } + +func GetEggPointRecord(c *gin.Context) { + +} diff --git a/app/router/router.go b/app/router/router.go index 4b34001..43b83c8 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -90,6 +90,7 @@ func route(r *gin.RouterGroup) { rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换 rPointsCenter.GET("/contributionValue", hdl.GetContributionValue) // 积分中心-贡献值 rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细 + rPointsCenter.GET("/record", hdl.GetEggPointRecord) // 积分中心-蛋蛋分历史记录 } } diff --git a/go.mod b/go.mod index a27006d..4ddfbca 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.19 // replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models // -//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules +// replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules require ( github.com/boombuler/barcode v1.0.1 @@ -32,7 +32,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241122104932-0eac76d1a591 + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241122012509-ceb61ba8203c code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241122112751-6744679ac54a code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5