fix: 适配无认证环境的mycourse接口
- 移除用户未登录的错误返回 - 在无JWT认证时使用默认用户ID进行测试 - 清理未使用的gerror导入 - 适配同事调整的路由配置(无需认证组)
This commit is contained in:
parent
c63133380f
commit
06b7842580
@ -6,7 +6,6 @@ import (
|
|||||||
"hotgo/internal/library/contexts"
|
"hotgo/internal/library/contexts"
|
||||||
"hotgo/internal/service"
|
"hotgo/internal/service"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
|
||||||
"github.com/gogf/gf/v2/os/gtime"
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,10 +21,11 @@ func New() *sMyCourse {
|
|||||||
|
|
||||||
// GetList 获取我的课程列表
|
// GetList 获取我的课程列表
|
||||||
func (s *sMyCourse) GetList(ctx context.Context, req *v1.MyCourseListReq) (res *v1.MyCourseListRes, err error) {
|
func (s *sMyCourse) GetList(ctx context.Context, req *v1.MyCourseListReq) (res *v1.MyCourseListRes, err error) {
|
||||||
// 从JWT中间件解析出的用户ID
|
// 获取用户ID(测试环境下使用默认用户ID)
|
||||||
userId := contexts.GetUserId(ctx)
|
userId := contexts.GetUserId(ctx)
|
||||||
if userId <= 0 {
|
if userId <= 0 {
|
||||||
return nil, gerror.New("用户未登录")
|
// 测试环境下使用默认用户ID
|
||||||
|
userId = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// 模拟数据 - 实际项目中应该从数据库查询
|
// 模拟数据 - 实际项目中应该从数据库查询
|
||||||
|
Loading…
x
Reference in New Issue
Block a user