Browse Source

fix:edit api/sop_task/list

jimmyyem 4 months ago
parent
commit
9921ed098f
2 changed files with 5 additions and 4 deletions
  1. 4 3
      hook/authcheck.go
  2. 1 1
      internal/logic/sop_task/get_api_sop_task_list_logic.go

+ 4 - 3
hook/authcheck.go

@@ -4,15 +4,16 @@ import (
 	"context"
 	"errors"
 	"wechat-api/ent"
+	tokenModel "wechat-api/ent/token"
 )
 
 // CheckDesktopAuth 检查token是否合法同时返回token实例
 func CheckDesktopAuth(tokenStr string, client *ent.Client) (*ent.Token, error) {
 	if tokenStr == "" {
-		return nil, errors.New("check auth failed")
+		return nil, errors.New("auth cannot be null")
 	}
-	
-	token, err := client.Token.Query().Where().Only(context.Background())
+
+	token, err := client.Token.Query().Where(tokenModel.Token(tokenStr)).Only(context.Background())
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
internal/logic/sop_task/get_api_sop_task_list_logic.go

@@ -35,7 +35,7 @@ func (l *GetApiSopTaskListLogic) GetApiSopTaskList(req *types.SopApiListReq, r *
 	tokenStr := r.Header.Get("Authorization")
 	token, err := hook.CheckDesktopAuth(tokenStr, l.svcCtx.DB)
 	if err != nil {
-		return nil, errorx.NewCodeInvalidArgumentError("check auth failed")
+		return nil, errorx.NewCodeInvalidArgumentError("check auth failed:" + err.Error())
 	}
 
 	var predicates []predicate.SopTask