sun-pc 4 сар өмнө
parent
commit
e150c40a62

+ 1 - 1
src/api/home.go

@@ -30,7 +30,7 @@ func HomeContent(c *gin.Context, apictx *ApiSession) (interface{}, error) {
 	} else {
 		// 新增
 		form.CreateTime = time.Now()
-		return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionRoles, &form)
+		return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionHome, &form)
 	}
 
 }

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 1
src/http.client/category.http


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 1 - 2
src/http.client/home.http


+ 0 - 31
src/http.client/role.http

@@ -1,31 +0,0 @@
-@baseUrl = http://192.168.110.131:8086/moutai
-@token = your_jwt_token_here
-
-### 创建角色
-POST {{baseUrl}}/admin/role/create
-Authorization: Bearer {{token}}
-Content-Type: application/json
-
-{
-    "name": "管理员",
-    "key": "admin"
-}
-
-### 删除角色
-POST {{baseUrl}}/admin/role/delete/{{roleId}}
-Authorization: Bearer {{token}}
-
-### 获取角色列表
-GET {{baseUrl}}/admin/role/list
-Authorization: Bearer {{token}}
-
-### 更新角色
-POST {{baseUrl}}/admin/role/update
-Authorization: Bearer {{token}}
-Content-Type: application/json
-
-{
-    "_id": "role_id_here",
-    "name": "新角色名称",
-    "key": "admin"
-}

+ 0 - 56
src/http.client/user.http

@@ -1,56 +0,0 @@
-@baseUrl = http://192.168.110.131:8086/moutai
-@token = your_jwt_token_here
-
-### 用户登录
-POST {{baseUrl}}/user/login/password
-Content-Type: application/json
-
-{
-    "loginName": "admin",
-    "password": "your_password"
-}
-
-### 创建用户
-POST {{baseUrl}}/admin/user/create
-Authorization: Bearer {{token}}
-Content-Type: application/json
-
-{
-    "loginName": "newuser",
-    "password": "password123",
-    "name": "新用户",
-    "roleId": "role_id_here",
-    "avatar": "avatar_url"
-}
-
-### 删除用户
-POST {{baseUrl}}/admin/user/delete/{{userId}}
-Authorization: Bearer {{token}}
-
-### 获取用户列表
-GET {{baseUrl}}/admin/user/list
-Authorization: Bearer {{token}}
-
-### 更新用户
-POST {{baseUrl}}/admin/user/update
-Authorization: Bearer {{token}}
-Content-Type: application/json
-
-{
-    "_id": "user_id_here",
-    "name": "更新的用户名",
-    "avatar": "new_avatar_url",
-    "roleId": "new_role_id"
-}
-
-### 禁用用户
-POST {{baseUrl}}/admin/user/disable/{{userId}}
-Authorization: Bearer {{token}}
-
-### 启用用户
-POST {{baseUrl}}/admin/user/enable/{{userId}}
-Authorization: Bearer {{token}}
-
-### 获取用户个人信息
-GET {{baseUrl}}/user/profile
-Authorization: Bearer {{token}}

+ 1 - 1
src/tools/conver.go

@@ -1,4 +1,4 @@
-package main
+package tools
 
 import (
 	"encoding/json"

+ 67 - 0
src/tools/web.go

@@ -0,0 +1,67 @@
+package main
+
+import (
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"net/url"
+
+	"github.com/gin-contrib/cors"
+	"github.com/gin-gonic/gin"
+)
+
+// https://auth.3dqueen.cloud/login/oauth/authorize?client_id=e537ce727be61ad962d0&redirect_uri=http://localhost:9999/cmf/login/callback&response_type=code&scope=openid&state=STATE
+func main() {
+	engine := gin.Default()
+
+	// store := cookie.NewStore([]byte("spu3d-server"))
+	// engine.Use(sessions.Sessions("dcsession", store))
+	// engine.Static("/public", "static")
+	config := cors.DefaultConfig()
+	// config.AllowOrigins == []string{"http://google.com", "http://facebook.com"}
+	config.AllowAllOrigins = true
+	config.AllowHeaders = append(config.AllowHeaders, "authorization")
+	engine.Use(cors.New(config))
+
+	s := engine.Group("/cmf")
+	s.GET("/login/callback", func(ctx *gin.Context) {
+		fmt.Println(ctx.Query("code"), ctx.Query("state"))
+
+		code := ctx.Query("code")
+		state := ctx.Query("state")
+
+		// 要请求的目标 URL
+		baseURL := "http://127.0.0.1:3002/moutai/getToken"
+
+		// 创建请求参数
+		params := url.Values{
+			"code":  {code},
+			"state": {state},
+		}
+
+		// 将参数附加到 URL 上
+		finalURL := fmt.Sprintf("%s?%s", baseURL, params.Encode())
+
+		// 发起 GET 请求
+		resp, err := http.Get(finalURL)
+		if err != nil {
+			fmt.Println("Error making request:", err)
+			return
+		}
+		defer resp.Body.Close()
+
+		// 读取响应
+		body, err := ioutil.ReadAll(resp.Body)
+		if err != nil {
+			fmt.Println("Error reading response:", err)
+			return
+		}
+
+		// 打印响应
+		fmt.Println(string(body))
+
+		ctx.JSON(200, "success")
+	})
+	engine.Run(":9999")
+
+}

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно