sun-pc-linux 1 ay önce
ebeveyn
işleme
16354d8adf
100 değiştirilmiş dosya ile 551 ekleme ve 10552 silme
  1. 9 6
      imgsearchimg/api/Dockerfile
  2. 32 76
      imgsearchimg/api/app.py
  3. 15 0
      imgsearchimg/api/build.sh
  4. 1 1
      imgsearchimg/api/config.py
  5. 0 52
      imgsearchimg/api/generate.py
  6. 50 447
      imgsearchimg/api/image_search.py
  7. 5 8
      imgsearchimg/api/requirements.txt
  8. 15 0
      imgsearchimg/func/build.sh
  9. 0 38
      pack-queentree/config-service.yaml
  10. 0 82
      pack-queentree/docker-compose.yaml
  11. 0 64
      pack-queentree/nginx/conf.d/default.conf
  12. 0 1
      pack-queentree/nginx/www/index.html
  13. 0 21
      pack-queentree/readme.md
  14. 0 4
      pack-queentree/start.sh
  15. 3 16
      pack-sku3d/config-service.yaml
  16. 0 31
      pack-sku3d/docker-compose.yaml
  17. 111 0
      sku3d/sku3d/api/a-service-fassi.go
  18. 109 0
      sku3d/sku3d/api/a-service-img.go
  19. 3 127
      sku3d/sku3d/api/router.go
  20. 115 115
      sku3d/sku3d/api/service-cat.go
  21. 2 2
      sku3d/sku3d/app.yaml
  22. 1 1
      sku3d/sku3d/db/db.go
  23. 27 0
      sku3d/sku3d/db/model/matimage.go
  24. 2 0
      sku3d/sku3d/db/repo/repo.go
  25. 51 0
      sku3d/sku3d/test/test.http
  26. 0 183
      tree/.drone.yml
  27. 0 16
      tree/.gitignore
  28. 0 19
      tree/assetcenter/Dockerfile
  29. 0 121
      tree/assetcenter/api/api.go
  30. 0 327
      tree/assetcenter/api/controller.go
  31. 0 157
      tree/assetcenter/api/jwt.go
  32. 0 109
      tree/assetcenter/api/material-asset.go
  33. 0 94
      tree/assetcenter/api/move.go
  34. 0 88
      tree/assetcenter/api/router.go
  35. 0 15
      tree/assetcenter/api/servcie-test.go
  36. 0 189
      tree/assetcenter/api/service-array.go
  37. 0 190
      tree/assetcenter/api/service-asset.go
  38. 0 17
      tree/assetcenter/api/service-clean.go
  39. 0 790
      tree/assetcenter/api/service-database-asset.go
  40. 0 186
      tree/assetcenter/api/service-database-assetconf.go
  41. 0 219
      tree/assetcenter/api/service-database-category.go
  42. 0 118
      tree/assetcenter/api/service-database-design-product.go
  43. 0 72
      tree/assetcenter/api/service-database-design-scene.go
  44. 0 203
      tree/assetcenter/api/service-database-design.go
  45. 0 86
      tree/assetcenter/api/service-database-package.go
  46. 0 1
      tree/assetcenter/api/service-database-render.go
  47. 0 91
      tree/assetcenter/api/service-database-upload-env3d.go
  48. 0 51
      tree/assetcenter/api/service-database-upload-image.go
  49. 0 104
      tree/assetcenter/api/service-database-upload-mat.go
  50. 0 73
      tree/assetcenter/api/service-database-upload.go
  51. 0 157
      tree/assetcenter/api/service-database.go
  52. 0 142
      tree/assetcenter/api/service-import.go
  53. 0 79
      tree/assetcenter/api/service-lib.go
  54. 0 127
      tree/assetcenter/api/service-minio.go
  55. 0 370
      tree/assetcenter/api/service-obs.go
  56. 0 59
      tree/assetcenter/api/service-project.go
  57. 0 18
      tree/assetcenter/api/service-save.go
  58. 0 106
      tree/assetcenter/api/service-test.go
  59. 0 81
      tree/assetcenter/api/service-upload-mat.go
  60. 0 189
      tree/assetcenter/api/service.go
  61. 0 62
      tree/assetcenter/app.yaml
  62. 0 36
      tree/assetcenter/build.sh
  63. 0 32
      tree/assetcenter/bus/comm-utils.go
  64. 0 118
      tree/assetcenter/bus/hdr.go
  65. 0 60
      tree/assetcenter/bus/main.go
  66. 0 116
      tree/assetcenter/bus/mongo.go
  67. 0 51
      tree/assetcenter/bus/osgconv.go
  68. 0 56
      tree/assetcenter/bus/replyers.go
  69. 0 66
      tree/assetcenter/bus/search-image.go
  70. 0 52
      tree/assetcenter/bus/shadow.go
  71. 0 17
      tree/assetcenter/bus/taskReq.go
  72. 0 81
      tree/assetcenter/bus/tree-asset-add-matgroup.go
  73. 0 607
      tree/assetcenter/bus/tree-asset-list.go
  74. 0 43
      tree/assetcenter/bus/tree-asset-meshpack.go
  75. 0 244
      tree/assetcenter/bus/tree-category-query.go
  76. 0 204
      tree/assetcenter/bus/tree-db.go
  77. 0 149
      tree/assetcenter/bus/tree-define-add-matgroup.go
  78. 0 149
      tree/assetcenter/bus/tree-define-add-meshpack.go
  79. 0 221
      tree/assetcenter/bus/tree-query.go
  80. 0 16
      tree/assetcenter/bus/user.go
  81. 0 170
      tree/assetcenter/bus/utils.go
  82. 0 238
      tree/assetcenter/conf/app.go
  83. 0 45
      tree/assetcenter/db/db.go
  84. 0 51
      tree/assetcenter/db/model/application.go
  85. 0 167
      tree/assetcenter/db/model/asset.go
  86. 0 195
      tree/assetcenter/db/model/database.go
  87. 0 37
      tree/assetcenter/db/model/decorate.go
  88. 0 63
      tree/assetcenter/db/model/design.go
  89. 0 45
      tree/assetcenter/db/model/env3d.go
  90. 0 115
      tree/assetcenter/db/model/mat.go
  91. 0 141
      tree/assetcenter/db/model/mesh.go
  92. 0 44
      tree/assetcenter/db/model/perms.go
  93. 0 29
      tree/assetcenter/db/model/productTpl.go
  94. 0 129
      tree/assetcenter/db/model/project.go
  95. 0 338
      tree/assetcenter/db/model/res.go
  96. 0 210
      tree/assetcenter/db/model/task.go
  97. 0 26
      tree/assetcenter/db/model/user-qiye.go
  98. 0 85
      tree/assetcenter/db/model/user-role.go
  99. 0 91
      tree/assetcenter/db/model/user.go
  100. 0 14
      tree/assetcenter/db/redis.go

+ 9 - 6
imgsearchimg/api/Dockerfile

@@ -1,11 +1,13 @@
 # 使用Python 3.11.11作为基础镜像
-# FROM python:3.11.11-slim
+FROM python:3.11.11-slim
 # FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/wallies/python-cuda:3.11-cuda11.8-runtime
-FROM registry.cn-hangzhou.aliyuncs.com/serverless_devs/pytorch:22.12-py3
+# FROM registry.cn-hangzhou.aliyuncs.com/serverless_devs/pytorch:22.12-py3
 
 RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
-RUN sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list && \
-    sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
+# RUN sed -i 's|http://archive.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list && \
+#     sed -i 's|http://security.ubuntu.com/ubuntu|http://mirrors.aliyun.com/ubuntu|g' /etc/apt/sources.list
+# 设置环境变量,避免交互式安装时的提示
+
 
 # 设置工作目录
 WORKDIR /app
@@ -24,12 +26,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
 # 复制项目文件
 COPY . .
 
+ENV MONGODB=mongodb://root:root@172.31.69.25:37018/
 
 # 安装Python依赖
 RUN pip install --no-cache-dir -r requirements.txt
 
 
-EXPOSE 5001
+EXPOSE 5000
 
 # 设置默认命令
-CMD ["python", "func_test.py"]
+CMD ["python", "app.py"]

+ 32 - 76
imgsearchimg/api/app.py

@@ -1,10 +1,8 @@
-from flask import Flask, request, jsonify, render_template, send_from_directory
+from flask import Flask, request, jsonify
 import os
 from image_search import ImageSearchEngine
-import magic
-from urllib.request import urlretrieve
 import time
-from . import config
+import config
 
 app = Flask(__name__)
 
@@ -17,22 +15,8 @@ def allowed_file(filename):
     """检查文件是否允许上传"""
     return '.' in filename and filename.rsplit('.', 1)[1].lower() in config.ALLOWED_EXTENSIONS
 
-def is_valid_image(file_path):
-    """检查文件是否为有效的图片文件"""
-    try:
-        mime = magic.Magic(mime=True)
-        file_type = mime.from_file(file_path)
-        return file_type.startswith('image/')
-    except Exception:
-        return False
-
-@app.route('/')
-def index():
-    """渲染主页"""
-    return render_template('index.html')
-
-@app.route('/upload', methods=['POST'])
-def upload_file():
+@app.route('/add', methods=['POST'])
+def add_image_file():
     """处理图片上传请求"""
     try:
         # 获取并验证参数
@@ -40,34 +24,27 @@ def upload_file():
         if not data:
             return jsonify({'error': '请求必须包含JSON数据'}), 400
         
-        product_id = data.get('product_id')
+        product_id = data.get('imageId')
         image_url = data.get('url')
         
         if not product_id:
             return jsonify({'error': '缺少product_id参数'}), 400
         if not image_url:
             return jsonify({'error': '缺少url参数'}), 400
+        
         if not isinstance(image_url, str) or not (image_url.startswith('http://') or image_url.startswith('https://')):
             return jsonify({'error': '无效的图片URL'}), 400
-        
-        time_base = str(time.time() * 1000)
-        image_path = os.path.join(config.UPLOAD_FOLDER, time_base + os.path.basename(image_url))
-        urlretrieve(image_url, image_path)
-
-        if allowed_file(image_path) and is_valid_image(image_path):
-            # 添加图片到搜索引擎
-            if search_engine.add_image_from_url(image_path, product_id):
-                # 删除临时图片文件
-                os.remove(image_path)
-                return jsonify({'message': '上传成功', 'product_id': product_id})
-            else:
-                return jsonify({'error': '处理图片失败'}), 500
+    
+        # 添加图片到搜索引擎
+        if search_engine.add_image_from_url(image_url, product_id):
+            return jsonify({'message': '上传成功', 'product_id': product_id})
         else:
-            return jsonify({'error': '图片错误'}), 500
+            return jsonify({'error': '处理图片失败'}), 500
+       
             
     except Exception as e:
         return jsonify({'error': str(e)}), 500
-
+    
 @app.route('/search', methods=['POST'])
 def search():
     """处理图片搜索请求"""
@@ -105,51 +82,30 @@ def search():
         except ValueError:
             return jsonify({'error': '参数类型错误'}), 400
         
-        start_download_time = time.time()
-        time_base = str(time.time() * 1000)
-        image_path = os.path.join(config.UPLOAD_FOLDER, time_base + os.path.basename(image_url))
-        urlretrieve(image_url, image_path)
-        end_download_time = time.time()
-        print(f"下载耗时: { end_download_time - start_download_time } s",)
+     
+      
 
-        if allowed_file(image_path) and is_valid_image(image_path):
-            # 搜索相似图片,使用用户指定的 limit
-            start_search_time = time.time()
-            results = search_engine.search(image_path, top_k=limit)
-            os.remove(image_path)
-            # 格式化结果并过滤不在分数范围内的结果
-            formatted_results = []
-            for product_id, score in results:
-                similarity = round(score * 100, 2)  # 转换为百分比
-                if min_score <= similarity <= max_score:
-                    formatted_results.append({
-                        'product_id': product_id,
-                        'similarity': similarity
-                    })
-            end_search_time = time.time()
-            print(f"搜索耗时: { end_search_time - start_search_time } s",)
-            return jsonify({'results': formatted_results})
-        else:
-            return jsonify({'error': '图片错误'})
+        start_search_time = time.time()
+
+        results = search_engine.search(image_url, top_k=limit)
+        # 格式化结果并过滤不在分数范围内的结果
+        formatted_results = []
+        for product_id, score in results:
+            similarity = score  # 转换为百分比
+            if min_score <= similarity <= max_score:
+                formatted_results.append({
+                    'Id': product_id,
+                    'Score': similarity
+                })
+        end_search_time = time.time()
+        print(f"搜索耗时: { end_search_time - start_search_time } s",)
+
+        return jsonify(formatted_results), 200
+    
 
     except Exception as e:
         return jsonify({'error': str(e)}), 500
 
-# @app.route('/images')
-# def list_images():
-#     """列出所有已索引的图片"""
-#     try:
-#         images = []
-#         for path in search_engine.image_paths:
-#             filename = os.path.basename(path)
-#             images.append({
-#                 'filename': filename,
-#                 'path': '/static/images/' + filename
-#             })
-#         return jsonify({'images': images})
-#     except Exception as e:
-#         return jsonify({'error': str(e)}), 500
-
 @app.route('/remove/<product_id>', methods=['POST'])
 def remove_image(product_id):
     """移除指定商品ID的图片特征"""

+ 15 - 0
imgsearchimg/api/build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# 设置变量
+IMAGE_NAME="crpi-tlcs37dul3eo9h1x.cn-hangzhou.personal.cr.aliyuncs.com/lymat/fassi"
+VERSION="v1"
+
+# 构建 Docker 镜像
+echo "Building Docker image..."
+docker build -t ${IMAGE_NAME}:${VERSION} .
+
+# 推送镜像到仓库
+echo "Pushing Docker image..."
+docker push ${IMAGE_NAME}:${VERSION}
+
+echo "Build and push completed successfully!"

+ 1 - 1
imgsearchimg/api/config.py

@@ -1,6 +1,6 @@
 UPLOAD_FOLDER = 'static/images'
 ALLOWED_EXTENSIONS = {'png', 'jpg', 'jpeg', 'gif', 'bmp'}
-ALIYUN_FUNCTION_URL = "http://img-fun-alnilgdbfc.cn-hangzhou.fcapp.run"
+ALIYUN_FUNCTION_URL = "https://imagefeature-hauveswkcf.cn-hangzhou.fcapp.run"
 
 TOP_K = 5
 MIN_SCORE = 0.0

+ 0 - 52
imgsearchimg/api/generate.py

@@ -1,52 +0,0 @@
-import pymongo
-import numpy as np
-import faiss
-import time
-from bson.objectid import ObjectId
-
-# MongoDB连接配置
-client = pymongo.MongoClient("mongodb://root:faiss_image_search@localhost:27017/")
-db = client["faiss_index"]
-collection = db["mat_vectors"]
-
-collection.create_index([("product_id", 1)], unique=True)
-collection.create_index([("faiss_id", 1)], unique=True)
-
-# FAISS配置
-dimension = 2048
-base_index = faiss.IndexFlatL2(dimension)
-index = faiss.IndexIDMap(base_index)
-
-# 生成随机向量
-def generate_random_vector(dimension):
-    return np.random.random(dimension).astype('float32')
-
-# 插入100万条数据
-def insert_million_records():
-    batch_size = 10000  # 每批插入的数据量
-    total_records = 200000
-    start_time = time.time()
-
-    for i in range(0, total_records, batch_size):
-        batch = []
-        for j in range(batch_size):
-            faiss_id = i + j
-            vector = generate_random_vector(dimension)
-            index.add_with_ids(np.array([vector]), np.array([faiss_id]))
-
-            record = {
-                "_id": ObjectId(),
-                "product_id": ObjectId(),
-                "faiss_id": faiss_id,
-                "vector": vector.tolist()
-            }
-            batch.append(record)
-
-        collection.insert_many(batch)
-        print(f"Inserted {i + batch_size} records")
-
-    end_time = time.time()
-    print(f"Total time taken: {end_time - start_time} seconds")
-
-if __name__ == "__main__":
-    insert_million_records()

+ 50 - 447
imgsearchimg/api/image_search.py

@@ -1,55 +1,62 @@
 import faiss
 import numpy as np
-from PIL import Image
-import io
-import os
-from typing import List, Tuple, Optional, Union
-import torch
-import torchvision.transforms as transforms
-import torchvision.models as models
-from torchvision.models import ResNet50_Weights
-from scipy import ndimage
-
-import torch.nn.functional as F
+
+from typing import List, Tuple, Optional
+# import torch
+
 from pymongo import MongoClient
 import datetime
 import time
 
+import requests
+import config
+import os
+
+def RequestAliyunFc(url):
+    # 定义URL
+    api = config.ALIYUN_FUNCTION_URL  # 替换为实际的URL
+    # 定义参数
+    payload = {'url': url}
+
+    print("payload", payload)
+    # headers = {
+    #     'Content-Type': 'application/json'  # 明确指定请求头为JSON
+    # }
+
+
+    # 发送POST请求
+    response = requests.post(api, json=payload)
+    # 检查请求是否成功
+    if response.status_code == 200:
+        # 获取返回的JSON数据
+        json_data = response.json()
+        print(json_data)
+        return json_data.get("vector")
+    
+    print(f'请求失败,状态码: {response.text}')
+    return None
+
+
 class ImageSearchEngine:
     def __init__(self):
 
+        mongodburi = os.getenv("MONGODB")
+        if not mongodburi:
+            mongodburi = "mongodb://root:root@localhost:37018/"
         # 添加mongodb
-        self.mongo_client = MongoClient("mongodb://root:faiss_image_search@localhost:27017/")  # MongoDB 连接字符串
+        self.mongo_client = MongoClient(mongodburi)  # MongoDB 连接字符串
         self.mongo_db = self.mongo_client["faiss_index"]  # 数据库名称
         self.mongo_collection = self.mongo_db["mat_vectors"]  # 集合名称
         self.mongo_collection.create_index([("product_id", 1)], unique=True)
         self.mongo_collection.create_index([("faiss_id", 1)], unique=True)
         # 初始化一个id生成计数
         self.faiss_id_max = 0
-     
-        # 检查GPU是否可用(仅用于PyTorch模型)
-        self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
-        print(f"使用设备: {self.device}")
-        
-        # 定义基础预处理转换
-        self.base_transform = transforms.Compose([
-            transforms.Grayscale(num_output_channels=3),  # 转换为灰度图但保持3通道
-            transforms.ToTensor(),
-            transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225])
-        ])
-        
-    
-        # 加载预训练的ResNet模型
-        self.model = models.resnet50(weights=ResNet50_Weights.IMAGENET1K_V2)
-        # 移除最后的全连接层
-        self.model = torch.nn.Sequential(*list(self.model.children())[:-1])
-        self.model = self.model.to(self.device)
-        self.model.eval()
-        
-        # 初始化FAISS索引(2048是ResNet50的特征维度)
         self.dimension = 2048
-        # self.index = faiss.IndexFlatL2(self.dimension)
 
+        # 检查GPU是否可用(仅用于PyTorch模型)
+        # self.device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
+        # print(f"使用设备: {self.device}")
+        
         # 改为支持删除的索引
         base_index = faiss.IndexFlatL2(self.dimension)
         self.index = faiss.IndexIDMap(base_index) 
@@ -71,371 +78,14 @@ class ImageSearchEngine:
             yield batch
 
 
-    def _process_image(self, image_path: str) -> Optional[torch.Tensor]:
-
-        # 这里调用阿里云云函数处理图片
-
-
-
-        """处理单张图片并提取特征。
-        
-        Args:
-            image_path: 图片路径
-            
-        Returns:
-            处理后的特征向量,如果处理失败返回None
-        """
+    def _process_image(self, image_url: str):
         try:
-            # 读取图片
-            image = Image.open(image_path)
-            
-            # 确保图片是RGB模式
-            if image.mode != 'RGB':
-                image = image.convert('RGB')
-            
-
-            start_ms_time = time.time()
-            # 提取多尺度特征
-            multi_scale_features = self._extract_multi_scale_features(image)
-            end_ms_time = time.time()
-            print(f"提取多尺度特征耗时: { end_ms_time - start_ms_time } s",)
-            if multi_scale_features is None:
-                return None
-            
-            start_sw_time = time.time()
-            # 提取滑动窗口特征
-            sliding_window_features = self._extract_sliding_window_features(image)
-            end_sw_time = time.time()
-            print(f"提取滑动窗口耗时: { end_sw_time - start_sw_time } s",)
-            if sliding_window_features is None:
-                return None
-            
-            # 组合特征(加权平均)
-            combined_feature = multi_scale_features * 0.6 + sliding_window_features * 0.4
-            
-            # 标准化特征
-            combined_feature = F.normalize(combined_feature, p=2, dim=0)
-            
-            return combined_feature
-            
+        # 这里调用阿里云云函数处理图片
+            return RequestAliyunFc(image_url)
         except Exception as e:
             print(f"处理图片时出错: {e}")
             return None
 
-    def _extract_multi_scale_features(self, image: Image.Image) -> Optional[torch.Tensor]:
-        """基于原图分辨率的多尺度特征提取(智能动态调整版)
-        
-        Args:
-            image: PIL图片对象
-            
-        Returns:
-            多尺度特征向量,处理失败返回None
-        """
-        try:
-            # 获取原图信息
-            orig_w, orig_h = image.size
-            max_edge = max(orig_w, orig_h)
-            aspect_ratio = orig_w / orig_h
-
-            # 动态调整策略 -------------------------------------------
-            # 策略1:根据最大边长确定基准尺寸
-            base_size = min(max_edge, 3000)  # 不超过模型支持的最大尺寸
-            
-            # 策略2:自动生成窗口尺寸(等比数列)
-            min_size = 224  # 最小特征尺寸
-            num_scales = 4  # 固定采样点数
-            scale_factors = np.logspace(0, 1, num_scales, base=2)
-            window_sizes = [int(base_size * f) for f in scale_factors]
-            window_sizes = sorted({min(max(s, min_size), 3000) for s in window_sizes})
-            
-            # 策略3:根据长宽比调整尺寸组合
-            if aspect_ratio > 1.5:  # 宽幅图像
-                window_sizes = [int(s*aspect_ratio) for s in window_sizes]
-            elif aspect_ratio < 0.67:  # 竖幅图像
-                window_sizes = [int(s/aspect_ratio) for s in window_sizes]
-
-            # 预处理优化 --------------------------------------------
-            # 选择最优基准尺寸(最接近原图尺寸的2的幂次)
-            base_size = 2 ** int(np.log2(base_size))
-            base_transform = transforms.Compose([
-                transforms.Resize((base_size, base_size),
-                                interpolation=transforms.InterpolationMode.LANCZOS),
-                self.base_transform
-            ])
-            
-            # 半精度加速
-            self.model.half()
-            img_base = base_transform(image).unsqueeze(0).to(self.device).half()
-
-            # 动态特征提取 ------------------------------------------
-            features = []
-            for size in window_sizes:
-                # 保持长宽比的重采样
-                target_size = (int(size*aspect_ratio), size) if aspect_ratio > 1 else (size, int(size/aspect_ratio))
-                
-                # GPU加速的智能插值
-                img_tensor = torch.nn.functional.interpolate(
-                    img_base, 
-                    size=target_size,
-                    mode= 'area' if size < base_size else 'bicubic',  # 下采样用area,上采样用bicubic
-                    align_corners=False
-                )
-
-                # 自适应归一化(保持原图统计特性)
-                if hasattr(self, 'adaptive_normalize'):
-                    img_tensor = self.adaptive_normalize(img_tensor)
-
-                # 混合精度推理
-                with torch.no_grad(), torch.cuda.amp.autocast():
-                    feature = self.model(img_tensor)
-                
-                features.append(feature.squeeze().float())
-
-            # 动态权重分配 ------------------------------------------
-            # 基于尺寸差异的权重(尺寸越接近原图权重越高)
-            size_diffs = [abs(size - base_size) for size in window_sizes]
-            weights = 1 / (torch.tensor(size_diffs, device=self.device) + 1e-6)
-            weights = weights / weights.sum()
-
-            # 加权融合
-            final_feature = torch.stack([f * w for f, w in zip(features, weights)]).sum(dim=0)
-            
-            return final_feature
-
-        except Exception as e:
-            print(f"智能特征提取失败: {e}")
-            return None
-
-
-
-    def _extract_multi_scale_features_bak(self, image: Image.Image) -> Optional[torch.Tensor]:
-        """提取多尺度特征。
-        
-        Args:
-            image: PIL图片对象
-            
-        Returns:
-            多尺度特征向量,如果处理失败返回None
-        """
-        try:
-            features_list = []
-            window_sizes = [256, 512,1024,1560,2048,2560,3000]
-            # 多尺度转换 - 增加更多尺度
-            #self.multi_scale_sizes = [224, 384, 512, 768, 1024, 1536,2048,3000]
-            for size in window_sizes:
-                # 调整图片大小
-                transform = transforms.Compose([
-                    transforms.Resize((size, size), interpolation=transforms.InterpolationMode.LANCZOS),
-                    self.base_transform
-                ])
-                
-                # 应用变换
-                img_tensor = transform(image).unsqueeze(0).to(self.device)
-                
-                # 提取特征
-                with torch.no_grad():
-                    feature = self.model(img_tensor)
-                
-                features_list.append(feature.squeeze())
-            
-            # 计算加权平均,较大尺度的权重更高
-            weights = torch.linspace(1, 2, len(features_list)).to(self.device)
-            weights = weights / weights.sum()
-            
-            weighted_features = torch.stack([f * w for f, w in zip(features_list, weights)])
-            final_feature = weighted_features.sum(dim=0)
-            
-            return final_feature
-            
-        except Exception as e:
-            print(f"提取多尺度特征时出错: {e}")
-            return None
-
-    def _extract_sliding_window_features(self, image: Image.Image) -> Optional[torch.Tensor]:
-        """优化版滑动窗口特征提取(动态调整+批量处理)
-        
-        Args:
-            image: PIL图片对象
-            
-        Returns:
-            滑动窗口特征向量,处理失败返回None
-        """
-        try:
-            # 获取原图信息
-            orig_w, orig_h = image.size
-            aspect_ratio = orig_w / orig_h
-            
-            # 动态窗口配置 -------------------------------------------
-            # 根据原图尺寸自动选择关键窗口尺寸(示例逻辑,需根据实际调整)
-            max_dim = max(orig_w, orig_h)
-            window_sizes = sorted({
-                int(2 ** np.round(np.log2(max_dim * 0.1))),  # 约10%尺寸
-                int(2 ** np.floor(np.log2(max_dim * 0.5))),  # 约50%尺寸
-                int(2 ** np.ceil(np.log2(max_dim)))          # 接近原图尺寸
-            } & {256, 512, 1024, 2048, 3000})  # 与预设尺寸取交集
-            
-            # 智能步长调整(窗口尺寸越大步长越大)
-            stride_ratios = {256:0.5, 512:0.4, 1024:0.3, 2048:0.2, 3000:0.15}
-            
-            # 预处理优化 --------------------------------------------
-            # 生成基准图像(最大窗口尺寸)
-            max_win_size = max(window_sizes)
-            base_size = (int(max_win_size * aspect_ratio), max_win_size) if aspect_ratio > 1 else \
-                        (max_win_size, int(max_win_size / aspect_ratio))
-            
-            transform = transforms.Compose([
-                transforms.Resize(base_size[::-1], interpolation=transforms.InterpolationMode.LANCZOS),
-                self.base_transform
-            ])
-            base_img = transform(image).to(self.device)
-            
-            # 半精度加速
-            self.model.half()
-            base_img = base_img.half()
-
-            # 批量特征提取 ------------------------------------------
-            all_features = []
-            for win_size in window_sizes:
-                # 动态步长选择
-                stride = int(win_size * stride_ratios.get(win_size, 0.3))
-                
-                # 生成窗口坐标(考虑边缘填充)
-                h, w = base_img.shape[1:]
-                num_h = (h - win_size) // stride + 1
-                num_w = (w - win_size) // stride + 1
-                
-                # 调整窗口数量上限(防止显存溢出)
-                MAX_WINDOWS = 32  # 根据显存调整
-                if num_h * num_w > MAX_WINDOWS:
-                    stride = int(np.sqrt(h * w * win_size**2 / MAX_WINDOWS))
-                    num_h = (h - win_size) // stride + 1
-                    num_w = (w - win_size) // stride + 1
-
-                # 批量裁剪窗口
-                windows = []
-                for i in range(num_h):
-                    for j in range(num_w):
-                        top = i * stride
-                        left = j * stride
-                        window = base_img[:, top:top+win_size, left:left+win_size]
-                        windows.append(window)
-                
-                if not windows:
-                    continue
-
-                # 批量处理(自动分块防止OOM)
-                BATCH_SIZE = 8  # 根据显存调整
-                with torch.no_grad(), torch.cuda.amp.autocast():
-                    for i in range(0, len(windows), BATCH_SIZE):
-                        batch = torch.stack(windows[i:i+BATCH_SIZE])
-                        features = self.model(batch)
-                        all_features.append(features.cpu().float())  # 转移至CPU释放显存
-
-            # 特征融合 ---------------------------------------------
-            if not all_features:
-                return None
-            
-            final_feature = torch.cat([f.view(-1, f.shape[-1]) for f in all_features], dim=0)
-            final_feature = final_feature.mean(dim=0).to(self.device)
-
-            return final_feature
-
-        except Exception as e:
-            print(f"滑动窗口特征提取失败: {e}")
-            return None
-
-
-    def _extract_sliding_window_features_bak(self, image: Image.Image) -> Optional[torch.Tensor]:
-        """使用滑动窗口提取特征。
-        
-        Args:
-            image: PIL图片对象
-            
-        Returns:
-            滑动窗口特征向量,如果处理失败返回None
-        """
-        try:
-            window_sizes = [256, 512,1024,1560,2048,2560,3000]
-            stride_ratio = 0.25  # 步长比例
-            
-            features_list = []
-
-            for window_size in window_sizes:
-                # 调整图片大小,保持宽高比
-                aspect_ratio = image.size[0] / image.size[1]
-                if aspect_ratio > 1:
-                    new_width = int(window_size * aspect_ratio)
-                    new_height = window_size
-                else:
-                    new_width = window_size
-                    new_height = int(window_size / aspect_ratio)
-                
-                transform = transforms.Compose([
-                    transforms.Resize((new_height, new_width), interpolation=transforms.InterpolationMode.LANCZOS),
-                    self.base_transform
-                ])
-                
-                # 转换图片
-                img_tensor = transform(image)
-                
-                # 计算步长
-                stride = int(window_size * stride_ratio)
-                
-                # 使用滑动窗口提取特征
-                for i in range(0, img_tensor.size(1) - window_size + 1, stride):
-                    for j in range(0, img_tensor.size(2) - window_size + 1, stride):
-                        window = img_tensor[:, i:i+window_size, j:j+window_size].unsqueeze(0).to(self.device)
-                        
-                        with torch.no_grad():
-                            feature = self.model(window)
-                        
-                        features_list.append(feature.squeeze())
-            
-            # 如果没有提取到特征,返回None
-            if not features_list:
-                return None
-            
-            # 计算所有特征的平均值
-            final_feature = torch.stack(features_list).mean(dim=0)
-            
-            return final_feature
-            
-        except Exception as e:
-            print(f"提取滑动窗口特征时出错: {e}")
-            return None
-
-    def extract_features(self, img: Image.Image) -> np.ndarray:
-        """结合多尺度和滑动窗口提取特征。
-        
-        Args:
-            img: PIL图像对象
-            
-        Returns:
-            特征向量
-        """
-        try:
-            # 提取多尺度特征
-            multi_scale_features = self._extract_multi_scale_features(img)
-            if multi_scale_features is None:
-                raise ValueError("无法提取多尺度特征")
-            
-            # 提取滑动窗口特征
-            sliding_window_features = self._extract_sliding_window_features(img)
-            if sliding_window_features is None:
-                raise ValueError("无法提取滑动窗口特征")
-            
-            # 组合特征
-            combined_feature = multi_scale_features * 0.6 + sliding_window_features * 0.4
-            
-            # 标准化特征
-            combined_feature = F.normalize(combined_feature, p=2, dim=0)
-            
-            # 转换为numpy数组
-            return combined_feature.cpu().numpy()
-            
-        except Exception as e:
-            print(f"特征提取失败: {e}")
-            raise
 
     def add_image_from_url(self, image_path: str, product_id: str) -> bool:
         """从URL添加图片到索引。
@@ -455,7 +105,8 @@ class ImageSearchEngine:
                 return False
             
             # 转换为numpy数组并添加到索引
-            feature_np = feature.cpu().numpy().reshape(1, -1).astype('float32')
+            # feature_np = feature.cpu().numpy().reshape(1, -1).astype('float32')
+            feature_np = np.array(feature).reshape(1, -1).astype('float32')
 
             idx = self.faiss_id_max + 1 
             print(f"当前: idx { idx }")
@@ -464,6 +115,7 @@ class ImageSearchEngine:
                 return False
             self.faiss_id_max = idx
             
+            #走upsert的逻辑
             # 向数据库写入记录
             record = {
                 "faiss_id": idx,
@@ -530,8 +182,10 @@ class ImageSearchEngine:
                 print("无法提取查询图片的特征")
                 return []
             
+
             # 将特征转换为numpy数组
-            feature_np = feature.cpu().numpy().reshape(1, -1).astype('float32')
+            fn = np.array(feature)
+            feature_np = fn.reshape(1, -1).astype('float32')
             
             start_vector_time = time.time()
             # 搜索最相似的图片
@@ -563,8 +217,6 @@ class ImageSearchEngine:
             return []
 
 
-
-
     def _load_index(self) -> bool:
         """从数据库分批加载数据并初始化faiss_id_max"""
         try:
@@ -665,54 +317,6 @@ class ImageSearchEngine:
             print(f"清除索引时出错: {e}")
             return False
 
-    def remove_image(self, image_path: str) -> bool:
-        """从索引中移除指定图片。
-        
-        Args:
-            image_path: 要移除的图片路径
-            
-        Returns:
-            是否成功移除
-        """
-        try:
-            if image_path in self.image_paths:
-                idx = self.image_paths.index(image_path)
-                
-                # 创建新的索引
-                new_index = faiss.IndexFlatL2(self.dimension)
-                
-                # 获取所有特征
-                all_features = faiss.vector_to_array(self.index.get_xb()).reshape(-1, self.dimension)
-                
-                # 移除指定图片的特征
-                mask = np.ones(len(self.image_paths), dtype=bool)
-                mask[idx] = False
-                filtered_features = all_features[mask]
-                
-                # 更新索引
-                if len(filtered_features) > 0:
-                    new_index.add(filtered_features)
-                
-                # 更新图片路径列表
-                self.image_paths.pop(idx)
-                self.product_ids.pop(idx)
-                
-                # 更新索引
-                self.index = new_index
-                
-                # 保存更改
-                self._save_index()
-                
-                print(f"已移除图片: {image_path}")
-                return True
-            else:
-                print(f"图片不存在: {image_path}")
-                return False
-                
-        except Exception as e:
-            print(f"移除图片时出错: {e}")
-            return False
-
     def remove_by_product_id(self, product_id: str) -> bool:
         """通过 product_id 删除向量索引和数据库记录。
         
@@ -769,7 +373,6 @@ class ImageSearchEngine:
 
         except Exception as e:
             print(f"删除 product_id 为 {product_id} 的记录时出错: {e}")
-            traceback.print_exc()
             return False
 
     def get_index_size(self) -> int:

+ 5 - 8
imgsearchimg/api/requirements.txt

@@ -1,9 +1,6 @@
-torch==2.0.1
-torchvision==0.15.2
-faiss-cpu==1.7.4
-Flask==2.3.3
-Pillow==10.0.0
+
+faiss_cpu==1.7.4
+Flask==3.1.0
 numpy==1.24.3
-scipy==1.11.2
-python-magic==0.4.27
-pymongo
+pymongo==4.11
+Requests==2.32.3

+ 15 - 0
imgsearchimg/func/build.sh

@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# 设置变量
+IMAGE_NAME="crpi-tlcs37dul3eo9h1x.cn-hangzhou.personal.cr.aliyuncs.com/lymat/imgfeature"
+VERSION="v1"
+
+# 构建 Docker 镜像
+echo "Building Docker image..."
+docker build -t ${IMAGE_NAME}:${VERSION} .
+
+# 推送镜像到仓库
+echo "Pushing Docker image..."
+docker push ${IMAGE_NAME}:${VERSION}
+
+echo "Build and push completed successfully!"

+ 0 - 38
pack-queentree/config-service.yaml

@@ -1,38 +0,0 @@
-log:
-  fileName: comm-bus.log
-  level: 1
-  serviceName: bus
-  
-configer:
-  -
-    name: tree-mongo
-    value: mongodb://root:tree@tree-mongo:27017/queentree?authSource=admin
-    devValue: mongodb://root:tree@124.71.139.24:37019/queentree?authSource=admin
-    # devValue: mongodb://root:tree@127.0.0.1:37019/queentree?authSource=admin
-
-  -
-    name: redis
-    value: redis:6379#0#root#packtree
-
-  - name: bus-network #外网bus地址
-    # value: nats://124.71.139.24:14220
-    value: nats://192.168.0.162:14220
-
-# adapter:
-#   -
-#     busName:
-#       service2
-#     nats:
-#       nats://pack2-nats-1:4222
-#     apis:
-#       - service2.licence.check
-#     streams:
-#       - service2-vip-pay#service2.pay.succ
-startLocalNats: true
-startNatsShellParams: "-p 4222 -m 8222 -js -c server.conf"
-startNatsPort: 4222
-
-nats:
-  url: nats://bus:4222
-  maxReconnect: 10000
-  reconnDelaySecond: 5

+ 0 - 82
pack-queentree/docker-compose.yaml

@@ -1,82 +0,0 @@
-version: '3.8'
-
-# 网络
-networks:
-  default:
-    external:
-      name: default-network
-
-services:
-  #nginx反向代理
-  tree-nginx:
-    image: "registry.cn-chengdu.aliyuncs.com/infish/pack-comm-nginx:1.23.1"
-    restart: always
-    ports:
-      - 18082:80
-    volumes:
-      - ./nginx/conf.d:/etc/nginx/conf.d
-      - ./nginx/www:/usr/share/nginx/html
-    depends_on:
-      - tree-main
-      - tree-task
-      - tree-count
-
-  #bus消息中间件
-  tree-bus:
-    restart: always
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-comm-bus:v1.0.1
-    volumes:
-      - ./config-service.yaml:/root/bus/app.yaml
-
-    depends_on:
-      - tree-mongo
-      - tree-redis    
-    ports:
-      - 14220:4222
-      - 14225:4333
-      
-  #redis缓存
-  tree-redis:
-    image: "redis:alpine"
-    restart: always
-    command:
-      --requirepass "packtree" #这一行是设置密码
-    privileged: true
-
-  #mongo -alpha数据库
-  tree-mongo:
-    image: mongo:4.4.1
-    restart: always
-    environment:
-      MONGO_INITDB_ROOT_USERNAME: root
-      MONGO_INITDB_ROOT_PASSWORD: tree
-    volumes:
-      - ~/data/packs-queentree/mongo/db:/data/db
-      - ~/data/packs-queentree/mongo/log:/var/log/mongodb
-    ports: 
-      - 37019:27017
-
-  #tree
-  tree-main:
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-queentree-tree:v1.0.1
-    restart: always
-    environment:
-      NATS: nats://tree-bus:4222
-    depends_on:
-      - tree-bus
-      
-  tree-task:
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-tree-taskcenter:v1.0.1
-    restart: always
-    environment:
-      NATS: nats://tree-bus:4222
-    depends_on:
-      - tree-bus
-
-  tree-count:
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-queentree-count:v1.0.0
-    restart: always
-    environment:
-      NATS: nats://tree-bus:4222
-    depends_on:
-      - tree-bus

+ 0 - 64
pack-queentree/nginx/conf.d/default.conf

@@ -1,64 +0,0 @@
-server {
-    listen       80;
-    listen  [::]:80;
-    server_name  localhost;
-    #access_log  /var/log/nginx/host.access.log  main;
-    location / {
-        root   /usr/share/nginx/html;
-        index  index.html index.htm;
-    }
-    #error_page  404              /404.html;
-
-    # redirect server error pages to the static page /50x.html
-    #
-    error_page   500 502 503 504  /50x.html;
-    location = /50x.html {
-        root   /usr/share/nginx/html;
-    }
-
-    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
-    #
-    #location ~ \.php$ {
-    #    proxy_pass   http://127.0.0.1;
-    #}
-
-    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
-    #
-    #location ~ \.php$ {
-    #    root           html;
-    #    fastcgi_pass   127.0.0.1:9000;
-    #    fastcgi_index  index.php;
-    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
-    #    include        fastcgi_params;
-    #}
-
-    # deny access to .htaccess files, if Apache's document root
-    # concurs with nginx's one
-    #
-    #location ~ /\.ht {
-    #    deny  all;
-    #}
-    #资产中心接口
-    location /assetcenter/ {
-       proxy_pass  http://tree-main:8902/assetcenter/;
-    }
-
-    location /taskcenter/ws {
-      proxy_pass http://tree-task:9502/taskcenter/ws;
-      proxy_http_version 1.1;
-      proxy_set_header Upgrade $http_upgrade;
-      proxy_set_header Connection "Upgrade";
-      proxy_set_header X-Real-IP $remote_addr;
-      proxy_read_timeout 500s;
-      proxy_send_timeout 500s;
-    }
-
-    location /taskcenter/ {
-       proxy_pass  http://tree-task:9502/taskcenter/;
-    }
-
-    # 统计
-    location /queencount/ {
-       proxy_pass  http://tree-count:8902/queencount/;
-    }
-}

+ 0 - 1
pack-queentree/nginx/www/index.html

@@ -1 +0,0 @@
-hello world~!!!

+ 0 - 21
pack-queentree/readme.md

@@ -1,21 +0,0 @@
-# 包含的微服务说明
-1 pay 模块 registry.cn-chengdu.aliyuncs.com/infish/sku3dpaytest:latest
-    environment:
-      REDIS: redis:6379/0
-      NATS: nats://192.168.0.162:24222
-
-    ports:
-      - 18888:8888
-
-## 流程
-
-1. 构建每个服务的镜像
-2. 配置到对应service的image下
-3. docker compose up
-
-
-## task 1.0.1 tree 1.0.1
-
-> 大文件source无法存储到数据库,添加config.source存储source内容的文件,obs路径
-
-- 适配后台glb等等模型转换逻辑,添加tree和task服务对应接口逻辑

+ 0 - 4
pack-queentree/start.sh

@@ -1,4 +0,0 @@
-#!/bin/bash
-
-docker-compose up -d --remove-orphans
-docker-compose ps

+ 3 - 16
pack-sku3d/config-service.yaml

@@ -4,34 +4,21 @@ log:
   serviceName: pack-sku3d
   
 configer:
-  -
-    name: mall-mongo
-    value: mongodb://root:root@sku3d-mongo:27017/custom-mall?authSource=admin
-    devValue: mongodb://root:root@124.71.139.24:37018/custom-mall?authSource=admin
+
   -
     name: user-mongo
     value: mongodb://root:root@sku3d-mongo:27017/usercenter?authSource=admin
     devValue: mongodb://root:root@124.71.139.24:37018/usercenter?authSource=admin
-  -
-    name: malluser-mongo
-    value: mongodb://root:root@sku3d-mongo:27017/mall-users?authSource=admin
-    devValue: mongodb://root:root@124.71.139.24:37018/mall-users?authSource=admin
+
   -
     name: website-mongo
     value: mongodb://root:root@sku3d-mongo:27017/sku3d?authSource=admin
-    devValue: mongodb://root:root@124.71.139.24:37018/sku3d?authSource=admin
+    devValue: mongodb://root:root@localhost:37018/sku3d?authSource=admin
   -
     name: redis
     value: sku3d-redis:6379#0#default#packsku3d
     devValue: 124.71.139.24:16379#0#default#packsku3d
 
-adapter:
-  -
-    busName: comm
-    nats: nats://comm-bus:4222
-  -
-    busName: queentree
-    nats: nats://tree-bus:4222
 
 startLocalNats: true
 startNatsShellParams: "-p 4222 -m 8222 -js -c server.conf"

+ 0 - 31
pack-sku3d/docker-compose.yaml

@@ -17,10 +17,7 @@ services:
       - ./nginx/www:/usr/share/nginx/html
 
     depends_on:
-      - sku3d-mall
       - sku3d-usercenter
-      - sku3d-website
-      - sku3d-malluser
 
   # nats消息中间件
   sku3d-bus:
@@ -59,14 +56,6 @@ services:
     ports: 
       - 37018:27017
 
-  # 商城服务
-  sku3d-mall:
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-sku3d-mall:v1.0.2
-    restart: always
-    depends_on:
-      - sku3d-bus
-    environment: 
-      NATS: nats://sku3d-bus:4222
 
   #user服务
   sku3d-usercenter:
@@ -77,25 +66,5 @@ services:
     environment: 
       NATS: nats://sku3d-bus:4222
   
-  #商城c端用户
-  sku3d-malluser:
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-sku3d-malluser:v1.0.0
-    restart: always
-    depends_on:
-      - sku3d-bus
-    environment: 
-      NATS: nats://sku3d-bus:4222
 
-  #sku3d-webite官网服务
-  sku3d-website:
-    image: registry.cn-chengdu.aliyuncs.com/infish/pack-sku3d-website:v1.0.0
-    restart: always
-    depends_on:
-      - sku3d-bus
-    environment: 
-      NATS: nats://sku3d-bus:4222
 
-  #商城c端用户
-  eps2svg-srv:
-    image: registry.cn-chengdu.aliyuncs.com/infish/eps2svg:v1.0.0
-    restart: always

+ 111 - 0
sku3d/sku3d/api/a-service-fassi.go

@@ -0,0 +1,111 @@
+package api
+
+import (
+	"bytes"
+	"encoding/json"
+	"fmt"
+	"io/ioutil"
+	"net/http"
+	"sku3dweb/conf"
+
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+var hostUrl = "http://localhost:5000"
+
+func AddFassiImage(imgId primitive.ObjectID, url string) error {
+	//http请求python
+	if len(conf.AppConfig.SearchImageAddr) > 0 {
+		hostUrl = conf.AppConfig.SearchImageAddr
+	}
+
+	api := hostUrl + "/add" // 替换为实际的URL
+
+	// 定义参数
+	payload := map[string]string{"imageId": imgId.Hex(), "url": url}
+	jsonData, err := json.Marshal(payload)
+	if err != nil {
+		fmt.Println("JSON编码失败:", err)
+		return err
+	}
+
+	// 发送POST请求
+	resp, err := http.Post(api, "application/json", bytes.NewBuffer(jsonData))
+	if err != nil {
+		fmt.Println("请求失败:", err)
+		return err
+	}
+	defer resp.Body.Close()
+	if resp.StatusCode != http.StatusOK {
+		return NewError("fassi 添加失败")
+	}
+
+	// 读取响应内容
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		fmt.Println("读取响应失败:", err)
+		return err
+	}
+
+	// 解析JSON响应
+	var result map[string]interface{}
+	if err := json.Unmarshal(body, &result); err != nil {
+		fmt.Println("JSON解析失败:", err)
+		return err
+	}
+	// 打印JSON响应
+	fmt.Println("返回的JSON数据:", result)
+
+	return nil
+}
+
+type QueryResp struct {
+	Id    primitive.ObjectID
+	Score float32
+}
+
+func QueryFassiImage(url string) ([]QueryResp, error) {
+	//http请求python
+	// 解析JSON响应
+	out := []QueryResp{}
+
+	api := hostUrl + "/search" // 替换为实际的URL
+	// 定义参数
+	payload := map[string]string{"url": url}
+	jsonData, err := json.Marshal(payload)
+	if err != nil {
+		fmt.Println("JSON编码失败:", err)
+		return out, err
+	}
+
+	// 发送POST请求
+	resp, err := http.Post(api, "application/json", bytes.NewBuffer(jsonData))
+	if err != nil {
+		fmt.Println("请求失败:", err)
+		return []QueryResp{}, err
+	}
+	defer resp.Body.Close()
+	if resp.StatusCode != http.StatusOK {
+		return []QueryResp{}, NewError("fassi 查询失败")
+	}
+
+	// 读取响应内容
+	body, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		fmt.Println("读取响应失败:", err)
+		return []QueryResp{}, err
+	}
+
+	if err := json.Unmarshal(body, &out); err != nil {
+		fmt.Println("JSON解析失败:", err)
+		return out, err
+	}
+	// 打印JSON响应
+	fmt.Println("返回的JSON数据:", out)
+	return out, nil
+}
+
+func RomoveFassiImage(id string) error {
+	//http请求python
+	return nil
+}

+ 109 - 0
sku3d/sku3d/api/a-service-img.go

@@ -0,0 +1,109 @@
+package api
+
+import (
+	"sku3dweb/db/model"
+	"sku3dweb/db/repo"
+	"time"
+
+	"github.com/gin-gonic/gin"
+	"go.mongodb.org/mongo-driver/bson"
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+func FassiApi(r *GinRouter) {
+	r.POSTJWT("/image/create", createImg)
+	r.GETJWT("/image/fassi/list", SearchByImg)
+	r.GETJWT("/image/list", SearchByFields)
+	r.POSTJWT("/image/delete/:id", DeleteImage)
+}
+
+func DeleteImage(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	id := c.Param("id")
+	err := RomoveFassiImage(id)
+	if err != nil {
+		return nil, err
+	}
+	return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, id)
+}
+
+func SearchByFields(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	page, size, query := UtilQueryPageSize(c)
+
+	pageOption := &repo.PageSearchOptions{
+		CollectName: repo.CollectionMatImages,
+		Page:        page,
+		Size:        size,
+		Query:       query,
+		Project:     []string{"nameCn", "createTime", "thumbnail", "price", "from"},
+		// Sort: bson.M{"_id"},
+	}
+	return repo.RepoPageSearch(apictx.CreateRepoCtx(), pageOption)
+}
+
+func createImg(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+
+	data := &model.MatImage{}
+	err := c.ShouldBindJSON(data)
+	if err != nil {
+		return nil, err
+	}
+	data.CreateTime = time.Now()
+	data.UpdateTime = time.Now()
+	data.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
+
+	idstr, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionMatImages, data)
+	if err != nil {
+		return nil, err
+	}
+	imgId, _ := primitive.ObjectIDFromHex(idstr)
+
+	return imgId, AddFassiImage(imgId, data.RawImage.Url)
+}
+
+func SearchByImg(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+
+	data := &struct {
+		Url string
+	}{}
+	err := c.ShouldBindJSON(data)
+	if err != nil || len(data.Url) < 1 {
+		return nil, NewError("参数错误")
+	}
+
+	images, err := QueryFassiImage(data.Url)
+	if err != nil {
+		return nil, err
+	}
+
+	var list = []map[string]interface{}{}
+	if len(images) < 1 {
+		return list, nil
+	}
+
+	var ids = []primitive.ObjectID{}
+	for _, item := range images {
+		ids = append(ids, item.Id)
+
+	}
+	param := &repo.DocSearchOptions{
+		CollectName: repo.CollectionMatImages,
+		Query:       repo.Map{"_id": bson.M{"$in": ids}},
+	}
+	err = repo.RepoSeachDocs(apictx.CreateRepoCtx(), param, &list)
+	if err != nil {
+		return nil, err
+	}
+
+	var ImageMap = map[primitive.ObjectID]map[string]interface{}{}
+	for _, item := range list {
+		ImageMap[item["_id"].(primitive.ObjectID)] = item
+	}
+
+	var out = []interface{}{}
+	for _, item := range images {
+		value := ImageMap[item.Id]
+		value["score"] = item.Score
+		out = append(out, value)
+	}
+	return out, nil
+}

+ 3 - 127
sku3d/sku3d/api/router.go

@@ -12,138 +12,14 @@ func RegRouters(svc *Service) {
 	svc.Gin.Use(Logger())
 
 	//登录
-	spud3dGroup := svc.NewGinRouter("/sku3dsite")
+	spud3dGroup := svc.NewGinRouter("/longyuan")
 
 	spud3dGroup.POSTJWT("/login/succ", ServiceLoginSucc)
-
-	//数据存储
-	spud3dGroup.POSTJWTTest("/data/image/policy", ServiceObsCreateImagePolicy)
-	// spud3dGroup.GETJWT("/obs/list", ServiceObsList)
-	spud3dGroup.POSTJWT("/obs/upload", ServiceObsUploadPolicy)
-	// spud3dGroup.POSTJWT("/obs/delete", ServiceObsRemove)
-	// spud3dGroup.POSTJWT("/obs/folder", ServiceObsCreateFolder)
-
 	//minio
-	spud3dGroup.POSTJWT("/minio/policy", MinioCreateUserPolicy)
-
-	//资源路由管理
-	CreateWebRouter(spud3dGroup)
-
-	RegMeshCrud(spud3dGroup)
-
-	RegMatCrud(spud3dGroup)
-
-	//web端
-	// spud3dGroup.POST("/web/login/password", ServiceUserLoginPassword)
-	// spud3dGroup.POST("/web/sms", ServiceSmsSend)
-	// spud3dGroup.POST("/web/login/sms", ServiceUserLoginSms)
-	// spud3dGroup.POSTJWT("/web/login/switch", ServiceLoginSwitchParent)
-
-	// spud3dGroup.POSTJWT("/web/user/loginout", ServiceWebUserLoginout)
-	// spud3dGroup.GETJWT("/web/user/profile", ServiceWebUserProfile)
-	// spud3dGroup.POSTJWT("/web/user/profile", ServiceWebUserUpdateProfile)
-	// spud3dGroup.POSTJWT("/web/user/resetpwd", ServiceWebUserResetPwd)
-
-	// spud3dGroup.POSTJWT("/web/user/editset", ServiceWebUserUpdateEditSet)
-	// spud3dGroup.POSTJWT("/web/user/editset/basecolor", ServiceWebUserUpdateEditSetBaseColor)
-	// spud3dGroup.POSTJWT("/web/user/editset/defaultEnv3d", ServiceWebUserUpdateEditSetDefaultEnv3d)
-
-	// spud3dGroup.POSTJWT("/design/create", ServiceDesignCreate)
-	// spud3dGroup.POSTJWT("/design/resetshoe", ServiceDesignResetShoe)
-	// spud3dGroup.POSTJWT("/design/resetdesign", ServiceDesignResetDesign)
-
-	// spud3dGroup.POSTJWT("/design/update/:id", ServiceDesignUpdate)
-
-	spud3dGroup.GETJWT("/design/list", ServiceDesignList)
-	spud3dGroup.GET("/design/public", ServiceDesignPublicList)
-
-	// spud3dGroup.POSTJWT("/design/delete/:id", ServiceDesignDelete)
-	// spud3dGroup.POSTJWT("/design/scene/create/:id/:scope", ServiceDesignCreateScene)
-	// spud3dGroup.POSTJWT("/design/scene/update/:id/:scope", ServiceDesignUpdateScene)
-	// spud3dGroup.POSTJWT("/design/scene/delete/:id/:scope", ServiceDesignRomoveScene)
-	// spud3dGroup.POSTJWT("/design/rename/:id", ServiceDesignRename)
-
-	// spud3dGroup.POSTJWT("/design/scene/thumbnail/:id", ServiceDesignSceneThumbnail)
-	// spud3dGroup.POSTJWT("/design/public/:id", ServiceDesignPublic)
-	// spud3dGroup.POSTJWT("/design/copy/:id", ServiceDesignCopy)
-
-	spud3dGroup.GET("/design/share", ServiceShareDesign)
-	spud3dGroup.GET("/design/detail/:id", ServiceDesignDetail)
-
-	spud3dGroup.POSTJWT("/design/scene/render", ServiceTaskCreate)
-
-	spud3dGroup.GETJWT("/task/list/:id", ServiceTaskList)
-	spud3dGroup.GETJWT("/task/detail/:id", ServiceTaskDetail)
-	spud3dGroup.POSTJWT("/task/remove/:id", ServiceTaskRemove)
-
-	CreateBackgroundRouter(spud3dGroup)
-
-	// spud3dGroup.POST("/hdr/conv", ServiceConvHdr)
-
-	RegAdminRouter(spud3dGroup)
-
-	RegAdminActionRouter(spud3dGroup)
+	// spud3dGroup.POSTJWT("/oss/policy", MinioCreateUserPolicy)
 
+	FassiApi(spud3dGroup)
 	CreateCatRouter(spud3dGroup)
-	CreatePermsRouter(spud3dGroup)
-
-	CreateQiyeUserRouter(spud3dGroup)
-	CreateUserUploadRouter(spud3dGroup)
-
-	CreateLibRouter(spud3dGroup)
-
-	CreateUserCamerasRouter(spud3dGroup)
-
-	RegisterTeamLib(spud3dGroup)
-
-	RegCollocateRouter(spud3dGroup)
-
-	RegImageMat(spud3dGroup)
-
-	// 会员
-	Member(spud3dGroup)
-
-	// 会员用户
-	MemberUser(spud3dGroup)
-
-	// 会员申请
-	Order(spud3dGroup)
-	// for _, proxy := range svc.Conf.Proxies {
-	// 	spud3dGroup.group.GET(proxy.Prefix, utils.CreateServiceProxy(proxy))
-	// 	spud3dGroup.group.POST(proxy.Prefix, utils.CreateServiceProxy(proxy))
-	// }
-	Queentree(spud3dGroup)
-
-	CreateUserSettingRouter(spud3dGroup)
-
-	RegTree(spud3dGroup)
-
-	RegTreeAssetOps(spud3dGroup)
-
-	RegTreeAssetRemove(spud3dGroup)
-
-	regAssetUpdator(spud3dGroup)
-
-	RegShareApis(spud3dGroup)
-
-	RegQueenterApis(spud3dGroup)
-
-	// !20241220新增
-	// 分类管理
-	spud3dGroup.POSTJWT("/im/cate/create", CategoryCreate)
-	spud3dGroup.POSTJWT("/im/cate/delete/:id", DeleteCategory)
-	spud3dGroup.GETJWT("/im/cate/list", CategoryList)
-	spud3dGroup.POSTJWT("/im/cate/update", UpdateCategory)
-
-	// 素材管理
-	spud3dGroup.POSTJWT("/im/material/create", CreateMaterial)
-	spud3dGroup.POSTJWT("/im/material/delete/:id", DeleteMaterial)
-	spud3dGroup.GETJWT("/im/material/list", MaterialList)
-	spud3dGroup.POSTJWT("/im/material/update", UpdateMaterial)
-
-	// 图片搜索新增
-	spud3dGroup.POSTJWT("/tree/:assetType/u2m/:id", updateToMilvus)
-	spud3dGroup.POSTJWT("/tree/:assetType/search/image", searchToMilvus)
 }
 
 func Logger() gin.HandlerFunc {

+ 115 - 115
sku3d/sku3d/api/service-cat.go

@@ -6,10 +6,10 @@ import (
 	"time"
 
 	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
 )
 
 func CreateCatRouter(router *GinRouter) {
+
 	//分类操作
 	CreateCRUD(router, "/category", &CRUDOption{
 		Collection: repo.CollectionCategory,
@@ -26,135 +26,135 @@ func CreateCatRouter(router *GinRouter) {
 		SearchProject: []string{"name", "type", "children", "createTime"},
 	})
 
-	router.GET("/qiye/res/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		_, _, query := UtilQueryPageSize(c)
-
-		body := &struct {
-			Id string
-		}{Id: query["id"].(string)}
-		if len(body.Id) < 1 {
-			return nil, NewError("id不能为空")
-		}
-
-		options := &repo.DocsSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"userId": body.Id}}
-		options.Project = []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"}
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
-		return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
-	})
-
-	router.GET("/qiye/lib/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		_, _, query := UtilQueryPageSize(c)
-
-		body := &struct {
-			Id string
-		}{Id: query["id"].(string)}
+	// router.GET("/qiye/res/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 	_, _, query := UtilQueryPageSize(c)
 
-		if len(body.Id) < 1 {
-			return nil, NewError("id不能为空")
-		}
-		options := &repo.DocsSearchOptions{CollectName: repo.CollectionLib2Category, Query: repo.Map{"userId": body.Id}}
-		options.Project = []string{"categoryIds", "type"}
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
-
-		return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
-	})
+	// 	body := &struct {
+	// 		Id string
+	// 	}{Id: query["id"].(string)}
+	// 	if len(body.Id) < 1 {
+	// 		return nil, NewError("id不能为空")
+	// 	}
 
-	router.GET("/platform/res/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		options := &repo.DocsSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"userId": PLATFORM_USER_ID}}
-		options.Project = []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"}
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
-		return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
-	})
+	// 	options := &repo.DocsSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"userId": body.Id}}
+	// 	options.Project = []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"}
+	// 	_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
+	// 	return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
+	// })
 
-	router.GET("/dadong/res/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		options := &repo.DocsSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"userId": DADONG_USER_ID}}
-		options.Project = []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"}
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
-		return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
-	})
+	// router.GET("/qiye/lib/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 	_, _, query := UtilQueryPageSize(c)
 
-	router.GET("/platform/lib/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		options := &repo.DocsSearchOptions{CollectName: repo.CollectionLib2Category, Query: repo.Map{"userId": PLATFORM_USER_ID}}
-		options.Project = []string{"categoryIds", "type"}
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
-		return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
-	})
+	// 	body := &struct {
+	// 		Id string
+	// 	}{Id: query["id"].(string)}
 
-	router.GET("/dadong/lib/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		options := &repo.DocsSearchOptions{CollectName: repo.CollectionLib2Category, Query: repo.Map{"userId": DADONG_USER_ID}}
-		options.Project = []string{"categoryIds", "type"}
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
-		return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
-	})
+	// 	if len(body.Id) < 1 {
+	// 		return nil, NewError("id不能为空")
+	// 	}
+	// 	options := &repo.DocsSearchOptions{CollectName: repo.CollectionLib2Category, Query: repo.Map{"userId": body.Id}}
+	// 	options.Project = []string{"categoryIds", "type"}
+	// 	_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
 
-	CreateCRUD(router, "/res/category", &CRUDOption{
-		Collection: repo.CollectionLibCategory,
-		NewModel2: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			cat := &model.ResCategory{}
-			c.ShouldBindJSON(cat)
-			cat.UserId = apictx.User.Parent
-			cat.CreateTime = time.Now()
-			return cat, nil
-		},
+	// 	return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
+	// })
 
-		EmtyModel: func(*gin.Context) interface{} {
-			return &model.ResCategory{}
-		},
-		JWT: true,
-		SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
-			return map[string]interface{}{"userId": apictx.User.Parent}
-		},
+	// router.GET("/platform/res/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 	options := &repo.DocsSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"userId": PLATFORM_USER_ID}}
+	// 	options.Project = []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"}
+	// 	_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
+	// 	return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
+	// })
 
-		SearchProject: []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"},
+	// router.GET("/dadong/res/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 	options := &repo.DocsSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"userId": DADONG_USER_ID}}
+	// 	options.Project = []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"}
+	// 	_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
+	// 	return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
+	// })
 
-		Remove: func(c *gin.Context, apictx *ApiSession, id string) (interface{}, error) {
-			team := &model.ResCategory{}
+	// router.GET("/platform/lib/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 	options := &repo.DocsSearchOptions{CollectName: repo.CollectionLib2Category, Query: repo.Map{"userId": PLATFORM_USER_ID}}
+	// 	options.Project = []string{"categoryIds", "type"}
+	// 	_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
+	// 	return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
+	// })
 
-			ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"_id": id}, Project: []string{"orderId", "type"}}, team)
+	// router.GET("/dadong/lib/category/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 	options := &repo.DocsSearchOptions{CollectName: repo.CollectionLib2Category, Query: repo.Map{"userId": DADONG_USER_ID}}
+	// 	options.Project = []string{"categoryIds", "type"}
+	// 	_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), options)
+	// 	return map[string]interface{}{"list": list, "total": len(list), "page": 1, "size": len(list)}, nil
+	// })
 
-			if !ok {
-				return nil, NewError("删除失败!")
-			}
+	// CreateCRUD(router, "/res/category", &CRUDOption{
+	// 	Collection: repo.CollectionLibCategory,
+	// 	NewModel2: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 		cat := &model.ResCategory{}
+	// 		c.ShouldBindJSON(cat)
+	// 		cat.UserId = apictx.User.Parent
+	// 		cat.CreateTime = time.Now()
+	// 		return cat, nil
+	// 	},
 
-			minOrderId := team.OrderId //后面有几个零
-			if minOrderId > 0 {
-				var maxStep int64 = 1
-				currValue := minOrderId
-				for {
-					if currValue%10 == 0 {
-						currValue = currValue / 10
-						maxStep = maxStep * 10
-					} else {
-						break
-					}
-				}
-				maxOrderId := minOrderId + maxStep - 1
-				return repo.RepoDeleteDocs(apictx.CreateRepoCtx(), repo.CollectionLibCategory, &bson.M{"orderId": bson.M{"$gte": minOrderId, "$lt": maxOrderId}, "type": team.Type})
-			}
+	// 	EmtyModel: func(*gin.Context) interface{} {
+	// 		return &model.ResCategory{}
+	// 	},
+	// 	JWT: true,
+	// 	SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
+	// 		return map[string]interface{}{"userId": apictx.User.Parent}
+	// 	},
 
-			return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionLibCategory, id)
-		},
-	})
+	// 	SearchProject: []string{"name", "type", "parent", "createTime", "type", "value", "level", "orderId"},
+
+	// 	Remove: func(c *gin.Context, apictx *ApiSession, id string) (interface{}, error) {
+	// 		team := &model.ResCategory{}
+
+	// 		ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"_id": id}, Project: []string{"orderId", "type"}}, team)
+
+	// 		if !ok {
+	// 			return nil, NewError("删除失败!")
+	// 		}
+
+	// 		minOrderId := team.OrderId //后面有几个零
+	// 		if minOrderId > 0 {
+	// 			var maxStep int64 = 1
+	// 			currValue := minOrderId
+	// 			for {
+	// 				if currValue%10 == 0 {
+	// 					currValue = currValue / 10
+	// 					maxStep = maxStep * 10
+	// 				} else {
+	// 					break
+	// 				}
+	// 			}
+	// 			maxOrderId := minOrderId + maxStep - 1
+	// 			return repo.RepoDeleteDocs(apictx.CreateRepoCtx(), repo.CollectionLibCategory, &bson.M{"orderId": bson.M{"$gte": minOrderId, "$lt": maxOrderId}, "type": team.Type})
+	// 		}
+
+	// 		return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionLibCategory, id)
+	// 	},
+	// })
 
-	CreateCRUD(router, "/lib/category", &CRUDOption{
-		Collection: repo.CollectionLib2Category,
-		NewModel2: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			cat := &model.LibCategory{}
-			c.ShouldBindJSON(cat)
-			cat.UserId = apictx.User.Parent
-			cat.CreateTime = time.Now()
-			return cat, nil
-		},
+	// CreateCRUD(router, "/lib/category", &CRUDOption{
+	// 	Collection: repo.CollectionLib2Category,
+	// 	NewModel2: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
+	// 		cat := &model.LibCategory{}
+	// 		c.ShouldBindJSON(cat)
+	// 		cat.UserId = apictx.User.Parent
+	// 		cat.CreateTime = time.Now()
+	// 		return cat, nil
+	// 	},
 
-		EmtyModel: func(*gin.Context) interface{} {
-			return &model.LibCategory{}
-		},
-		JWT: true,
-		SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
-			return map[string]interface{}{"userId": apictx.User.Parent}
-		},
-		SearchProject: []string{"type", "categoryIds", "createTime"},
-	})
+	// 	EmtyModel: func(*gin.Context) interface{} {
+	// 		return &model.LibCategory{}
+	// 	},
+	// 	JWT: true,
+	// 	SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
+	// 		return map[string]interface{}{"userId": apictx.User.Parent}
+	// 	},
+	// 	SearchProject: []string{"type", "categoryIds", "createTime"},
+	// })
 
 	//team
 

+ 2 - 2
sku3d/sku3d/app.yaml

@@ -2,8 +2,8 @@
 port: 7902
 
 nats:
-  url: nats://124.71.139.24:14223
-  # url: nats://127.0.0.1:14223
+  # url: nats://124.71.139.24:14223
+  url: nats://127.0.0.1:14223
   maxReconnect: 1000
   reconnDelaySecond: 5
   renderStreamTopic: sku3drender-req-stream#sku3drender.request#sku3drender-queue

+ 1 - 1
sku3d/sku3d/db/db.go

@@ -33,7 +33,7 @@ func (db *MongoDB) GetOrCreateDatabase(name string) *mongo.Database {
 var MongoInst *MongoDB
 
 func NewMongoDB(bus *comm.NatsBus) *MongoDB {
-	inst, err := bus.NewMongoDBFromConfig("website-mongo")
+	inst, err := bus.NewMongoDBFromConfigDev("website-mongo")
 	if err != nil {
 		panic(err)
 	}

+ 27 - 0
sku3d/sku3d/db/model/matimage.go

@@ -0,0 +1,27 @@
+package model
+
+import (
+	"time"
+
+	"go.mongodb.org/mongo-driver/bson/primitive"
+)
+
+type MatImage struct {
+	Id        primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
+	UserId    primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"` //用户Id
+	Thumbnail *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`     //封面图
+	RawImage  *OssType           `bson:"rawImage,omitempty" json:"rawImage"`       //原始大图
+	PhyWidth  int                `bson:"phyWidth,omitempty" json:"phyWidth"`       //物理尺寸 宽度
+	PhyHeight int                `bson:"phyHeight,omitempty" json:"phyHeight"`     //物理尺寸 高度
+
+	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
+	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
+
+	NameCN string `bson:"nameCn,omitempty" json:"nameCn"` //中文名称
+	NameEN string `bson:"nameEn,omitempty" json:"nameEn"` //英文名称
+	From   string `bson:"from,omitempty" json:"from"`     //来源
+	Price  int    `bson:"price,omitempty" json:"price"`   //价格 //单位分
+
+	Categories []string `bson:"categories,omitempty" json:"categories"`   //所属分类Id
+	CusNum     string   `bson:"cusNum,omitempty" json:"cusNum,omitempty"` //编号
+}

+ 2 - 0
sku3d/sku3d/db/repo/repo.go

@@ -20,6 +20,8 @@ type RepoSession struct {
 }
 
 const (
+	CollectionMatImages = "mat-images"
+
 	CollectionUser         = "users"
 	CollectionUserSetting  = "usersetting"
 	CollectionProject      = "projects"

+ 51 - 0
sku3d/sku3d/test/test.http

@@ -0,0 +1,51 @@
+@baseUrl = http://localhost:18081/usercenter
+@baseUrl2 = http://localhost:7902/longyuan
+@token = Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3MzkyNDU3MzIsImlkIjoiNjMwNWMzZGRkNWQ3OGRiY2I3MGI3ZjcwIiwia2V5Ijoic2t1M2QtdXNlciIsIm5hbWUiOiIxMzQwODU0NzgyMyIsIm9yaWdfaWF0IjoxNzM5MTU5MzMyLCJwYXJlbnQiOiI2MzA1YzNkZGQ1ZDc4ZGJjYjcwYjdmNzAiLCJwaG9uZSI6IjEzNDA4NTQ3ODIzIiwicm9sZSI6IiIsInN0YXRlIjoxLCJ1c2VyVHlwZSI6Mn0.LsDl1clBPDheCtJEb2RVAOame4t8_QBiao0Ty5xFlUE
+
+
+### 登录
+POST {{baseUrl}}/login/password
+Authorization: {{token}}
+Content-Type: application/json
+{
+    "loginName": "liwei",
+    "password": "图片描述"
+}
+
+### 图片
+POST {{baseUrl2}}/image/create
+Authorization: {{token}}
+Content-Type: application/json
+
+{
+
+    "rawImage": {"url":"https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/tmp/a3.png"},
+    "nameCn": "test1"
+}
+
+### 搜索图片
+GET  {{baseUrl2}}/image/fassi/list
+Authorization: {{token}}
+Content-Type: application/json
+
+{
+    "url":"https://sku3d-test.obs.cn-east-3.myhuaweicloud.com/tmp/a3.png"
+}
+
+### 删除图片
+POST {{baseUrl}}/admin/image/delete/67611f5d35ffb6c795a6edcf
+Authorization: {{token}}
+
+### 获取图片列表
+GET {{baseUrl2}}/image/list
+Authorization: {{token}}
+
+### 更新图片
+POST {{baseUrl}}/admin/image/update
+Authorization: {{token}}
+Content-Type: application/json
+
+{
+    "_id": "676393dfd94b5ee22ba7e3c1",
+    "sort": 2
+}

+ 0 - 183
tree/.drone.yml

@@ -1,183 +0,0 @@
----
-kind: pipeline
-type: docker
-name: default
-
-steps:
-- name: 1.submodules
-  image: alpine/git
-  commands:
-  - git submodule update --init --recursive
-
-- name: 2.building
-  image: golang:1.17
-  environment:
-    GOOS: linux
-    GOARCH: amd64
-    GO111MODULE: on
-    CGO_ENABLED: 0
-    GOPROXY: https://proxy.golang.com.cn,direct
-  
-  commands:
-  - cd assetcenter
-  - go version
-  - go env
-  - go build
-
-- name: 3.dockerbuild(test)  
-  image: plugins/docker
-  settings:
-    username: infish2018
-    password: infish@2022
-    repo: registry.cn-chengdu.aliyuncs.com/infish/queentreetest
-    registry: registry.cn-chengdu.aliyuncs.com
-    mirror: https://17itejgx.mirror.aliyuncs.com
-
-    tags:
-      - latest
-      - '0.0.1'
-    context: assetcenter/
-    dockerfile: assetcenter/Dockerfile
-  when:
-    branch:
-    - test
-
-- name: 4.ssh-deploy(test)
-  image: appleboy/drone-ssh
-  settings:
-    host:
-      - 124.71.139.24
-    username: root
-    password:
-      from_secret: serverpassword
-    port: 22
-    command_timeout: 3m
-    script:
-      - cd /root/services/compose-comm-test
-      - docker pull registry.cn-chengdu.aliyuncs.com/infish/queentreetest:latest
-      - docker-compose up -d
-      - docker-compose ps
-  when:
-    branch:
-    - test
-    
-- name: 3.dockerbuild(release) 
-  image: plugins/docker
-  settings:
-    username: infish2018
-    password: infish@2022
-    repo: registry.cn-chengdu.aliyuncs.com/infish/queentree
-    registry: registry.cn-chengdu.aliyuncs.com
-    mirror: https://17itejgx.mirror.aliyuncs.com
-
-    tags:
-      - latest
-      - '0.0.1'
-    context: assetcenter/
-    dockerfile: assetcenter/Dockerfile
-  when:
-    branch:
-    - release
-
-- name: 4.ssh-deploy(release)
-  image: appleboy/drone-ssh
-  settings:
-    host:
-      - 124.71.139.24
-    username: root
-    password:
-      from_secret: serverpassword
-    port: 22
-    command_timeout: 3m
-    script:
-      - cd /root/services/platform-release
-      - docker pull registry.cn-chengdu.aliyuncs.com/infish/queentree:latest
-      - docker-compose up -d
-      - docker-compose ps
-  when:
-    branch:
-    - release
-
-- name: 3.dockerbuild(dadongtest)  
-  image: plugins/docker
-  settings:
-    username: infish2018
-    password: infish@2022
-    repo: registry.cn-chengdu.aliyuncs.com/waibao/dadongtreetest
-    registry: registry.cn-chengdu.aliyuncs.com
-    mirror: https://17itejgx.mirror.aliyuncs.com
-
-    tags:
-      - latest
-      - '0.0.1'
-    context: assetcenter/
-    dockerfile: assetcenter/Dockerfile
-  when:
-    branch:
-    - dadongtest
-
-- name: 4.ssh-deploy(dadongtest)
-  image: appleboy/drone-ssh
-  settings:
-    host:
-      - 124.71.170.116
-    username: root
-    password:
-      from_secret: dadongpassword
-    port: 22
-    command_timeout: 3m
-    script:
-      - cd /root/sku3d-test
-      - docker pull registry.cn-chengdu.aliyuncs.com/waibao/dadongtreetest:latest
-      - docker-compose up -d
-      - docker-compose ps
-  when:
-    branch:
-    - dadongtest
-
-- name: 3.dockerbuild(dadongrelease)  
-  image: plugins/docker
-  settings:
-    username: infish2018
-    password: infish@2022
-    repo: registry.cn-chengdu.aliyuncs.com/waibao/dadongtree
-    registry: registry.cn-chengdu.aliyuncs.com
-    mirror: https://17itejgx.mirror.aliyuncs.com
-
-    tags:
-      - latest
-      - '0.0.1'
-    context: assetcenter/
-    dockerfile: assetcenter/Dockerfile
-  when:
-    branch:
-    - dadongrelease
-
-- name: 4.ssh-deploy(dadongrelease)
-  image: appleboy/drone-ssh
-  settings:
-    host:
-      - 124.71.170.116
-    username: root
-    password:
-      from_secret: dadongpassword
-    port: 22
-    command_timeout: 3m
-    script:
-      - cd /root/sku3d
-      - docker pull registry.cn-chengdu.aliyuncs.com/waibao/dadongtree:latest
-      - docker-compose up -d
-      - docker-compose ps
-  when:
-    branch:
-    - dadongrelease
-
-trigger:
-  branch:
-  - test
-  - release
-  - dadongrelease
-  - dadongtest
-
-  event:
-  - push

+ 0 - 16
tree/.gitignore

@@ -1,16 +0,0 @@
-sku3dweb
-sku3dweb.exe
-*.log
-worker-shadow/bin/shadow/_baked_lightmaps/
-worker-sku3drender/bin/cache/
-worker-sku3drender-local/bin/cache/
-worker-treeRender/bin/cache/
-local-sku3d/bin/render/bin/cache/
-.idea/
-sku3d/uploads/
-assetcenter/__debug_bin.exe
-assetcenter/sku3dweb
-assetcenter/sku3dweb.exe
-*.exe
-
-./custom-mall/custom-mall

+ 0 - 19
tree/assetcenter/Dockerfile

@@ -1,19 +0,0 @@
-FROM registry.cn-chengdu.aliyuncs.com/infish/alpine
-# https://github.com/Docker-Hub-frolvlad/docker-alpine-glibc
-
-RUN echo -e https://mirrors.ustc.edu.cn/alpine/v3.15/main > /etc/apk/repositories \
-  && cat /etc/apk/repositories \
-# 设置时区为上海
-  && apk add tzdata && cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \
-  && echo "Asia/Shanghai" > /etc/timezone \
-  && apk del tzdata \
-  && mkdir -p /root/queentree
-
-WORKDIR /root/queentree
-
-ADD ./app.yaml ./app.yaml
-ADD ./tree-service ./tree-service
-
-EXPOSE 8902
-
-ENTRYPOINT ["./tree-service"]

+ 0 - 121
tree/assetcenter/api/api.go

@@ -1,121 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-
-	"github.com/gin-contrib/cors"
-	"github.com/gin-contrib/sessions"
-	"github.com/gin-contrib/sessions/cookie"
-	"github.com/gin-gonic/gin"
-	"github.com/go-redis/redis/v8"
-)
-
-type Service struct {
-	Gin            *gin.Engine
-	Mongo          *db.MongoDB
-	Redis          *redis.Client
-	Port           int32
-	DebugUserId    string
-	DebugUserPhone string
-	DebugUserRole  string
-	JWT            *UtilsJwt
-	Conf           *conf.AppConf
-}
-
-func (svc *Service) Run() {
-	svc.Gin.Run(fmt.Sprintf(":%d", svc.Port))
-}
-
-type ApiSession struct {
-	Svc  *Service
-	User *JWTUser
-}
-
-func (api *ApiSession) CreateRepoCtx() *repo.RepoSession {
-	return &repo.RepoSession{
-		Ctx:    context.Background(),
-		Client: api.Svc.Mongo,
-	}
-}
-
-func NewHttpService(app *conf.AppConf, dbMongo *db.MongoDB, redisClient *redis.Client) *Service {
-
-	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))
-
-	jwt := NewUitlsJwt(app)
-
-	s := &Service{Conf: app, Redis: redisClient, JWT: jwt, Gin: engine, Mongo: dbMongo, Port: app.Port, DebugUserId: app.Debug.UserId, DebugUserPhone: app.Debug.UserPhone, DebugUserRole: app.Debug.UserRole}
-
-	RegRouters(s)
-
-	return s
-}
-
-// GinRouter 路由
-type GinRouter struct {
-	group *gin.RouterGroup
-	svc   *Service
-}
-
-func (svc *Service) NewGinRouter(path string) *GinRouter {
-	return &GinRouter{group: svc.Gin.Group(path), svc: svc}
-}
-
-// RouterInterface 路由接口
-type RouterInterface interface {
-	GET(path string, httpHandler Handler)
-	POST(path string, httpHandler Handler)
-}
-
-// GET http Get 请求
-func (g GinRouter) GET(path string, httpHandler Handler) {
-	g.group.GET(path, ResultWrapper(httpHandler, g.svc))
-}
-
-// POST http POST 请求
-func (g GinRouter) POST(path string, httpHandler Handler) {
-	g.group.POST(path, ResultWrapper(httpHandler, g.svc))
-}
-
-// GETJWT http Get 请求
-func (g GinRouter) GETJWT(path string, httpHandler JWTHander) {
-	g.group.GET(path, g.svc.JWT.MiddleFunc(), ResultJWTWrapper(httpHandler, g.svc))
-}
-
-// GETJWTTest http Get 请求
-func (g GinRouter) GETJWTTest(path string, httpHandler JWTHander) {
-	g.group.GET(path, ResultJWTTestWrapper(httpHandler, g.svc))
-}
-
-// POSTJWT http POST 请求
-func (g GinRouter) POSTJWT(path string, httpHandler JWTHander) {
-	g.group.POST(path, g.svc.JWT.MiddleFunc(), ResultJWTWrapper(httpHandler, g.svc))
-}
-
-// DeleteJWT http POST 请求
-func (g GinRouter) DeleteJWT(path string, httpHandler JWTHander) {
-	g.group.DELETE(path, g.svc.JWT.MiddleFunc(), ResultJWTWrapper(httpHandler, g.svc))
-}
-
-// DeleteJWT http POST 请求
-func (g GinRouter) DeleteJWTTEST(path string, httpHandler JWTHander) {
-	g.group.DELETE(path, ResultJWTTestWrapper(httpHandler, g.svc))
-}
-
-// POSTJWTTest 测试
-func (g GinRouter) POSTJWTTest(path string, httpHandler JWTHander) {
-	g.group.POST(path, ResultJWTTestWrapper(httpHandler, g.svc))
-}

+ 0 - 327
tree/assetcenter/api/controller.go

@@ -1,327 +0,0 @@
-package api
-
-import (
-	"assetcenter/log"
-	"crypto/md5"
-	"encoding/json"
-	"fmt"
-	"net/http"
-	"runtime"
-	"strconv"
-	"strings"
-
-	jwt "github.com/appleboy/gin-jwt/v2"
-	"github.com/gin-gonic/gin"
-)
-
-// Handler 包装http处理函数
-type Handler func(c *gin.Context, apictx *ApiSession) (interface{}, error)
-
-// JWTHander JWT授权的http处理函数
-type JWTHander func(c *gin.Context, apictx *ApiSession) (interface{}, error)
-
-// ResultWrapper 统一返回结果处理
-func ResultWrapper(handle Handler, svc *Service) gin.HandlerFunc {
-
-	return func(c *gin.Context) {
-
-		defer func() {
-			if r := recover(); r != nil {
-
-				fmt.Println("recover success.")
-				fmt.Println(r)
-
-				buf := make([]byte, 1<<16)
-				runtime.Stack(buf, true)
-				fmt.Println("buf", string(buf))
-
-				c.JSON(http.StatusOK, NewFailResultWithData("系统异常", r))
-			}
-		}()
-
-		data, err := handle(c, &ApiSession{Svc: svc, User: nil})
-		if err != nil {
-			httpErr, ok := err.(HTTPError)
-			if ok {
-				c.JSON(http.StatusOK, NewFailResultWithCode(httpErr.Error(), httpErr.Code))
-				return
-			}
-			c.JSON(http.StatusOK, NewFailResult(err.Error()))
-			return
-		}
-
-		if data != nil {
-			c.JSON(http.StatusOK, NewOkResult(data))
-		}
-	}
-}
-
-// ResultJWTWrapper JWT授权处理handler
-func ResultJWTWrapper(handle JWTHander, svc *Service) gin.HandlerFunc {
-
-	return func(c *gin.Context) {
-
-		defer func() {
-			if r := recover(); r != nil {
-				fmt.Println("recover success.")
-				fmt.Println(r)
-
-				buf := make([]byte, 1<<16)
-				runtime.Stack(buf, true)
-				fmt.Println("buf", string(buf))
-
-				c.JSON(http.StatusOK, NewFailResultWithData("系统异常", r))
-			}
-		}()
-
-		claims := jwt.ExtractClaims(c)
-
-		var usr *JWTUser
-
-		if claims["id"] != nil {
-			id := claims["id"].(string)
-			name := claims["phone"].(string)
-			role := claims["role"].(string)
-			parent := claims["parent"].(string)
-			state := int32(claims["state"].(float64))
-
-			usr = &JWTUser{ID: id, Phone: name, Parent: parent, Role: role, State: state}
-		}
-		var apis = &ApiSession{
-			Svc:  svc,
-			User: usr,
-		}
-		data, err := handle(c, apis)
-
-		if err != nil {
-			fmt.Println(err)
-			httpErr, ok := err.(HTTPError)
-			if ok {
-				c.JSON(http.StatusOK, NewFailResultWithCode(httpErr.Error(), httpErr.Code))
-				return
-			}
-
-			c.JSON(http.StatusOK, NewFailResult(err.Error()))
-			return
-		}
-		if data != nil {
-			c.JSON(http.StatusOK, NewOkResult(data))
-		}
-	}
-}
-
-// ResultJWTTestWrapper test 默认一个测试用户 JWT授权处理handler
-func ResultJWTTestWrapper(handle JWTHander, svc *Service) gin.HandlerFunc {
-
-	return func(c *gin.Context) {
-
-		defer func() {
-			if r := recover(); r != nil {
-
-				fmt.Println("recover success.")
-				fmt.Println(r)
-
-				buf := make([]byte, 1<<16)
-				runtime.Stack(buf, true)
-				fmt.Println("buf", string(buf))
-
-				c.JSON(http.StatusOK, NewFailResultWithData("error", r))
-			}
-		}()
-
-		var usr *JWTUser = &JWTUser{ID: svc.DebugUserId, Phone: svc.DebugUserPhone, Parent: svc.DebugUserId, Role: svc.DebugUserRole}
-
-		data, err := handle(c, &ApiSession{Svc: svc, User: usr})
-
-		if err != nil {
-			fmt.Println(err)
-			httpErr, ok := err.(HTTPError)
-			if ok {
-				c.JSON(http.StatusOK, NewFailResultWithCode(httpErr.Error(), httpErr.Code))
-				return
-			}
-
-			c.JSON(http.StatusOK, NewFailResult(err.Error()))
-			return
-		}
-		c.JSON(http.StatusOK, NewOkResult(data))
-	}
-}
-
-// ResultSuc 成功
-func ResultSuc(c *gin.Context, data interface{}) {
-	c.JSON(http.StatusOK, NewOkResult(data))
-}
-
-// ResultFail 失败
-func ResultFail(c *gin.Context, msg string) {
-	c.JSON(http.StatusOK, NewFailResult(msg))
-}
-
-// ResultFail401 失败2
-func ResultFail401(c *gin.Context, msg string, data interface{}) {
-	c.JSON(http.StatusOK, &HTTPResult{ErrorNo: 401, Result: data, ErrorDesc: msg})
-}
-
-// UtilMd5 结算md5的值
-func UtilMd5(s string) string {
-	data := []byte(s)
-	has := md5.Sum(data)
-	return fmt.Sprintf("%x", has)
-}
-
-// UtilQueryPageSize 分页数据
-func UtilQueryPageSize(c *gin.Context) (page int64, size int64, query map[string]interface{}) {
-	p := c.Query("page")
-	s := c.Query("size")
-	q := c.Query("query")
-
-	var _page = 1
-
-	if len(p) > 0 {
-		_page, _ = strconv.Atoi(p)
-	}
-	page = int64(_page)
-
-	var _size = 10
-	if len(s) > 0 {
-		_size, _ = strconv.Atoi(s)
-	}
-	size = int64(_size)
-
-	if len(q) > 0 {
-		json.Unmarshal([]byte(q), &query)
-	} else {
-		query = map[string]interface{}{}
-	}
-	return
-}
-
-func UtilQueryPageSize2(c *gin.Context) (page int64, size int64, query map[string]interface{}, fields []string) {
-	p := c.Query("page")
-	s := c.Query("size")
-	q := c.Query("query")
-	f := c.Query("fields")
-
-	var _page = 1
-
-	if len(p) > 0 {
-		_page, _ = strconv.Atoi(p)
-	}
-	page = int64(_page)
-
-	var _size = 10
-	if len(s) > 0 {
-		_size, _ = strconv.Atoi(s)
-	}
-	size = int64(_size)
-
-	if len(q) > 0 {
-		json.Unmarshal([]byte(q), &query)
-	} else {
-		query = map[string]interface{}{}
-	}
-	if len(f) > 0 {
-		fields = strings.Split(f, ",")
-	} else {
-		fields = []string{}
-	}
-	return
-}
-
-// HTTPResult 客户端统一返回结构体
-type HTTPResult struct {
-	ErrorNo   int32       `json:"errorNo"`
-	Result    interface{} `json:"result"`
-	ErrorDesc string      `json:"errorDesc"`
-}
-
-func (err HTTPResult) Error() string {
-	return err.ErrorDesc
-}
-
-// HTTPError 统一错误处理
-type HTTPError struct {
-	Code    int32  `json:"code"`
-	Message string `json:"message"`
-}
-
-func (err HTTPError) Error() string {
-	return err.Message
-}
-
-// NewOkResult 创建正确结果
-func NewOkResult(obj interface{}) *HTTPResult {
-	return &HTTPResult{ErrorNo: 200, Result: obj}
-}
-
-// NewFailResult 创建错误结构
-func NewFailResult(desc string) *HTTPResult {
-	return &HTTPResult{ErrorNo: 500, Result: nil, ErrorDesc: desc}
-}
-
-// NewFailResultWithData 创建错误返回结果
-func NewFailResultWithData(desc string, data interface{}) *HTTPResult {
-	return &HTTPResult{ErrorNo: 500, Result: data, ErrorDesc: desc}
-}
-
-// NewFailResultWithCode 创建错误结构
-func NewFailResultWithCode(desc string, code int32) *HTTPResult {
-	return &HTTPResult{ErrorNo: code, Result: nil, ErrorDesc: desc}
-}
-
-// NewError NewError
-func NewError(desc string) HTTPError {
-	return HTTPError{Code: 500, Message: desc}
-}
-
-func NewLogError(desc string) HTTPError {
-	pc, file, line, _ := runtime.Caller(1)
-	log.Errorf("%s:%d=>%s %v", file, line, runtime.FuncForPC(pc).Name(), desc)
-
-	return HTTPError{Code: 500, Message: desc}
-}
-
-func NewLogWithError(err error) HTTPError {
-	pc, file, line, _ := runtime.Caller(1)
-	log.Errorf("%s:%d=>%s %s", file, line, runtime.FuncForPC(pc).Name(), err.Error())
-
-	return HTTPError{Code: 500, Message: err.Error()}
-}
-
-// NewErrorWithCode NewErrorWithCode
-func NewErrorWithCode(desc string, code int32) HTTPError {
-	return HTTPError{Code: code, Message: desc}
-}
-
-// JWTUser jwt登录用户
-type JWTUser struct {
-	ID     string `json:"id"`
-	Parent string `json:"parent"`
-	Phone  string `json:"phone"`
-	Role   string `json:"role"`
-	Perms  string `json:"perms"`
-	State  int32  `json:"state"`
-}
-
-func UtilQueryMap(c *gin.Context) map[string]interface{} {
-	query := map[string]interface{}{}
-	q := c.Query("query")
-	if len(q) > 0 {
-		json.Unmarshal([]byte(q), &query)
-	}
-	return query
-}
-
-func BoolValue(value bool) *bool {
-	return &value
-}
-func Int32Value(value int32) *int32 {
-	return &value
-}
-func Float32Value(value float32) *float32 {
-	return &value
-}
-func Float64Value(value float64) *float64 {
-	return &value
-}

+ 0 - 157
tree/assetcenter/api/jwt.go

@@ -1,157 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"fmt"
-	"log"
-	"time"
-
-	jwt "github.com/appleboy/gin-jwt/v2"
-	"github.com/gin-gonic/gin"
-)
-
-var identityKey = "id"
-
-type UtilsJwt struct {
-	jwt *jwt.GinJWTMiddleware
-}
-
-func (j *UtilsJwt) MiddleFunc() gin.HandlerFunc {
-	return j.jwt.MiddlewareFunc()
-}
-
-func (j *UtilsJwt) JwtCreateToken(data interface{}) (string, time.Time, error) {
-	return j.jwt.TokenGenerator(data)
-}
-
-func NewUitlsJwt(app *conf.AppConf) *UtilsJwt {
-
-	var utils = &UtilsJwt{
-		jwt: nil,
-	}
-
-	var jwtImpl *jwt.GinJWTMiddleware
-
-	jwtImpl, err := jwt.New(&jwt.GinJWTMiddleware{
-		Realm:       app.Jwt.Realm,
-		Key:         []byte(app.Jwt.Key),
-		Timeout:     time.Hour * time.Duration(app.Jwt.TimeoutHour),
-		MaxRefresh:  time.Hour * time.Duration(app.Jwt.TimeoutHour),
-		IdentityKey: identityKey,
-		PayloadFunc: func(data interface{}) jwt.MapClaims {
-			if v, ok := data.(*JWTUser); ok {
-				return jwt.MapClaims{
-					"id":     v.ID,
-					"phone":  v.Phone,
-					"role":   v.Role,
-					"parent": v.Parent,
-					"state":  v.State,
-				}
-			}
-			return jwt.MapClaims{}
-		},
-		IdentityHandler: func(c *gin.Context) interface{} {
-			claims := jwt.ExtractClaims(c)
-			// lg.Debug().Msgf("token: %v\n", claims)
-
-			u := &JWTUser{
-				ID:     claims["id"].(string), //uint32(claims["id"].(float64)),
-				Phone:  claims["phone"].(string),
-				Role:   claims["role"].(string),
-				Parent: claims["parent"].(string),
-			}
-			if claims["state"] != nil {
-				u.State = int32(claims["state"].(float64))
-			}
-
-			return u
-		},
-
-		Authenticator: func(c *gin.Context) (interface{}, error) {
-			return &JWTUser{Phone: "empty"}, nil
-		},
-
-		Authorizator: func(data interface{}, c *gin.Context) bool {
-			u := data.(*JWTUser)
-			return u.State > 0
-		},
-
-		LoginResponse: func(c *gin.Context, status int, token string, expire time.Time) {
-
-			t, _ := jwtImpl.ParseTokenString(token)
-			fmt.Println("LoginResponse==>", status, token)
-
-			ResultSuc(c, map[string]interface{}{
-				"user":   t.Claims,
-				"token":  token,
-				"expire": expire.Format(time.RFC3339),
-			})
-		},
-
-		LogoutResponse: func(c *gin.Context, status int) {
-			ResultSuc(c, true)
-		},
-
-		RefreshResponse: func(c *gin.Context, status int, token string, expire time.Time) {
-
-			ResultSuc(c, map[string]interface{}{
-				"status": status,
-				"token":  token,
-				"expire": expire.Format(time.RFC3339),
-			})
-		},
-
-		Unauthorized: func(c *gin.Context, status int, token string) {
-			if token == "用户名/密码 不正确" {
-				ResultFail401(c, "账号密码不对", map[string]interface{}{
-					"status": -1,
-					"token":  token,
-				})
-				return
-			}
-
-			fmt.Println("xxxxx")
-			fmt.Println(token, status)
-
-			ResultFail401(c, token, map[string]interface{}{
-				"status": status,
-				"token":  token,
-			})
-		},
-
-		HTTPStatusMessageFunc: func(e error, c *gin.Context) string {
-
-			// if e == jwt.ErrFailedAuthentication {
-			// 	return "用户名/密码 不正确"
-			// }
-			fmt.Println("HTTPStatusMessageFunc", e)
-			return e.Error()
-		},
-
-		// TokenLookup is a string in the form of "<source>:<name>" that is used
-		// to extract token from the request.
-		// Optional. Default value "header:Authorization".
-		// Possible values:
-		// - "header:<name>"
-		// - "query:<name>"
-		// - "cookie:<name>"
-		// - "param:<name>"
-		TokenLookup: "header: Authorization, query: token, cookie: jwt",
-		// TokenLookup: "query:token",
-		// TokenLookup: "cookie:token",
-
-		// TokenHeadName is a string in the header. Default value is "Bearer"
-		TokenHeadName: "Bearer",
-
-		// TimeFunc provides the current time. You can override it to use another time value. This is useful for testing or if your server uses a different time zone than your tokens.
-		TimeFunc: time.Now,
-	})
-
-	if err != nil {
-		log.Fatal("JWT Error:" + err.Error())
-	}
-
-	utils.jwt = jwtImpl
-
-	return utils
-}

+ 0 - 109
tree/assetcenter/api/material-asset.go

@@ -1,109 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/repo"
-	"errors"
-	"fmt"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func DbMaterialDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// 查询db数据库看是否存在queenter库
-	search := &comm.Database{}
-	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-		CollectName: repo.CollectionDatabase,
-		Query:       repo.Map{"name": fmt.Sprintf("%s-%s", "queenter", apictx.User.Parent)}},
-		search)
-	fmt.Println(err)
-	if err != nil {
-		return nil, err
-	}
-	// 找到数据,返回material库信息
-	if ok {
-		for _, v := range search.Assets {
-			if v.Type == comm.AssetTypeMaterialGroup {
-				return map[string]interface{}{
-					"dbid":    search.Id,
-					"dbAsset": v,
-				}, nil
-			}
-		}
-		return nil, errors.New("没有找到material信息")
-	}
-	// 没有找到queenter库,创建一个
-	database := &comm.Database{}
-	database.CreateTime = time.Now()
-	database.Categories = &comm.DbCategory{}
-	database.Label = "queenter"
-	database.Name = fmt.Sprintf("%s-%s", "queenter", apictx.User.Parent)
-
-	database.Assets = CreateDefaultDbAssets(apictx.User.Parent)
-	// 初始化资源表
-	materialAsset := &comm.DbAsset{}
-	for _, asset := range database.Assets {
-		if asset.Type == comm.AssetTypeMaterialGroup {
-			materialAsset = asset
-			break
-		}
-	}
-	database.UserId = apictx.User.ID
-	id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionDatabase, database)
-	if err != nil {
-		return nil, err
-
-	}
-	return map[string]interface{}{
-		"dbid":    id,
-		"dbAsset": materialAsset,
-	}, nil
-}
-
-func CreateDefaultDbAssets(userId string) []*comm.DbAsset {
-	return []*comm.DbAsset{
-		{
-			Id:         primitive.NewObjectID().Hex(),
-			UserId:     userId,
-			Label:      "模型",
-			Type:       comm.AssetTypeMesh,
-			Collection: "mesh",
-			CreateTime: time.Now(),
-		},
-
-		{
-			Id:         primitive.NewObjectID().Hex(),
-			UserId:     userId,
-			Label:      "图片",
-			Type:       comm.AssetTypeImage,
-			Collection: "image",
-			CreateTime: time.Now(),
-		},
-		{
-			Id:         primitive.NewObjectID().Hex(),
-			UserId:     userId,
-			Label:      "材质球",
-			Type:       comm.AssetTypeMaterial,
-			Collection: "material",
-			CreateTime: time.Now(),
-		},
-		{
-			Id:         primitive.NewObjectID().Hex(),
-			UserId:     userId,
-			Label:      "材质球组",
-			Type:       comm.AssetTypeMaterialGroup,
-			Collection: "materialGroup",
-			CreateTime: time.Now(),
-		},
-		{
-			Id:         primitive.NewObjectID().Hex(),
-			UserId:     userId,
-			Label:      "环境球",
-			Type:       comm.AssetTypeEnv3d,
-			Collection: "env3d",
-			CreateTime: time.Now(),
-		},
-	}
-}

+ 0 - 94
tree/assetcenter/api/move.go

@@ -1,94 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/repo"
-	"fmt"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-func Move(r *GinRouter) {
-	// 同步色卡名和序列
-	r.GET("/move/mat/cardInfo", MoveCardInfo)
-}
-
-func MoveCardInfo(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	collections := []string{
-		"personal_mat_user",
-		"platform_mat_company",
-		"company_mats_user",
-		"platform_mat2d_user",
-		"platform_mat_team",
-		"company_mats_company",
-		"company_mat2d_user",
-		"platform_mat2d_company",
-		"personal_mat_user",
-	}
-
-	for _, collect := range collections {
-		fmt.Println("-----------------同步开始------------------------")
-		fmt.Println("-----------------" + collect + "------------------------")
-		ok, mats := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), &repo.DocsSearchOptions{
-			Db:          "sku3d-tree",
-			CollectName: collect,
-			Project:     []string{"name", "cusNum", "source"},
-		})
-
-		// fmt.Println(ok)
-		if !ok {
-			continue
-		}
-
-		isUpdate := false
-		if len(mats) > 0 {
-			for _, mat := range mats {
-				if mat["name"] == nil {
-					mat["name"] = "默认"
-				}
-				if mat["cusNum"] == nil {
-					mat["cusNum"] = "mr-001"
-				}
-
-				if source, ok := mat["source"]; ok {
-
-					if sv, ok := source.(map[string]interface{}); ok {
-						if slistv, ok := sv["colorCards"]; ok {
-							if slist, ok := slistv.(primitive.A); ok {
-								if len(slist) > 0 {
-									for i, list := range slist {
-										_name := list.(map[string]interface{})["name"]
-										_cusNum := list.(map[string]interface{})["cusNum"]
-										if _name == nil {
-											slist[i].(map[string]interface{})["name"] = mat["name"]
-											isUpdate = true
-										}
-										if _cusNum == nil {
-											slist[i].(map[string]interface{})["cusNum"] = mat["cusNum"]
-											isUpdate = true
-										}
-									}
-								}
-							}
-						}
-					}
-					fmt.Println(isUpdate)
-					fmt.Println(mat["name"])
-					fmt.Println(mat["_id"].(primitive.ObjectID).Hex())
-					// return mat["source"], nil
-					if isUpdate {
-						repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), "sku3d-tree", collect, mat["_id"].(primitive.ObjectID).Hex(), &mat)
-
-					}
-
-				}
-
-			}
-
-		}
-
-	}
-	fmt.Println("-----------------同步结束------------------------")
-
-	return 1, nil
-}

+ 0 - 88
tree/assetcenter/api/router.go

@@ -1,88 +0,0 @@
-package api
-
-import (
-	"fmt"
-
-	"github.com/gin-gonic/gin"
-)
-
-// RegRouters 注册路由
-func RegRouters(svc *Service) {
-
-	//登录
-	spud3dGroup := svc.NewGinRouter("/" + svc.Conf.Name)
-	spud3dGroup.group.Use(Logger())
-
-	spud3dGroup.GET("/profile", AssetProfile)
-	spud3dGroup.POST("/import", AssetImport)
-	spud3dGroup.POST("/clean", AssetClean)
-
-	//数据存储
-	spud3dGroup.POST("/save/policy", UploadPolicy)
-
-	// spud3dGroup.GETJWT("/obs/list", ServiceObsList)
-	// spud3dGroup.POSTJWT("/obs/upload", ServiceObsUploadPolicy)
-	// spud3dGroup.POSTJWT("/obs/delete", ServiceObsRemove)
-	// spud3dGroup.POSTJWT("/obs/folder", ServiceObsCreateFolder)
-
-	//minio
-	//spud3dGroup.POSTJWT("/minio/policy", MinioCreateUserPolicy)
-
-	//资产列表管理
-	CreateAssetRouter(spud3dGroup)
-
-	// CreateUserUploadRouter(spud3dGroup)
-
-	// CreateLibRouter(spud3dGroup)
-
-	//数据库管理
-	CreateDatabaseRouter(spud3dGroup)
-
-	//资产定义路由
-	CreateDatabaseAssetConfRouter(spud3dGroup)
-
-	// !20240415更新 获取queenter库material详情,如果本地不存在则创建
-	// 适配queenter库
-	spud3dGroup.GETJWT("/queenter/materialGroup/detail", DbMaterialDetail)
-
-	//资产上传更新管理
-	CreateDatabaseAssetRouter(spud3dGroup)
-
-	//分类管理
-	CreateDatabaseCategoryRouter(spud3dGroup)
-
-	CreateDatabaseDesignRouter(spud3dGroup)
-
-	CreateDatabaseDesignProductRouter(spud3dGroup)
-
-	CreateDatabaseDesignSceneRouter(spud3dGroup)
-
-	// test
-	TestRouter(spud3dGroup)
-
-	Move(spud3dGroup)
-
-}
-
-func Logger() gin.HandlerFunc {
-
-	return func(c *gin.Context) {
-		// 开始时间
-		// start := time.Now()
-		// 处理请求
-		c.Next()
-		// 结束时间
-		// end := time.Now()
-		//执行时间
-		// latency := end.Sub(start)
-
-		path := c.Request.URL.Path
-
-		clientIP := c.ClientIP()
-		// method := c.Request.Method
-		// statusCode := c.Writer.Status()
-
-		out := fmt.Sprintf("%15s=> %s", clientIP, path)
-		fmt.Println(out)
-	}
-}

+ 0 - 15
tree/assetcenter/api/servcie-test.go

@@ -1,15 +0,0 @@
-package api
-
-import (
-	"fmt"
-
-	"github.com/gin-gonic/gin"
-)
-
-//ServiceTestHttp JWT授权的http处理函数
-func ServiceTestHttp(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	fmt.Println("test")
-
-	return "hello world " + apictx.Svc.DebugUserPhone, nil
-}

+ 0 - 189
tree/assetcenter/api/service-array.go

@@ -1,189 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/repo"
-	"fmt"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type DetailHandler func(c *gin.Context, apictx *ApiSession, entity interface{}) (interface{}, error)
-
-type ArrayCRUDOption struct {
-	Collection     string
-	ArrayFieldPath string
-	NewModel       CreateModel
-	EmtyModel      EmptyModel
-	DocModel       EmptyModel
-	SearchProject  []string
-	Query          repo.Map
-	OnUpdate       Update
-	OnDetail       DetailHandler
-
-	NeedsUpdate bool
-	NeedsRemove bool
-}
-
-func CreateArrayCRUD(router *GinRouter, prefix string, option *ArrayCRUDOption) {
-
-	//创建
-	creatpath := fmt.Sprintf("%s/create/:id", prefix)
-	if option.NewModel != nil {
-
-		router.POSTJWT(creatpath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			id := c.Param("id")
-			if len(id) < 1 {
-				return nil, NewError("参数id不能为空")
-			}
-			var entity interface{} = nil
-			entity, _ = option.NewModel(c, apictx)
-			if entity == nil {
-				return nil, NewError("数据已存在!")
-			}
-			ret, _ := repo.RepoDocArrayAppend(apictx.CreateRepoCtx(), option.Collection, id, option.ArrayFieldPath, entity)
-			if ret.ModifiedCount == 1 {
-				return entity, nil
-			}
-			return nil, NewError("创建失败!")
-		})
-	}
-
-	//更新
-	if option.NeedsUpdate {
-		updatePath := fmt.Sprintf("%s/update/:id", prefix)
-		router.POSTJWT(updatePath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			docId := c.Param("id")
-			if len(docId) < 1 {
-				return nil, NewError("id不能为空!")
-			}
-			m := option.EmtyModel(c, apictx)
-			err := c.ShouldBindJSON(m)
-			if err != nil {
-				fmt.Println(err)
-				return nil, NewError("参数解析错误")
-			}
-
-			if option.OnUpdate != nil {
-				option.OnUpdate(c, apictx, m)
-			}
-			updateQuery := repo.Map{}
-			for k, v := range option.Query {
-				p := fmt.Sprintf("%s.%s", option.ArrayFieldPath, k)
-				updateQuery[p] = v
-			}
-			updateSet := repo.Map{}
-			spath := fmt.Sprintf("%s.$", option.ArrayFieldPath)
-			updateSet[spath] = m
-
-			updateOption := &repo.ArrayOneUpdateOption{CollectName: option.Collection, Id: docId, Query: updateQuery, Set: updateSet}
-
-			return repo.RepoDocArrayOneUpdate(apictx.CreateRepoCtx(), updateOption)
-		})
-	}
-
-	//数组所有数据
-	SearchPath := fmt.Sprintf("%s/list/:id", prefix)
-
-	pageSearchFn := func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		docId := c.Param("id")
-		if len(docId) < 1 {
-			return nil, NewError("id不能为空!")
-		}
-		query := UtilQueryMap(c)
-		query["_id"], _ = primitive.ObjectIDFromHex(docId)
-
-		_, list := repo.RepoSeachDocsMap(apictx.CreateRepoCtx(), &repo.DocsSearchOptions{
-			CollectName: option.Collection,
-			Query:       query,
-			Project:     option.SearchProject,
-		})
-
-		out := map[string]interface{}{"list": []string{}}
-		if list != nil {
-			out["list"] = list
-		}
-		return out, nil
-	}
-	router.GETJWT(SearchPath, pageSearchFn)
-
-	//删除
-	if option.NeedsRemove {
-		removePath := fmt.Sprintf("%s/delete/:id", prefix)
-		router.POSTJWT(removePath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			id := c.Param("id")
-			if len(id) < 1 {
-				return nil, NewError("参数不能为空")
-			}
-
-			body := map[string]interface{}{}
-			c.ShouldBindJSON(&body)
-
-			ArrayQuery := repo.Map{}
-			if len(body) < 1 {
-				return nil, NewError("body参数不能为空")
-			}
-			query := bson.M{}
-			for k, v := range body {
-				query[k] = v
-			}
-			ArrayQuery[option.ArrayFieldPath] = query
-
-			options := &repo.ArrayOneRemoveOption{
-				CollectName: option.Collection,
-				Id:          id,
-				ArrayQuery:  ArrayQuery,
-			}
-
-			ret, err := repo.RepoDocArrayOneRemove(apictx.CreateRepoCtx(), options)
-			if ret.ModifiedCount < 1 {
-				return nil, NewError("删除失败!")
-			}
-
-			return ret, err
-		})
-	}
-
-	//详情
-	if option.OnDetail != nil && option.DocModel != nil {
-		DetailPath := fmt.Sprintf("%s/detail/:id", prefix)
-		router.GETJWT(DetailPath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-			docId := c.Param("id")
-			if len(docId) < 1 {
-				return nil, NewError("id不能为空!")
-			}
-			query := UtilQueryMap(c)
-
-			filter := repo.Map{}
-			if len(query) > 0 {
-				filter[option.ArrayFieldPath] = query
-			}
-
-			m := option.DocModel(c, apictx)
-
-			err := repo.RepoDocArraySearch(apictx.CreateRepoCtx(), &repo.ArrayOneSearchOption{
-				CollectName: option.Collection,
-				ArrayQuery:  filter,
-				Id:          docId,
-				Field:       option.ArrayFieldPath,
-			}, m)
-
-			if err != nil {
-				return nil, NewError("数据不存在!")
-			}
-
-			retOut, err := option.OnDetail(c, apictx, m)
-			if err != nil {
-				return nil, err
-			}
-			if retOut != nil {
-				return retOut, nil
-			}
-			return m, nil
-		})
-	}
-
-}

+ 0 - 190
tree/assetcenter/api/service-asset.go

@@ -1,190 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-const (
-	CategoyScopeGlobal = "global"
-	CategoyScopeQiye   = "qiye"
-)
-
-func AssetProfile(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	var floatv float32 = 1
-
-	profile := map[string]interface{}{
-		"name":     apictx.Svc.Conf.Name,
-		"version":  apictx.Svc.Conf.Version,
-		"saveType": apictx.Svc.Conf.SaveType,
-		"assets":   apictx.Svc.Conf.Assets,
-		"category": apictx.Svc.Conf.Category,
-		"assetConf": map[string]interface{}{
-			"decorate": &model.AssetDecorateMesh{
-				Components: []*model.MeshMatConf{
-					&model.MeshMatConf{
-						Name:     "xx",
-						Index:    1,
-						Material: &model.MatConfig{},
-					},
-				},
-			},
-			"texture": &model.AssetTexture{},
-			"env3d":   &model.Env3d{},
-			"material": model.AssetMaterial{
-				Config: &model.MatConfig{
-					Uvtransform: &model.MaterailUv{},
-					CullFace:    "",
-					Version:     1,
-					Type:        "default",
-					Albedo:      &model.MatTextureColor{Color: &model.Vect3{}, Texture: &model.OssType{}, UseTexture: BoolValue(true)},
-					Roughness:   &model.MatTextureFactor{Texture: &model.OssType{}, Factor: &floatv},
-					Normal:      &model.MatNormal{Texture: &model.OssType{}, Factor: &floatv},
-					Metalness:   &model.MatTextureFactor{Texture: &model.OssType{}, Factor: &floatv},
-					Opacity:     &model.MatTextureFactorWithEnable{Enable: *BoolValue(false), Factor: &floatv, Texture: &model.OssType{}},
-					Specular:    &model.MatTextureColor{Color: &model.Vect3{}, Texture: &model.OssType{}, UseTexture: BoolValue(true)},
-				},
-			},
-			"boxtpl": &model.Boxtpl{Components: []*model.BoxtplComponent{
-				&model.BoxtplComponent{
-					UV: &model.BoxtplCompUv{},
-				},
-			}},
-		},
-	}
-	return profile, nil
-}
-
-func UploadAsset(c *gin.Context, apictx *ApiSession, asset *conf.AppAsset) (interface{}, error) {
-
-	body := repo.RepoAssetCreateDefaultValue(asset)
-	if body == nil {
-		return nil, NewError("不支持的上传类型")
-	}
-	c.ShouldBindJSON(body.GetEntity())
-
-	return body.Upload(apictx.CreateRepoCtx(), apictx.User.ID)
-}
-
-func UpdateAsset(c *gin.Context, apictx *ApiSession, asset *conf.AppAsset) (interface{}, error) {
-	body := repo.RepoAssetCreateDefaultValue(asset)
-	if body == nil {
-		return nil, NewError("不支持的资产类型")
-	}
-	c.ShouldBindJSON(body.GetEntity())
-
-	return body.Update(apictx.CreateRepoCtx())
-}
-
-func DetailAsset(c *gin.Context, apictx *ApiSession, asset *conf.AppAsset) (interface{}, error) {
-	id := c.Param("id")
-
-	body := repo.RepoAssetCreateDefaultValue(asset)
-	if body == nil {
-		return nil, NewError("不支持的资产类型")
-	}
-	c.ShouldBindJSON(body.GetEntity())
-
-	return body.Detail(apictx.CreateRepoCtx(), id)
-}
-
-func RemoveAsset(c *gin.Context, apictx *ApiSession, asset *conf.AppAsset) (interface{}, error) {
-	body := &struct {
-		Id string
-	}{}
-
-	c.ShouldBindJSON(body)
-	collectionName := "asset-" + asset.Type
-	if len(body.Id) < 1 {
-		return nil, NewError("id不能为空!")
-	}
-	return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), collectionName, body.Id)
-}
-
-func UpdateAssetState(c *gin.Context, apictx *ApiSession, asset *conf.AppAsset) (interface{}, error) {
-	body := &struct {
-		Id    string
-		State int
-	}{}
-
-	c.ShouldBindJSON(body)
-	collectionName := "asset-" + asset.Type
-	if len(body.Id) < 1 {
-		return nil, NewError("id不能为空!")
-	}
-	return repo.RepoUpdateSetDocProps(apictx.CreateRepoCtx(), collectionName, body.Id, bson.M{"$set": bson.M{"state": body.State}})
-}
-
-func UserAssetList(c *gin.Context, apictx *ApiSession, asset *conf.AppAsset) (interface{}, error) {
-
-	page, size, query, fields := UtilQueryPageSize2(c)
-
-	uid, _ := primitive.ObjectIDFromHex(apictx.User.ID)
-	query["userId"] = uid
-
-	collectionName := "asset-" + asset.Type
-
-	// ParseCategories(query, apictx)
-
-	project := []string{"name", "thumbnail", "createTime", "state", "categories", "meshState", "images", "file", "osgjs"}
-	if len(fields) > 0 {
-		project = fields
-	}
-
-	return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		CollectName: collectionName,
-		Page:        page,
-		Size:        size,
-		Query:       query,
-		Project:     project,
-		Sort:        bson.M{"createTime": -1},
-	})
-}
-
-func CreateAssetRouter(router *GinRouter) {
-	assets := conf.AppConfig.Assets
-	if len(assets) < 1 {
-		return
-	}
-
-	for _, asset := range assets {
-
-		targetAsset := &conf.AppAsset{Type: asset.Type, Name: asset.Name, IsMesh: asset.IsMesh, IsImage: asset.IsImage, DefaultCategory: asset.DefaultCategory}
-		router.POSTJWT("/upload/"+asset.Type, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return UploadAsset(c, apictx, targetAsset)
-		})
-
-		router.POSTJWT("/update/"+asset.Type, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return UpdateAsset(c, apictx, targetAsset)
-		})
-
-		router.POSTJWT(asset.Type+"/state", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return UpdateAssetState(c, apictx, targetAsset)
-		})
-
-		router.GET(asset.Type+"/detail/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-			return DetailAsset(c, apictx, targetAsset)
-		})
-
-		router.POSTJWT("/delete/"+asset.Type, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return RemoveAsset(c, apictx, targetAsset)
-		})
-
-		router.GETJWT("/user/"+asset.Type+"/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return UserAssetList(c, apictx, targetAsset)
-		})
-		router.GETJWT("/team/"+asset.Type+"/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return UserAssetList(c, apictx, targetAsset)
-		})
-		router.GET("/platform/"+asset.Type+"/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			return UserAssetList(c, apictx, targetAsset)
-		})
-	}
-}

+ 0 - 17
tree/assetcenter/api/service-clean.go

@@ -1,17 +0,0 @@
-package api
-
-import (
-	"github.com/gin-gonic/gin"
-)
-
-func AssetClean(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	// ret, err := repo.RepoDeleteDocs(apictx.CreateRepoCtx(), repo.CollectionAssetCategory, bson.M{})
-	// if err != nil {
-	// 	return ret, err
-	// }
-
-	// return repo.RepoDeleteDocs(apictx.CreateRepoCtx(), repo.CollectionCategory, bson.M{})
-
-	return nil, nil
-}

+ 0 - 790
tree/assetcenter/api/service-database-asset.go

@@ -1,790 +0,0 @@
-package api
-
-import (
-	"assetcenter/bus"
-	"assetcenter/conf"
-
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func UploadAsset2(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf) (interface{}, error) {
-
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-		body.Source.ViewMode = "prod"
-		if apictx.User != nil {
-			body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		}
-
-		return UploadAssetPackage(apictx, dbConf, body)
-
-	case model.AssetTypePackage:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-		body.Source.ViewMode = "scene"
-
-		if apictx.User != nil {
-			body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		}
-
-		return UploadAssetPackage(apictx, dbConf, body)
-
-	case model.AssetTypeEnv3d:
-		body := &comm.AssetEnv3dHdr{}
-		c.ShouldBindJSON(body)
-		if apictx.User != nil {
-			body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		}
-		return UploadEnv3d(apictx, dbConf, body)
-	case model.AssetTypeMaterial:
-		body := &comm.AssetMat{}
-		c.ShouldBindJSON(body)
-		if apictx.User != nil {
-			body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		}
-		return UploadMaterial(apictx, dbConf, body)
-
-	case model.AssetTypeMaterialGroup:
-		body := &comm.AssetMatGroup{}
-		err := c.ShouldBindJSON(body)
-
-		if err != nil {
-			return nil, err
-		}
-
-		if apictx.User != nil {
-			body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		}
-		return UploadMaterialGroup(apictx, dbConf, body)
-
-	case model.AssetTypeImage:
-		body := &comm.AssetImage{}
-		c.ShouldBindJSON(body)
-		if apictx.User != nil {
-			body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		}
-		return UploadImage(apictx, dbConf, body)
-	}
-
-	return nil, NewError("不支持的上传类型")
-}
-
-func PublicAssetList(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf) (interface{}, error) {
-
-	page, size, query, fields := UtilQueryPageSize2(c)
-	collectionName := dbConf.AssetConf.Collection
-
-	err := bus.ParseCategories(query, apictx.CreateRepoCtx(), dbConf)
-	if err != nil {
-		return nil, err
-	}
-
-	project := []string{"name"}
-	if dbConf.AssetConf.Type == model.AssetTypeMesh {
-		project = []string{"name", "assetState", "source"}
-	}
-	if len(fields) > 0 {
-		project = fields
-	}
-
-	out, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		Db:          dbConf.Db.Name,
-		CollectName: collectionName,
-		Page:        page,
-		Size:        size,
-		Query:       query,
-		Project:     project,
-		Sort:        bson.M{"createTime": -1},
-	})
-	if err != nil {
-		return nil, err
-	}
-
-	for _, item := range out.List {
-		item["defineId"] = dbConf.AssetConf.Id
-	}
-	return out, nil
-}
-
-func AssetList(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf) (interface{}, error) {
-
-	page, size, query, fields := UtilQueryPageSize2(c)
-	collectionName := dbConf.AssetConf.Collection
-	if query["userId"] != nil && len(query["userId"].(string)) > 0 {
-		query["userId"], _ = primitive.ObjectIDFromHex(apictx.User.ID)
-	}
-	if query["ownerId"] != nil && len(query["ownerId"].(string)) > 0 {
-		query["ownerId"], _ = primitive.ObjectIDFromHex(query["ownerId"].(string))
-	}
-
-	err := bus.ParseCategories(query, apictx.CreateRepoCtx(), dbConf)
-	if err != nil {
-		return nil, err
-	}
-
-	project := []string{"name"}
-	assetType := dbConf.AssetConf.Type
-	if assetType == model.AssetTypeMesh {
-		project = []string{"name", "assetState", "source"}
-	}
-	if len(fields) > 0 {
-		project = fields
-	}
-
-	var list interface{}
-
-	if conf.AppConfig.IsSaveLocal() {
-		if assetType == model.AssetTypePackage || assetType == model.AssetTypeMesh {
-			list = []*comm.AssetPackage{}
-		} else if assetType == model.AssetTypeMaterial {
-			list = []*comm.AssetMat{}
-		} else if assetType == model.AssetTypeMaterialGroup {
-			list = []*comm.AssetMatGroup{}
-		} else if assetType == model.AssetTypeImage {
-			list = []*comm.AssetImage{}
-		} else if assetType == model.AssetTypeEnv3d {
-			list = []*comm.AssetEnv3dHdr{}
-		}
-	}
-
-	if list != nil {
-		out, err := repo.RepoPageSearchEntitys(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-			Db:          dbConf.Db.Name,
-			CollectName: collectionName,
-			Page:        page,
-			Size:        size,
-			Query:       query,
-			Project:     project,
-			Sort:        bson.M{"createTime": -1},
-			List:        &list,
-		})
-
-		if l, ok := list.([]*comm.AssetPackage); ok {
-			for _, item := range l {
-				item.UpdateSourceUrl(conf.AppConfig.GetSaveLocalUrl)
-			}
-		} else if l, ok := list.([]*comm.AssetMat); ok {
-			for _, item := range l {
-				item.UpdateSourceUrl(conf.AppConfig.GetSaveLocalUrl)
-			}
-		} else if l, ok := list.([]*comm.AssetMatGroup); ok {
-			for _, item := range l {
-				item.UpdateSourceUrl(conf.AppConfig.GetSaveLocalUrl)
-			}
-		} else if l, ok := list.([]*comm.AssetImage); ok {
-			for _, item := range l {
-				item.UpdateSourceUrl(conf.AppConfig.GetSaveLocalUrl)
-			}
-		} else if l, ok := list.([]*comm.AssetEnv3dHdr); ok {
-			for _, item := range l {
-				item.UpdateSourceUrl(conf.AppConfig.GetSaveLocalUrl)
-			}
-		}
-		return out, err
-	}
-
-	out, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		Db:          dbConf.Db.Name,
-		CollectName: collectionName,
-		Page:        page,
-		Size:        size,
-		Query:       query,
-		Project:     project,
-		Sort:        bson.M{"createTime": -1},
-	})
-	if err != nil {
-		return nil, err
-	}
-
-	for _, item := range out.List {
-		item["defineId"] = dbConf.AssetConf.Id
-	}
-	return out, nil
-}
-
-func AssetDelete(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf, id string) (interface{}, error) {
-	return repo.RepoDeleteDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, dbConf.AssetConf.Collection, id)
-}
-
-func AssetCopy(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf, id string, toDbConf *comm.AssetDbConf, ownerId string, ownerType string, assetType string) (interface{}, error) {
-	collectionName := dbConf.AssetConf.Collection
-	var body model.IAsset
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-		body = &comm.AssetPackage{}
-	case model.AssetTypeEnv3d:
-		body = &comm.AssetEnv3dHdr{}
-	case model.AssetTypeMaterial:
-		body = &comm.AssetMat{}
-	case model.AssetTypeMaterialGroup:
-		body = &comm.AssetMatGroup{}
-
-	case model.AssetTypeImage:
-		body = &comm.AssetImage{}
-	case model.AssetTypePackage:
-		body = &comm.AssetPackage{}
-	}
-
-	if body == nil {
-		return nil, NewError("不支持的拷贝类型")
-	}
-
-	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(),
-		&repo.DocSearchOptions{
-			Db:          dbConf.Db.Name,
-			CollectName: collectionName,
-			Query:       repo.Map{"_id": id},
-		}, body)
-	if !ok {
-		return nil, NewError("资产已删除!")
-	}
-	if err != nil {
-		return nil, err
-	}
-	body.SetIdEmpty()
-	body.ResetCreateTime()
-	body.SetOwner(ownerId, ownerType)
-	if len(assetType) > 0 {
-		body.SetAssetType(assetType)
-	}
-	return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), toDbConf.Db.Name, toDbConf.AssetConf.Collection, body)
-}
-
-func AssetCopy2My(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf, id string, toDbConf *comm.AssetDbConf, ownerId string, ownerType string, assetType string) (interface{}, error) {
-	collectionName := dbConf.AssetConf.Collection
-	var body model.IAsset
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-		body = &comm.AssetPackage{}
-	case model.AssetTypeEnv3d:
-		body = &comm.AssetEnv3dHdr{}
-	case model.AssetTypeMaterial:
-		body = &comm.AssetMat{}
-	case model.AssetTypeMaterialGroup:
-		body = &comm.AssetMatGroup{}
-
-	case model.AssetTypeImage:
-		body = &comm.AssetImage{}
-	case model.AssetTypePackage:
-		body = &comm.AssetPackage{}
-	}
-
-	if body == nil {
-		return nil, NewError("不支持的拷贝类型")
-	}
-
-	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(),
-		&repo.DocSearchOptions{
-			Db:          dbConf.Db.Name,
-			CollectName: collectionName,
-			Query:       repo.Map{"_id": id},
-		}, body)
-	if !ok {
-		return nil, NewError("资产已删除!")
-	}
-	if err != nil {
-		return nil, err
-	}
-	body.SetIdEmpty()
-	body.ResetCreateTime()
-	body.SetOwner(ownerId, ownerType)
-	if len(assetType) > 0 {
-		body.SetAssetType(assetType)
-	}
-
-	//todo fixme 设置用户自己的信息
-	// info, err := bus.NatsCenter.GetUserInfo(apictx.User.ID)
-	// if err != nil {
-	// 	return nil, err
-	// }
-	//body.SetUserInfo(apictx.User.ID, &comm.AssetUserInfo{Name: info.Name, Thumbnail: &comm.OssType{Url: info.Avatar, Size: 0}})
-	body.SetUserInfo(apictx.User.ID, nil)
-
-	return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), toDbConf.Db.Name, toDbConf.AssetConf.Collection, body)
-}
-
-type IAssetLocalable interface {
-	UpdateSourceUrl(comm.UpdateUrlHandler)
-}
-
-func AssetDetail(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf, id string) (interface{}, error) {
-
-	_, _, _, fields := UtilQueryPageSize2(c)
-	collectionName := dbConf.AssetConf.Collection
-
-	project := []string{"name", "thumbnail", "createTime", "assetType", "cusNum", "state", "categories", "cusCategories", "source", "assetState", "queenter", "userData"}
-
-	if len(fields) > 0 {
-		project = fields
-	}
-
-	if conf.AppConfig.IsSaveLocal() {
-
-		var p IAssetLocalable
-		aType := dbConf.AssetConf.Type
-		if aType == model.AssetTypeMesh || aType == model.AssetTypePackage {
-			p = &comm.AssetPackage{}
-		} else if aType == model.AssetTypeMaterial {
-			p = &comm.AssetMat{}
-		} else if aType == model.AssetTypeMaterialGroup {
-			p = &comm.AssetMatGroup{}
-		} else if aType == model.AssetTypeImage {
-			p = &comm.AssetImage{}
-		} else if aType == model.AssetTypeEnv3d {
-			p = &comm.AssetEnv3dHdr{}
-		}
-
-		if p != nil {
-			ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-				Db:          dbConf.Db.Name,
-				CollectName: collectionName,
-				Query:       repo.Map{"_id": id},
-				Project:     project,
-			}, p)
-			if !ok {
-				return nil, NewError("资产不存在!")
-			}
-			p.UpdateSourceUrl(conf.AppConfig.GetSaveLocalUrl)
-			return p, err
-		}
-	}
-
-	ok, body := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-		Db:          dbConf.Db.Name,
-		CollectName: collectionName,
-		Query:       repo.Map{"_id": id},
-		Project:     project,
-	})
-
-	if !ok {
-		return nil, NewError("资产不存在!")
-	}
-
-	return body, nil
-}
-
-func AssetUpdateComm(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf) (interface{}, error) {
-
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-		if body.Source != nil {
-			body.Source.ViewMode = "prod"
-		}
-
-		return UpdateAssetPackageComm(apictx, dbConf, body)
-
-	case model.AssetTypeEnv3d:
-		body := &comm.AssetEnv3dHdr{}
-		c.ShouldBindJSON(body)
-
-		return UpdateHdrComm(apictx, dbConf, body)
-	case model.AssetTypeMaterial:
-		body := &comm.AssetMat{}
-		c.ShouldBindJSON(body)
-		return UpdateMaterialComm(apictx, dbConf, body)
-	case model.AssetTypeMaterialGroup:
-		body := &comm.AssetMatGroup{}
-		c.ShouldBindJSON(body)
-		return UpdateMaterialGroup(apictx, dbConf, body)
-
-	case model.AssetTypeImage:
-		body := &comm.AssetImage{}
-		c.ShouldBindJSON(body)
-		return UpdateImageComm(apictx, dbConf, body)
-
-	case model.AssetTypePackage:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-		if body.Source != nil {
-			body.Source.ViewMode = "scene"
-		}
-
-		return UpdateAssetPackageComm(apictx, dbConf, body)
-	}
-
-	return nil, NewError("不支持的类型")
-}
-
-func AssetUpdateSource(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf) (interface{}, error) {
-
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-
-		return UpdateAssetPackageSource(apictx, dbConf, body)
-	case model.AssetTypePackage:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-
-		return UpdateAssetPackageSource(apictx, dbConf, body)
-
-	case model.AssetTypeEnv3d:
-		body := &comm.AssetEnv3dHdr{}
-		c.ShouldBindJSON(body)
-
-		return UpdateHdrSource(apictx, dbConf, body)
-	case model.AssetTypeMaterial:
-		body := &comm.AssetMat{}
-		c.ShouldBindJSON(body)
-		return UpdateMaterialComm(apictx, dbConf, body)
-	case model.AssetTypeMaterialGroup:
-		body := &comm.AssetMatGroup{}
-		c.ShouldBindJSON(body)
-		return UpdateMaterialGroup(apictx, dbConf, body)
-
-	case model.AssetTypeImage:
-		body := &comm.AssetImage{}
-		c.ShouldBindJSON(body)
-		return UpdateImageSource(apictx, dbConf, body)
-	}
-
-	return nil, NewError("不支持的类型")
-}
-
-func InsertAsset(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf) (interface{}, error) {
-
-	var asset interface{} = nil
-
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-	case model.AssetTypePackage:
-		body := &comm.AssetPackage{}
-		c.ShouldBindJSON(body)
-		body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		body.UpdateTime = time.Now()
-		body.CreateTime = time.Now()
-		body.Id = primitive.NilObjectID
-		asset = body
-	}
-
-	if asset != nil {
-		collectionName := dbConf.AssetConf.Collection
-		return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
-	}
-
-	return nil, NewError("不支持的类型")
-}
-
-func AssetProcess(c *gin.Context, apictx *ApiSession, dbConf *comm.AssetDbConf, id string) (interface{}, error) {
-
-	switch dbConf.AssetConf.Type {
-	case model.AssetTypeMesh:
-		return ProcessPackage(apictx, dbConf, id)
-	case model.AssetTypePackage:
-		return ProcessPackage(apictx, dbConf, id)
-		// case model.AssetTypeEnv3d:
-		// 	return ProcessHdr(apictx, dbConf, id)
-	}
-
-	return nil, NewError("不支持的类型")
-}
-
-type AssetEvent struct {
-	DefId string
-	DbId  string // 哪个资产库的统计表
-	Api   string
-}
-
-func CreateDatabaseAssetRouter(router *GinRouter) {
-
-	//dbId的数据上传对应的资产库
-	router.POSTJWT("/upload/:dbId/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbId")
-		assetConfId := c.Param("assetConfId")
-		if len(dbId) < 1 || len(assetConfId) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		ret, err := UploadAsset2(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf})
-		if err != nil {
-			return nil, err
-		}
-		bus.NatsCenter.PublishObj("asset.added", &AssetEvent{Api: "upload", DbId: dbId, DefId: assetConf.Id})
-
-		return ret, nil
-	})
-
-	router.POSTJWT("/updatecomm/:dbid/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		if len(dbId) < 1 || len(assetConfId) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-		return AssetUpdateComm(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf})
-	})
-
-	router.POSTJWT("/updatesource/:dbid/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		if len(dbId) < 1 || len(assetConfId) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetUpdateSource(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf})
-	})
-
-	//删除
-	router.POSTJWT("/delete/:dbid/:assetConfId/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		id := c.Param("id")
-
-		if len(dbId) < 1 || len(assetConfId) < 1 || len(id) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		ret, err := AssetDelete(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf}, id)
-		if err != nil {
-			return nil, err
-		}
-		bus.NatsCenter.PublishObj("asset.removed", &AssetEvent{Api: "upload", DbId: dbId, DefId: assetConf.Id})
-
-		return ret, nil
-	})
-
-	//拷贝
-	router.POSTJWT("/copy/:dbid/:assetConfId/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		id := c.Param("id")
-
-		body := &struct {
-			DbId      string
-			AssetType string
-			DefineId  string
-			OwnerId   string
-			OwnerType string
-		}{}
-
-		err := c.ShouldBindJSON(body)
-		if err != nil {
-			return nil, err
-		}
-		if len(body.DbId) < 1 || len(body.DefineId) < 1 {
-			return nil, NewError("目标库Id不合法")
-		}
-
-		if len(dbId) < 1 || len(assetConfId) < 1 || len(id) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		fromDbConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if fromDbConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		toDbConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), body.DbId, body.DefineId)
-		if toDbConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetCopy(c, apictx, fromDbConf, id, toDbConf, body.OwnerId, body.OwnerType, body.AssetType)
-	})
-
-	router.POSTJWT("/insertById/:dbid/:assetConfId/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		id := c.Param("id")
-
-		body := &struct {
-			DbId      string
-			DefineId  string
-			OwnerId   string
-			OwnerType string
-			AssetType string
-		}{}
-
-		err := c.ShouldBindJSON(body)
-		if err != nil {
-			return nil, err
-		}
-		if len(body.DbId) < 1 || len(body.DefineId) < 1 {
-			return nil, NewError("目标库Id不合法")
-		}
-
-		if len(dbId) < 1 || len(assetConfId) < 1 || len(id) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		fromDbConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if fromDbConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		toDbConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), body.DbId, body.DefineId)
-		if toDbConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetCopy2My(c, apictx, fromDbConf, id, toDbConf, body.OwnerId, body.OwnerType, body.AssetType)
-	})
-
-	//拷贝
-	router.POSTJWT("/insert/:dbid/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-
-		toDbConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if toDbConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return InsertAsset(c, apictx, toDbConf)
-	})
-
-	//列表查询
-	router.GETJWT("/list/:dbid/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		if len(dbId) < 1 || len(assetConfId) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetList(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf})
-	})
-
-	//公开的列表查询
-	router.GET("/public/:dbid/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		if len(dbId) < 1 || len(assetConfId) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return PublicAssetList(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf})
-	})
-
-	//列表查询
-	router.GET("/asset/:dbid/:assetConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		if len(dbId) < 1 || len(assetConfId) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetList(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf})
-	})
-
-	//详情
-	router.GET("/detail/:dbid/:assetConfId/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		id := c.Param("id")
-
-		if len(dbId) < 1 || len(assetConfId) < 1 || len(id) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-
-		assetConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if assetConf.AssetConf == nil || len(assetConf.Db.Name) < 1 {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetDetail(c, apictx, assetConf, id)
-	})
-
-	//资产处理
-	router.POSTJWT("/process/:dbid/:assetConfId/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		id := c.Param("id")
-
-		if len(dbId) < 1 || len(assetConfId) < 1 || len(id) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		return AssetProcess(c, apictx, &comm.AssetDbConf{Db: db, AssetConf: assetConf}, id)
-	})
-
-	//pack生成阴影
-	router.POSTJWT("/processshadow/:dbid/:assetConfId/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		dbId := c.Param("dbid")
-		assetConfId := c.Param("assetConfId")
-		id := c.Param("id")
-
-		body := &struct {
-			Scale int32
-			Width int32
-		}{}
-
-		err := c.ShouldBindJSON(body)
-		if err != nil {
-			body.Scale = 15
-			body.Width = 512
-		}
-
-		if body.Scale < 15 {
-			return nil, NewError("scale需要>=15!")
-		}
-
-		if len(dbId) < 1 || len(assetConfId) < 1 || len(id) < 1 {
-			return nil, NewError("数据Id不合法!")
-		}
-		assetConf := repo.GetDatabaseCollectionSimple(apictx.CreateRepoCtx(), dbId, assetConfId)
-		if assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-
-		if assetConf.AssetConf.Type != model.AssetTypePackage && assetConf.AssetConf.Type != model.AssetTypeMesh {
-			return nil, NewError("该类型不支持生成阴影!")
-		}
-
-		return ProcessPackageShadow(apictx, assetConf, id, body.Scale, body.Width)
-	})
-
-	// router.GETJWT("/team/"+asset.Type+"/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// 	return UserAssetList(c, apictx, targetAsset)
-	// })
-	// router.GET("/platform/"+asset.Type+"/list", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// 	return UserAssetList(c, apictx, targetAsset)
-	// })
-}

+ 0 - 186
tree/assetcenter/api/service-database-assetconf.go

@@ -1,186 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"assetcenter/utils"
-	"fmt"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func CreateDatabaseAssetConfRouter(router *GinRouter) {
-
-	//创建资产定义
-	router.POST("/assetconf/create/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("数据库Id不能为空")
-		}
-		body := &comm.DbAsset{}
-		c.ShouldBindJSON(body)
-		body.Id = primitive.NewObjectID().Hex()
-
-		if len(body.Label) < 1 || body.Type == 0 {
-			return nil, NewError("数据不合法!")
-		}
-		body.CreateTime = time.Now()
-
-		//数据库名字添加一个随机数
-		var createCollRandomName = func(assetType int) string {
-			typePrefixMap := map[int]string{}
-			typePrefixMap[model.AssetTypeMesh] = "mesh"
-			typePrefixMap[model.AssetTypeImage] = "image"
-			typePrefixMap[model.AssetTypeMaterial] = "material"
-			typePrefixMap[model.AssetTypeMaterialGroup] = "matgroup"
-			typePrefixMap[model.AssetTypeEnv3d] = "hdr"
-			typePrefixMap[model.AssetTypePackage] = "scene"
-			prefix := typePrefixMap[assetType]
-			if len(prefix) < 1 {
-				return ""
-			}
-			return fmt.Sprintf("%s-%s-%s", prefix, time.Now().Format("20060102"), utils.RandName(6))
-		}
-		coll := createCollRandomName(body.Type)
-		if len(coll) < 1 {
-			return nil, fmt.Errorf("不支持的资产类型")
-		}
-		body.Collection = coll
-		database := &comm.Database{}
-		ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"assets.collection": body.Collection, "_id": id}, Project: []string{"_id"}}, database)
-		if ok {
-			return nil, NewError("资产库编号不能重复")
-		}
-
-		return repo.RepoDocArrayAppend(
-			apictx.CreateRepoCtx(),
-			repo.CollectionDatabase,
-			id,
-			"assets",
-			body,
-		)
-	})
-
-	//创建资产定义
-	router.GET("/assetconf/list/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("数据库Id不能为空")
-		}
-
-		database := &comm.Database{}
-
-		_, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"_id": id}, Project: []string{"assets"}}, database)
-
-		return database.Assets, err
-	})
-
-	//删除资产定义
-	router.POST("/assetconf/delete/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("数据库Id不能为空")
-		}
-		body := &comm.DbAsset{}
-		c.ShouldBindJSON(body)
-		if len(body.Id) < 1 {
-			return nil, NewError("资产Id不能为空!")
-		}
-
-		return repo.RepoDocArrayOneRemove(
-			apictx.CreateRepoCtx(),
-			&repo.ArrayOneRemoveOption{
-				CollectName: repo.CollectionDatabase,
-				Id:          id,
-				ArrayQuery:  repo.Map{"assets": bson.M{"id": body.Id}},
-			},
-		)
-	})
-
-	//更新资产标签
-	router.POST("/assetconf/update/label/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("数据库Id不能为空")
-		}
-		body := &comm.DbAsset{}
-		c.ShouldBindJSON(body)
-		if len(body.Id) < 1 || len(body.Label) < 1 {
-			return nil, NewError("参数非法")
-		}
-		optSet := repo.Map{}
-		optSet["assets.$.label"] = body.Label
-		option := &repo.ArrayOneUpdateOption{
-			CollectName: repo.CollectionDatabase,
-			Id:          id,
-			Query:       repo.Map{"assets.id": body.Id},
-			Set:         optSet,
-		}
-		return repo.RepoDocArrayOneUpdate(
-			apictx.CreateRepoCtx(),
-			option,
-		)
-	})
-
-	router.POST("/assetconf/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("数据库Id不能为空")
-		}
-
-		body := &comm.DbAsset{}
-		c.ShouldBindJSON(body)
-
-		if len(body.Id) < 1 || len(body.Label) < 1 {
-			return nil, NewError("参数非法")
-		}
-		optSet := repo.Map{}
-
-		if len(body.Label) > 0 {
-			optSet["assets.$.label"] = body.Label
-		}
-		if body.CategoryIds != nil {
-			optSet["assets.$.categoryIds"] = body.CategoryIds
-		}
-		option := &repo.ArrayOneUpdateOption{
-			CollectName: repo.CollectionDatabase,
-			Id:          id,
-			Query:       repo.Map{"assets.id": body.Id},
-			Set:         optSet,
-		}
-
-		return repo.RepoDocArrayOneUpdate(
-			apictx.CreateRepoCtx(),
-			option,
-		)
-	})
-
-	//更新资产分类
-	router.POST("/assetconf/update/categoryIds/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("数据库Id不能为空")
-		}
-		body := &comm.DbAsset{}
-		c.ShouldBindJSON(body)
-		if len(body.Id) < 1 {
-			return nil, NewError("参数非法")
-		}
-		optSet := repo.Map{}
-		optSet["assets.$.categoryIds"] = body.CategoryIds
-		option := &repo.ArrayOneUpdateOption{
-			CollectName: repo.CollectionDatabase,
-			Id:          id,
-			Query:       repo.Map{"assets.id": body.Id},
-			Set:         optSet,
-		}
-		return repo.RepoDocArrayOneUpdate(
-			apictx.CreateRepoCtx(),
-			option,
-		)
-	})
-}

+ 0 - 219
tree/assetcenter/api/service-database-category.go

@@ -1,219 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/repo"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func CreateDatabaseCategoryRouter(router *GinRouter) {
-
-	//创建分类定义
-	router.POSTJWT("/user/category/:scope", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		scope := c.Param("scope")
-		if len(scope) < 1 || !primitive.IsValidObjectID(apictx.User.Parent) {
-			return nil, NewError("Id参数非法!")
-		}
-
-		body := &comm.DbCategory{}
-		c.ShouldBindJSON(body)
-		body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.Parent)
-		body.Scope = scope
-
-		body.CreateTime = time.Now()
-		if body.Id.IsZero() {
-			body.CreateTime = time.Now()
-		} else {
-			body.UpdateTime = time.Now()
-		}
-
-		curr := &comm.DbCategory{}
-		ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionCategories,
-			Project:     []string{"_id"},
-			Query:       repo.Map{"userId": body.UserId, "scope": body.Scope},
-		}, curr)
-		if err != nil {
-			return nil, err
-		}
-
-		if !ok { //没有查询到新增
-			id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionCategories, body)
-			if err != nil {
-				return nil, err
-			}
-			body.Id, _ = primitive.ObjectIDFromHex(id)
-			return body, nil
-		}
-
-		body.Id = primitive.NilObjectID
-		return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionCategories, curr.Id.Hex(), body)
-	})
-
-	// //更新
-	// router.POSTJWT("/dbcategory/update/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// 	id := c.Param("id")
-	// 	if len(id) < 1 {
-	// 		return nil, NewError("数据库Id不能为空")
-	// 	}
-	// 	body := &model.DbCategory{}
-	// 	c.ShouldBindJSON(body)
-	// 	if len(body.Id) < 1 {
-	// 		return nil, NewError("id不能为空")
-	// 	}
-
-	// 	optSet := repo.Map{}
-	// 	if len(body.Name) > 0 {
-	// 		optSet["categories.$.name"] = body.Name
-	// 	}
-	// 	if len(body.Value) > 0 {
-	// 		optSet["categories.$.value"] = body.Value
-	// 	}
-
-	// 	option := &repo.ArrayOneUpdateOption{
-	// 		CollectName: repo.CollectionDatabase,
-	// 		Id:          id,
-	// 		Query:       repo.Map{"categories.id": body.Id},
-	// 		Set:         optSet,
-	// 	}
-	// 	return repo.RepoDocArrayOneUpdate(
-	// 		apictx.CreateRepoCtx(),
-	// 		option,
-	// 	)
-	// })
-
-	//获取用户的所有分类定义和 资产分类定义
-	router.GETJWT("/user/category/:scope", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		scope := c.Param("scope")
-		if len(scope) < 1 || !primitive.IsValidObjectID(apictx.User.Parent) {
-			return nil, NewError("Id参数非法!")
-		}
-
-		uidObj, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
-
-		ok, ret := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionCategories,
-			Query:       repo.Map{"userId": uidObj, "scope": scope},
-		})
-		if !ok {
-			return nil, NewError("no find!")
-		}
-		return ret, nil
-	})
-
-	//创建资产分类
-	router.POSTJWT("/user/assetcategory/:scope", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		scope := c.Param("scope")
-		if len(scope) < 1 || !primitive.IsValidObjectID(apictx.User.Parent) {
-			return nil, NewError("Id参数非法!")
-		}
-
-		body := &comm.DbAssetUserCategory{}
-		c.ShouldBindJSON(body)
-		body.UserId, _ = primitive.ObjectIDFromHex(apictx.User.Parent)
-		body.Scope = scope
-
-		body.CreateTime = time.Now()
-
-		curr := &comm.DbAssetUserCategory{}
-		ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionDbAssetCategory,
-			Project:     []string{"_id"},
-			Query:       repo.Map{"userId": body.UserId, "scope": body.Scope},
-		}, curr)
-		if err != nil {
-			return nil, err
-		}
-
-		if !ok { //没有查询到新增
-
-			body.CreateTime = time.Now()
-			id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionDbAssetCategory, body)
-			if err != nil {
-				return nil, err
-			}
-			body.Id, _ = primitive.ObjectIDFromHex(id)
-			return body, nil
-		}
-
-		body.Id = primitive.NilObjectID
-		body.UpdateTime = time.Now()
-
-		return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionDbAssetCategory, curr.Id.Hex(), body)
-	})
-
-	router.GETJWT("/user/assetcategory/:scope", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		scope := c.Param("scope")
-		if len(scope) < 1 || !primitive.IsValidObjectID(apictx.User.Parent) {
-			return nil, NewError("Id参数非法!")
-		}
-		uidObj, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
-
-		ok, ret := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionDbAssetCategory,
-			Query:       repo.Map{"userId": uidObj, "scope": scope},
-		})
-		if !ok {
-			return nil, NewError("no find!")
-		}
-		return ret, nil
-	})
-
-	router.GETJWT("/user/categoryconf/:scope", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		scope := c.Param("scope")
-		if len(scope) < 1 || !primitive.IsValidObjectID(apictx.User.Parent) {
-			return nil, NewError("Id参数非法!")
-		}
-		uidObj, _ := primitive.ObjectIDFromHex(apictx.User.Parent)
-
-		_, ret1 := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionCategories,
-			Query:       repo.Map{"userId": uidObj, "scope": scope},
-		})
-
-		_, ret2 := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionDbAssetCategory,
-			Query:       repo.Map{"userId": uidObj, "scope": scope},
-		})
-
-		return map[string]interface{}{
-			"categories":      ret1,
-			"assetCategories": ret2,
-		}, nil
-	})
-
-	router.GET("/public/category/:cateId/:assetCateConfId", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		cateId := c.Param("cateId")
-		assetCateConfId := c.Param("assetCateConfId")
-
-		if !primitive.IsValidObjectID(cateId) || !primitive.IsValidObjectID(assetCateConfId) {
-			return nil, NewError("Id参数非法!")
-		}
-
-		cateIdObj, _ := primitive.ObjectIDFromHex(cateId)
-		ok, ret := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionCategories,
-			Query:       repo.Map{"_id": cateIdObj},
-		})
-		if !ok {
-			return nil, NewError("no find!")
-		}
-
-		assetCateIdObj, _ := primitive.ObjectIDFromHex(assetCateConfId)
-		_, assetConf := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionDbAssetCategory,
-			Query:       repo.Map{"_id": assetCateIdObj},
-		})
-
-		return map[string]interface{}{
-			"categories":      ret,
-			"assetCategories": assetConf,
-		}, nil
-	})
-}

+ 0 - 118
tree/assetcenter/api/service-database-design-product.go

@@ -1,118 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"errors"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-// 注册设计相关接口
-func CreateDatabaseDesignProductRouter(router *GinRouter) {
-
-	//获取项目单品详情
-	router.GETJWT("/design/product/detail", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Query("id")
-		ok, ret := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDesignProducts, Query: repo.Map{"_id": id}})
-		if !ok {
-			return nil, NewError("获取单品失败!")
-		}
-		return ret, nil
-	})
-
-	router.POSTJWT("/design/product/add/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		projId := c.Param("id")
-		body := &model.ProductHeader{}
-		c.ShouldBindJSON(body)
-
-		if len(projId) < 1 || len(body.FromDbConfId) < 1 || len(body.FromAssetConfId) < 1 || len(body.FromId) < 1 {
-			return nil, NewError("参数不合法!")
-		}
-
-		db, assetConf := repo.GetDatabaseCollection(apictx.CreateRepoCtx(), body.FromDbConfId, body.FromAssetConfId)
-		if len(db.Name) < 1 || assetConf == nil {
-			return nil, NewError("没有对应的资产定义!")
-		}
-		body.CreateTime = time.Now()
-
-		if assetConf.Type == model.AssetTypeMesh {
-			asset := &model.AssetStaticMesh{}
-			ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{Db: db.Name, CollectName: assetConf.Collection, Query: repo.Map{"_id": body.FromId}}, asset)
-			if err != nil {
-				return nil, err
-			}
-			if !ok {
-				return nil, errors.New("对应的模型不存在!")
-			}
-
-			product := &model.DesignProduct{
-				FromDbConfId:    body.FromDbConfId,
-				FromAssetConfId: body.FromAssetConfId,
-				FromId:          body.FromId,
-				Thumbnail:       asset.Thumbnail,
-				Name:            asset.Name,
-				StaticMesh:      asset.Source,
-			}
-			product.ProjectId, _ = primitive.ObjectIDFromHex(projId)
-
-			id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionDesignProducts, product)
-			if err != nil {
-				return nil, err
-			}
-			body.Id = id
-			body.Name = asset.Name
-			body.Thumbnail = asset.Thumbnail
-		} else {
-			return nil, NewError("该资产类型不支持创建单品!")
-		}
-
-		ret, err := repo.RepoDocArrayAppend(apictx.CreateRepoCtx(), repo.CollectionDesigns, projId, "products", body)
-		if err != nil {
-			return nil, err
-		}
-		if ret.ModifiedCount < 1 {
-			return nil, errors.New("添加失败!")
-		}
-		return body, nil
-	})
-
-	router.POSTJWT("/design/product/update", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		// if len(c.Param("id")) < 1 {
-		// 	return nil, NewError("项目Id不能为空!")
-		// }
-
-		body := &model.DesignProduct{}
-		c.ShouldBindJSON(body)
-		if body.Id == primitive.NilObjectID {
-			return nil, NewError("单品Id不能为空!")
-		}
-
-		id := body.Id.Hex()
-		body.Id = primitive.NilObjectID
-		body.ProjectId = primitive.NilObjectID
-		body.UpdateTime = time.Now()
-
-		return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionDesignProducts, id, body)
-	})
-
-	router.POSTJWT("/design/product/delete/:did/:pid", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		desiginId := c.Param("did")
-		prouductId := c.Param("pid")
-
-		if len(desiginId) < 1 || len(prouductId) < 1 {
-			return nil, NewError("参数不合法!")
-		}
-
-		_, err := repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionDesignProducts, prouductId)
-		if err != nil {
-			return nil, err
-		}
-
-		//删除数组内容
-		return repo.RepoDocArrayOneRemove(apictx.CreateRepoCtx(), &repo.ArrayOneRemoveOption{CollectName: repo.CollectionDesigns, Id: desiginId, ArrayQuery: repo.Map{"products": bson.M{"id": prouductId}}})
-	})
-}

+ 0 - 72
tree/assetcenter/api/service-database-design-scene.go

@@ -1,72 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-// 注册设计相关接口
-func CreateDatabaseDesignSceneRouter(router *GinRouter) {
-
-	//项目场景列表管理
-	CreateArrayCRUD(router, "/design/scene", &ArrayCRUDOption{
-		Collection:  repo.CollectionDesigns,
-		NeedsUpdate: true,
-		NeedsRemove: true,
-		NewModel: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			prod := model.ProductHeader{}
-			c.ShouldBindJSON(&prod)
-
-			sceneProd := &model.SceneProduct{
-				Id: prod.Id,
-				// Name:    prod.Name,
-				// Type:    "product",
-				Locked:  false,
-				Visible: true,
-				Transform: &model.Transform{
-					Pos:   model.Vect3{0, 0, 0},
-					Scale: model.Vect3{1, 1, 1},
-					Rot:   model.Vect3{0, 0, 0},
-				},
-			}
-
-			scene := &model.DesignScene{
-				Id:         primitive.NewObjectID().Hex(),
-				Name:       prod.Name,
-				Thumbnail:  prod.Thumbnail,
-				CreateTime: time.Now(),
-				Product:    []*model.SceneProduct{sceneProd},
-			}
-			return scene, nil
-		},
-
-		EmtyModel: func(c *gin.Context, apictx *ApiSession) interface{} {
-			return &model.DesignScene{}
-		},
-		ArrayFieldPath: "scenes",
-		SearchProject:  []string{"name", "id", "thumbnail", "createTime"},
-	})
-
-	router.POSTJWT("/design/create/scene/:id", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		projId := c.Param("id")
-
-		scene := &model.DesignScene{}
-		c.ShouldBindJSON(scene)
-		if len(scene.Name) < 1 {
-			return nil, NewError("场景名称不能为空!")
-		}
-		scene.Id = primitive.NewObjectID().Hex()
-		scene.CreateTime = time.Now()
-		scene.Product = []*model.SceneProduct{}
-
-		ret, _ := repo.RepoDocArrayAppend(apictx.CreateRepoCtx(), repo.CollectionDesigns, projId, "scenes", scene)
-		if ret.ModifiedCount == 1 {
-			return scene, nil
-		}
-		return nil, NewError("创建失败!")
-	})
-}

+ 0 - 203
tree/assetcenter/api/service-database-design.go

@@ -1,203 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"fmt"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-// 注册设计相关接口
-func CreateDatabaseDesignRouter(router *GinRouter) {
-
-	router.GETJWT("/design/list", DesignList)
-	router.POSTJWT("/design/create", DesignCreate)
-	router.POSTJWT("/design/update", DesignSave)
-	router.POSTJWT("/design/delete/:id", DesignDelete)
-	router.GETJWT("/design/detail/:id", DesignDetail)
-	router.POSTJWT("/design/save", DesignSave)
-}
-
-func DesignList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	page, size, query := UtilQueryPageSize(c)
-
-	if query == nil {
-		query = map[string]interface{}{}
-	}
-
-	query["userId"], _ = primitive.ObjectIDFromHex(apictx.User.ID)
-
-	return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		CollectName: repo.CollectionDesigns,
-		Page:        page,
-		Size:        size,
-		Query:       query,
-		Project:     []string{"name", "thumbnail", "createTime"},
-		Sort:        bson.M{"createTime": -1},
-	})
-}
-
-// 创建设计
-func DesignCreate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	body := &struct {
-		Name string
-		From string
-		Id   string
-	}{}
-
-	err := c.ShouldBindJSON(body)
-	if err != nil {
-		return nil, NewError("参数解析错误")
-	}
-	if len(body.Name) < 1 {
-		body.Name = "未定义"
-	}
-
-	//创建空设计
-	d3d := &model.Design3d{
-		Name:       body.Name,
-		CreateTime: time.Now(),
-		Products:   []*model.ProductHeader{},
-		Scenes:     []*model.DesignScene{},
-	}
-	d3d.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-	return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionDesigns, d3d)
-
-	// if len(body.From) < 1 || len(body.Id) < 1 {
-	// 	return nil, NewError("单品Id或类型不能为空!")
-	// }
-	// if body.From != "decorate" && body.From != "boxtpl" {
-	// 	return nil, NewError("不支持的模型类型")
-	// }
-
-	// collection := UtilAssetCollectionName(body.From)
-	// updateProjectIdCollection := ""
-	// updateProjectId := ""
-
-	// if body.From == "decorate" {
-	// 	assetHeader := &model.AssetDecorateMesh{}
-	// 	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: collection, Query: repo.Map{"_id": body.Id}}, assetHeader)
-	// 	if err != nil {
-	// 		return nil, err
-	// 	}
-	// 	if !ok {
-	// 		return nil, NewError("对应的装饰不存在!")
-	// 	}
-
-	// 	projectDecorate := &model.ProjectDecorateMesh{}
-	// 	projectDecorate.CopyFromAsset(assetHeader)
-	// 	//projectDecorate.ProjectId, _ = primitive.ObjectIDFromHex(prjId)
-	// 	updateProjectIdCollection = repo.CollectionProjectDecorate
-
-	// 	decorateId, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionProjectDecorate, projectDecorate)
-
-	// 	if err != nil {
-	// 		return nil, err
-	// 	}
-	// 	updateProjectId = decorateId
-
-	// 	header := &model.ProductHeader{
-	// 		Name:       projectDecorate.Name,
-	// 		From:       body.From,
-	// 		Id:         decorateId,
-	// 		Thumbnail:  *projectDecorate.Thumbnail,
-	// 		CreateTime: time.Now(),
-	// 	}
-	// 	project.Products = []*model.ProductHeader{header}
-	// } else if body.From == "boxtpl" {
-	// 	assetHeader := &model.Boxtpl{}
-	// 	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: collection, Query: repo.Map{"_id": body.Id}}, assetHeader)
-	// 	if err != nil {
-	// 		return nil, err
-	// 	}
-	// 	if !ok {
-	// 		return nil, NewError("对应的装饰不存在!")
-	// 	}
-
-	// 	projectBoxtpl := &model.ProjectBoxtpl{}
-	// 	projectBoxtpl.CopyFromAsset(assetHeader)
-	// 	//projectDecorate.ProjectId, _ = primitive.ObjectIDFromHex(prjId)
-	// 	updateProjectIdCollection = repo.CollectionProjectBoxTpl
-
-	// 	boxId, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), updateProjectIdCollection, projectBoxtpl)
-	// 	if err != nil {
-	// 		return nil, err
-	// 	}
-	// 	updateProjectId = boxId
-
-	// 	header := &model.ProductHeader{
-	// 		Name:       projectBoxtpl.Name,
-	// 		From:       body.From,
-	// 		Id:         boxId,
-	// 		Thumbnail:  *projectBoxtpl.Thumbnail,
-	// 		CreateTime: time.Now(),
-	// 	}
-	// 	project.Products = []*model.ProductHeader{header}
-	// }
-
-	// prjId, err := repo.AddProject(apictx.CreateRepoCtx(), project)
-	// if err != nil {
-	// 	return nil, err
-	// }
-
-	// uid, _ := primitive.ObjectIDFromHex(prjId)
-	// _, err = repo.RepoUpdateSetDocProps(apictx.CreateRepoCtx(), updateProjectIdCollection, updateProjectId, bson.M{"$set": bson.M{"projectId": uid}})
-	// if err != nil {
-	// 	repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionProject, prjId)
-	// 	return nil, err
-	// }
-	// return prjId, nil
-}
-
-func DesignSave(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	body := &model.Design3d{}
-	err := c.ShouldBindJSON(body)
-	if err != nil {
-		fmt.Println(err)
-		return nil, NewError("参数解析错误" + err.Error())
-	}
-	if len(body.Id) < 1 {
-		return nil, NewError("ID不能为空")
-	}
-
-	id := body.Id.Hex()
-	body.Id = primitive.NilObjectID
-	body.UserId = primitive.NilObjectID
-	body.CreateTime = time.Time{}
-	body.UpdateTime = time.Now()
-
-	return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), repo.CollectionDesigns, id, body)
-}
-
-func DesignDelete(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	id := c.Param("id")
-	if len(id) < 1 {
-		return nil, NewError("参数不能为空")
-	}
-	return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionDesigns, id)
-}
-
-func DesignDetail(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	id := c.Param("id")
-	if len(id) < 1 {
-		return nil, NewError("参数id不能为空")
-	}
-
-	prj := &model.Design3d{}
-
-	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDesigns, Query: repo.Map{"_id": id}}, prj)
-
-	if err != nil {
-		return nil, err
-	}
-
-	if !ok {
-		return nil, NewError("没有数据!")
-	}
-	return prj, nil
-}

+ 0 - 86
tree/assetcenter/api/service-database-package.go

@@ -1,86 +0,0 @@
-package api
-
-import (
-	"assetcenter/bus"
-	"assetcenter/conf"
-	"assetcenter/db/repo"
-	funcgraph "assetcenter/funcGraph"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func UpdateAssetPackageComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetPackage) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-type OsgConvRequest struct {
-	AssetId string `json:"assetId"`
-	DbId    string `json:"dbId"`
-	Table   string `json:"table"`
-	MeshUrl string `json:"meshUrl"`
-
-	LocalPath string `json:"localPath"`
-	WkDir     string `json:"wkDir"`
-}
-
-func UploadAssetPackage(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetPackage) (interface{}, error) {
-	asset := body
-	asset.Enable = BoolValue(false)
-	body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-
-	transTask := asset.TransTask
-	shadowTask := asset.ShadowTask
-
-	if comm.TransTaskIsNotEmpty(transTask) {
-		// 转换文件存在,更新状态
-		asset.Source = nil
-
-	}
-
-	asset.CreateTime = time.Now()
-	asset.UpdateTime = time.Now()
-
-	collectionName := dbConf.AssetConf.Collection
-	assetId, err := repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
-	if err != nil {
-		return nil, err
-	}
-	url, err := bus.NatsCenter.RequestConfig("bus-network")
-	if err != nil {
-		return nil, err
-	}
-	if comm.TransTaskIsNotEmpty(transTask) {
-		// 模型转换
-		funcgraph.OsgConvRequest(transTask.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, url)
-
-	}
-
-	if comm.ShadowIsNotEmpty(shadowTask) {
-		// 阴影转换
-		funcgraph.CreateShadow(shadowTask.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, 15, 512, url)
-	}
-
-	return assetId, err
-}
-
-func UpdateAssetPackageSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetPackage) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}

+ 0 - 1
tree/assetcenter/api/service-database-render.go

@@ -1 +0,0 @@
-package api

+ 0 - 91
tree/assetcenter/api/service-database-upload-env3d.go

@@ -1,91 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func UploadEnv3d(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetEnv3dHdr) (interface{}, error) {
-	asset := body
-
-	source := asset.Source
-	asset.Enable = BoolValue(false)
-	if source == nil || source.File.Size < 1 || len(source.File.Url) < 1 {
-		asset.AssetState = model.AssetState_Empty
-	} else {
-		// !hdr 无效,直接成功
-		// asset.AssetState = model.AssetState_Waiting
-
-		asset.AssetState = model.AssetState_Succ
-		// asset.Source.ToneMap = &model.ToneMap{
-		// 	Method:     Int32Value(1),
-		// 	Exposure:   Float64Value(1),
-		// 	Brightness: Float64Value(0.1),
-		// 	Contrast:   Float64Value(0.06),
-		// 	Saturation: Float64Value(1),
-		// }
-		// asset.Source.Options = &model.Env3dOption{
-		// 	Rotation: 0,
-		// 	Exposure: 1,
-		// }
-	}
-	asset.CreateTime = time.Now()
-	asset.UpdateTime = time.Now()
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-
-	// assetSource := asset.Source
-
-	collectionName := dbConf.AssetConf.Collection
-	assetId, err := repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
-	if err != nil {
-		return nil, err
-	}
-
-	// !hdr 没用上
-	// if asset.AssetState == model.AssetState_Waiting { //模型转换请求
-
-	// 	url, err := bus.NatsCenter.RequestConfig("bus-network")
-	// 	if err != nil {
-	// 		return nil, err
-	// 	}
-
-	// 	err = funcgraph.CreateHdr(assetSource.File.Url, assetId, dbConf.Db.Name, dbConf.AssetConf.Collection, url)
-	// 	if err != nil {
-	// 		update := bson.M{"$set": bson.M{"assetState": model.AssetState_Failed}}
-	// 		repo.RepoUpdateSetDbDocProps(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, assetId, update)
-	// 	}
-	// }
-
-	return assetId, err
-}
-
-func UpdateHdrComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetEnv3dHdr) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func UpdateHdrSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetEnv3dHdr) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}

+ 0 - 51
tree/assetcenter/api/service-database-upload-image.go

@@ -1,51 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func UploadImage(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetImage) (interface{}, error) {
-	asset := body
-	// source := asset.Source
-	asset.Enable = BoolValue(false)
-	asset.AssetState = model.AssetState_Succ
-
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-
-	asset.CreateTime = time.Now()
-	asset.UpdateTime = time.Now()
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
-}
-
-func UpdateImageComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetImage) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func UpdateImageSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetImage) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		asset.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}

+ 0 - 104
tree/assetcenter/api/service-database-upload-mat.go

@@ -1,104 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func UploadMaterial(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
-	asset := body
-	// source := asset.Source
-	asset.Enable = BoolValue(false)
-	asset.AssetState = model.AssetState_Succ
-	if conf.AppConfig.IsSaveLocal() {
-		body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	asset.CreateTime = time.Now()
-	asset.UpdateTime = time.Now()
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
-}
-
-func UploadMaterialGroup(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMatGroup) (interface{}, error) {
-	asset := body
-	// source := asset.Source
-	asset.Enable = BoolValue(false)
-	asset.AssetState = model.AssetState_Succ
-	if conf.AppConfig.IsSaveLocal() {
-		body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	asset.CreateTime = time.Now()
-	asset.UpdateTime = time.Now()
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoDbAddDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, asset)
-}
-
-func UpdateMaterialGroup(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMatGroup) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func UpdateMaterialComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func UpdateMaterialSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *comm.AssetMat) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-	if conf.AppConfig.IsSaveLocal() {
-		body.UpdateSourceUrl(conf.AppConfig.TrimSaveLocalUrl)
-	}
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func ProcessMat(apictx *ApiSession, dbConf *comm.AssetDbConf, id string) (interface{}, error) {
-
-	// mesh := &model.AssetMat{}
-
-	// ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-	// 	Db:          dbConf.DbName,
-	// 	CollectName: dbConf.AssetConf.Collection,
-	// 	Query:       repo.Map{"_id": id},
-	// 	Project:     []string{"source.file"},
-	// }, mesh)
-	// if err != nil {
-	// 	return nil, err
-	// }
-	// if !ok {
-	// 	return nil, NewError("hdr已删除!")
-	// }
-
-	// err = bus.NatsCenter.HdrAssetProcessReq(dbConf.DbName, dbConf.AssetConf.Collection, id, mesh.Source.File.Url)
-	// assetState := model.AssetState_Waiting
-	// if err != nil {
-	// 	assetState = model.AssetState_Failed
-	// }
-	// update := bson.M{"$set": bson.M{"assetState": assetState}}
-
-	// return repo.RepoUpdateSetDbDocProps(apictx.CreateRepoCtx(), dbConf.DbName, dbConf.AssetConf.Collection, id, update)
-	return nil, NewError("no impl!")
-}

+ 0 - 73
tree/assetcenter/api/service-database-upload.go

@@ -1,73 +0,0 @@
-package api
-
-import (
-	"assetcenter/bus"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	funcgraph "assetcenter/funcGraph"
-	"assetcenter/tree"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func UpdateStaticMeshComm(apictx *ApiSession, dbConf *comm.AssetDbConf, body *model.AssetStaticMesh) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func UpdateStaticMeshSource(apictx *ApiSession, dbConf *comm.AssetDbConf, body *model.AssetStaticMesh) (interface{}, error) {
-	asset := body
-	asset.UpdateTime = time.Now()
-	id := asset.Id.Hex()
-	asset.Id = primitive.NilObjectID
-
-	collectionName := dbConf.AssetConf.Collection
-	return repo.RepoUpdateSeDbDoc(apictx.CreateRepoCtx(), dbConf.Db.Name, collectionName, id, asset)
-}
-
-func ProcessPackage(apictx *ApiSession, dbConf *comm.AssetDbConf, id string) (interface{}, error) {
-	url, err := bus.NatsCenter.RequestConfig("bus-network")
-	if err != nil {
-		return nil, err
-	}
-	return true, tree.ProcessPack(apictx.CreateRepoCtx(), id, dbConf.Db.Name, dbConf.AssetConf.Collection, url)
-}
-
-func ProcessPackageShadow(apictx *ApiSession, dbConf *comm.AssetDbConf, id string, scale, width int32) (interface{}, error) {
-
-	mesh := &comm.AssetPackage{}
-
-	ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-		Db:          dbConf.Db.Name,
-		CollectName: dbConf.AssetConf.Collection,
-		Query:       repo.Map{"_id": id},
-		Project:     []string{"config", "transTask", "shadowTask", "source"},
-	}, mesh)
-	if err != nil {
-		return nil, err
-	}
-	if !ok {
-		return nil, NewError("模型已删除!")
-	}
-
-	url, err := bus.NatsCenter.RequestConfig("bus-network")
-	if err != nil {
-		return nil, err
-	}
-
-	transTask := mesh.TransTask
-	shadowTask := mesh.ShadowTask
-
-	if comm.ShadowIsNotEmpty(shadowTask) {
-		err = funcgraph.CreateShadow(transTask.File.Url, id, dbConf.Db.Name, dbConf.AssetConf.Collection, scale, width, url)
-	}
-
-	return true, err
-}

+ 0 - 157
tree/assetcenter/api/service-database.go

@@ -1,157 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/repo"
-	"assetcenter/utils"
-	"fmt"
-	"math/rand"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func init() {
-	// 保证每次生成的随机数不一样
-	rand.Seed(time.Now().UnixNano())
-}
-
-func CreateDatabaseRouter(router *GinRouter) {
-
-	router.POSTJWT("/db/import/defaultdb", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		search := &comm.Database{}
-		ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"name": "qdb-default"}, Project: []string{"_id"}}, search)
-		if ok {
-			return nil, NewError("默认数据库已存在!")
-		}
-		db := comm.CreateDefaultDatabase()
-		return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionDatabase, db)
-	})
-
-	router.POSTJWT("/db/category/save", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		body := &struct {
-			Id         string `json:"_id"`
-			Categories []*comm.CategoryNode
-		}{}
-		err := c.ShouldBindJSON(body)
-		if err != nil {
-			return nil, err
-		}
-
-		search := &comm.Database{}
-		ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"_id": body.Id}, Project: []string{"_id", "categories"}}, search)
-
-		if ok { //已存在
-			search.Categories.Categories = body.Categories
-			search.Categories.UpdateTime = time.Now()
-
-		} else {
-			search.Categories = &comm.DbCategory{
-				Id:         primitive.NewObjectID(),
-				Scope:      "default",
-				CreateTime: time.Now(),
-				UpdateTime: time.Now(),
-				Categories: body.Categories,
-			}
-		}
-		return repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), "database", body.Id, bson.M{"categories": search.Categories})
-	})
-
-	CreateCRUD(router, "/db", &CRUDOption{
-		Collection: repo.CollectionDatabase,
-
-		NewModel: func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			cat := &comm.Database{}
-			c.ShouldBindJSON(cat)
-
-			//前端指定Label
-			if len(cat.Label) < 1 {
-				return nil, NewError("参数不合法!")
-			}
-
-			//判断当前用户的数据库是否已经到上线
-			limit := &comm.UserDatabase{}
-			ok, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionUserDatabase, Query: repo.Map{"_id": apictx.User.Parent}}, limit)
-			if err != nil {
-				return nil, err
-			}
-			if !ok { //没有对于的数据
-				limit.Id, _ = primitive.ObjectIDFromHex(apictx.User.Parent)
-				limit.UserName = apictx.User.Phone
-				limit.Limits = 4 //默认只能创建3个数据库
-				_, err = repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionUserDatabase, limit)
-				if err != nil {
-					return nil, err
-				}
-			}
-
-			count, err := repo.RepoCountDoc(apictx.CreateRepoCtx(), repo.CollectionDatabase, repo.Map{"userId": apictx.User.Parent})
-			if err != nil {
-				return nil, err
-			}
-			if count >= int64(limit.Limits) {
-				return nil, fmt.Errorf("已经超出数据库个数上线,请联系管理员添加")
-			}
-
-			//数据库名字添加一个随机数
-			var createDbRandomName = func() string {
-				return fmt.Sprintf("db-%s-%s", time.Now().Format("20060102"), utils.RandName(6))
-			}
-
-			cat.CreateTime = time.Now()
-			cat.Assets = comm.CreateDefaultDbAssets()
-			cat.Categories = &comm.DbCategory{}
-			cat.UserId = apictx.User.Parent
-			cat.Name = createDbRandomName()
-
-			search := &comm.Database{}
-			ok, _ = repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"name": cat.Name}, Project: []string{"_id"}}, search)
-			if ok {
-				return nil, NewError("数据库编号已存在!")
-			}
-
-			cat.Assets = comm.CreateDefaultDbAssets()
-			cat.CreateTime = time.Now()
-
-			return cat, nil
-		},
-
-		EmtyModel: func(c *gin.Context, apictx *ApiSession) interface{} {
-			return &comm.Database{}
-		},
-		SearchFilter: func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{} {
-			return map[string]interface{}{"userId": apictx.User.ID}
-			// return map[string]interface{}{}
-		},
-		JWT:           true,
-		SearchProject: []string{"name", "label", "createTime"},
-		DetailProject: []string{"name", "label", "createTime", "categories", "assetsCategory", "assets"},
-		Remove: func(c *gin.Context, apictx *ApiSession, id string) (interface{}, error) {
-			// team := &model.ResCategory{}
-			// ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionCategory, Query: repo.Map{"_id": id}, Project: []string{"orderId", "type"}}, team)
-			// if !ok {
-			// 	return nil, NewError("删除失败!")
-			// }
-			// minOrderId := team.OrderId //后面有几个零
-			// if minOrderId > 0 {
-			// 	var maxStep int64 = 1
-			// 	currValue := minOrderId
-			// 	for {
-			// 		if currValue%10 == 0 {
-			// 			currValue = currValue / 10
-			// 			maxStep = maxStep * 10
-			// 		} else {
-			// 			break
-			// 		}
-			// 	}
-			// 	maxOrderId := minOrderId + maxStep - 1
-			// 	return repo.RepoDeleteDocs(apictx.CreateRepoCtx(), repo.CollectionCategory, &bson.M{"orderId": bson.M{"$gte": minOrderId, "$lt": maxOrderId}, "type": team.Type})
-			// }
-			return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionDatabase, id)
-		},
-	})
-}

+ 0 - 142
tree/assetcenter/api/service-import.go

@@ -1,142 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"context"
-	"errors"
-	"fmt"
-	"math"
-	"time"
-
-	"github.com/gin-gonic/gin"
-)
-
-func AssetImport(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	valueIdMap, err := ImportCategry(apictx.Svc.Mongo)
-
-	if err != nil {
-		return nil, err
-	}
-
-	err = ImportAssetCategory(apictx, valueIdMap)
-
-	return true, err
-}
-
-func ImportCategry(dbMongo *db.MongoDB) (map[string]string, error) {
-
-	valueIdMap := map[string]string{}
-
-	CategoryConf := conf.AppConfig.Category
-	if CategoryConf == nil {
-		return valueIdMap, nil
-	}
-
-	if len(CategoryConf.DefaultCategory) < 1 {
-		return valueIdMap, errors.New("category.defaultCategory 不能为空!")
-	}
-
-	ctx := &repo.RepoSession{
-		Client: dbMongo,
-		Ctx:    context.Background(),
-	}
-
-	userId := CategoryConf.QiyeUserId
-
-	total, err := repo.RepoCountDoc(ctx, repo.CollectionCategories, repo.Map{})
-	if err != nil {
-		return valueIdMap, err
-	}
-	if total > 0 {
-		return valueIdMap, errors.New("数据已存在,无法导入。请先清除现有数据")
-	}
-
-	var createOrderId = func(deep int32, brotherIndex int32, parentOrder int64) int64 {
-
-		step := math.Pow(100, float64(4-deep))
-
-		orderId := int64(step) * int64(brotherIndex+1)
-
-		return int64(orderId + parentOrder)
-	}
-
-	var IteUpdate func(deep int32, cates []*conf.DefaultCategoryConf, parent string, parentOrder int64) error
-	IteUpdate = func(deep int32, cates []*conf.DefaultCategoryConf, parent string, parentOrder int64) error {
-		if len(cates) < 1 {
-			return nil
-		}
-		for index, item := range cates {
-
-			currOrderId := createOrderId(deep, int32(index), parentOrder)
-
-			insertItem := &model.ResCategory{
-				Type:       "imported",
-				Name:       item.Name,
-				Level:      &deep,
-				Value:      item.Value,
-				Parent:     parent,
-				UserId:     userId,
-				OrderId:    currOrderId,
-				CreateTime: time.Now(),
-			}
-
-			id, err := repo.RepoAddDoc(ctx, repo.CollectionCategories, insertItem)
-			if err != nil {
-				return err
-			}
-			fmt.Println("added", id)
-			valueIdMap[item.Value] = id
-			err = IteUpdate(deep+1, item.Children, id, currOrderId)
-			if err != nil {
-				return err
-			}
-		}
-		return nil
-	}
-
-	err = IteUpdate(0, CategoryConf.DefaultCategory, "", 0)
-	if err != nil {
-		return valueIdMap, err
-	}
-	return valueIdMap, nil
-}
-
-func ImportAssetCategory(apictx *ApiSession, valueIdMap map[string]string) error {
-
-	AssetsConf := conf.AppConfig.Assets
-	if AssetsConf == nil {
-		return nil
-	}
-
-	if len(AssetsConf) < 1 {
-		return errors.New("AppConfig.Assets 不能为空!")
-	}
-
-	userId := conf.AppConfig.Category.QiyeUserId
-
-	for _, asset := range AssetsConf {
-		if len(asset.DefaultCategory) > 0 {
-			//添加默认分类设置
-
-			ids := []string{}
-			for _, cat := range asset.DefaultCategory {
-				if len(valueIdMap[cat]) > 0 {
-					ids = append(ids, valueIdMap[cat])
-					continue
-				}
-				return errors.New(cat + "没有对应的分类ID")
-			}
-			assetCate := &model.LibCategory{Type: asset.Type, CreateTime: time.Now(), CategoryIds: ids, UserId: userId}
-			id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionDbAssetCategory, assetCate)
-			if err != nil {
-				return err
-			}
-			fmt.Sprintln("added "+asset.Type+"=>", id)
-		}
-	}
-	return nil
-}

+ 0 - 79
tree/assetcenter/api/service-lib.go

@@ -1,79 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"fmt"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-)
-
-/**
-db.designs.find({"editor.users":{$not:{$elemMatch:{$nin: [1,2,3]}}}, 'editor.users.0': {$exists: true}}).explain()
-**/
-
-func ParseCategory(filter []string, src []*model.ResCategory) []string {
-	out := []string{}
-
-	if len(filter) < 1 {
-		for _, v := range src {
-			out = append(out, v.Id.Hex())
-		}
-		return out
-	}
-
-	// rootCate := []string{}
-	// for _, v := range src {
-	// 	if v.Level == 0 {
-	// 		rootCate = append(rootCate, v.Id.Hex())
-	// 	}
-	// }
-	return out
-}
-
-func CreateLibRouter(router *GinRouter) {
-
-	//获取款式列表
-	router.GETJWT("/lib/public/design", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		page, size, query := UtilQueryPageSize(c)
-		categories := query["categories"]
-		if categories == nil {
-			return nil, NewError("query.categories不能为空!")
-		}
-		strCategories := []string{}
-
-		cates, ok := categories.([]interface{})
-		if !ok {
-			return nil, NewError("query.categories必须是数组!")
-		}
-		for _, c := range cates {
-			strCategories = append(strCategories, c.(string))
-		}
-
-		designCates := []*model.ResCategory{}
-		err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{CollectName: repo.CollectionLibCategory, Query: repo.Map{"type": "design"}}, &designCates)
-		if err != nil {
-			return nil, err
-		}
-
-		//展开当前用户team的资源授权,如果没有则为所有
-		fmt.Sprintln(cates)
-
-		if len(strCategories) > 0 {
-			query["categories"] = bson.M{"$not": bson.M{"$elemMatch": bson.M{"$nin": strCategories}}}
-			query["categories.0"] = bson.M{"$exists": true}
-		}
-		//展开待查询的cates
-		//{$not:{$elemMatch:{$nin: [1,2,3]}}}, 'editor.users.0': {$exists: true}}
-
-		return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-			CollectName: repo.CollectionDesigns,
-			Page:        page,
-			Size:        size,
-			Query:       query,
-			Project:     []string{"name", "thumbnail", "createTime", "isPublic"},
-		})
-	})
-
-}

+ 0 - 127
tree/assetcenter/api/service-minio.go

@@ -1,127 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"context"
-	"fmt"
-	"log"
-	"path"
-	"strings"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"github.com/minio/minio-go/v7"
-	"github.com/minio/minio-go/v7/pkg/credentials"
-)
-
-func createMinioClient(conf *conf.AppConf) *minio.Client {
-
-	endpoint := conf.Minio.Endpoint
-
-	accessKeyID := conf.Minio.AccessKey
-	secretAccessKey := conf.Minio.AccessSec
-	useSSL := false
-
-	// Initialize minio client object.
-	minioClient, err := minio.New(endpoint, &minio.Options{
-		Creds:  credentials.NewStaticV4(accessKeyID, secretAccessKey, ""),
-		Secure: useSSL,
-	})
-	if err != nil {
-		log.Fatalln(err)
-		return nil
-	}
-	return minioClient
-}
-
-func MinioCreateUserPolicy(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	body := struct {
-		Key string
-	}{}
-	err := c.ShouldBindJSON(&body)
-	if err != nil {
-		return nil, NewError("参数解析错误!")
-	}
-	if len(body.Key) < 1 {
-		return nil, NewError("Object Key不能为空")
-	}
-	// Initialize policy condition config.
-	policy := minio.NewPostPolicy()
-
-	// Apply upload policy restrictions:
-	policy.SetBucket(apictx.Svc.Conf.Minio.Bucket)
-
-	fkey := body.Key //fmt.Sprintf("u/%s/%s", apictx.User.Parent, body.Key)
-	//去掉斜杠
-	fkey = strings.TrimPrefix(fkey, "/")
-	policy.SetKey(fkey)
-	policy.SetExpires(time.Now().UTC().Add(time.Second * 600)) // expires in 10 days
-
-	// Only allow 'png' images.
-	// policy.SetContentType("image/png")
-
-	// Only allow content size in range 1KB to 1MB.
-	policy.SetContentLengthRange(0, 5*1024*1024)
-
-	// Add a user metadata using the key "custom" and value "user"
-	// policy.SetUserMetadata("custom", "user")
-
-	client := createMinioClient(apictx.Svc.Conf)
-	url, err := client.PresignedPutObject(
-		context.Background(), apictx.Svc.Conf.Minio.Bucket, fkey, time.Second*600,
-	)
-	//_, formdata, err := client.PresignedPostPolicy(context.Background(), policy)
-
-	outUrl := fmt.Sprintf("%s://%s%s?%s", url.Scheme, url.Host, url.Path, url.RawQuery)
-
-	if err != nil {
-		return nil, err
-	}
-
-	out := map[string]interface{}{
-		"uploadUrl": outUrl,
-		"url":       fmt.Sprintf("//%s/%s/%s", apictx.Svc.Conf.Minio.Endpoint, apictx.Svc.Conf.Minio.Bucket, fkey),
-		"saveType":  conf.SaveType_Minio,
-	}
-	return out, nil
-}
-
-func MinioUploadFile(client *minio.Client, bucketName string, fpath string, key string) (string, int64) {
-	info, err := client.FPutObject(context.Background(), bucketName, key, fpath, minio.PutObjectOptions{})
-	fmt.Println(info)
-	if err != nil {
-		return "", 0
-	}
-	return info.Key, info.Size
-}
-
-func MinioUploadLocalFile(client *minio.Client, bucketName string, fpath string, minioDir string) (string, int64) {
-
-	_, name := path.Split(fpath)
-	keyFormat := "%s/%s"
-	if strings.HasSuffix(minioDir, "/") {
-		keyFormat = "%s%s"
-	}
-	minioKey := fmt.Sprintf(keyFormat, minioDir, name)
-
-	opts := minio.PutObjectOptions{}
-
-	fpathExt := path.Ext(fpath)
-	isGzFile := fpathExt == ".gz"
-	if isGzFile {
-		opts.ContentType = "text/plain"
-		opts.ContentEncoding = "gzip"
-	}
-
-	info, err := client.FPutObject(context.Background(), bucketName, minioKey, fpath, opts)
-	fmt.Println(info)
-	if err != nil {
-		info, err = client.FPutObject(context.Background(), bucketName, minioKey, fpath, opts)
-		if err != nil {
-			return "", 0
-		}
-	}
-
-	return minioKey, info.Size
-}

+ 0 - 370
tree/assetcenter/api/service-obs.go

@@ -1,370 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"assetcenter/log"
-	"fmt"
-	"os"
-	"path"
-	"strings"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"github.com/huaweicloud/huaweicloud-sdk-go-obs/obs"
-)
-
-func CreateObsClient() (*obs.ObsClient, error) {
-	obsConf := conf.AppConfig.Obs
-	return obs.New(obsConf.AccessKeyId, obsConf.SecrateKey, obsConf.Endpoint)
-}
-
-// u/xxx/img/up/timps.png
-func ServiceObsCreateImagePolicy(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	body := struct {
-		Ext string
-	}{}
-
-	err := c.ShouldBindJSON(&body)
-	if err != nil {
-		return nil, NewError("参数解析错误!")
-	}
-	if len(body.Ext) < 1 {
-		return nil, NewError("上传文件的扩展名不能为空")
-	}
-
-	fkey := fmt.Sprintf("u/%s/images/uploads/%v.%s", apictx.User.Parent, time.Now().UnixNano(), body.Ext)
-
-	client, err := CreateObsClient()
-	if err != nil {
-		return nil, NewError("创建ObsClient 失败!")
-	}
-
-	defer func() {
-		client.Close()
-	}()
-
-	// 除key,policy,signature外,表单上传时的其他参数,支持的值:
-	// 	acl
-	// 	cache-control
-	// 	content-type
-	// 	content-disposition
-	// 	content-encoding
-	// 	expires
-	bucketName := apictx.Svc.Conf.Obs.Bucket
-
-	result, err := client.CreateBrowserBasedSignature(&obs.CreateBrowserBasedSignatureInput{
-		Bucket:  bucketName,
-		Key:     fkey,
-		Expires: 300,
-		FormParams: map[string]string{
-			"x-obs-acl": "public-read",
-		},
-	})
-
-	if err != nil {
-		return nil, NewLogWithError(err)
-	}
-
-	obsConf := conf.AppConfig.Obs
-
-	out := map[string]interface{}{
-		"accessKeyId":  obsConf.AccessKeyId,
-		"originPolicy": result.OriginPolicy,
-		"policy":       result.Policy,
-		"signature":    result.Signature,
-		"host":         fmt.Sprintf("//%s.%s", bucketName, obsConf.Endpoint),
-		"key":          fkey,
-	}
-	return out, nil
-}
-
-func ServiceObsList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	prefix := c.Query("prefix")
-
-	if len(prefix) < 1 {
-		return nil, NewError("prefix不能为空")
-	}
-
-	client, err := CreateObsClient()
-	if err != nil {
-		return nil, NewError("创建ObsClient 失败!")
-	}
-
-	defer func() {
-		client.Close()
-	}()
-
-	bucketName := apictx.Svc.Conf.Obs.Bucket
-	result, err := client.ListObjects(&obs.ListObjectsInput{
-		Bucket: bucketName,
-		ListObjsInput: obs.ListObjsInput{
-			Prefix:    prefix,
-			Delimiter: "/",
-		},
-	})
-	if err != nil {
-		return nil, err
-	}
-
-	fmt.Println("result=>", prefix)
-	fmt.Println(result.CommonPrefixes, result.IsTruncated)
-	out := []*model.ObsItem{}
-
-	imgExts := map[string]bool{".jpeg": true, ".jpg": true, ".gif": true, ".png": true, ".svg": true, ".bmp": true}
-
-	for k, v := range result.Contents {
-		fmt.Println(k, v.Key, v.LastModified, v.Size)
-		if prefix == v.Key {
-			continue
-		}
-		isDirSuffix := strings.HasSuffix(v.Key, "/")
-		isDir := (isDirSuffix && v.Size == 0)
-		isImage := false
-
-		originKey := strings.ToLower(v.Key)
-		if !isDir && imgExts[path.Ext(originKey)] {
-			isImage = true
-		}
-
-		keys := strings.Split(v.Key, "/")
-		name := ""
-		if isDir {
-			name = keys[len(keys)-2]
-		} else {
-			name = keys[len(keys)-1]
-		}
-		obsConf := conf.AppConfig.Obs
-		url := ""
-		if !isDir {
-			url = fmt.Sprintf("//%s.%s/%s", bucketName, obsConf.Endpoint, v.Key)
-		}
-
-		out = append(out, &model.ObsItem{
-			Name:         name,
-			Size:         uint64(v.Size),
-			IsImage:      isImage,
-			Url:          url,
-			IsDir:        isDir,
-			LastModified: v.LastModified,
-		})
-	}
-
-	for _, v := range result.CommonPrefixes {
-		keys := strings.Split(v, "/")
-		name := keys[len(keys)-2]
-
-		out = append(out, &model.ObsItem{
-			Name:    name,
-			IsImage: false,
-			IsDir:   true,
-		})
-	}
-
-	outMap := map[string]interface{}{
-		"list":        out,
-		"isTruncated": result.IsTruncated,
-	}
-	return outMap, nil
-}
-
-// 管理后台上传文件
-func ServiceObsUploadPolicy(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	body := struct {
-		Key string
-	}{}
-
-	err := c.ShouldBindJSON(&body)
-	if err != nil {
-		return nil, NewError("参数解析错误!")
-	}
-	if len(body.Key) < 1 {
-		return nil, NewError("上传文件的key不能为空")
-	}
-	client, err := CreateObsClient()
-	if err != nil {
-		return nil, NewError("创建ObsClient 失败!")
-	}
-	defer func() {
-		client.Close()
-	}()
-	bucketName := apictx.Svc.Conf.Obs.Bucket
-
-	result, err := client.CreateBrowserBasedSignature(&obs.CreateBrowserBasedSignatureInput{
-		Bucket:  bucketName,
-		Key:     body.Key,
-		Expires: 600,
-		FormParams: map[string]string{
-			"x-obs-acl": "public-read",
-		},
-	})
-
-	if err != nil {
-		return nil, NewLogWithError(err)
-	}
-	obsConf := conf.AppConfig.Obs
-	out := map[string]interface{}{
-		"accessKeyId":  obsConf.AccessKeyId,
-		"originPolicy": result.OriginPolicy,
-		"policy":       result.Policy,
-		"signature":    result.Signature,
-		"host":         fmt.Sprintf("https://%s.%s", bucketName, obsConf.Endpoint),
-		"key":          body.Key,
-		"saveType":     conf.SaveType_Obs,
-	}
-	return out, nil
-}
-
-func ServiceObsRemove(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-	body := struct {
-		Key string
-	}{}
-	err := c.ShouldBindJSON(&body)
-	if err != nil {
-		return nil, NewError("参数解析错误!")
-	}
-	if len(body.Key) < 1 {
-		return nil, NewError("文件的key不能为空")
-	}
-
-	client, err := CreateObsClient()
-	if err != nil {
-		return nil, NewError("创建ObsClient 失败!")
-	}
-
-	defer func() {
-		client.Close()
-	}()
-
-	bucketName := apictx.Svc.Conf.Obs.Bucket
-	result, err := client.DeleteObject(&obs.DeleteObjectInput{
-		Bucket: bucketName,
-		Key:    body.Key,
-	})
-
-	if err != nil {
-		return nil, err
-	}
-
-	return result, nil
-}
-
-func ServiceObsCreateFolder(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	body := struct {
-		Key string
-	}{}
-	err := c.ShouldBindJSON(&body)
-	if err != nil {
-		return nil, NewError("参数解析错误!")
-	}
-	if len(body.Key) < 1 {
-		return nil, NewError("文件的key不能为空")
-	}
-
-	client, err := CreateObsClient()
-	if err != nil {
-		return nil, NewError("创建ObsClient 失败!")
-	}
-
-	defer func() {
-		client.Close()
-	}()
-
-	bucketName := apictx.Svc.Conf.Obs.Bucket
-	result, err := client.PutObject(&obs.PutObjectInput{
-		PutObjectBasicInput: obs.PutObjectBasicInput{
-			ObjectOperationInput: obs.ObjectOperationInput{
-				Bucket: bucketName,
-				Key:    body.Key,
-				ACL:    obs.AclPublicRead,
-			},
-		},
-	})
-
-	if err != nil {
-		return nil, err
-	}
-
-	return result, nil
-}
-
-func UploadFile(obsClient *obs.ObsClient, bucketName string, fpath string, obsDir string) *model.OssType {
-
-	_, obsname := path.Split(fpath)
-	keyFormat := "%s/%s"
-	if strings.HasSuffix(obsDir, "/") {
-		keyFormat = "%s%s"
-	}
-	obsKey := fmt.Sprintf(keyFormat, obsDir, obsname)
-
-	input := &obs.PutFileInput{}
-	input.Bucket = bucketName
-	input.Key = obsKey
-	input.SourceFile = fpath
-
-	fpathExt := path.Ext(fpath)
-	isGzFile := fpathExt == ".gz"
-	if isGzFile {
-		input.ContentType = "text/plain"
-		input.Metadata = map[string]string{"Content-Encoding": "gzip"}
-	}
-	result, err := obsClient.PutFile(input)
-
-	isUploadOk := true
-
-	if err != nil {
-		log.Errorf("upload obs fail %s", fpath)
-		log.Error(err)
-		isUploadOk = false
-	}
-
-	if result.StatusCode != 200 {
-		isUploadOk = false
-	}
-
-	if !isUploadOk {
-		result, err = obsClient.PutFile(input)
-
-		if err != nil {
-			log.Errorf("upload obs fail2 %s", fpath)
-			log.Error(err)
-			return &model.OssType{}
-		}
-		if result.StatusCode != 200 {
-			return &model.OssType{}
-		}
-	}
-
-	if isGzFile {
-		metaRet, err := obsClient.SetObjectMetadata(&obs.SetObjectMetadataInput{
-			Bucket:          bucketName,
-			Key:             obsKey,
-			ContentEncoding: "gzip",
-			ContentType:     "text/plain",
-		})
-		fmt.Println(metaRet, err)
-
-		if err != nil {
-			metaRet, err = obsClient.SetObjectMetadata(&obs.SetObjectMetadataInput{
-				Bucket:          bucketName,
-				Key:             obsKey,
-				ContentEncoding: "gzip",
-				ContentType:     "text/plain",
-			})
-			fmt.Println(metaRet, err)
-		}
-	}
-
-	fi, err := os.Stat(fpath)
-	size := int64(1)
-	if err == nil {
-		size = fi.Size()
-	}
-
-	obsConf := conf.AppConfig.Obs
-
-	return &model.OssType{Url: fmt.Sprintf("//%s.%s/%s", bucketName, obsConf.Endpoint, obsKey), Size: int64(size)}
-}

+ 0 - 59
tree/assetcenter/api/service-project.go

@@ -1,59 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-func ServiceProjectCreate(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	body := &struct {
-		Name string
-	}{}
-	err := c.ShouldBindJSON(body)
-	if err != nil {
-		return nil, NewError("参数解析错误")
-	}
-	if len(body.Name) < 1 {
-		return nil, NewError("名称不能为空")
-	}
-
-	project := &model.Project{
-		Name:       body.Name,
-		CreateTime: time.Now(),
-		Products:   []*model.Product{},
-		Scenes:     []*model.Scene{},
-	}
-	project.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-
-	return repo.AddProject(apictx.CreateRepoCtx(), project)
-}
-
-func ServiceProjectList(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	page, size, query := UtilQueryPageSize(c)
-
-	if query == nil {
-		query = map[string]interface{}{}
-	}
-
-	query["userId"], _ = primitive.ObjectIDFromHex(apictx.User.ID)
-
-	return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		CollectName: repo.CollectionProject,
-		Page:        page,
-		Size:        size,
-		Query:       query,
-		Project:     []string{"name", "thumbnail", "createTime"},
-	})
-}
-
-func ServiceProjectDelete(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	id := c.Param("id")
-	if len(id) < 1 {
-		return nil, NewError("参数不能为空")
-	}
-	return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), repo.CollectionProject, id)
-}

+ 0 - 18
tree/assetcenter/api/service-save.go

@@ -1,18 +0,0 @@
-package api
-
-import (
-	"assetcenter/conf"
-
-	"github.com/gin-gonic/gin"
-)
-
-func UploadPolicy(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	saveType := apictx.Svc.Conf.SaveType
-	if saveType == conf.SaveType_Obs {
-		return ServiceObsUploadPolicy(c, apictx)
-	}
-	if saveType == conf.SaveType_Minio {
-		return MinioCreateUserPolicy(c, apictx)
-	}
-	return nil, NewError("不支持的存储类型")
-}

+ 0 - 106
tree/assetcenter/api/service-test.go

@@ -1,106 +0,0 @@
-package api
-
-import (
-	"assetcenter/bus"
-	"assetcenter/db/repo"
-	"fmt"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson"
-	"infish.cn/comm"
-)
-
-func TestRouter(r *GinRouter) {
-	r.GET("/test/print", Printa)
-	r.GET("/test/prinb", Printb)
-	// r.GET("/test/print", Printa)
-	r.GET("/test/cate", CateParse)
-
-}
-
-func CateParse(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// userId:6742fcd3446577969d26d97
-	// userId, _ := primitive.ObjectIDFromHex("6742fcd3446577969d26d97")
-
-	dbName := "sku3d-tree"
-	query := map[string]interface{}{
-		// "categories": []interface{}{"1735781110196"},
-		"categories": []interface{}{"61dcf7784b133be3f60fd6e0"},
-		// "userId":     userId,
-	}
-	dbConf := &comm.AssetDbConf{}
-	if query["categories"] != nil {
-		enity := &comm.Database{}
-		ok, _ := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-			CollectName: repo.CollectionDatabase,
-			Query:       repo.Map{"name": dbName},
-			Project:     []string{"categories"},
-		}, enity)
-		if !ok {
-			return nil, fmt.Errorf("没有查询到数据库:%s", dbName)
-		}
-		dbConf.Db = enity
-	}
-
-	bus.ParseCategories(query, apictx.CreateRepoCtx(), dbConf)
-
-	return repo.RepoPageSearch(apictx.CreateRepoCtx(), &repo.PageSearchOptions{
-		Db:          dbName,
-		CollectName: "company_shoe_user",
-		Query:       query,
-		Page:        1,
-		Size:        100,
-		Sort:        bson.M{"createTime": -1},
-	})
-}
-
-func Printa(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	// _, bset := GetIncrementTimes("day", "1h")
-	// fmt.Println(bset)
-
-	query := make(map[string]interface{})
-	b, _ := time.ParseDuration(fmt.Sprintf("%dh", -(24 * 10)))
-	now := time.Now()
-	end := now.Add(b)
-	fmt.Println(end)
-	query["createTime"] = bson.M{"$lte": end}
-	parm := &repo.PageSearchOptions{
-		CollectName: "database",
-		Project:     []string{"_id", "name", "createTime"},
-		Sort:        bson.M{"createTime": -1},
-	}
-
-	parm.Query = query
-	var assetCount []comm.Database
-
-	err := repo.RepoDocsSearch(apictx.CreateRepoCtx(), parm, &assetCount)
-	if err != nil {
-		return nil, err
-	}
-	return assetCount[0], nil
-}
-
-func Printb(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-	query := make(map[string]interface{})
-	b, _ := time.ParseDuration(fmt.Sprintf("%dh", -(24 * 50)))
-	now := time.Now()
-	end := now.Add(b)
-	fmt.Println(end)
-	query["createTime"] = bson.M{"$lte": end}
-	parm := &repo.DocSearchOptions{
-		CollectName: "database",
-		Project:     []string{"_id", "name", "createTime"},
-		Sort:        bson.M{"createTime": -1}, // 降序 小于等于createTime中取时间最近的 第一条
-	}
-
-	parm.Query = query
-	var assetCount comm.Database
-
-	_, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), parm, &assetCount)
-	if err != nil {
-		return nil, err
-	}
-
-	return assetCount, nil
-}

+ 0 - 81
tree/assetcenter/api/service-upload-mat.go

@@ -1,81 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"time"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-func CreateUserUploadMatRouter(router *GinRouter) {
-
-	//上传2d面料
-	router.POSTJWT("/upload/imgmat", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		body := &struct {
-			Name      string
-			Category  string
-			Category2 string
-			Image     *model.OssType
-		}{}
-		c.ShouldBindJSON(&body)
-		if body.Image == nil || len(body.Image.Url) < 1 {
-			return nil, NewError("图片不能为空")
-		}
-		nopublic := false
-		platform := true
-
-		imgmat := &model.ImageMat{
-			Category:   body.Category,
-			Category2:  body.Category2,
-			Name:       "2d面料",
-			IsPublic:   &nopublic,
-			Image:      body.Image,
-			Platform:   &platform,
-			CreateTime: time.Now(),
-			State:      model.LibState_Created,
-		}
-		imgmat.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		if len(body.Name) > 0 {
-			imgmat.Name = body.Name
-		}
-		return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionImageMat, imgmat)
-	})
-
-	//面料
-	router.POSTJWT("/upload/fabric", func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-		body := &struct {
-			Name      string
-			Category  string
-			Category2 string
-			Thumbnail *model.OssType
-		}{}
-
-		c.ShouldBindJSON(&body)
-		if body.Thumbnail == nil || len(body.Thumbnail.Url) < 1 {
-			return nil, NewError("封面不能为空")
-		}
-
-		public := false
-		fabric := &model.Fabric{
-			Category:   body.Category,
-			Category2:  body.Category2,
-			ColorCards: []*model.MaterialHeader{},
-			Name:       "面料1",
-			Thumbnail:  &model.OssType{Url: "", Size: 0},
-			CreateTime: time.Now(),
-			IsPublic:   &public,
-			Price:      0,
-			State:      model.LibState_Created,
-		}
-		fabric.UserId, _ = primitive.ObjectIDFromHex(apictx.User.ID)
-		if len(body.Name) > 0 {
-			fabric.Name = body.Name
-		}
-		return repo.RepoAddDoc(apictx.CreateRepoCtx(), repo.CollectionFabric, fabric)
-	})
-
-}

+ 0 - 189
tree/assetcenter/api/service.go

@@ -1,189 +0,0 @@
-package api
-
-import (
-	"assetcenter/db/repo"
-	"encoding/hex"
-	"fmt"
-	"reflect"
-
-	"github.com/gin-gonic/gin"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type CreateModel func(c *gin.Context, apictx *ApiSession) (interface{}, error)
-type EmptyModel func(c *gin.Context, apictx *ApiSession) interface{}
-
-type PostCreateModel func(c *gin.Context, apictx *ApiSession, id string, entity interface{}) (interface{}, error)
-
-type CreateModel2 func(c *gin.Context, apictx *ApiSession) (interface{}, error)
-type SearchFilterFn func(c *gin.Context, apictx *ApiSession, query map[string]interface{}) map[string]interface{}
-type Update func(c *gin.Context, apictx *ApiSession, entity interface{})
-type SearchPostFn func(page *repo.PageResult, c *gin.Context, apictx *ApiSession, query map[string]interface{}) (interface{}, error)
-type RemoveFn func(c *gin.Context, apictx *ApiSession, id string) (interface{}, error)
-
-type CRUDOption struct {
-	Collection        string
-	NewModel          CreateModel
-	PostNewModel      PostCreateModel
-	EmtyModel         EmptyModel
-	SearchFilter      SearchFilterFn
-	SearchPostProcess SearchPostFn
-	SearchSort        interface{}
-	Remove            RemoveFn
-	JWT               bool
-	SearchProject     []string
-	DetailProject     []string
-	OnUpdate          Update
-	noUpdate          bool
-}
-
-func CreateCRUD(router *GinRouter, prefix string, option *CRUDOption) {
-
-	//创建
-	if option.NewModel != nil {
-		creatpath := fmt.Sprintf("%s/create", prefix)
-		router.POSTJWT(creatpath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-			entity, err := option.NewModel(c, apictx)
-			if err != nil {
-				return nil, err
-			}
-
-			if entity == nil {
-				return nil, NewError("数据已存在!")
-			}
-			_id, err := repo.RepoAddDoc(apictx.CreateRepoCtx(), option.Collection, entity)
-			if err != nil {
-				return nil, err
-			}
-			if option.PostNewModel != nil {
-				return option.PostNewModel(c, apictx, _id, entity)
-			}
-			return _id, err
-		})
-	}
-
-	//更新
-	if !option.noUpdate {
-		updatePath := fmt.Sprintf("%s/update", prefix)
-		router.POSTJWT(updatePath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-
-			m := option.EmtyModel(c, apictx)
-			err := c.ShouldBindJSON(m)
-
-			if err != nil {
-				fmt.Println(err)
-				return nil, NewError("参数解析错误")
-			}
-
-			v := reflect.ValueOf(m)
-			v = v.Elem()
-
-			mid := v.FieldByName("Id")
-
-			if !mid.IsValid() {
-				return nil, NewError("ID不能为空")
-			}
-
-			slice := mid.Slice(0, mid.Len())
-			objId := hex.EncodeToString(slice.Bytes())
-			for i := 0; i < 12; i++ {
-				mid.Index(i).SetUint(0)
-			}
-
-			if option.OnUpdate != nil {
-				option.OnUpdate(c, apictx, m)
-			}
-
-			out, err := repo.RepoUpdateSetDoc(apictx.CreateRepoCtx(), option.Collection, objId, m)
-			if err != nil {
-				return nil, err
-			}
-			if out.MatchedCount != 1 {
-				return nil, NewError("文件不存在!")
-			}
-
-			return out, nil
-		})
-	}
-
-	//分页查询
-	SearchPath := fmt.Sprintf("%s/list", prefix)
-
-	pageSearchFn := func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		page, size, query := UtilQueryPageSize(c)
-
-		if option.SearchFilter != nil {
-			filter := option.SearchFilter(c, apictx, query)
-			for k, v := range filter {
-				query[k] = v
-			}
-		}
-
-		pageOption := &repo.PageSearchOptions{
-			CollectName: option.Collection,
-			Page:        page,
-			Size:        size,
-			Query:       query,
-			Project:     option.SearchProject,
-		}
-		if option.SearchSort != nil {
-			pageOption.Sort = option.SearchSort
-		}
-
-		pageResult, err := repo.RepoPageSearch(apictx.CreateRepoCtx(), pageOption)
-		if err != nil {
-			return nil, err
-		}
-
-		if option.SearchPostProcess != nil {
-			return option.SearchPostProcess(pageResult, c, apictx, query)
-		}
-
-		return pageResult, nil
-	}
-
-	if option.JWT {
-		router.GETJWT(SearchPath, pageSearchFn)
-	} else {
-		router.GET(SearchPath, pageSearchFn)
-	}
-	//删除
-	removePath := fmt.Sprintf("%s/delete/:id", prefix)
-	router.POSTJWT(removePath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-		id := c.Param("id")
-		if len(id) < 1 {
-			return nil, NewError("参数不能为空")
-		}
-
-		if option.Remove != nil {
-			return option.Remove(c, apictx, id)
-		}
-
-		return repo.RepoDeleteDoc(apictx.CreateRepoCtx(), option.Collection, id)
-
-	})
-
-	//详情
-	if len(option.DetailProject) > 0 {
-		detailPath := fmt.Sprintf("%s/detail/:id", prefix)
-		router.GET(detailPath, func(c *gin.Context, apictx *ApiSession) (interface{}, error) {
-			id := c.Param("id")
-			if len(id) < 1 {
-				return nil, NewError("参数不能为空")
-			}
-			uid, _ := primitive.ObjectIDFromHex(id)
-
-			ok, ret := repo.RepoSeachDocMap(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: option.Collection,
-				Query:       repo.Map{"_id": uid},
-				Project:     option.DetailProject,
-			})
-
-			if !ok {
-				return nil, NewError("没有查询到数据")
-			}
-			return ret, nil
-		})
-	}
-}

+ 0 - 62
tree/assetcenter/app.yaml

@@ -1,62 +0,0 @@
-# http
-port: 8902
-name: assetcenter
-version: 1.0.0
-saveType: obs
-localSaveMode: false
-
-jwt: 
-  timeoutHour: 87600
-  # realm: queentree
-  # key: queentreelocalkey
-  realm: spu3d
-  key: spu3d secret
-  
-taskCenter: http://192.168.110.207:9502/taskcenter
-
-redis:
-  addr: 124.70.148.113:6379
-  password: ""
-  db: 0
-
-log:
-  fileName: assettest.log
-  level: 1
-  serviceName: assettest
-
-mongo: 
-  dsn: mongodb://root:root@124.71.139.24:27033/queentree?authSource=admin
-  Database: queentree
-
-debug: 
-  userId: test
-  userPhone: 15208364621
-  UserRole: string
-
-obs:
-  bucket: sku3d-test
-  accessKeyId: "RA1D7CFVCVKUFX1FHHPB"
-  secrateKey: "cDrR2NgAF2KaA4MRkcK19r93P3P6hLKOPhHvPu9p"
-  endpoint: "obs.cn-east-3.myhuaweicloud.com"
-
-minio:
-  bucket: queentree
-  endpoint : 127.0.0.1:51427
-  accessKey: queentree
-  accessSec: queentree
-
-treeDNS: https://3dqueen.cloud/tree/v1/assetcenter
-nats:
-  url: nats://124.71.139.24:14220
-
-  maxReconnect: 1000
-  reconnDelaySecond: 5
-
-  hdrProcStreamTopic: hdrproc-req-stream#hdrproc.request#hdrproc-queue
-  osgConvStreamTopic: sku3d-convglb-result-stream#convglb.result#convglb-result-queue
-  osgShadowStreamTopic: sku3d-convshadow-result-stream#convshadow.result#convshadow-result-queue
-  hdrConvStreamTopic: sku3d-convhdr-result-stream#convhdr.result#convhdr-result-queue
-
-searchImageAddr: http://124.70.149.18:5050
-
-# searchImageAddr: http://search-image:5000

+ 0 - 36
tree/assetcenter/build.sh

@@ -1,36 +0,0 @@
-#!/bin/bash
-
-# 编译应用
-echo "building..."
-go build -o tree-service
-
-# 命名镜像
-# 202240821 适配大文档source文件模型转换
-local_imge="pack-queentree-tree:v1.0.1"
-repository_image="registry.cn-chengdu.aliyuncs.com/infish/pack-queentree-tree:v1.0.1"
-
-# 删除本地已存在的镜像
-docker rmi $repository_image
-
-# 创建本地镜像
-docker build -t $local_imge .
-
-# 镜像标签
-docker tag $local_imge $repository_image
-
-# push到镜像仓库,需要登陆对应docker仓库账号
-docker push $repository_image
-
-# 删除编译的文件
-rm -rf tree-service
-
-# 运行示例
-# docker run  -itd -p 20001:20001 --name comm-pay-service pay-service:1.0.0
-
-
-
-
-
-
-
-

+ 0 - 32
tree/assetcenter/bus/comm-utils.go

@@ -1,32 +0,0 @@
-package bus
-
-import "math/rand"
-
-type TreeAddDefineResp struct {
-	DbId       string
-	Host       string
-	DefineId   string
-	Collection string
-}
-
-type TreeAddDefReq struct {
-	DbName string
-	UserId string
-	Name   string
-}
-
-type TreeRemoveDefReq struct {
-	DbId     string
-	DefineId string
-}
-
-// 长度为62
-var bytes []byte = []byte("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890")
-
-func RandName(n int) string {
-	result := make([]byte, n)
-	for i := 0; i < n; i++ {
-		result[i] = bytes[rand.Int31()%62]
-	}
-	return string(result)
-}

+ 0 - 118
tree/assetcenter/bus/hdr.go

@@ -1,118 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db/model"
-)
-
-type ConvHdrResult struct {
-	AssetId string `json:"assetId"`
-	DbId    string `json:"dbId"`
-	Table   string `json:"table"`
-
-	FileUrl string `json:"meshUrl"`
-	Env3d   *Env3d `bson:"env3d,omitempty" json:"env3d"` //模型文件字段名字
-}
-
-type Env3d struct {
-	Thumbnail *model.OssType      `bson:"thumbnail,omitempty" json:"thumbnail"`
-	HDR       string              `bson:"hdr,omitempty" json:"hdr"`
-	Config    *model.Evn3dHdrConf `bson:"config,omitempty" json:"config"`
-}
-
-// func CreateHdrResultWather(app *conf.AppConf) *comm.NatsStreamWather {
-
-// 	topics := strings.Split(app.Nats.HdrConvStreamTopic, "#")
-
-// 	return &comm.NatsStreamWather{
-// 		Stream: topics[0],
-// 		Topic:  topics[1],
-// 		Queue:  topics[2],
-// 		Entity: func() interface{} { return &ConvHdrResult{} },
-// 		Cb: func(msg *nats.Msg, entity interface{}) {
-// 			result := entity.(*ConvHdrResult)
-// 			//保存osgjs
-// 			if result.Env3d == nil || len(result.DbId) < 1 || len(result.Table) < 1 {
-// 				msg.AckSync()
-// 				return
-// 			}
-// 			err := RepoHrResult(result)
-// 			if err != nil {
-// 				msg.Nak()
-// 				return
-// 			}
-// 			msg.AckSync()
-// 		},
-// 	}
-// }
-
-// !hdr 没用上
-// func RepoHrResult(data *ConvHdrResult) error {
-
-// 	// 查询源资源文档,是否存在config.source
-// 	// 存在,下载源source文件,更新对应模型路径后上传到原本位置
-// 	assetConfig := &comm.AssetEnv3dHdr{}
-// 	_, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-// 		Db:          data.DbId,
-// 		CollectName: data.Table,
-// 		Query:       repo.Map{"_id": data.AssetId},
-// 		Project:     []string{"config"},
-// 	}, assetConfig)
-// 	if err != nil {
-// 		fmt.Printf("%#v/n", data)
-// 		fmt.Println("查询资源错误", err)
-// 		return err
-// 	}
-
-// 	update := bson.M{}
-// 	update["thumbnail"] = data.Env3d.Thumbnail
-// 	if assetConfig.Config != nil && len(assetConfig.Config.Source) > 0 {
-// 		assetConfigSource := assetConfig.Config.Source
-// 		if !strings.Contains(assetConfigSource, "http:") || !strings.Contains(assetConfigSource, "https:") {
-// 			assetConfigSource = fmt.Sprintf("%s%s", "https:", assetConfigSource)
-// 		}
-// 		// 下载
-// 		source, err := comm.DownloadToSourceHdrMap(assetConfigSource)
-// 		if err != nil {
-// 			fmt.Println("下载source文件出错:", err)
-// 			return err
-// 		}
-// 		// 修改文件
-// 		source["config"] = data.Env3d.Config
-
-// 		// 转换为json
-// 		newSource, err := json.Marshal(source)
-// 		if err != nil {
-// 			fmt.Println("newSource json文件出错:", err)
-// 			return err
-// 		}
-
-// 		bucketName := conf.AppConfig.Obs.Bucket
-// 		client, err := CreateObsClient()
-// 		if err != nil {
-// 			fmt.Println("create huawei client 出错:", err)
-// 			return err
-// 		}
-// 		obsKey, err := comm.ParseUrl(assetConfig.Config.Source)
-// 		if err != nil {
-// 			fmt.Println("get obsKey 出错:", err)
-// 			return err
-// 		}
-// 		obsret := UploadFile(client, bucketName, obsKey, newSource)
-// 		if obsret.Size < 0 {
-// 			fmt.Println("obs 上传出错")
-// 			return errors.New("obs 上传出错")
-// 		}
-// 		fmt.Printf("上传结果: %#v\n", obsret)
-
-// 		update["assetState"] = model.AssetState_Succ
-
-// 	} else {
-// 		update["source.config"] = data.Env3d.Config
-// 		update["assetState"] = model.AssetState_Succ
-// 	}
-
-// 	ret, err := repo.RepoUpdateSetDbDocProps(CreateRepoCtx(), data.DbId, data.Table, data.AssetId, bson.M{"$set": update})
-// 	fmt.Println("updated hdr=>", ret)
-
-// 	return err
-// }

+ 0 - 60
tree/assetcenter/bus/main.go

@@ -1,60 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-
-	"infish.cn/comm"
-)
-
-var NatsCenter *comm.NatsBus
-
-func NewNatsBus(app *conf.AppConf) *comm.NatsBus {
-
-	bus, _ := comm.NewNatsBus2(app.Nats.Url, app.Nats.MaxReconnect,
-		app.Nats.ReconnDelaySecond,
-		[]*comm.NatsStreamWather{
-			CreateOsgConvResultWather(app),
-			CreateShadowResultWather(app),
-			// CreateHdrResultWather(app),
-		},
-		[]*comm.NatsMsgReplyer{
-			newReplayer(),
-			addTreeDefineMatgroup(),
-			removeTreeDefineMatgroup(),
-
-			addTreeDefineMeshpack(),
-			removeTreeDefineMeshpack(),
-			RegTreeCategoryQuery(),
-			RegTreeAssetAddMatgroup(),
-			RegTreeAssetDetailMatgroup(),
-			RegTreeAssetDetailMeshPack(),
-			RegTreeDbCategoriesQuery(),
-
-			RegTreeAssetList(),
-			RegTreeUserCategoryUpdate(),
-			RegTreeUserAssetCategoryUpdate(),
-			RegTreeUserAssetCategoryQuery(),
-			RegTreeDbAssetsQuery(),
-			RegTreeDbAssetsUpdate(),
-			RegTreeDbCategoriesUpdate(),
-
-			RegTreeAssetInsert(),
-			RegTreeAssetPackDetail(),
-			RegTreeAssetMatgroupDetail(),
-			RegTreeAssetImageDetail(),
-			RegTreeAssetRemove(),
-			RegTreeAssetDetail(),
-
-			RegTreeAssetUpdate(),
-			RegTreeAssetPackProcess(),
-			RegTreeAssetCreate(),
-
-			RegTreeAssetRecreateShadow(),
-
-			// 图片搜索
-			RegTreeSearchImage(),
-		})
-	NatsCenter = bus
-
-	return NatsCenter
-}

+ 0 - 116
tree/assetcenter/bus/mongo.go

@@ -1,116 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"assetcenter/log"
-	"context"
-	"fmt"
-
-	"go.mongodb.org/mongo-driver/bson"
-	"infish.cn/comm"
-)
-
-const (
-	AssetState_Empty    = 0
-	AssetState_Waiting  = 100 //等待处理
-	AssetState_Proccing = 101 //正在处理
-	AssetState_Failed   = 102 //处理失败!
-	AssetState_Succ     = 200 //处理成功
-)
-
-func CreateRepoCtx() *repo.RepoSession {
-	return &repo.RepoSession{
-		Client: db.MongoClient,
-		Ctx:    context.Background(),
-	}
-}
-
-func RepoOsgconvResult(data *OsgConvertorResult) error {
-
-	fmt.Println("begin update asset state=>", data.DbId, data.Table)
-	log.Info("osgconv result: ", *data)
-
-	// 查询源资源文档,是否存在config.source
-	// 存在,下载源source文件,更新对应模型路径后上传到原本位置
-	asset := &comm.AssetPackage{}
-	_, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-		Db:          data.DbId,
-		CollectName: data.Table,
-		Query:       repo.Map{"_id": data.AssetId},
-		Project:     []string{"transTask"},
-	}, asset)
-	if err != nil {
-		log.Info("%#v/n", data)
-		log.Info("查询资源错误", err)
-		return err
-	}
-
-	update := bson.M{}
-
-	if comm.TransTaskIsNotEmpty(asset.TransTask) {
-		update["transTask.osgjs"] = &comm.OssType{
-			Url:  data.Osgjs.Url,
-			Size: data.Osgjs.Size,
-		}
-	}
-
-	if conf.AppConfig.IsSaveLocal() {
-		data.Osgjs.Url = conf.AppConfig.TrimSaveLocalUrl(data.Osgjs.Url)
-	}
-	log.Info("osgconv更新条件:", update)
-
-	ret, err := repo.RepoUpdateSetDbDocProps(CreateRepoCtx(), data.DbId, data.Table, data.AssetId, bson.M{"$set": update})
-
-	fmt.Println("RepoOsgconvResult update state=>", ret)
-	log.Infof("osgconv更新结果:%#v,err:%#v", ret, err)
-
-	return err
-}
-
-func RepoShadowResult(data *OsgShadowResult) error {
-	log.Infof("shadow result: %#v\n", *data)
-
-	asset := &comm.AssetPackage{}
-	_, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-		Db:          data.DbId,
-		CollectName: data.Table,
-		Query:       repo.Map{"_id": data.AssetId},
-		Project:     []string{"source", "config"},
-	}, asset)
-	if err != nil {
-		log.Info("%#v/n", data)
-		log.Info("查询资源错误", err)
-		return err
-	}
-
-	update := bson.M{}
-	if len(asset.Config) > 0 {
-		// 解析文件拿到file
-		// 更新到 shadowTask
-		source := &comm.Queen3dPackageSource{}
-		err := comm.FetchAndParseJSON(asset.Config, source)
-		if err != nil {
-			log.Error("shadow parse json err: ", err)
-			return err
-		}
-		update["shadowTask"] = &comm.ShadowTask{
-			File: &comm.TransFile{
-				Id:  source.Geoms[0].Id,
-				Url: source.Geoms[0].File.Url,
-			},
-			Shadow: &comm.OssType{
-				Url:  data.Shadow.Url,
-				Size: data.Shadow.Size,
-			},
-		}
-	} else if asset.Source != nil {
-		update["source.geoms.0.shadow"] = data.Shadow
-	}
-
-	ret, err := repo.RepoUpdateSetDbDocProps(CreateRepoCtx(), data.DbId, data.Table, data.AssetId, bson.M{"$set": update})
-	fmt.Println("updated shadow=>", ret)
-
-	return err
-}

+ 0 - 51
tree/assetcenter/bus/osgconv.go

@@ -1,51 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"strings"
-
-	"github.com/nats-io/nats.go"
-	"infish.cn/comm"
-)
-
-type OsgConvertorResult struct {
-	AssetId string `json:"assetId"`
-	DbId    string `json:"dbId"`
-	Table   string `json:"table"`
-	Error   string `json:"error"`
-
-	MeshUrl string         `json:"meshUrl"`
-	Osgjs   *model.OssType `json:"Osgjs"`
-}
-
-func CreateOsgConvResultWather(app *conf.AppConf) *comm.NatsStreamWather {
-
-	topics := strings.Split(app.Nats.OsgConvStreamTopic, "#")
-
-	return &comm.NatsStreamWather{
-		Stream:        topics[0],
-		Topic:         topics[1],
-		Queue:         topics[2],
-		MaxDeliver:    5, // 添加 MaxDeliver 配置
-		AckPolicy:     nats.AckExplicitPolicy,
-		AckWaitMinute: 5,
-		Entity:        func() interface{} { return &OsgConvertorResult{} },
-		Cb: func(msg *nats.Msg, entity interface{}) {
-			result := entity.(*OsgConvertorResult)
-			//保存osgjs
-			if result.Osgjs == nil || len(result.Osgjs.Url) < 1 || len(result.DbId) < 1 || len(result.Table) < 1 {
-				msg.AckSync()
-				return
-			}
-
-			err := RepoOsgconvResult(result)
-			if err != nil {
-				msg.Nak()
-				return
-			}
-			msg.AckSync()
-
-		},
-	}
-}

+ 0 - 56
tree/assetcenter/bus/replyers.go

@@ -1,56 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"errors"
-	"time"
-
-	"github.com/nats-io/nats.go"
-	"infish.cn/comm"
-)
-
-func newReplayer() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "queentree.asset.op.enable",
-		Entity:  func() interface{} { return &comm.PublicAssetReq{} },
-		Cb2: func(_ *nats.Msg, entity interface{}) (interface{}, error) {
-			req := entity.(*comm.PublicAssetReq)
-
-			asset := &struct {
-				Enable     *bool     `bson:"enable,omitempty" json:"enable"`
-				CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-				UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-			}{
-				Enable: &req.Enable,
-			}
-
-			if *asset.Enable {
-				asset.CreateTime = time.Now()
-			}
-
-			ctx := &repo.RepoSession{
-				Ctx:    context.Background(),
-				Client: db.MongoClient,
-			}
-
-			//跟新数据库状态
-			dbConf := repo.GetDatabaseCollectionSimple(ctx, req.DbId, req.DefineId)
-			if dbConf == nil || len(dbConf.Db.Name) < 1 {
-				return false, errors.New("db con err")
-			}
-
-			asset.UpdateTime = time.Now()
-			id := req.Id
-			collectionName := dbConf.AssetConf.Collection
-
-			ret, err := repo.RepoUpdateSeDbDoc(ctx, dbConf.Db.Name, collectionName, id, asset)
-			if err != nil {
-				return false, err
-			}
-			return ret, nil
-		},
-	}
-}

+ 0 - 66
tree/assetcenter/bus/search-image.go

@@ -1,66 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-
-	"github.com/nats-io/nats.go"
-	"infish.cn/comm"
-)
-
-type BusTreeSearchImageReq struct {
-	DbName string
-	Coll   string
-	Result []*MlivusSearchRes
-}
-
-// func BusTreeSearchImage(req *BusTreeSearchImageReq) (out interface{}, err error) {
-// 	err = NatsCenter.RequestPackApi("tree.search.image",
-// 		req,
-// 		&out, &comm.RequestOptions{
-// 			DeployPack: "queentree",
-// 		})
-// 	return out, err
-// }
-
-func RegTreeSearchImage() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.search.image",
-		Entity:  func() interface{} { return &BusTreeSearchImageReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*BusTreeSearchImageReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是BusTreeSearchImageReq类型")
-			}
-			fmt.Println(*req)
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			handleLists := make([]map[string]interface{}, 0)
-			for _, list := range req.Result {
-				handleList := make(map[string]interface{})
-				found, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-					Db:          req.DbName,
-					CollectName: req.Coll,
-					Query:       repo.Map{"_id": list.ProductId},
-				}, handleList)
-				if !found || err != nil {
-					continue
-				}
-				handleList["score"] = list.Score
-				handleList["imHash"] = list.ImHash
-				handleLists = append(handleLists, handleList)
-			}
-
-			return handleLists, nil
-		},
-	}
-}

+ 0 - 52
tree/assetcenter/bus/shadow.go

@@ -1,52 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db/model"
-	"assetcenter/log"
-	"strings"
-
-	"github.com/nats-io/nats.go"
-	"infish.cn/comm"
-)
-
-type OsgShadowResult struct {
-	AssetId string `json:"assetId"`
-	DbId    string `json:"dbId"`
-	Table   string `json:"table"`
-
-	MeshUrl string         `json:"meshUrl"`
-	Shadow  *model.OssType `json:"shadow"`
-}
-
-func CreateShadowResultWather(app *conf.AppConf) *comm.NatsStreamWather {
-
-	topics := strings.Split(app.Nats.OsgShadowStreamTopic, "#")
-
-	return &comm.NatsStreamWather{
-		Stream:        topics[0],
-		Topic:         topics[1],
-		Queue:         topics[2],
-		MaxDeliver:    5, // 添加 MaxDeliver 配置
-		AckPolicy:     nats.AckExplicitPolicy,
-		AckWaitMinute: 5,
-		Entity:        func() interface{} { return &OsgShadowResult{} },
-		Cb: func(msg *nats.Msg, entity interface{}) {
-			result := entity.(*OsgShadowResult)
-			log.Info("------------------------[shadow-result]-------------------------")
-			log.Infof("%#v\n", *result)
-			//保存osgjs
-			if result.Shadow == nil || len(result.Shadow.Url) < 1 || len(result.DbId) < 1 || len(result.Table) < 1 {
-				msg.AckSync()
-				return
-			}
-
-			err := RepoShadowResult(result)
-			if err != nil {
-				msg.Nak()
-				return
-			}
-			msg.AckSync()
-		},
-	}
-}

+ 0 - 17
tree/assetcenter/bus/taskReq.go

@@ -1,17 +0,0 @@
-package bus
-
-type MeshAssetProcessRequest struct {
-	DatabaseId string `json:"databaseId"`
-	Collection string `json:"collection"`
-	AssetId    string `json:"assetId"`
-	UserId     string `json:"userId"`
-	MeshUrl    string `json:"meshUrl"`
-}
-
-type HdrAssetProcessRequest struct {
-	DatabaseId string `json:"databaseId"`
-	Collection string `json:"collection"`
-	AssetId    string `json:"assetId"`
-	UserId     string `json:"userId"`
-	FileUrl    string `json:"fileUrl"`
-}

+ 0 - 81
tree/assetcenter/bus/tree-asset-add-matgroup.go

@@ -1,81 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-
-	"github.com/nats-io/nats.go"
-	"infish.cn/comm"
-)
-
-type TreeAddMatgroupReq struct {
-	DbName     string
-	Collection string
-	Matgroup   *comm.AssetMatGroup
-}
-
-func RegTreeAssetAddMatgroup() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.add.matgroup",
-		Entity:  func() interface{} { return &TreeAddMatgroupReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAddMatgroupReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-			if len(req.DbName) < 1 || len(req.Collection) < 1 {
-				return nil, fmt.Errorf("DbName Collection 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			return repo.RepoDbAddDoc(CreateRepoCtx(), req.DbName, req.Collection, req.Matgroup)
-		},
-	}
-}
-
-type AssetReq struct {
-	DbHost     string
-	DbName     string
-	Collection string
-	AssetId    string
-}
-
-func RegTreeAssetDetailMatgroup() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.detail.matgroup",
-		Entity:  func() interface{} { return &AssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*AssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是AssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Collection) < 1 || len(req.AssetId) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			out := &comm.AssetMatGroup{}
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{Db: req.DbName, CollectName: req.Collection, Query: repo.Map{"_id": req.AssetId}}, out)
-			if err != nil {
-				return nil, err
-			}
-			if !ok {
-				return nil, fmt.Errorf("查询的色卡不存在")
-			}
-			return out, nil
-		},
-	}
-}

+ 0 - 607
tree/assetcenter/bus/tree-asset-list.go

@@ -1,607 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"assetcenter/tree"
-	"strings"
-
-	"context"
-	"fmt"
-	"time"
-
-	"github.com/nats-io/nats.go"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-type TreeListReq struct {
-	DbName     string
-	Collection string
-	Page       int
-	Size       int
-	Project    []string
-	Query      map[string]interface{}
-}
-
-func RegTreeAssetList() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.list",
-		Entity:  func() interface{} { return &TreeListReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeListReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是TreeListReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Collection) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-			if req.Page == 0 {
-				req.Page = 1
-			}
-			if req.Size == 0 {
-				req.Size = 10
-			}
-
-			fmt.Println("tree.asset.list ==>: ", req.DbName, req.Collection)
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			fmt.Println("list request query", req.Query)
-
-			if req.Query["userId"] != nil {
-				userId, ok := req.Query["userId"].(string)
-				if ok {
-					req.Query["userId"], _ = primitive.ObjectIDFromHex(userId)
-				}
-			}
-			if req.Query["ownerId"] != nil && len(req.Query["ownerId"].(string)) > 0 {
-				req.Query["ownerId"], _ = primitive.ObjectIDFromHex(req.Query["ownerId"].(string))
-			}
-
-			dbConf := &comm.AssetDbConf{}
-			if req.Query["categories"] != nil {
-				enity := &comm.Database{}
-				ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-					CollectName: repo.CollectionDatabase,
-					Query:       repo.Map{"name": req.DbName},
-					Project:     []string{"categories"},
-				}, enity)
-				if !ok {
-					return nil, fmt.Errorf("没有查询到数据库:%s", req.DbName)
-				}
-				dbConf.Db = enity
-			}
-			ctx := CreateRepoCtx()
-			err := ParseCategories(req.Query, ctx, dbConf)
-			if err != nil {
-				return nil, err
-			}
-
-			return repo.RepoPageSearch(CreateRepoCtx(), &repo.PageSearchOptions{
-				Db:          req.DbName,
-				CollectName: req.Collection,
-				Page:        int64(req.Page),
-				Size:        int64(req.Size),
-				Query:       req.Query,
-				Project:     req.Project,
-				Sort:        bson.M{"createTime": -1},
-			})
-		},
-	}
-}
-
-type AssetInsertReq struct {
-	DbName   string
-	Coll     string
-	Pack     *comm.AssetPackage
-	Mat3d    *comm.AssetMatGroup
-	Img      *comm.AssetImage
-	OtherMat *comm.AssetMat
-}
-type AssetInsertResp struct {
-	Id string
-}
-
-func RegTreeAssetInsert() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.insert",
-		Entity:  func() interface{} { return &AssetInsertReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*AssetInsertReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是AssetInsertReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Coll) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			var insert interface{} = nil
-			if req.Pack != nil {
-				insert = req.Pack
-				req.Pack.Id = primitive.NilObjectID
-				req.Pack.CreateTime = time.Now()
-				req.Pack.UpdateTime = time.Now()
-			} else if req.Img != nil {
-				insert = req.Img
-				req.Img.Id = primitive.NilObjectID
-				req.Img.CreateTime = time.Now()
-				req.Img.UpdateTime = time.Now()
-			} else if req.Mat3d != nil {
-				insert = req.Mat3d
-				req.Mat3d.Id = primitive.NilObjectID
-				req.Mat3d.CreateTime = time.Now()
-				req.Mat3d.UpdateTime = time.Now()
-			} else if req.OtherMat != nil {
-				insert = req.OtherMat
-				req.OtherMat.Id = primitive.NilObjectID
-				req.OtherMat.CreateTime = time.Now()
-				req.OtherMat.UpdateTime = time.Now()
-			} else {
-				return nil, fmt.Errorf("不支持的类型")
-			}
-
-			fmt.Println("tree.asset.insert ==>: ", req.DbName, req.Coll)
-			fmt.Println("tree.asset.insert req data==>: \n", req)
-			id, err := repo.RepoDbAddDoc(CreateRepoCtx(), req.DbName, req.Coll, insert)
-
-			return &AssetInsertResp{Id: id}, err
-		},
-	}
-}
-
-type TreeAssetReq struct {
-	DbName string
-	Coll   string
-	Id     string
-}
-
-func RegTreeAssetPackDetail() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.scenepack.detail",
-		Entity:  func() interface{} { return &TreeAssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是TreeAssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Coll) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			// out := &comm.AssetPackage{}
-
-			// ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-			// 	Db:          req.DbName,
-			// 	CollectName: req.Coll,
-			// 	Query:       repo.Map{"_id": req.Id},
-			// }, out)
-
-			// if !ok {
-			// 	return nil, fmt.Errorf("没有对应的数据")
-			// }
-			// return out, err
-			ok, ret := repo.RepoSeachDocMap(CreateRepoCtx(), &repo.DocSearchOptions{
-				Db:          req.DbName,
-				CollectName: req.Coll,
-				Query:       repo.Map{"_id": req.Id},
-			})
-
-			if !ok {
-				return nil, fmt.Errorf("没有对应的数据")
-			}
-			return ret, nil
-		},
-	}
-}
-
-func RegTreeAssetImageDetail() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.image.detail",
-		Entity:  func() interface{} { return &TreeAssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是TreeAssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Coll) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			out := &comm.AssetImage{}
-
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				Db:          req.DbName,
-				CollectName: req.Coll,
-				Query:       repo.Map{"_id": req.Id},
-			}, out)
-
-			if !ok {
-				return nil, fmt.Errorf("没有对应的数据")
-			}
-			return out, err
-		},
-	}
-}
-
-func RegTreeAssetMatgroupDetail() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.matgroup.detail",
-		Entity:  func() interface{} { return &TreeAssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是TreeAssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Coll) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			out := &comm.AssetMatGroup{}
-
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				Db:          req.DbName,
-				CollectName: req.Coll,
-				Query:       repo.Map{"_id": req.Id},
-			}, out)
-
-			if !ok {
-				return nil, fmt.Errorf("没有对应的数据")
-			}
-			return out, err
-		},
-	}
-}
-
-func RegTreeAssetDetail() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.detail",
-		Entity:  func() interface{} { return &TreeAssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是TreeAssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Coll) < 1 || len(req.Id) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			// tree.asset.detail接口日志
-			fmt.Println("[tree.asset.detail]: db:", req.DbName, "coll:", req.Coll, "id:", req.Id)
-			ok, ret := repo.RepoSeachDocMap(CreateRepoCtx(), &repo.DocSearchOptions{
-				Db:          req.DbName,
-				CollectName: req.Coll,
-				Query:       repo.Map{"_id": req.Id},
-			})
-
-			if !ok {
-				return nil, fmt.Errorf("没有对应的数据")
-			}
-			return ret, nil
-		},
-	}
-}
-
-func RegTreeAssetRemove() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.remove",
-		Entity:  func() interface{} { return &TreeAssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是TreeAssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Coll) < 1 || len(req.Id) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			// 如果删除的时面料类型,则对应删除图片向量
-			userId := ""
-			if strings.Contains(req.Coll, "mat") {
-				// 查询面料url
-				result := map[string]interface{}{}
-				found, _ := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-					Db:          req.DbName,
-					CollectName: req.Coll,
-					Query:       repo.Map{"_id": req.Id},
-					Project:     []string{"userId"},
-				}, &result)
-
-				if found {
-					if u, ok := result["userId"]; ok {
-						if _userId, ok := u.(primitive.ObjectID); ok {
-							userId = _userId.Hex()
-						}
-					}
-				}
-			}
-			fmt.Println("from mlivus remove: ", req.Coll, userId)
-
-			_, err := repo.RepoDeleteDbDoc(CreateRepoCtx(), req.DbName, req.Coll, req.Id)
-			// 成功删除
-			if err != nil {
-				if len(userId) > 0 {
-					tableName := fmt.Sprintf("%s_%s", req.Coll, userId)
-					// 删除向量数据库对应的图片
-					go deleteImageToMlivus(tableName, req.Id)
-				}
-
-			}
-			return nil, err
-		},
-	}
-}
-
-type UpdateCommReq struct {
-	Pack     *comm.AssetPackage
-	OtherMat *comm.AssetMat
-	Env3d    *comm.AssetEnv3dHdr
-	Mat3d    *comm.AssetMatGroup
-	Img      *comm.AssetImage
-	Coll     string
-	Db       string
-}
-
-type CreateShadowReq struct {
-	Width int
-	Scale int
-	Id    string
-	Coll  string
-	Db    string
-}
-
-func RegTreeAssetUpdate() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.update.header",
-		Entity:  func() interface{} { return &UpdateCommReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*UpdateCommReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是UpdateCommReq类型")
-			}
-			if len(req.Db) < 1 || len(req.Coll) < 1 || (req.Pack == nil && req.Mat3d == nil && req.Img == nil) {
-				return nil, fmt.Errorf("参数错误")
-			}
-
-			if req.Pack != nil {
-				url, err := NatsCenter.RequestConfig("bus-network")
-				if err != nil {
-					return nil, err
-				}
-
-				req.Pack.UpdateTime = time.Now()
-				// id := req.Pack.Id.Hex()
-				// req.Pack.Id = primitive.NilObjectID
-				// _, err := repo.RepoUpdateSeDbDoc(CreateRepoCtx(), req.Db, req.Coll, id, req.Pack)
-				_, err = tree.UpdateAssetPackageHeader(CreateRepoCtx(), req.Db, req.Coll, req.Pack, url)
-				return nil, err
-			}
-			if req.OtherMat != nil {
-				id := req.OtherMat.Id.Hex()
-				req.OtherMat.Id = primitive.NilObjectID
-				_, err := repo.RepoUpdateSeDbDoc(CreateRepoCtx(), req.Db, req.Coll, id, req.OtherMat)
-				return nil, err
-			}
-			if req.Env3d != nil {
-				req.Env3d.UpdateTime = time.Now()
-				id := req.Env3d.Id.Hex()
-				req.Env3d.Id = primitive.NilObjectID
-				_, err := repo.RepoUpdateSeDbDoc(CreateRepoCtx(), req.Db, req.Coll, id, req.Env3d)
-				return nil, err
-			}
-
-			if req.Mat3d != nil {
-				req.Mat3d.UpdateTime = time.Now()
-				id := req.Mat3d.Id.Hex()
-				req.Mat3d.Id = primitive.NilObjectID
-				_, err := repo.RepoUpdateSeDbDoc(CreateRepoCtx(), req.Db, req.Coll, id, req.Mat3d)
-				return nil, err
-			}
-
-			if req.Img != nil {
-				req.Img.UpdateTime = time.Now()
-				id := req.Img.Id.Hex()
-				req.Img.Id = primitive.NilObjectID
-				_, err := repo.RepoUpdateSeDbDoc(CreateRepoCtx(), req.Db, req.Coll, id, req.Img)
-				return nil, err
-			}
-
-			return nil, fmt.Errorf("不支持的更新类型")
-		},
-	}
-}
-
-func RegTreeAssetPackProcess() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.pack.retreat",
-		Entity:  func() interface{} { return &UpdateCommReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*UpdateCommReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是UpdateCommReq类型")
-			}
-			if len(req.Db) < 1 || len(req.Coll) < 1 || req.Pack == nil {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			url, err := NatsCenter.RequestConfig("bus-network")
-			if err != nil {
-				return nil, err
-			}
-
-			return nil, tree.ProcessPack(CreateRepoCtx(), req.Pack.Id.Hex(), req.Db, req.Coll, url)
-		},
-	}
-}
-
-func RegTreeAssetRecreateShadow() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.pack.reshadow",
-		Entity:  func() interface{} { return &CreateShadowReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*CreateShadowReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是CreateShadowReq类型")
-			}
-			if len(req.Db) < 1 || len(req.Coll) < 1 || len(req.Id) < 1 {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			url, err := NatsCenter.RequestConfig("bus-network")
-			if err != nil {
-				return nil, err
-			}
-
-			return nil, tree.CreatePackShadow(CreateRepoCtx(), req.Id, req.Db, req.Coll, req.Scale, req.Width, url)
-		},
-	}
-}
-
-type AssetEvent struct {
-	DefId string
-	DbId  string // 哪个资产库的统计表
-	Api   string
-}
-
-func RegTreeAssetCreate() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.create",
-		Entity:  func() interface{} { return &UpdateCommReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*UpdateCommReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是UpdateCommReq类型")
-			}
-			if len(req.Db) < 1 || len(req.Coll) < 1 {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			fmt.Println("tree.asset.create ==>: ", req.Db, req.Coll)
-			fmt.Println("tree.asset.create req data==>: \n", req)
-			url, err := NatsCenter.RequestConfig("bus-network")
-			if err != nil {
-				return nil, err
-			}
-
-			if req.Pack != nil {
-				return tree.UploadAssetPackage(CreateRepoCtx(), req.Db, req.Coll, req.Pack, url)
-			}
-
-			if req.OtherMat != nil {
-				return repo.RepoDbAddDoc(CreateRepoCtx(), req.Db, req.Coll, req.OtherMat)
-			}
-			if req.Env3d != nil {
-				return repo.RepoDbAddDoc(CreateRepoCtx(), req.Db, req.Coll, req.Env3d)
-			}
-
-			if req.Mat3d != nil {
-				matId, err := repo.RepoDbAddDoc(CreateRepoCtx(), req.Db, req.Coll, req.Mat3d)
-				if err != nil {
-					return "", err
-				}
-
-				// 上传成功存储对应封面图图片向量
-				if len(req.Mat3d.Thumbnail.Url) > 0 {
-					tableName := fmt.Sprintf("%s_%s", req.Coll, req.Mat3d.UserId.Hex())
-					fmt.Println("upload to mlivus: ", tableName, req.Mat3d.Thumbnail.Url, matId)
-					go uploadImageToMlivus(tableName, matId, req.Mat3d.Thumbnail.Url)
-				}
-				return matId, err
-			}
-
-			if req.Img != nil {
-				return repo.RepoDbAddDoc(CreateRepoCtx(), req.Db, req.Coll, req.Img)
-			}
-
-			base := &comm.Database{}
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDatabase,
-				Query:       repo.Map{"name": req.Db},
-				Project:     []string{"assets"},
-			}, base)
-
-			if ok {
-				for _, v := range base.Assets {
-					if v.Collection == req.Coll {
-						NatsCenter.PublishObj("asset.added", &AssetEvent{Api: "upload", DbId: base.Id.Hex(), DefId: v.Id})
-						break
-					}
-				}
-			}
-
-			return nil, fmt.Errorf("不支持的类型")
-		},
-	}
-}

+ 0 - 43
tree/assetcenter/bus/tree-asset-meshpack.go

@@ -1,43 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-
-	"github.com/nats-io/nats.go"
-	"infish.cn/comm"
-)
-
-func RegTreeAssetDetailMeshPack() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.asset.detail.pack",
-		Entity:  func() interface{} { return &AssetReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*AssetReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误不是AssetReq类型")
-			}
-			if len(req.DbName) < 1 || len(req.Collection) < 1 || len(req.AssetId) < 1 {
-				return nil, fmt.Errorf("DbName Collection AssetId 不能为空")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			out := &comm.AssetPackage{}
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{Db: req.DbName, CollectName: req.Collection, Query: repo.Map{"_id": req.AssetId}}, out)
-			if err != nil {
-				return nil, err
-			}
-			if !ok {
-				return nil, fmt.Errorf("查询的色卡不存在")
-			}
-			return out, nil
-		},
-	}
-}

+ 0 - 244
tree/assetcenter/bus/tree-category-query.go

@@ -1,244 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-	"time"
-
-	"github.com/nats-io/nats.go"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-type TreeQueryDbCategoryReq struct {
-	DefineCollection string
-	DbName           string
-	UserId           string
-	AssetScope       string
-}
-
-func RegTreeCategoryQuery() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.category.query",
-		Entity:  func() interface{} { return &TreeQueryDbCategoryReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeQueryDbCategoryReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-
-			if len(req.DbName) < 1 || len(req.DefineCollection) < 1 {
-				return nil, fmt.Errorf("DbName 或 DefineName 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			enity := &comm.Database{}
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDatabase,
-				Query:       repo.Map{"name": req.DbName},
-				Project:     []string{"categories", "assets"},
-			}, enity)
-			if !ok {
-				return nil, fmt.Errorf("没有查询到数据库:%s", req.DbName)
-			}
-
-			defineId := ""
-			for _, a := range enity.Assets {
-				if a.Collection == req.DefineCollection {
-					defineId = a.Id
-					break
-				}
-			}
-			if len(defineId) < 1 {
-				return nil, fmt.Errorf("没有查询到%s的定义", req.DefineCollection)
-			}
-
-			if len(req.UserId) > 0 && len(req.AssetScope) > 0 { //自定义分类
-				userCaties := &comm.DbCategory{}
-				userId, _ := primitive.ObjectIDFromHex(req.UserId)
-				_, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-					CollectName: repo.CollectionCategories,
-					Query:       repo.Map{"userId": userId, "scope": req.AssetScope},
-				}, userCaties)
-				if err != nil {
-					return nil, err
-				}
-				userAssetCaties := &comm.DbAssetUserCategory{}
-				_, err = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-					CollectName: repo.CollectionDbAssetCategory,
-					Query:       repo.Map{"userId": userId},
-				}, userAssetCaties)
-
-				if err != nil {
-					return nil, err
-				}
-
-				cates := &comm.DbCategory{}
-				for _, v := range userAssetCaties.CategoryConfs {
-					if v.DbAssetId.Hex() == defineId {
-						for _, id := range v.CategoryIds {
-							for _, c := range userCaties.Categories {
-								if c.Id == id {
-									cates.Categories = append(cates.Categories, c)
-									break
-								}
-							}
-						}
-					}
-				}
-				return cates, nil
-			}
-			if len(req.DbName) < 1 {
-				return nil, fmt.Errorf("DbName不能为空")
-			}
-
-			cates := &comm.DbCategory{}
-			for _, v := range enity.Assets {
-				if v.Id != defineId {
-					continue
-				}
-				for _, id := range v.CategoryIds {
-					for _, c := range enity.Categories.Categories {
-						if c.Id == id {
-							cates.Categories = append(cates.Categories, c)
-							break
-						}
-					}
-				}
-			}
-			return cates, nil
-		},
-	}
-}
-
-func RegTreeUserCategoryUpdate() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.user.category.update",
-		Entity:  func() interface{} { return &comm.DbCategory{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*comm.DbCategory)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			curr := &comm.DbCategory{}
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionCategories,
-				Project:     []string{"_id"},
-				Query:       repo.Map{"userId": req.UserId, "scope": req.Scope},
-			}, curr)
-			if err != nil {
-				return nil, err
-			}
-
-			if !ok { //没有查询到新增
-				id, err := repo.RepoAddDoc(CreateRepoCtx(), repo.CollectionCategories, req)
-				if err != nil {
-					return nil, err
-				}
-				req.Id, _ = primitive.ObjectIDFromHex(id)
-				return req, nil
-			}
-			req.Id = primitive.NilObjectID
-
-			return repo.RepoUpdateSetDoc(CreateRepoCtx(), repo.CollectionCategories, curr.Id.Hex(), req)
-		},
-	}
-}
-
-func RegTreeUserAssetCategoryUpdate() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.user.assetCategory.update",
-		Entity:  func() interface{} { return &comm.DbAssetUserCategory{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*comm.DbAssetUserCategory)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			curr := &comm.DbAssetUserCategory{}
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDbAssetCategory,
-				Project:     []string{"_id"},
-				Query:       repo.Map{"userId": req.UserId, "scope": req.Scope},
-			}, curr)
-			if err != nil {
-				return nil, err
-			}
-
-			if !ok { //没有查询到新增
-				req.CreateTime = time.Now()
-				req.UpdateTime = time.Now()
-				id, err := repo.RepoAddDoc(CreateRepoCtx(), repo.CollectionDbAssetCategory, req)
-				if err != nil {
-					return nil, err
-				}
-				req.Id, _ = primitive.ObjectIDFromHex(id)
-				return true, nil
-			}
-
-			req.Id = primitive.NilObjectID
-			req.UpdateTime = time.Now()
-			req.CreateTime = curr.CreateTime
-			_, err = repo.RepoUpdateSetDoc(CreateRepoCtx(), repo.CollectionDbAssetCategory, curr.Id.Hex(), req)
-
-			return true, err
-		},
-	}
-}
-
-type TreeUserAssetCateReq struct {
-	UserId string
-	Scope  string
-}
-
-func RegTreeUserAssetCategoryQuery() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.user.assetCategory.query",
-		Entity:  func() interface{} { return &TreeUserAssetCateReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeUserAssetCateReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			uid, _ := primitive.ObjectIDFromHex(req.UserId)
-			curr := &comm.DbAssetUserCategory{}
-			_, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDbAssetCategory,
-				Query:       repo.Map{"userId": uid, "scope": req.Scope},
-			}, curr)
-			if err != nil {
-				return nil, err
-			}
-			return curr, nil
-		},
-	}
-}

+ 0 - 204
tree/assetcenter/bus/tree-db.go

@@ -1,204 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-
-	"github.com/nats-io/nats.go"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-type TreeDbCategoryReq struct {
-	DbName     string
-	UserId     string
-	AssetScope string
-}
-
-type TreeDbCategoryResp struct {
-	Db                *comm.Database
-	UserAssetCategory *comm.DbAssetUserCategory
-	UserCategory      *comm.DbCategory
-}
-
-type TreeDbReq struct {
-	DbName string
-}
-
-func RegTreeDbCategoriesQuery() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.db.category",
-		Entity:  func() interface{} { return &TreeDbCategoryReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeDbCategoryReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-
-			if len(req.DbName) < 1 || len(req.AssetScope) < 1 {
-				return nil, fmt.Errorf("请求参数错误 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			enity := &comm.Database{}
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDatabase,
-				Query:       repo.Map{"name": req.DbName},
-				Project:     []string{"categories", "assets"},
-			}, enity)
-			if !ok {
-				return nil, fmt.Errorf("没有查询到数据库:%s", req.DbName)
-			}
-
-			if len(req.UserId) < 1 {
-				return &TreeDbCategoryResp{
-					Db: enity,
-				}, nil
-			}
-
-			userCaties := &comm.DbCategory{}
-			userId, _ := primitive.ObjectIDFromHex(req.UserId)
-			_, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionCategories,
-				Query:       repo.Map{"userId": userId, "scope": req.AssetScope},
-			}, userCaties)
-			if err != nil {
-				return nil, err
-			}
-
-			userAssetCaties := &comm.DbAssetUserCategory{}
-			_, err = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDbAssetCategory,
-				Query:       repo.Map{"userId": userId, "scope": req.AssetScope},
-			}, userAssetCaties)
-
-			if err != nil {
-				return nil, err
-			}
-			return &TreeDbCategoryResp{
-				Db:                enity,
-				UserAssetCategory: userAssetCaties,
-				UserCategory:      userCaties,
-			}, nil
-		},
-	}
-}
-
-func RegTreeDbAssetsQuery() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.db.assets",
-		Entity:  func() interface{} { return &TreeDbReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeDbReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-			if len(req.DbName) < 1 {
-				return nil, fmt.Errorf("请求参数错误 不能为空")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			enity := &comm.Database{}
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDatabase,
-				Query:       repo.Map{"name": req.DbName},
-				Project:     []string{"assets"},
-			}, enity)
-			if !ok {
-				return nil, fmt.Errorf("没有查询到数据库:%s", req.DbName)
-			}
-			return enity, nil
-		},
-	}
-}
-
-type TreeDbUpdateReq struct {
-	DbName string
-	Db     *comm.Database
-}
-
-func RegTreeDbAssetsUpdate() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.db.assets.update",
-		Entity:  func() interface{} { return &TreeDbUpdateReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeDbUpdateReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-			if len(req.DbName) < 1 || req.Db == nil {
-				return nil, fmt.Errorf("请求参数错误 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			update := bson.M{"$set": bson.M{"assets": req.Db.Assets}}
-			_, err := repo.RepoUpdateSetDocProps(CreateRepoCtx(),
-				repo.CollectionDatabase,
-				req.Db.Id.Hex(), update)
-
-			return nil, err
-		},
-	}
-}
-
-type UpdateDbCateReq struct {
-	DbName string
-	Cate   *comm.DbCategory
-}
-
-func RegTreeDbCategoriesUpdate() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.db.category.update",
-		Entity:  func() interface{} { return &UpdateDbCateReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*UpdateDbCateReq)
-			if !ok {
-				return nil, fmt.Errorf("参数错误")
-			}
-			if len(req.DbName) < 1 || req.Cate == nil {
-				return nil, fmt.Errorf("请求参数错误 不能为空")
-			}
-
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			dbtree := &comm.DbCategory{}
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{
-				CollectName: repo.CollectionDatabase,
-				Project:     []string{"_id"},
-				Query:       repo.Map{"name": req.DbName},
-			}, dbtree)
-			if !ok {
-				return nil, fmt.Errorf("没有对应的数据库")
-			}
-
-			update := bson.M{"$set": bson.M{"categories": req.Cate}}
-			_, err := repo.RepoUpdateSetDocProps(CreateRepoCtx(),
-				repo.CollectionDatabase,
-				dbtree.Id.Hex(), update)
-
-			return nil, err
-		},
-	}
-}

+ 0 - 149
tree/assetcenter/bus/tree-define-add-matgroup.go

@@ -1,149 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-	"math/rand"
-	"time"
-
-	"github.com/nats-io/nats.go"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func init() {
-	// 保证每次生成的随机数不一样
-	rand.Seed(time.Now().UnixNano())
-}
-
-func addTreeDefineMatgroup() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.define.add.matgroup",
-		Entity:  func() interface{} { return &TreeAddDefReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAddDefReq)
-			if !ok || len(req.Name) < 1 {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var createRandomColl = func() string {
-				return fmt.Sprintf("matgrp-%s-%s", time.Now().Format("20060102"), RandName(6))
-			}
-			collName := createRandomColl()
-			if len(req.DbName) < 1 {
-				return nil, fmt.Errorf("数据库名字不能为空")
-			}
-			body := &comm.DbAsset{
-				Collection:  collName,
-				Label:       req.Name,
-				Type:        model.AssetTypeMaterialGroup,
-				CategoryIds: []string{},
-				CreateTime:  time.Now(),
-				UserId:      req.UserId,
-			}
-			body.Id = primitive.NewObjectID().Hex()
-
-			database := &comm.Database{}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"name": req.DbName}, Project: []string{"_id"}}, database)
-			if err != nil {
-				return nil, fmt.Errorf("数据库不存在")
-			}
-
-			if !ok {
-				return nil, err
-			}
-
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"assets.collection": body.Collection, "_id": database.Id}, Project: []string{"_id"}}, database)
-			if ok {
-				return nil, fmt.Errorf("材料库编号重复")
-			}
-
-			ret, err := repo.RepoDocArrayAppend(
-				CreateRepoCtx(),
-				repo.CollectionDatabase,
-				database.Id.Hex(),
-				"assets",
-				body,
-			)
-			if err != nil {
-				return nil, err
-			}
-			if ret.MatchedCount < 1 {
-				return nil, fmt.Errorf("添加失败")
-			}
-			return &TreeAddDefineResp{
-				DbId:       database.Id.Hex(),
-				DefineId:   body.Id,
-				Collection: body.Collection,
-				Host:       conf.AppConfig.TreeDNS,
-			}, nil
-		},
-	}
-}
-
-func removeTreeDefineMatgroup() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.define.remove.matgroup",
-		Entity:  func() interface{} { return &TreeRemoveDefReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeRemoveDefReq)
-			if !ok || len(req.DbId) < 1 || len(req.DefineId) < 1 {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			filter := repo.Map{"assets.id": req.DefineId}
-			enity := &model.DatabaseAssetV0{}
-			err := repo.RepoDocArraySearch(CreateRepoCtx(), &repo.ArrayOneSearchOption{
-				CollectName: repo.CollectionDatabase,
-				ArrayQuery:  filter,
-				Id:          req.DbId,
-				Field:       "assets",
-			}, enity)
-
-			if err != nil {
-				return nil, err
-			}
-			if enity.Assets == nil {
-				return true, nil
-			}
-
-			//删除数据表
-			coll := enity.Assets.Collection
-			fmt.Println("todo fixed me need delete collection ", coll)
-
-			ret, err := repo.RepoDocArrayOneRemove(
-				CreateRepoCtx(),
-				&repo.ArrayOneRemoveOption{
-					CollectName: repo.CollectionDatabase,
-					Id:          req.DbId,
-					ArrayQuery:  repo.Map{"assets": bson.M{"id": req.DefineId}},
-				},
-			)
-
-			if err != nil {
-				return nil, err
-			}
-			if ret.MatchedCount < 1 {
-				return nil, fmt.Errorf("删除失败")
-			}
-			return nil, nil
-		},
-	}
-}

+ 0 - 149
tree/assetcenter/bus/tree-define-add-meshpack.go

@@ -1,149 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-	"assetcenter/db"
-	"assetcenter/db/model"
-	"assetcenter/db/repo"
-	"context"
-	"fmt"
-	"math/rand"
-	"time"
-
-	"github.com/nats-io/nats.go"
-	"go.mongodb.org/mongo-driver/bson"
-	"go.mongodb.org/mongo-driver/bson/primitive"
-	"infish.cn/comm"
-)
-
-func init() {
-	// 保证每次生成的随机数不一样
-	rand.Seed(time.Now().UnixNano())
-}
-
-func addTreeDefineMeshpack() *comm.NatsMsgReplyer {
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.define.add.meshpack",
-		Entity:  func() interface{} { return &TreeAddDefReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeAddDefReq)
-			if !ok || len(req.Name) < 1 {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var createRandomColl = func() string {
-				return fmt.Sprintf("meshpack-%s-%s", time.Now().Format("20060102"), RandName(6))
-			}
-			collName := createRandomColl()
-			if len(req.DbName) < 1 {
-				return nil, fmt.Errorf("数据库名字不能为空")
-			}
-			body := &comm.DbAsset{
-				Collection:  collName,
-				Label:       req.Name,
-				Type:        model.AssetTypePackage,
-				CategoryIds: []string{},
-				CreateTime:  time.Now(),
-				UserId:      req.UserId,
-			}
-			body.Id = primitive.NewObjectID().Hex()
-
-			database := &comm.Database{}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-			ok, err := repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"name": req.DbName}, Project: []string{"_id"}}, database)
-			if err != nil {
-				return nil, fmt.Errorf("数据库不存在")
-			}
-
-			if !ok {
-				return nil, err
-			}
-
-			ok, _ = repo.RepoSeachDoc(CreateRepoCtx(), &repo.DocSearchOptions{CollectName: repo.CollectionDatabase, Query: repo.Map{"assets.collection": body.Collection, "_id": database.Id}, Project: []string{"_id"}}, database)
-			if ok {
-				return nil, fmt.Errorf("材料库编号重复")
-			}
-
-			ret, err := repo.RepoDocArrayAppend(
-				CreateRepoCtx(),
-				repo.CollectionDatabase,
-				database.Id.Hex(),
-				"assets",
-				body,
-			)
-			if err != nil {
-				return nil, err
-			}
-			if ret.MatchedCount < 1 {
-				return nil, fmt.Errorf("添加失败")
-			}
-			return &TreeAddDefineResp{
-				DbId:       database.Id.Hex(),
-				DefineId:   body.Id,
-				Collection: body.Collection,
-				Host:       conf.AppConfig.TreeDNS,
-			}, nil
-		},
-	}
-}
-
-func removeTreeDefineMeshpack() *comm.NatsMsgReplyer {
-
-	return &comm.NatsMsgReplyer{
-		Subject: "tree.define.remove.meshpack",
-		Entity:  func() interface{} { return &TreeRemoveDefReq{} },
-		Cb2: func(msg *nats.Msg, entity interface{}) (interface{}, error) {
-			req, ok := entity.(*TreeRemoveDefReq)
-			if !ok || len(req.DbId) < 1 || len(req.DefineId) < 1 {
-				return nil, fmt.Errorf("参数错误")
-			}
-			var CreateRepoCtx = func() *repo.RepoSession {
-				return &repo.RepoSession{
-					Ctx:    context.Background(),
-					Client: db.MongoClient,
-				}
-			}
-
-			filter := repo.Map{"assets.id": req.DefineId}
-			enity := &model.DatabaseAssetV0{}
-			err := repo.RepoDocArraySearch(CreateRepoCtx(), &repo.ArrayOneSearchOption{
-				CollectName: repo.CollectionDatabase,
-				ArrayQuery:  filter,
-				Id:          req.DbId,
-				Field:       "assets",
-			}, enity)
-
-			if err != nil {
-				return nil, err
-			}
-			if enity.Assets == nil {
-				return true, nil
-			}
-
-			//删除数据表
-			coll := enity.Assets.Collection
-			fmt.Println("todo fixed me need delete collection ", coll)
-
-			ret, err := repo.RepoDocArrayOneRemove(
-				CreateRepoCtx(),
-				&repo.ArrayOneRemoveOption{
-					CollectName: repo.CollectionDatabase,
-					Id:          req.DbId,
-					ArrayQuery:  repo.Map{"assets": bson.M{"id": req.DefineId}},
-				},
-			)
-
-			if err != nil {
-				return nil, err
-			}
-			if ret.MatchedCount < 1 {
-				return nil, fmt.Errorf("删除失败")
-			}
-			return nil, nil
-		},
-	}
-}

+ 0 - 221
tree/assetcenter/bus/tree-query.go

@@ -1,221 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db/repo"
-	"encoding/json"
-	"fmt"
-
-	"go.mongodb.org/mongo-driver/bson"
-	"infish.cn/comm"
-)
-
-type IteChildren func(n *comm.CategoryNode) []string
-type FindChild func(n *comm.CategoryNode, id string) []string
-
-func FindCategoryIds(c *comm.DbCategory, parents []string) ([]string, [][]string) {
-	out := []string{}
-	andOut := [][]string{}
-	var allChildren IteChildren
-	allChildren = func(n *comm.CategoryNode) []string {
-		ids := []string{}
-		if n == nil {
-			return ids
-		}
-		ids = append(ids, n.Id)
-		if n.Children != nil {
-			for _, c := range n.Children {
-				cids := allChildren(c)
-				if len(cids) > 0 {
-					ids = append(ids, cids...)
-				}
-			}
-		}
-		return ids
-	}
-	var findChildrens FindChild
-	findChildrens = func(n *comm.CategoryNode, id string) []string {
-		ids := []string{}
-		if n == nil {
-			return ids
-		}
-
-		if n.Id == id {
-			ids = allChildren(n)
-			return ids
-		}
-
-		if n.Children == nil {
-			return ids
-		}
-
-		//查找孩子节点
-		for _, c := range n.Children {
-			ids = findChildrens(c, id)
-			if len(ids) > 0 {
-				break
-			}
-		}
-		return ids
-	}
-	for _, v := range parents {
-		for _, catnode := range c.Categories {
-			extends := findChildrens(catnode, v)
-			if len(extends) > 0 {
-				andOut = append(andOut, extends)
-				out = append(out, extends...)
-				break
-			}
-		}
-	}
-	return out, andOut
-}
-
-func ParseCategories(query map[string]interface{}, repoSession *repo.RepoSession, dbConf *comm.AssetDbConf) error {
-
-	filters := []bson.M{}
-	keyfilters := []bson.M{}
-	//keyword
-	if query["keyword"] != nil {
-		keyword := query["keyword"].(string)
-		if len(keyword) > 0 {
-			keyfilters = append(keyfilters, bson.M{"name": bson.M{"$regex": keyword, "$options": "$i"}})
-			keyfilters = append(keyfilters, bson.M{"cusNum": bson.M{"$regex": keyword, "$options": "$i"}})
-			filters = append(filters, bson.M{"$or": keyfilters})
-		}
-		query["keyword"] = nil
-	}
-
-	if query["cusCategories"] != nil && query["cateId"] != nil {
-
-		categories := query["categories"].([]interface{})
-
-		cateId := query["cateId"].(string)
-		//查询所有子内容
-		if len(categories) > 0 {
-			cateConf := &comm.DbCategory{}
-			filterCaties := []string{}
-			//查询用户的
-			ok, _ := repo.RepoSeachDoc(repoSession, &repo.DocSearchOptions{CollectName: repo.CollectionCategories, Query: repo.Map{"_id": cateId}}, cateConf)
-			if !ok {
-				return fmt.Errorf("cate get error")
-			}
-
-			for _, c := range categories {
-				if c != nil {
-					if str, ok := c.(string); ok {
-						filterCaties = append(filterCaties, str)
-					}
-				}
-
-			}
-			extends, _ := FindCategoryIds(cateConf, filterCaties)
-			if len(extends) > 0 {
-				filter := bson.M{"categories": bson.M{"$elemMatch": bson.M{"$in": extends}}}
-				filters = append(filters, filter)
-			}
-		}
-		query["cusCategories"] = nil
-		query["cateId"] = nil
-	}
-
-	if query["cusCategories"] != nil && query["cateConfJson"] != nil {
-		categories := query["cusCategories"].([]interface{})
-		cnfJson := query["cateConfJson"].(string)
-		if len(cnfJson) > 0 {
-			cateConf := &comm.DbCategory{}
-			err := json.Unmarshal([]byte(cnfJson), cateConf)
-			if err != nil {
-				return fmt.Errorf("parse cateConfJson string error")
-			}
-
-			// filterCaties := []string{}
-			for _, c := range categories { //每个对于一种分类
-				currCate := c.(string)
-				if len(currCate) > 0 {
-					extends, _ := FindCategoryIds(cateConf, []string{currCate})
-					if len(extends) > 0 {
-						filter := bson.M{"cusCategories": bson.M{"$elemMatch": bson.M{"$in": extends}}}
-						filters = append(filters, filter)
-					}
-				}
-				// filterCaties = append(filterCaties, c.(string))
-			}
-			// extends := FindCategoryIds(cateConf, filterCaties)
-			// if len(extends) > 0 {
-			// 	filter := bson.M{"cusCategories": bson.M{"$elemMatch": bson.M{"$in": extends}}}
-			// 	filters = append(filters, filter)
-			// }
-		}
-		query["cusCategories"] = nil
-		query["cateConfJson"] = nil
-	}
-
-	if query["categories"] != nil && dbConf.Db.Categories != nil {
-
-		categories := query["categories"].([]interface{})
-		delete(query, "categories")
-
-		//查询所有子内容
-		if len(categories) > 0 {
-			cateConf := dbConf.Db.Categories
-			filterCaties := []string{}
-
-			for _, c := range categories {
-				if c != nil {
-					if str, ok := c.(string); ok {
-						filterCaties = append(filterCaties, str)
-					}
-				}
-			}
-			oldextends, andExtends := FindCategoryIds(cateConf, filterCaties)
-			// extends, andExtends := FindCategoryIds(cateConf, filterCaties)
-			// if len(extends) > 0 {
-			// 	filter := bson.M{"categories": bson.M{"$elemMatch": bson.M{"$in": extends}}}
-			// 	filters = append(filters, filter)
-			// }
-			fmt.Println("old and :=============================================")
-			fmt.Println(oldextends)
-			fmt.Println(andExtends)
-			// todo待测试
-			// !多个分类筛选,包含在所有分类中
-			andArrayCons := []bson.M{}
-			// if len(andExtends) > 0 {
-			// 	for _, cateCon := range andExtends {
-			// 		if len(cateCon) > 0 {
-			// 			andArrayCons = append(andArrayCons, bson.M{"categories": bson.M{"$elemMatch": bson.M{"$in": cateCon}}})
-			// 		}
-			// 	}
-			// 	// !20250102 fix
-			// 	if len(andArrayCons) > 0 {
-			// 		filters = append(filters, bson.M{"$and": andArrayCons})
-			// 	}
-			// } else {
-			// 	// !20250102 fix
-			// 	// 如果没有子分类 传递的categories是叶子分类
-			// 	query["categories"] = bson.M{"$elemMatch": bson.M{"$in": filterCaties}}
-
-			// }
-			if len(andExtends) > 0 {
-				for _, cateCon := range andExtends {
-					if len(cateCon) > 0 {
-						andArrayCons = append(andArrayCons, bson.M{"categories": bson.M{"$elemMatch": bson.M{"$in": cateCon}}})
-					}
-				}
-			}
-			if len(andArrayCons) > 0 {
-				filters = append(filters, bson.M{"$and": andArrayCons})
-			}
-
-		}
-		// query["categories"] = nil
-
-	}
-
-	if len(filters) > 0 {
-		query["$and"] = filters
-	}
-	fmt.Println("分类条件:==========================================>")
-	fmt.Printf("%#v\n", query)
-
-	return nil
-}

+ 0 - 16
tree/assetcenter/bus/user.go

@@ -1,16 +0,0 @@
-package bus
-
-import (
-	"assetcenter/db/model"
-)
-
-func GetUserInfo(id string) (user *model.User, err error) {
-
-	// payload := map[string]string{"id": id}
-	//
-	// NatsCenter.RequestPackApi()
-
-	// err = nats.bus.Request("user.op.info", payload, 3*time.Second, user)
-
-	return
-}

+ 0 - 170
tree/assetcenter/bus/utils.go

@@ -1,170 +0,0 @@
-package bus
-
-import (
-	"assetcenter/conf"
-	"assetcenter/log"
-	"crypto/sha256"
-	"encoding/json"
-	"errors"
-	"fmt"
-	"io"
-	"net/http"
-	"path"
-	"strings"
-)
-
-type SortMilvusSearchSlice []*MlivusSearchRes
-
-func (s SortMilvusSearchSlice) Len() int {
-	return len(s)
-}
-
-func (s SortMilvusSearchSlice) Swap(i, j int) {
-	s[i], s[j] = s[j], s[i]
-}
-
-func (s SortMilvusSearchSlice) Less(i, j int) bool {
-	return s[i].Score < s[j].Score
-}
-
-func RemoveDuplicateMilvusSearch(slice []*MlivusSearchRes) []*MlivusSearchRes {
-	keys := make(map[string]bool)
-	list := make([]*MlivusSearchRes, 0)
-
-	for _, entry := range slice {
-		if _, value := keys[entry.ProductId]; !value {
-			keys[entry.ProductId] = true
-			list = append(list, entry)
-		}
-	}
-
-	return list
-}
-
-type MlivusDeleteRes struct {
-	Status bool   `json:"status"`
-	Msg    string `json:"msg"`
-}
-
-func deleteImageToMlivus(tableName, product_id string) {
-	im_hash := product_id
-
-	req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", conf.AppConfig.SearchImageAddr, "/delete/record"), nil)
-	if err != nil {
-		log.Error(err)
-		return
-	}
-	q := req.URL.Query()
-	q.Add("table_name", tableName)
-	q.Add("im_hash", im_hash)
-	req.URL.RawQuery = q.Encode()
-	rep, err := http.DefaultClient.Do(req)
-	if err != nil {
-		log.Error(err)
-		return
-	}
-	defer rep.Body.Close()
-	res, _ := io.ReadAll(rep.Body)
-	uploadRes := MlivusDeleteRes{}
-	err = json.Unmarshal(res, &uploadRes)
-	if err != nil {
-		log.Error(err)
-		return
-	}
-
-}
-
-type MlivusSearchRes struct {
-	ImHash    string  `json:"im_hash"`
-	ProductId string  `json:"product_id"`
-	Score     float64 `json:"score"`
-}
-
-func searchImageToMlivus(tableName, url string) ([]*MlivusSearchRes, error) {
-	ext := strings.ToLower(path.Ext(url))
-	if ext != ".jpg" && ext != ".png" && ext != ".jpeg" {
-		return nil, errors.New("只支持jpg/png/jpeg图片")
-	}
-	req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", conf.AppConfig.SearchImageAddr, "/img/search"), nil)
-	if err != nil {
-		log.Error(err)
-		return nil, errors.New("上传文件请求配置失败")
-	}
-	q := req.URL.Query()
-	q.Add("table_name", tableName)
-	q.Add("url", url)
-	req.URL.RawQuery = q.Encode()
-	rep, err := http.DefaultClient.Do(req)
-	if err != nil {
-		log.Error(err)
-		return nil, errors.New("处理图片失败")
-	}
-	defer rep.Body.Close()
-	res, _ := io.ReadAll(rep.Body)
-	uploadRes := []*MlivusSearchRes{}
-	err = json.Unmarshal(res, &uploadRes)
-	if err != nil {
-		fmt.Println(err)
-		return nil, err
-	}
-	return uploadRes, nil
-}
-
-type MlivusUploadRes struct {
-	ImHash string `json:"id"`
-}
-
-func uploadImageToMlivus(tableName, productId, url string) {
-	im_hash := productId
-	// ext := strings.ToLower(path.Ext(url))
-	// fmt.Println(ext)
-	// if ext != ".jpg" && ext != ".png" && ext != ".jpeg" {
-	// 	log.Error("只支持jpg/png/jpeg图片")
-	// 	return
-	// }
-	req, err := http.NewRequest("POST", fmt.Sprintf("%s%s", conf.AppConfig.SearchImageAddr, "/img/upload"), nil)
-	if err != nil {
-		log.Error(err)
-		return
-	}
-	q := req.URL.Query()
-	q.Add("table_name", tableName)
-	q.Add("product_id", productId)
-	q.Add("im_hash", im_hash)
-	q.Add("url", url)
-	req.URL.RawQuery = q.Encode()
-	rep, err := http.DefaultClient.Do(req)
-	if err != nil {
-		log.Error(err)
-		return
-	}
-	defer rep.Body.Close()
-	res, _ := io.ReadAll(rep.Body)
-	uploadRes := MlivusUploadRes{}
-	err = json.Unmarshal(res, &uploadRes)
-	if err != nil {
-		log.Error(err)
-		return
-	}
-
-}
-
-func getImageHash(url string) string {
-	data := []byte(url)
-	hasher := sha256.New()
-	hasher.Write(data)
-	hash := hasher.Sum(nil)
-
-	return fmt.Sprintf("%x", hash)
-}
-
-// func getUserById(apictx *ApiSession, id primitive.ObjectID) (*model.UserSmaple, error) {
-// 	user := &model.UserSmaple{}
-// 	_, err := repo.RepoSeachDoc(apictx.CreateRepoCtx(), &repo.DocSearchOptions{
-// 		Db:          "user",
-// 		CollectName: repo.CollectionUsers,
-// 		Query:       repo.Map{"_id": id},
-// 		Project:     []string{"name", "avatar", "city", "loginName"},
-// 	}, user)
-// 	return user, err
-// }

+ 0 - 238
tree/assetcenter/conf/app.go

@@ -1,238 +0,0 @@
-package conf
-
-import (
-	"fmt"
-	"os"
-	"strconv"
-	"strings"
-
-	"assetcenter/log"
-
-	"github.com/spf13/viper"
-)
-
-const (
-	SaveType_Obs   = "obs"
-	SaveType_OSS   = "oss"
-	SaveType_Minio = "minio"
-)
-
-type TaskConfig struct {
-	Name              string
-	Broker            string
-	DefaultQueue      string
-	ResultBackend     string
-	ResultsExpireIn   int32
-	AmqpExchange      string
-	AmqpExchangeType  string
-	AmqpBindingKey    string
-	AmqpPrefetchCount int32
-}
-
-type AppAsset struct {
-	Name            string //鞋楦
-	Type            string //"last"
-	IsMesh          bool   //是否转换模型true
-	IsImage         bool
-	DefaultCategory []string //默认的目录设定
-}
-
-type AppCatogry struct {
-	Scope           string //global全局设定 qiye 企业级设定
-	StartUpdate     bool   //程序启动的时候是否更新category 表数据 和 AssetCategry表的数据
-	QiyeUserId      string //scope为qiye的时候默认企业主账号ID
-	DefaultCategory []*DefaultCategoryConf
-}
-
-type DefaultCategoryConf struct {
-	Children []*DefaultCategoryConf
-	Name     string //分类名字
-	Value    string //分类的值
-}
-
-type MinioConfig struct {
-	Bucket    string
-	Endpoint  string
-	AccessKey string
-	AccessSec string
-}
-
-type AppConf struct {
-	Name     string
-	Version  string
-	SaveType string //obs, oss, minio
-
-	LocalSaveMode bool //本地存储模式, 数据库里面只存储key, 不存储host地址,以便应对本地IP变化后,无法访问资源的问题。
-	Assets        []*AppAsset
-
-	Category *AppCatogry
-	Jwt      struct {
-		Realm       string
-		Key         string
-		TimeoutHour int
-	}
-
-	Etcd struct {
-		Endpoints   []string
-		UserName    string
-		Password    string
-		DialTimeout int64
-	}
-	Mysql struct {
-		DSN string
-	}
-	Redis struct {
-		Addr     string
-		Password string // no password set
-		Db       int    // use default DB
-	}
-	Log struct {
-		FileName    string
-		Level       int32
-		ServiceName string
-	}
-	Port  int32
-	Mongo struct {
-		DSN      string
-		Database string
-	}
-
-	Debug struct {
-		UserId    string
-		UserPhone string
-		UserRole  string
-	}
-
-	Obs struct {
-		Bucket      string
-		AccessKeyId string
-		SecrateKey  string
-		Endpoint    string
-	}
-
-	Minio MinioConfig
-
-	Nats struct {
-		Url               string
-		MaxReconnect      int
-		ReconnDelaySecond int
-
-		MeshProcStreamTopic  string
-		HdrProcStreamTopic   string
-		OsgConvStreamTopic   string
-		OsgShadowStreamTopic string
-		HdrConvStreamTopic   string
-	}
-
-	TaskCenter string
-	TreeDNS    string
-
-	TrimLocalUrl    string
-	SearchImageAddr string
-}
-
-func (c *AppConf) IsSaveLocal() bool {
-	return c.LocalSaveMode && c.SaveType == SaveType_Minio
-}
-
-func (c *AppConf) TrimSaveLocalUrl(src string) string {
-	if strings.HasPrefix(src, c.TrimLocalUrl) {
-		return strings.TrimPrefix(src, c.TrimLocalUrl)
-	}
-	return src
-}
-
-func (c *AppConf) GetSaveLocalUrl(src string) string {
-	if len(src) < 1 {
-		return src
-	}
-	if strings.HasPrefix(src, "http://") || strings.HasPrefix(src, "//") || strings.HasPrefix(src, "https://") {
-		return src
-	}
-	return "//" + c.Minio.Endpoint + "/" + src
-}
-
-func LoadConfFile(filepath string) (*AppConf, error) {
-	file, err := os.Open(filepath)
-	if err != nil {
-		log.Errorf("can not open file:%s", filepath)
-		return nil, err
-	}
-	v := viper.New()
-	v.SetConfigType("yaml")
-	err = v.ReadConfig(file)
-	if err != nil {
-		return nil, err
-	}
-	c := new(AppConf)
-	err = v.Unmarshal(c)
-	return c, err
-}
-
-func NewAppConf(filePath string) (*AppConf, error) {
-
-	c, err := LoadConfFile(filePath)
-	if err != nil {
-		return c, err
-	}
-
-	//初始化log
-	_ = log.NewLoggerSugar(c.Log.ServiceName, c.Log.FileName, c.Log.Level)
-
-	//环境变量
-	mongo := os.Getenv("MONGO")
-	fmt.Println("env MONGO=>", mongo)
-
-	if len(mongo) > 0 {
-		c.Mongo.DSN = mongo
-		//解析出database mongodb://admin:123456@124.70.148.113:27018/sku3d_dadong?authSource=admin
-		start := strings.LastIndex(mongo, "/")
-		end := strings.LastIndex(mongo, "?")
-		database := mongo[start+1 : end]
-		if len(database) > 0 {
-			c.Mongo.Database = database
-		}
-		fmt.Println(c.Mongo.DSN, c.Mongo.Database)
-	}
-	//redis
-	redis := os.Getenv("REDIS")
-	fmt.Println("Env REDIS=>", redis)
-
-	if len(redis) > 0 {
-		c.Redis.Addr = redis
-		start := strings.LastIndex(redis, "/")
-		if start > 0 {
-			db := redis[start:]
-			dbint, _ := strconv.Atoi(db)
-			c.Redis.Db = dbint
-			c.Redis.Addr = string(redis[0:start])
-		}
-
-		fmt.Println(c.Redis.Addr, c.Redis.Db)
-	}
-	//taskCenter
-	natsHost := os.Getenv("NATS")
-	if len(natsHost) > 0 {
-		c.Nats.Url = natsHost
-	}
-	fmt.Println("Env NATS=>", natsHost)
-
-	//taskCenter
-	treeDns := os.Getenv("TREEDNS")
-	if len(treeDns) > 0 {
-		c.TreeDNS = treeDns
-	}
-	fmt.Println("Env TREEDNS=>", c.TreeDNS)
-
-	searchImageAddr := os.Getenv("SEARCH_IMAGE_ADDR")
-	if len(searchImageAddr) > 0 {
-		c.SearchImageAddr = searchImageAddr
-	}
-	fmt.Println("search image addr=>", searchImageAddr)
-
-	AppConfig = c
-
-	return c, nil
-}
-
-var AppConfig *AppConf = nil

+ 0 - 45
tree/assetcenter/db/db.go

@@ -1,45 +0,0 @@
-package db
-
-import (
-	"go.mongodb.org/mongo-driver/mongo"
-	"infish.cn/comm"
-)
-
-type MongoDB struct {
-	Client   *mongo.Client
-	Database *mongo.Database
-
-	Databases map[string]*mongo.Database //所有数据库
-}
-
-var MongoClient *MongoDB
-
-func (db *MongoDB) GetCollection(name string) *mongo.Collection {
-	return db.Database.Collection(name)
-}
-
-func (db *MongoDB) GetDbCollection(dbname string, name string) *mongo.Collection {
-	if len(dbname) < 1 {
-		return db.GetCollection(name)
-	}
-	return db.GetOrCreateDatabase(dbname).Collection(name)
-}
-
-func (db *MongoDB) GetOrCreateDatabase(name string) *mongo.Database {
-	datab := db.Databases[name]
-	if datab == nil {
-		datab = db.Client.Database(name)
-		db.Databases[name] = datab
-	}
-	return datab
-}
-
-func NewMongoDB(bus *comm.NatsBus) *MongoDB {
-	inst, err := bus.NewMongoDBFromConfig("tree-mongo")
-	if err != nil {
-		panic(err)
-	}
-
-	MongoClient = &MongoDB{Client: inst.Client, Database: inst.Database, Databases: map[string]*mongo.Database{}}
-	return MongoClient
-}

+ 0 - 51
tree/assetcenter/db/model/application.go

@@ -1,51 +0,0 @@
-package model
-
-import "go.mongodb.org/mongo-driver/bson/primitive"
-
-type AppAssetDef struct {
-	Name         string //资产名字
-	Desc         string //资产使用简介
-	Type         int    //资产类型
-	DbId         string //数据库Id
-	CollectionId string //数据表Id
-}
-
-type Database3dApp struct {
-	Id                       primitive.ObjectID `bson:"_id,omitempty" json:"_id"`                                     //
-	Name                     string             `bson:"name,omitempty" json:"name"`                                   //应用名字
-	AppIcon                  string             `bson:"appIcon,omitempty" json:"appIcon"`                             //应用图标
-	Desc                     string             `bson:"desc,omitempty" json:"desc"`                                   //应用描述
-	HomePageUrl              string             `bson:"homepageUrl,omitempty" json:"homepageUrl"`                     //应用网页地址
-	AuthorizationCallbackUrl string             `bson:"authorizedCallbackUrl,omitempty" json:"authorizedCallbackUrl"` //授权后回调地址
-
-	AppKey     string `bson:"appKey,omitempty" json:"appKey"`
-	AppSecrete string `bson:"appSecrete,omitempty" json:"appSecrete"`
-
-	//输入资产定义
-	InputAssetConfs []*AppAssetDef `bson:"inputAssetConfs,omitempty" json:"inputAssetConfs"`
-
-	//输出资产定义
-	OutputAssetConfs []*AppAssetDef `bson:"outputAssetConfs,omitempty" json:"outputAssetConfs"`
-}
-
-var Spu3dApp = &Database3dApp{
-	InputAssetConfs: []*AppAssetDef{
-		&AppAssetDef{
-			Name:         "盒型",
-			DbId:         "001",
-			CollectionId: "1111",
-		}, &AppAssetDef{
-			Name:         "场景",
-			DbId:         "001",
-			CollectionId: "1111",
-		},
-	},
-}
-
-type UserAssetOAuths struct {
-	Id               primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId           primitive.ObjectID `bson:"userId,omitempty" json:"userId"`
-	AppId            primitive.ObjectID `bson:"appId,omitempty" json:"appId"`
-	InputAssetConfs  []*AppAssetDef     `bson:"inputAssetConfs,omitempty" json:"inputAssetConfs"`
-	OutputAssetConfs []*AppAssetDef     `bson:"outputAssetConfs,omitempty" json:"outputAssetConfs"`
-}

+ 0 - 167
tree/assetcenter/db/model/asset.go

@@ -1,167 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-const (
-	AssetState_Created      = 1
-	AssetState_Complated    = 2
-	AssetState_Publish2Qiye = 3
-)
-
-const (
-	MeshState_SetFile   = 0 //create
-	MeshState_SetOsgjs  = 1 //模型转换到osgjs了,可以用于webgl显示了
-	MeshState_SetShadow = 2 //阴影已生成
-)
-
-type Asset struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-
-	Categories []string `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
-
-	State int32 `bson:"state,omitempty" json:"state"` //是否公开
-
-	Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
-
-	//图片相关
-	Image *OssType `bson:"image,omitempty" json:"image"`
-
-	//模型相关
-	Materials *[]struct {
-		Name string     `bson:"name" json:"name"`
-		Data *MatConfig `bson:"data" json:"data"`
-	} `bson:"materials,omitempty" json:"materials"`
-	Geometries []string `bson:"geometries,omitempty" json:"geometries"`
-	Osgjs      *OssType `bson:"osgjs,omitempty" json:"osgjs"`
-	File       *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
-	Shadow     *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
-	MeshState  *int32   `bson:"meshState,omitempty" json:"meshState,omitempty"`
-}
-type UvSize struct {
-	Width  int `bson:"width,omitempty" json:"width,omitempty"`
-	Height int `bson:"height,omitempty" json:"height,omitempty"`
-}
-
-type MeshMatConf struct {
-	UvMap        *OssType       `bson:"uvmap" json:"uvmap"`
-	UvSize       *UvSize        `bson:"uvsize" json:"uvsize"`
-	Name         string         `bson:"name" json:"name"`
-	Material     *MatConfig     `bson:"material" json:"material"`
-	TechMaterial *TechMatConfig `bson:"techMaterial" json:"techMaterial"`
-
-	Index   int               `bson:"index" json:"index"`
-	Images  []*ComponentImage `bson:"images" json:"images"`
-	Visible *bool             `bson:"visible" json:"visible"`
-}
-
-type AssetDecorateMesh struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	State      int                `bson:"state,omitempty" json:"state"` //created completed published
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Categories []string           `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
-
-	Components []*MeshMatConf `bson:"components,omitempty" json:"components"`
-	Osgjs      *OssType       `bson:"osgjs,omitempty" json:"osgjs"`
-	File       *OssType       `bson:"file,omitempty" json:"file"` //hdr or fbx
-	Shadow     *OssType       `bson:"shadow,omitempty" json:"shadow,omitempty"`
-}
-
-type AssetTexture struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	Categories []string           `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
-	State      int32              `bson:"state,omitempty" json:"state"`                     //是否公开
-	Image      *OssType           `bson:"image,omitempty" json:"image"`
-}
-
-/*盒型*/
-type Boxtpl struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	State      int                `bson:"state,omitempty" json:"state"` //created completed published
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Categories []string           `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
-
-	Osgjs  *OssType `bson:"osgjs,omitempty" json:"osgjs"`
-	File   *OssType `bson:"file,omitempty" json:"file"` //模型文件
-	Shadow *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
-
-	Type int `bson:"type,omitempty" json:"type,omitempty"` //动态生成或模型文件 默认模型
-
-	Components []*BoxtplComponent `bson:"components,omitempty" json:"components"` //模板部件
-}
-
-type BoxtplComponent struct {
-	Name  string        `bson:"name,omitempty" json:"name"`
-	Index int           `bson:"index,omitempty" json:"index"`
-	UV    *BoxtplCompUv `bson:"uv,omitempty" json:"uv"`
-}
-
-type BoxtplCompUv struct {
-	Width  uint    `bson:"width,omitempty" json:"width"`
-	Height uint    `bson:"height,omitempty" json:"height"`
-	Image  OssType `bson:"image,omitempty" json:"image"`
-}
-
-/*项目的盒型*/
-type ProjectBoxtpl struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	ProjectId  primitive.ObjectID `bson:"projectId,omitempty" json:"projectId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-
-	Osgjs  *OssType `bson:"osgjs,omitempty" json:"osgjs"`
-	File   *OssType `bson:"file,omitempty" json:"file"` //模型文件
-	Shadow *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
-	Type   int      `bson:"type,omitempty" json:"type,omitempty"` //动态生成或模型文件 默认模型
-
-	Components []*BoxtplComponent `bson:"components,omitempty" json:"components"` //模板部件
-}
-
-type ProjectDecorateMesh struct {
-	Id        primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	ProjectId primitive.ObjectID `bson:"projectId,omitempty" json:"projectId,omitempty"`
-
-	Name       string    `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail"`
-
-	Osgjs  *OssType `bson:"osgjs,omitempty" json:"osgjs"`
-	File   *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
-	Shadow *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
-
-	Materials []*MeshMatConf `bson:"materials,omitempty" json:"materials"`
-}
-
-type AssetMaterial struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"` //用户ID
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	Config     *MatConfig         `bson:"config,omitempty" json:"config"`
-	State      int                `bson:"state,omitempty" json:"state"`                     //created completed published
-	Categories []string           `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
-}

+ 0 - 195
tree/assetcenter/db/model/database.go

@@ -1,195 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"infish.cn/comm"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-const (
-	AssetTypeMesh          = 10 //"mesh"     //模型
-	AssetTypeImage         = 20 //"image"    //图片
-	AssetTypeMaterial      = 30 //"material" //材质球
-	AssetTypeMaterialGroup = 31 //"material" //材质球组
-	AssetTypeEnv3d         = 40 //"hdr "      //环境球
-	AssetTypePackage       = 50 //"package "  //3d资产包
-
-	AssetState_Empty    = 0
-	AssetState_Waiting  = 100 //等待处理
-	AssetState_Proccing = 101 //正在处理
-	AssetState_Failed   = 102 //处理失败!
-	AssetState_Succ     = 200 //处理成功
-)
-
-type DatabaseAssetV0 struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id"`       //数据库Id
-	UserId string             `bson:"userId,omitempty" json:"userId"` //数据库Id
-
-	Name       string    `bson:"name,omitempty" json:"name"`   //数据库名字
-	Label      string    `bson:"label,omitempty" json:"label"` //前端展示标签
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-
-	Categories *comm.DbCategory `bson:"categories,omitempty" json:"categories"` //数据的分类
-	Assets     *comm.DbAsset    `bson:"assets,omitempty" json:"assets"`         //资产定义
-}
-
-type Obb struct {
-	Min Vec3Obj `bson:"min,omitempty" json:"min"`
-	Max Vec3Obj `bson:"max,omitempty" json:"max"`
-}
-
-type StaticMesh struct {
-	Id      primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	OwnerId primitive.ObjectID `bson:"ownerId,omitempty" json:"ownerId,omitempty"`
-
-	Name       string    `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-	State      int       `bson:"state,omitempty" json:"state"` //created completed published
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Categories []string  `bson:"categories,omitempty" json:"categories,omitempty"` //所属分类Id
-
-	Components []*MeshMatConf `bson:"components,omitempty" json:"components"`
-	Osgjs      *OssType       `bson:"osgjs,omitempty" json:"osgjs"`
-	File       *OssType       `bson:"file,omitempty" json:"file"` //hdr or fbx
-	Shadow     *OssType       `bson:"shadow,omitempty" json:"shadow,omitempty"`
-	Obb        *Obb           `bson:"obb,omitempty" json:"obb,omitempty"`
-}
-
-type AssetBase struct {
-	OwnerId    primitive.ObjectID `bson:"ownerId,omitempty" json:"ownerId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Categories []string           `bson:"categories,omitempty" json:"categories"` //所属分类Id
-	TaskId     string             `bson:"taskId,omitempty" json:"taskId"`         //资产处理id
-	AssetState int                `bson:"assetState,omitempty" json:"assetState"`
-	Enable     *bool              `bson:"enable,omitempty" json:"enable"` //是否有效!
-}
-
-type StaticMeshSource struct {
-	Components  []*MeshMatConf `bson:"components,omitempty" json:"components"`
-	Osgjs       *OssType       `bson:"osgjs,omitempty" json:"osgjs"`
-	File        *OssType       `bson:"file,omitempty" json:"file"` //hdr or fbx
-	Glb         *OssType       `bson:"glb,omitempty" json:"glb"`   //hdr or fbx
-	Shadow      *OssType       `bson:"shadow,omitempty" json:"shadow,omitempty"`
-	BoundingBox *Obb           `bson:"boundingBox,omitempty" json:"boundingBox,omitempty"`
-}
-
-type HdrSource struct {
-	Config  *Evn3dHdrConf `bson:"config,omitempty" json:"config"`
-	File    *OssType      `bson:"file,omitempty" json:"file"` //hdr or fbx
-	Options *Env3dOption  `bson:"options,omitempty" json:"options"`
-	ToneMap *ToneMap      `bson:"toneMap,omitempty" json:"toneMap"`
-}
-
-type ImageSource struct {
-	File *OssType `bson:"file,omitempty" json:"file"` //hdr or fbx
-}
-
-type AssetUserInfo struct {
-	Name      string   `bson:"name,omitempty" json:"name"`
-	Thumbnail *OssType `bson:"thumbnail,omitempty" json:"thumbnail"`
-}
-
-type IAsset interface {
-	SetIdEmpty()
-	ResetCreateTime()
-	SetOwner(id string, otype string)
-	SetAssetType(atype string)
-	SetUserInfo(id string, info *comm.AssetUserInfo)
-}
-
-type AssetStaticMesh struct {
-	Id        primitive.ObjectID  `bson:"_id,omitempty" json:"_id"`
-	UserId    primitive.ObjectID  `bson:"userId,omitempty" json:"userId,omitempty"`       //用户Id
-	UserInfo  *comm.AssetUserInfo `bson:"userInfo,omitempty" json:"userInfo,omitempty"`   //用户Id
-	OwnerId   primitive.ObjectID  `bson:"ownerId,omitempty" json:"ownerId,omitempty"`     //userId teamId companyId
-	OwnerType string              `bson:"ownerType,omitempty" json:"ownerType,omitempty"` //user team company
-	AssetType string              `bson:"assetType,omitempty" json:"assetType,omitempty"` //user team company
-
-	Name   string `bson:"name,omitempty" json:"name"`
-	CusNum string `bson:"cusNum,omitempty" json:"cusNum,omitempty"` //型号
-
-	CreateTime    time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime    time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-	Thumbnail     *OssType  `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Categories    []string  `bson:"categories,omitempty" json:"categories"`       //所属分类Id
-	CusCategories []string  `bson:"cusCategories,omitempty" json:"cusCategories"` //用户自定义分类
-	TaskId        string    `bson:"taskId,omitempty" json:"taskId"`               //资产处理id
-	AssetState    int       `bson:"assetState,omitempty" json:"assetState"`
-	Enable        *bool     `bson:"enable,omitempty" json:"enable"` //是否有效!
-
-	Source *StaticMeshSource `bson:"source,omitempty" json:"source,omitempty"`
-
-	UserData interface{} `bson:"userData,omitempty" json:"userData,omitempty"` //用户数据
-}
-
-func (s *AssetStaticMesh) SetIdEmpty() {
-	s.Id = primitive.NilObjectID
-}
-
-func (s *AssetStaticMesh) ResetCreateTime() {
-	s.CreateTime = time.Now()
-	s.UpdateTime = time.Now()
-}
-
-func (s *AssetStaticMesh) SetOwner(id string, otype string) {
-	s.OwnerId, _ = primitive.ObjectIDFromHex(id)
-	s.OwnerType = otype
-}
-
-func (s *AssetStaticMesh) SetUserInfo(id string, info *comm.AssetUserInfo) {
-	s.UserId, _ = primitive.ObjectIDFromHex(id)
-	s.UserInfo = info
-}
-
-func (s *AssetStaticMesh) SetAssetType(otype string) {
-	s.AssetType = otype
-}
-
-type AssetMat struct {
-	Id        primitive.ObjectID  `bson:"_id,omitempty" json:"_id"`
-	UserId    primitive.ObjectID  `bson:"userId,omitempty" json:"userId,omitempty"`     //用户Id
-	UserInfo  *comm.AssetUserInfo `bson:"userInfo,omitempty" json:"userInfo,omitempty"` //用户Id
-	OwnerId   primitive.ObjectID  `bson:"ownerId,omitempty" json:"ownerId,omitempty"`
-	OwnerType string              `bson:"ownerType,omitempty" json:"ownerType,omitempty"` //user team company
-	AssetType string              `bson:"assetType,omitempty" json:"assetType,omitempty"` //user team company
-
-	CusNum string `bson:"cusNum,omitempty" json:"cusNum,omitempty"` //型号
-	Name   string `bson:"name,omitempty" json:"name"`
-
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Categories []string  `bson:"categories,omitempty" json:"categories"` //所属分类Id
-	TaskId     string    `bson:"taskId,omitempty" json:"taskId"`         //资产处理id
-	AssetState int       `bson:"assetState,omitempty" json:"assetState"`
-	Enable     *bool     `bson:"enable,omitempty" json:"enable"` //是否有效!
-
-	Source *MatConfig `bson:"source,omitempty" json:"source,omitempty"`
-
-	UserData interface{} `bson:"userData,omitempty" json:"userData,omitempty"` //用户数据
-}
-
-func (s *AssetMat) SetIdEmpty() {
-	s.Id = primitive.NilObjectID
-}
-func (s *AssetMat) ResetCreateTime() {
-	s.CreateTime = time.Now()
-	s.UpdateTime = time.Now()
-}
-func (s *AssetMat) SetOwner(id string, otype string) {
-	s.OwnerId, _ = primitive.ObjectIDFromHex(id)
-	s.OwnerType = otype
-}
-func (s *AssetMat) SetAssetType(otype string) {
-	s.AssetType = otype
-}
-func (s *AssetMat) SetUserInfo(id string, info *comm.AssetUserInfo) {
-	s.UserId, _ = primitive.ObjectIDFromHex(id)
-	s.UserInfo = info
-}

+ 0 - 37
tree/assetcenter/db/model/decorate.go

@@ -1,37 +0,0 @@
-package model
-
-// CREATE TABLE `execute_snapshot_his` (
-//  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
-//  `snapshot_id` varchar(32) NOT NULL,
-//  `job_name` varchar(32) NOT NULL,
-//  `group` varchar(32) NOT NULL,
-//  `cron` varchar(255) DEFAULT NULL,
-//  `target` varchar(255) DEFAULT NULL,
-//  `ip` varchar(32) DEFAULT NULL,
-//  `param` varchar(255) DEFAULT NULL,
-//  `state` tinyint(4) DEFAULT NULL,
-//  `before_time` datetime NOT NULL,
-//  `schedule_time` datetime NOT NULL,
-//  `end_time` datetime DEFAULT NULL,
-//  `times` bigint(20) NOT NULL,
-//  `mobile` varchar(32) DEFAULT NULL,
-//  `remark` varchar(32) DEFAULT NULL,
-//  PRIMARY KEY (`id`)
-//) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
-
-type OssType struct {
-	Url  string `bson:"url" json:"url"`
-	Size int64  `bson:"size" json:"size"`
-}
-
-func NewOssTypeWithMap(data map[string]interface{}) *OssType {
-	url := data["url"].(string)
-	size := data["size"].(int64)
-
-	return &OssType{Url: url, Size: size}
-}
-
-type MaterialConfig struct {
-	Id   string
-	Data interface{}
-}

+ 0 - 63
tree/assetcenter/db/model/design.go

@@ -1,63 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type Matrix [16]float64
-
-type SceneLight struct {
-	Id        string  `bson:"id,omitempty" json:"id"`
-	Type      string  `bson:"type,omitempty" json:"type"`
-	Enable    bool    `bson:"enable,omitempty" json:"enable"`
-	Matrix    Matrix  `bson:"matrix,omitempty" json:"matrix"`
-	Color     Vect3   `bson:"color,omitempty" json:"color"`
-	Intensity float64 `bson:"intensity,omitempty" json:"intensity"`
-}
-
-type DesignScene struct {
-	Id         string    `bson:"id,omitempty"  json:"id"`
-	Name       string    `bson:"name,omitempty"  json:"name"` //名字唯一
-	CreateTime time.Time `bson:"createTime,omitempty"  json:"createTime"`
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty"  json:"thumbnail"`
-
-	Product []*SceneProduct `bson:"products"  json:"products"`
-	Env3d   *Env3dConfig    `bson:"env3d,omitempty"  json:"env3d"`
-	Lights  []*SceneLight   `bson:"lights,omitempty"  json:"lights"`
-}
-
-type DesignProduct struct { //设计单品信息
-	Id              primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	ProjectId       primitive.ObjectID `bson:"projectId,omitempty" json:"projectId"`
-	FromDbConfId    string             `bson:"fromDbConfId,omitempty" json:"fromDbConfId"` //数据库定义Id
-	FromAssetConfId string             `bson:"fromAssetConfId,omitempty" json:"fromAssetConfId"`
-	FromId          string             `bson:"fromId,omitempty" json:"fromId"`
-	Name            string             `bson:"name,omitempty"  json:"name"`
-	Thumbnail       *OssType           `bson:"thumbnail,omitempty"  json:"thumbnail"`
-
-	StaticMesh *StaticMeshSource `bson:"staticMesh,omitempty" json:"staticMesh"` //静态模型资产
-	UpdateTime time.Time         `bson:"updateTime,omitempty"  json:"updateTime"`
-}
-
-type ProductHeader struct {
-	Id              string    `bson:"id,omitempty"  json:"id"`
-	FromDbConfId    string    `bson:"fromDbConfId,omitempty" json:"fromDbConfId"` //数据库定义Id
-	FromAssetConfId string    `bson:"fromAssetConfId,omitempty" json:"fromAssetConfId"`
-	FromId          string    `bson:"fromId,omitempty" json:"fromId"`
-	Name            string    `bson:"name,omitempty"  json:"name"`
-	Thumbnail       *OssType  `bson:"thumbnail,omitempty"  json:"thumbnail"`
-	CreateTime      time.Time `bson:"createTime,omitempty"  json:"createTime"`
-}
-
-type Design3d struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Thumbnail  *OssType           `bson:"thumbnail" json:"thumbnail"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"`
-	Products   []*ProductHeader   `bson:"products,omitempty" json:"products"`
-	Scenes     []*DesignScene     `bson:"scenes,omitempty" json:"scenes"`
-}

+ 0 - 45
tree/assetcenter/db/model/env3d.go

@@ -1,45 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type Env3d struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-	State      int                `bson:"state,omitempty" json:"state"` //created completed published
-
-	HDR    *OssType      `bson:"hdr,omitempty" json:"hdr"`
-	Config *Evn3dHdrConf `bson:"config,omitempty" json:"config"`
-
-	Options *Env3dOption `bson:"options,omitempty" json:"options"`
-
-	ToneMap *ToneMap `bson:"toneMap,omitempty" json:"toneMap"`
-
-	Background *Evn3dBackground `bson:"background,omitempty" json:"background"`
-}
-
-type Env3dConfig struct {
-	Id primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-
-	Name       string    `bson:"name,omitempty" json:"name"`
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime time.Time `bson:"updateTime,omitempty" json:"updateTime"`
-
-	HDR     *OssType      `bson:"hdr,omitempty" json:"hdr"`
-	Config  *Evn3dHdrConf `bson:"config,omitempty" json:"config"`
-	Options *Env3dOption  `bson:"options,omitempty" json:"options"`
-}
-
-type Evn3dBackground struct {
-	Color *Vect3   `bson:"color,omitempty" json:"color"`
-	Image *OssType `bson:"image,omitempty" json:"image"`
-	Type  int32    `bson:"type,omitempty" json:"type"`
-}

+ 0 - 115
tree/assetcenter/db/model/mat.go

@@ -1,115 +0,0 @@
-package model
-
-import (
-	"math"
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-const (
-	MatType_2D     = 3
-	MatType_Color  = 0
-	MatType_Effect = 2
-	MatType_Fabric = 1
-)
-
-//2D 面料
-type Mat2d struct {
-	Image *OssType `bson:"image,omitempty" json:"image"`
-	Name  string   `bson:"name,omitempty" json:"name"`
-	// Uvtransform *Uvtransform `bson:"uv,omitempty" json:"uv"`
-}
-
-type ImageMat struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"`
-	Image      *OssType           `bson:"image,omitempty" json:"image"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	Category   string             `bson:"category,omitempty" json:"category"`
-	Category2  string             `bson:"category2,omitempty" json:"category2"`
-
-	IsPublic *bool `bson:"isPublic,omitempty" json:"isPublic"`
-	Platform *bool `bson:"platform,omitempty" json:"platform"` //是否属于平台
-
-	ColorCards []*Mat2d `bson:"colorCards,omitempty" json:"colorCards"` //2D面料
-	Categories []string `bson:"categories,omitempty" json:"categories"` //目录列表
-	State      int32    `bson:"state,omitempty" json:"state"`
-}
-
-type MaterialHeader struct {
-	MatId       primitive.ObjectID `bson:"matId,omitempty" json:"matId"` //材质球Id
-	Thumbnail   *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Name        string             `bson:"name,omitempty" json:"name"`
-	BaseMap     *OssType           `bson:"baseMap,omitempty" json:"baseMap"`
-	NormalMap   *OssType           `bson:"normalMap,omitempty" json:"normalMap"`
-	RoughMap    *OssType           `bson:"roughMap,omitempty" json:"roughMap"`
-	MetalMap    *OssType           `bson:"metalMap,omitempty" json:"metalMap"`
-	Uvtransform *MaterailUv        `bson:"uv,omitempty" json:"uv"`
-}
-
-const MIN = 0.0001
-
-// MIN 为用户自定义的比较精度
-func IsEqualFloat32(f1, f2 float32) bool {
-	return math.Dim(float64(f1), float64(f2)) < MIN
-}
-func IsEqualFloat64(f1, f2 float64) bool {
-	return math.Dim(f1, f2) < MIN
-}
-
-func (mat *MaterialHeader) IsEqual(mat2 *MaterialHeader) bool {
-
-	changed := false
-	if mat.BaseMap == nil || mat2.BaseMap == nil {
-		changed = changed || mat.BaseMap != mat2.BaseMap
-	} else {
-		changed = changed || mat.BaseMap.Url != mat2.BaseMap.Url
-	}
-
-	if mat.NormalMap == nil || mat2.NormalMap == nil {
-		changed = changed || mat.NormalMap != mat2.NormalMap
-	} else {
-		changed = changed || mat.NormalMap.Url != mat2.NormalMap.Url
-	}
-	if mat.RoughMap == nil || mat2.RoughMap == nil {
-		changed = changed || mat.RoughMap != mat2.RoughMap
-	} else {
-		changed = changed || mat.RoughMap.Url != mat2.RoughMap.Url
-	}
-	if mat.MetalMap == nil || mat2.MetalMap == nil {
-		changed = changed || mat.MetalMap != mat2.MetalMap
-	} else {
-		changed = changed || mat.MetalMap.Url != mat2.MetalMap.Url
-	}
-	if changed {
-		return false
-	}
-
-	if mat.Uvtransform == nil || mat2.Uvtransform == nil {
-		changed = mat2.Uvtransform == nil
-	} else {
-		changed = changed || !IsEqualFloat64(mat.Uvtransform.OffsetX, mat2.Uvtransform.OffsetX) ||
-			!IsEqualFloat64(mat.Uvtransform.Scale, mat2.Uvtransform.Scale) ||
-			!IsEqualFloat64(mat.Uvtransform.Rotate, mat2.Uvtransform.Rotate)
-	}
-	return !changed
-}
-
-type Fabric struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	Category   string             `bson:"category,omitempty" json:"category"`
-	Category2  string             `bson:"category2,omitempty" json:"category2"`
-	IsPublic   *bool              `bson:"isPublic,omitempty" json:"isPublic"`
-	Price      float32            `bson:"price,omitempty" json:"price"`
-	ColorCards []*MaterialHeader  `bson:"colorCards,omitempty" json:"colorCards"`
-	Platform   *bool              `bson:"platform,omitempty" json:"platform"`
-	Categories []string           `bson:"categories,omitempty" json:"categories"`
-	State      int32              `bson:"state,omitempty" json:"state"`
-}

+ 0 - 141
tree/assetcenter/db/model/mesh.go

@@ -1,141 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type Mesh struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Category   string             `bson:"category,omitempty" json:"category"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-
-	Osgjsbin  *OssType `bson:"osgjsbin,omitempty" json:"osgjsbin"`
-	Osgjs     *OssType `bson:"osgjs,omitempty" json:"osgjs"`
-	Materials *[]struct {
-		Name string     `bson:"name" json:"name"`
-		Data *MatConfig `bson:"data" json:"data"`
-	} `bson:"materials,omitempty" json:"materials"`
-	Geometries []string `bson:"geometries,omitempty" json:"geometries"`
-	File       *OssType `bson:"file,omitempty" json:"file"`
-	Shadow     *OssType `bson:"shadow,omitempty" json:"shadow,omitempty"`
-	MeshState  *int32   `bson:"meshState,omitempty" json:"meshState,omitempty"`
-}
-
-type ShoeCompDef struct {
-	Node   string `bson:"node,omitempty" json:"node"`
-	MatId  int32  `bson:"matId,omitempty" json:"matId"`
-	Name   string `bson:"name,omitempty" json:"name"`
-	Enable bool   `bson:"enable,omitempty" json:"enable"`
-}
-
-type ShoeMesh struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	MeshId primitive.ObjectID `bson:"meshId,omitempty" json:"meshId,omitempty"`
-
-	Thumbnail      *OssType       `bson:"thumbnail,omitempty" json:"thumbnail,omitempty"`
-	Name           string         `bson:"name,omitempty" json:"name,omitempty"`
-	CreateTime     time.Time      `bson:"createTime,omitempty" json:"createTime,omitempty"`
-	LeftComponents []*ShoeCompDef `bson:"leftComponents,omitempty" json:"leftComponents,omitempty"`
-
-	Sex    uint8  `bson:"sex,omitempty" json:"sex,omitempty"`
-	Season uint8  `bson:"season,omitempty" json:"season,omitempty"`
-	Type   string `bson:"type,omitempty" json:"type,omitempty"`
-
-	IsPublic *bool `bson:"isPublic,omitempty" json:"isPublic,omitempty"`
-	Platform *bool `bson:"platform,omitempty" json:"platform,omitempty"` //是否属于平台
-}
-
-type LastMesh struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	MeshId primitive.ObjectID `bson:"meshId,omitempty" json:"meshId,omitempty"`
-
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail,omitempty"`
-	Name       string    `bson:"name,omitempty" json:"name,omitempty"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`
-
-	Sex    uint8  `bson:"sex,omitempty" json:"sex,omitempty"`
-	Season uint8  `bson:"season,omitempty" json:"season,omitempty"`
-	Type   string `bson:"type,omitempty" json:"type,omitempty"`
-
-	IsPublic   *bool    `bson:"isPublic,omitempty" json:"isPublic,omitempty"`
-	Platform   *bool    `bson:"platform,omitempty" json:"platform,omitempty"` //是否属于平台
-	State      int32    `bson:"state,omitempty" json:"state"`
-	Categories []string `bson:"categories,omitempty" json:"categories,omitempty"` //所有一级分类的id数组 contain filter里面的值
-	MeshState  *int32   `bson:"meshState,omitempty" json:"meshState,omitempty"`
-}
-
-type HeelMesh struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	MeshId primitive.ObjectID `bson:"meshId,omitempty" json:"meshId,omitempty"`
-
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail,omitempty"`
-	Name       string    `bson:"name,omitempty" json:"name,omitempty"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`
-
-	Sex    uint8  `bson:"sex,omitempty" json:"sex,omitempty"`
-	Season uint8  `bson:"season,omitempty" json:"season,omitempty"`
-	Type   string `bson:"type,omitempty" json:"type,omitempty"`
-
-	IsPublic   *bool    `bson:"isPublic,omitempty" json:"isPublic,omitempty"`
-	Platform   *bool    `bson:"platform,omitempty" json:"platform,omitempty"` //是否属于平台
-	State      int32    `bson:"state,omitempty" json:"state"`
-	Categories []string `bson:"categories,omitempty" json:"categories,omitempty"` //所有一级分类的id数组 contain filter里面的值
-	MeshState  *int32   `bson:"meshState,omitempty" json:"meshState,omitempty"`
-}
-
-type DecorateMesh struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	MeshId primitive.ObjectID `bson:"meshId,omitempty" json:"meshId,omitempty"`
-
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail,omitempty"`
-	Name       string    `bson:"name,omitempty" json:"name,omitempty"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`
-
-	Sex    uint8  `bson:"sex,omitempty" json:"sex,omitempty"`
-	Season uint8  `bson:"season,omitempty" json:"season,omitempty"`
-	Type   string `bson:"type,omitempty" json:"type,omitempty"`
-
-	IsPublic   *bool    `bson:"isPublic,omitempty" json:"isPublic,omitempty"`
-	Platform   *bool    `bson:"platform,omitempty" json:"platform,omitempty"` //是否属于平台
-	State      int32    `bson:"state,omitempty" json:"state"`
-	Categories []string `bson:"categories,omitempty" json:"categories,omitempty"` //所有一级分类的id数组 contain filter里面的值
-	MeshState  *int32   `bson:"meshState,omitempty" json:"meshState,omitempty"`
-}
-
-type SoleMesh struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	MeshId primitive.ObjectID `bson:"meshId,omitempty" json:"meshId,omitempty"`
-
-	Thumbnail  *OssType  `bson:"thumbnail,omitempty" json:"thumbnail,omitempty"`
-	Name       string    `bson:"name,omitempty" json:"name,omitempty"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`
-
-	Sex    uint8  `bson:"sex,omitempty" json:"sex,omitempty"`
-	Season uint8  `bson:"season,omitempty" json:"season,omitempty"`
-	Type   string `bson:"type,omitempty" json:"type,omitempty"`
-
-	IsPublic   *bool    `bson:"isPublic,omitempty" json:"isPublic,omitempty"`
-	Platform   *bool    `bson:"platform,omitempty" json:"platform,omitempty"` //是否属于平台
-	State      int32    `bson:"state,omitempty" json:"state"`
-	Categories []string `bson:"categories,omitempty" json:"categories,omitempty"` //所有一级分类的id数组 contain filter里面的值
-	MeshState  *int32   `bson:"meshState,omitempty" json:"meshState,omitempty"`
-}
-
-type StickerImage struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId,omitempty"`
-	Image      *OssType           `bson:"image,omitempty" json:"image,omitempty"`
-	Name       string             `bson:"name,omitempty" json:"name,omitempty"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime,omitempty"`
-	State      int32              `bson:"state,omitempty" json:"state"`
-	Categories []string           `bson:"categories,omitempty" json:"categories,omitempty"` //所有一级分类的id数组 contain filter里面的值
-}

+ 0 - 44
tree/assetcenter/db/model/perms.go

@@ -1,44 +0,0 @@
-package model
-
-import "go.mongodb.org/mongo-driver/bson/primitive"
-
-const (
-	Perm_Root        = "超级管理员"       //超级管理员
-	Perm_SubAccount  = "SubAccount"  //子账号管理
-	Perm_AccountRole = "AccountRole" //角色管理
-
-	Perm_Shoe_Public_list   = "ShoePublicList"   //款式查看企业公开列表
-	Perm_Shoe_Public_edit   = "ShoePublicEdit"   //款式编辑企业公开列表
-	Perm_Shoe_Public_Remove = "ShoePublicRemove" //款式删除权限
-	Perm_Shoe_Upload        = "ShoeUpload"       //款式上传
-	Perm_Shoe_Remove        = "ShoeRemove"       //款式删除
-)
-
-type PermItem struct {
-	Value string `bson:"value,omitempty" json:"value"`
-	Name  string `bson:"name,omitempty" json:"name"`
-}
-
-type Perms struct {
-	Id       primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Group    string             `bson:"group,omitempty" json:"group"`
-	Children []*PermItem        `bson:"children,omitempty" json:"children"`
-}
-
-// func (r *Role) IsPermOk(perm string) bool {
-// 	if r.Name == Perm_Root {
-// 		return true
-// 	}
-
-// 	if r.Perms == nil {
-// 		return false
-// 	}
-// 	for _, p := range r.Perms {
-// 		for _, item := range p.Children {
-// 			if item.Value == perm {
-// 				return true
-// 			}
-// 		}
-// 	}
-// 	return false
-// }

+ 0 - 29
tree/assetcenter/db/model/productTpl.go

@@ -1,29 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type ProductTplComponent struct {
-	Name       string `bson:"name,omitempty" json:"name"`
-	CreateType uint8  `bson:"createType,omitempty" json:"createType"` //0-模型创建 1-dynamic 动态生成
-	Label      string `bson:"label,omitempty" json:"label"`           //ui 显示的名字
-	UV         *struct {
-		Width  uint    `bson:"width,omitempty" json:"width"`
-		Height uint    `bson:"height,omitempty" json:"height"`
-		Image  OssType `bson:"image,omitempty" json:"image"`
-	} `bson:"uv,omitempty" json:"uv"`
-}
-
-type ProductTpl struct {
-	Id         primitive.ObjectID     `bson:"_id,omitempty" json:"_id"`
-	CreateTime time.Time              `bson:"createTime,omitempty" json:"createTime"`
-	MeshId     primitive.ObjectID     `bson:"meshId,omitempty" json:"meshId"`
-	Name       string                 `bson:"name,omitempty" json:"name"`
-	Thumbnail  *OssType               `bson:"thumbnail,omitempty" json:"thumbnail"`
-	Components []*ProductTplComponent `bson:"components,omitempty" json:"components"` //模板部件
-
-	IsPublic *bool `bson:"isPublic,omitempty" json:"isPublic"` //是否公开
-}

+ 0 - 129
tree/assetcenter/db/model/project.go

@@ -1,129 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type Transform struct {
-	Pos   Vect3 `bson:"pos" json:"pos"`
-	Scale Vect3 `bson:"scale" json:"scale"`
-	Rot   Vect3 `bson:"rot" json:"rot"`
-}
-
-type Vect2 [2]float64
-type Vect3 [3]float64
-type Vect4 [4]float64
-
-type VectXYWH struct {
-	Y float64 `bson:"y" json:"y"`
-	X float64 `bson:"x" json:"x"`
-	W float64 `bson:"w" json:"w"`
-	H float64 `bson:"h" json:"h"`
-}
-
-type DynamicProp struct {
-	Label string  `bson:"label"`
-	Name  string  `bson:"name"`
-	Value float32 `bson:"value"`
-	Type  string  `bson:"type"`
-}
-
-type ComponentTransform struct {
-	Translate []float32 `bson:"translate"`
-	Rotate    []float32 `bson:"rotate"`
-}
-
-type ComponentMaterial struct {
-	Thumbnail *OssType       `bson:"thumbnail,omitempty"`
-	Name      string         `bson:"name,omitempty"`
-	Id        string         `bson:"id"`
-	Offset    *Vect2         `bson:"offset"`
-	Repeat    *Vect2         `bson:"repeat"`
-	Props     []*DynamicProp `bson:"props"`
-}
-
-type ComponentImage struct {
-	Id     string   `bson:"id" json:"id"`
-	Image  *OssType `bson:"image" json:"image"`
-	Width  int      `bson:"width" json:"width"`
-	Height int      `bson:"height" json:"height"`
-
-	Position         Vect2   `bson:"position" json:"position"`
-	Scale            Vect2   `bson:"scale" json:"scale"`
-	Rotation         float64 `bson:"rotation" json:"rotation"`
-	FillType         string  `bson:"fillType" json:"fillType"`
-	Technology       string  `bson:"technology" json:"technology"`
-	BasicColor       Vect3   `bson:"basicColor" json:"basicColor"`
-	AotuFactor       float32 `bson:"aotuFactor" json:"aotuFactor"`
-	RoughFactor      float32 `bson:"roughFactor" json:"roughFactor"`
-	ReflectionFactor float32 `bson:"reflectionFactor" json:"reflectionFactor"`
-	MetalFactor      float32 `bson:"metalFactor" json:"metalFactor"`
-}
-
-type ProductComponentUv struct {
-	Img       *OssType           `bson:"img"`
-	Transform ComponentTransform `bson:"transform"`
-}
-type ProductComponent struct {
-	Id           string              `bson:"id"`
-	Uv           *ProductComponentUv `bson:"uv"`
-	BaseMaterial *ComponentMaterial  `bson:"baseMaterial"`
-	Images       []*ComponentImage   `bson:"images"`
-}
-
-type SceneProduct struct {
-	FromId    string     `bson:"fromId,omitempty" json:"fromId"` //多模型的支持
-	Id        string     `bson:"id,omitempty" json:"id"`
-	Name      string     `bson:"name,omitempty" json:"name"`
-	Type      string     `bson:"type,omitempty" json:"type"`
-	Locked    bool       `bson:"locked,omitempty" json:"locked"`
-	Visible   bool       `bson:"visible,omitempty" json:"visible"`
-	Transform *Transform `bson:"transform,omitempty" json:"transform"`
-}
-
-type Product struct {
-	Id         string              `bson:"id,omitempty"`
-	Name       string              `bson:"name,omitempty"` //名字唯一
-	Thumbnail  OssType             `bson:"thumbnail,omitempty"`
-	CreateTime time.Time           `bson:"createTime,omitempty"`
-	Components []*ProductComponent `bson:"components,omitempty"`
-}
-
-type SceneOfflineRender struct {
-	TaskId string  `bson:"taskId,omitempty"`
-	Image  OssType `bson:"image,omitempty"`
-}
-
-type Scene struct {
-	Id         string                `bson:"id,omitempty"`
-	Name       string                `bson:"name,omitempty"` //名字唯一
-	CreateTime time.Time             `bson:"createTime,omitempty"`
-	Thumbnail  *OssType              `bson:"thumbnail,omitempty"`
-	Renders    []*SceneOfflineRender `bson:"renders"`
-	Product    []*SceneProduct       `bson:"renders"`
-}
-
-type Project struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty"`
-	Name       string             `bson:"name,omitempty"`
-	Thumbnail  OssType            `bson:"thumbnail"`
-	CreateTime time.Time          `bson:"createTime,omitempty"`
-	UpdateTime time.Time          `bson:"updateTime,omitempty"`
-
-	UserId   primitive.ObjectID `bson:"userId,omitempty"`
-	Products []*Product         `bson:"products"`
-	Scenes   []*Scene           `bson:"scenes"`
-}
-
-//declare interface DesignConfig {
-
-// 	scenes: {
-// 	  lights: {
-// 		id: string;
-// 		name: string;
-// 		type: string;
-// 	  }[];
-// 	}[];
-//}

+ 0 - 338
tree/assetcenter/db/model/res.go

@@ -1,338 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-const (
-	LibState_Created      = 1
-	LibState_Complated    = 2
-	LibState_Publish2Qiye = 3
-)
-
-type Texture struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Image      OssType            `bson:"image,omitempty" json:"image"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-}
-
-type ObsItem struct {
-	Name         string    `json:"name"`
-	LastModified time.Time `json:"lastModified"`
-	Size         uint64    `json:"size"`
-	IsImage      bool      `json:"isImage"`
-	Url          string    `json:"url"`
-	IsDir        bool      `json:"isDir"`
-}
-
-type MaterailUv struct {
-	Scale   float64 `bson:"scale" json:"scale"`
-	Rotate  float64 `bson:"rotate" json:"rotate"`
-	OffsetX float64 `bson:"offsetX" json:"offsetX"`
-	OffsetY float64 `bson:"offsetY" json:"offsetY"`
-}
-
-type MatAlbedo struct {
-	Color      *Vect3   `bson:"color" json:"color"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-}
-
-type MatRoughness struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-}
-
-type MatMetalness struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-}
-type MatNormal struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-	FlipY      *bool    `bson:"flipY" json:"flipY"`
-}
-
-type MatDisplace struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-}
-
-type MatDiffuse struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-}
-
-type MatTextureFactorWithEnable struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-	Enable     bool     `bson:"enable" json:"enable"`
-}
-
-type MatTextureFactor struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-}
-
-type MatTextureColor struct {
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	Color      *Vect3   `bson:"color" json:"color"`
-}
-
-type MatOpacity struct {
-	Enable     bool     `bson:"enable" json:"enable"`
-	Factor     *float32 `bson:"factor" json:"factor"`
-	Texture    *OssType `bson:"texture" json:"texture"`
-	UseTexture *bool    `bson:"useTexture" json:"useTexture"`
-}
-
-type MatConfig struct {
-	Version     int         `bson:"version,omitempty" json:"version"`
-	Type        string      `bson:"type,omitempty" json:"type"` //高光流 金属流(默认) meta spec
-	Uvtransform *MaterailUv `bson:"uv,omitempty" json:"uv"`
-	CullFace    string      `bson:"cullFace" json:"cullFace"`
-
-	Albedo    *MatTextureColor            `bson:"albedo" json:"albedo"`
-	Roughness *MatTextureFactor           `bson:"roughness" json:"roughness"`
-	Metalness *MatTextureFactor           `bson:"metalness" json:"metalness"`
-	Normal    *MatNormal                  `bson:"normal" json:"normal"`
-	Opacity   *MatTextureFactorWithEnable `bson:"opacity" json:"opacity"`
-
-	Displace *MatTextureFactorWithEnable `bson:"displace,omitempty" json:"displace"` //置换
-	Diffuse  *MatTextureColor            `bson:"diffuse,omitempty" json:"diffuse"`
-	Specular *MatTextureColor            `bson:"specular" json:"specular"`
-	Gloss    *MatTextureFactor           `bson:"gloss,omitempty" json:"gloss"` //光泽贴图
-
-	UvMap string `bson:"uvMap,omitempty" json:"uvMap"` //uv包裹 box、uv
-}
-
-type TechMatConfig struct {
-	Version     int           `bson:"version,omitempty" json:"version"`
-	Type        string        `bson:"type,omitempty" json:"type"`
-	Uvtransform *MaterailUv   `bson:"uvtransform,omitempty" json:"uvtransform"`
-	CullFace    string        `bson:"cullFace" json:"cullFace"`
-	Albedo      *MatAlbedo    `bson:"albedo" json:"albedo"`
-	Roughness   *MatRoughness `bson:"roughness" json:"roughness"`
-	Metalness   *MatMetalness `bson:"metalness" json:"metalness"`
-	Specular    *MatAlbedo    `bson:"specular" json:"specular"`
-	Normal      *MatNormal    `bson:"normal" json:"normal"`
-	Opacity     *MatOpacity   `bson:"opacity" json:"opacity"`
-}
-
-type MaterialChannels struct {
-	Albedo       *MaterailFeature  `bson:"Albedo" json:"Albedo"`
-	Roughness    *MaterailFeature  `bson:"Roughness" json:"Roughness"`
-	NormalMap    *MaterailFeature  `bson:"NormalMap" json:"NormalMap"`
-	BumpMap      *MaterailFeature  `bson:"BumpMap" json:"BumpMap"`
-	Opacity      *OpacityFeature   `bson:"Opacity" json:"Opacity"`
-	AO           *AOFeature        `bson:"AO" json:"AO"`
-	MetalnessPBR *MaterailFeature  `bson:"MetalnessPBR" json:"MetalnessPBR"`
-	SpecularF0   float32           `bson:"SpecularF0" json:"SpecularF0"`
-	ClearCoat    *ClearCoatFeature `bson:"ClearCoat" json:"ClearCoat"`
-	Displacement *MaterailFeature  `bson:"Displacement" json:"Displacement"`
-	CavityMap    *MaterailFeature  `bson:"CavityMap" json:"CavityMap"`
-	Emissive     *Emissive         `bson:"Emissive" json:"Emissive"`
-}
-type Emissive struct {
-	Color  Vect3   `bson:"color" json:"color"`
-	Enable bool    `bson:"enable" json:"enable"`
-	Factor float32 `bson:"factor" json:"factor"`
-}
-
-type MaterailFeature struct {
-	Color   *Vect3   `bson:"color" json:"color"`
-	Texture *OssType `bson:"texture" json:"texture"`
-	Factor  *float32 `bson:"factor" json:"factor"`
-	Invert  *bool    `bson:"invert" json:"invert"`
-	Enable  *bool    `bson:"enable" json:"enable"`
-	FlipY   *bool    `bson:"flipY" json:"flipY"`
-}
-
-type OpacityFeature struct {
-	Enable                 bool    `bson:"enable" json:"enable"`
-	Type                   string  `bson:"type" json:"type"`
-	Factor                 float32 `bson:"factor" json:"factor"`
-	Invert                 bool    `bson:"invert" json:"invert"`
-	SampleChannel          string  `bson:"sampleChannel" json:"sampleChannel"`
-	RefractionTint         Vect3   `bson:"refractionTint" json:"refractionTint"`
-	RefractUseDiffuse      bool    `bson:"refractUseDiffuse" json:"refractUseDiffuse"`
-	RefractUseShininessMap bool    `bson:"refractUseShininessMap" json:"refractUseShininessMap"`
-	IOR                    float32 `bson:"IOR" json:"IOR"`
-	RoughnessFactor        float32 `bson:"roughnessFactor" json:"roughnessFactor"`
-	Texture                OssType `bson:"texture" json:"texture"`
-}
-
-type AOFeature struct {
-	Enable          bool    `bson:"enable" json:"enable"`
-	OccludeSpecular bool    `bson:"occludeSpecular" json:"occludeSpecular"`
-	Factor          float32 `bson:"factor" json:"factor"`
-	Texture         OssType `bson:"texture" json:"texture"`
-}
-
-type ClearCoatFeature struct {
-	Enable       bool    `bson:"enable" json:"enable"`
-	Thickness    float32 `bson:"thickness" json:"thickness"`
-	Intensity    float32 `bson:"intensity" json:"intensity"`
-	Color        Vect3   `bson:"color" json:"color"`
-	Reflectivity float32 `bson:"reflectivity" json:"reflectivity"`
-	Roughness    struct {
-		Factor float32 `bson:"factor" json:"factor"`
-	} `bson:"roughness" json:"roughness"`
-	Normalmap struct {
-		Factor float32 `bson:"factor" json:"factor"`
-		FlipY  bool    `bson:"flipY" json:"flipY"`
-	} `bson:"normalmap" json:"normalmap"`
-}
-
-//材质球
-type Material struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"` //用户ID
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Data       *MatConfig         `bson:"data,omitempty" json:"data"`
-	Thumbnail  *OssType           `bson:"thumbnail,omitempty" json:"thumbnail"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	Category   string             `bson:"category,omitempty" json:"category"`
-
-	IsPublic *bool `bson:"isPublic,omitempty" json:"isPublic"` //是否公开
-
-	IsEffect   *bool `bson:"effect,omitempty" json:"effect"`     //是否属于效果材质球
-	IsPlatform *bool `bson:"platform,omitempty" json:"platform"` //是否属于平台
-}
-
-type Env3dOption struct {
-	Rotation float64 `bson:"rotation" json:"rotation"`
-	Exposure float64 `bson:"exposure" json:"exposure"`
-}
-
-func NewEnv3dOptionWithMap(options map[string]interface{}) *Env3dOption {
-
-	Rotation := float64(0.0)
-	if v, ok := options["rotation"].(float64); ok {
-		Rotation = v
-	} else if v, ok := options["rotation"].(float64); ok {
-		Rotation = float64(v)
-	}
-	Exposure := float64(1.0)
-	if v, ok := options["exposure"].(float64); ok {
-		Exposure = v
-	} else if v, ok := options["exposure"].(float64); ok {
-		Exposure = float64(v)
-	}
-
-	return &Env3dOption{Rotation: Rotation, Exposure: Exposure}
-}
-
-func NewEnv3dToneMapWithMap(tone map[string]interface{}) *ToneMap {
-
-	method := int32(0)
-	Exposure := float64(1)
-	Saturation := float64(1)
-	Brightness := float64(0)
-	Contrast := float64(0)
-
-	if tone == nil {
-		return &ToneMap{
-			Method:     &method,
-			Exposure:   &Exposure,
-			Saturation: &Saturation,
-			Brightness: &Brightness,
-			Contrast:   &Contrast,
-		}
-	}
-
-	if v, ok := tone["method"].(int32); ok {
-		method = v
-	}
-
-	if v, ok := tone["exposure"].(float64); ok {
-		Exposure = v
-	}
-
-	if v, ok := tone["saturation"].(float64); ok {
-		Saturation = v
-	}
-
-	if v, ok := tone["brightness"].(float64); ok {
-		Brightness = v
-	}
-
-	if v, ok := tone["contrast"].(float64); ok {
-		Contrast = v
-	}
-
-	return &ToneMap{Method: &method, Exposure: &Exposure, Saturation: &Saturation, Brightness: &Brightness, Contrast: &Contrast}
-}
-
-func NewEnv3dBackgroundWithMap(options map[string]interface{}) *Evn3dBackground {
-	Color := options["color"].(primitive.A)
-	Image := &OssType{}
-	if options["image"] != nil {
-		Image = NewOssTypeWithMap(options["image"].(map[string]interface{}))
-	}
-	Type := options["type"].(int32)
-	return &Evn3dBackground{Color: &Vect3{Color[0].(float64), Color[1].(float64), Color[2].(float64)}, Image: Image, Type: Type}
-}
-
-type ToneMap struct {
-	Method     *int32   `bson:"method,omitempty" json:"method"`         //0 "linear" 值0 "reinhard" 值 1 "filmic”:值2
-	Exposure   *float64 `bson:"exposure,omitempty" json:"exposure"`     //默认值1 范围0到2
-	Brightness *float64 `bson:"brightness,omitempty" json:"brightness"` //默认值0 范围-1到 1
-	Contrast   *float64 `bson:"contrast,omitempty" json:"contrast"`     //默认值0 范围-1到1
-	Saturation *float64 `bson:"saturation,omitempty" json:"saturation"` //默认值1 范围0-2
-}
-
-type Evn3dTextureImage struct {
-	File             string  `bson:"file,omitempty" json:"file"`
-	SizeUncompressed int32   `bson:"sizeUncompressed,omitempty" json:"sizeUncompressed"`
-	Samples          uint32  `bson:"samples,omitempty" json:"samples"`
-	Height           float32 `bson:"height,omitempty" json:"height"`
-	Width            float32 `bson:"width,omitempty" json:"width"`
-	SizeCompressed   int32   `bson:"sizeCompressed,omitempty" json:"sizeCompressed"`
-	Blur             float32 `bson:"blur,omitempty,truncate" json:"blur"`
-}
-
-type Evn3dTexture struct {
-	Images    []*Evn3dTextureImage `bson:"images,omitempty" json:"images"`
-	LimitSize int32                `bson:"limitSize,omitempty" json:"limitSize"`
-	Encoding  string               `bson:"encoding,omitempty" json:"encoding"`
-	Type      string               `bson:"type,omitempty" json:"type"`
-	Format    string               `bson:"format,omitempty" json:"format"`
-}
-
-type Evn3dLight struct {
-	Direction  Vect3    `bson:"direction,omitempty" json:"direction"`
-	Lum_ratio  float64  `bson:"lum_ratio,omitempty" json:"lum_ratio"`
-	Color      Vect3    `bson:"color,omitempty" json:"color"`
-	Luminosity float64  `bson:"luminosity,omitempty" json:"luminosity"`
-	Sum        float64  `bson:"sum,omitempty" json:"sum"`
-	Area       VectXYWH `bson:"area,omitempty" json:"area"`
-	Error      int32    `bson:"error,omitempty" json:"error"`
-	Variance   float64  `bson:"variance,omitempty" json:"variance"`
-}
-
-type Evn3dHdrConf struct {
-	Textures       []*Evn3dTexture `bson:"textures,omitempty" json:"textures"`
-	WriteByChannel bool            `bson:"writeByChannel,omitempty" json:"writeByChannel"`
-	Lights         []*Evn3dLight   `bson:"lights,omitempty" json:"lights"`
-	DiffuseSPH     []float64       `bson:"diffuseSPH,omitempty" json:"diffuseSPH"`
-}
-
-type CanvasBackground struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Color      *Vect3             `bson:"color,omitempty" json:"color"`
-	Image      *OssType           `bson:"image,omitempty" json:"image"`
-	Type       int32              `bson:"type,omitempty" json:"type"`
-	Order      int32              `bson:"order,omitempty" json:"order"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-}

+ 0 - 210
tree/assetcenter/db/model/task.go

@@ -1,210 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type RenderComponent struct {
-	Name     string              `bson:"name,omitempty" json:"name"`
-	FabricId *primitive.ObjectID `bson:"fabricId,omitempty" json:"fabricId,omitempty"`
-	CardId   *primitive.ObjectID `bson:"cardId,omitempty" json:"cardId,omitempty"`
-	MatType  uint8               `bson:"matType,omitempty" json:"matType"`
-	// Imagemat    *ImageMatConf       `bson:"imageMat,omitempty" json:"imageMat,omitempty"`
-	// Uvtransform *Uvtransform        `bson:"transform,omitempty" json:"transform"`
-	Color   *Vect3     `bson:"color,omitempty" json:"color"`
-	GroupId uint64     `bson:"groupId,omitempty" json:"groupId"`
-	Visible *bool      `bson:"visible,omitempty" json:"visible"`
-	Card    *MatConfig `bson:"card,omitempty" json:"card"`
-}
-
-type RenderShoeComp struct {
-	Name   string
-	Config *RenderComponent
-}
-
-type RenderModelComp struct {
-	Id      string              `bson:"id,omitempty" json:"id"`
-	MeshId  *primitive.ObjectID `bson:"meshId,omitempty" json:"meshId,omitempty"`
-	MeshUrl string              `bson:"meshUrl,omitempty" json:"meshUrl,omitempty"`
-	Type    string              `bson:"type,omitempty" json:"type"`
-	TypeId  *primitive.ObjectID `bson:"typeId,omitempty" json:"typeId,omitempty"`
-	// Transform  ModelTransform      `bson:"transform,omitempty" json:"transform,omitempty"`
-	Components []*RenderShoeComp `bson:"components,omitempty" json:"components,omitempty"`
-}
-
-const (
-	TaskRunState_Created      = 0
-	TaskRunState_Quened       = 1
-	TaskRunState_WorkRuning   = 2
-	TaskRunState_ReWorkRuning = 3
-	TaskRunState_Succ         = 4
-	TaskRunState_Fail         = 5
-)
-
-type TaskRunResult struct {
-	Images []*OssType
-}
-
-type ConvMeshRunResult struct {
-	Osgjs     *OssType
-	Thumbnail *OssType
-	File      *OssType
-}
-
-type RenderTask struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     primitive.ObjectID `bson:"userId,omitempty" json:"userId"`
-	DesignId   primitive.ObjectID `bson:"designId" json:"designId"`
-
-
-	RunState   int32              `bson:"runState" json:"runState"`
-	RunPercent int32              `bson:"runPercent" json:"runPercent"`
-
-	RunResult  *TaskRunResult     `bson:"runResult" json:"runResult"`
-
-	Width      int32              `bson:"width" json:"width"`
-	Height     int32              `bson:"height" json:"height"`
-	CreateTime time.Time          `bson:"createTime" json:"createTime"`
-
-	Scene      *DesignScene       `bson:"scene" json:"scene"`
-	MeshId     string             `bson:"meshId" json:"meshId"`
-	MeshUrl    string             `bson:"meshUrl" json:"meshUrl"`
-	MeshShadow string             `bson:"meshShadow" json:"meshShadow"`
-
-	Cameras    []*RenderCamera    `bson:"cameras" json:"cameras"`
-
-	ShoeComps  []*RenderShoeComp  `bson:"shoeComps" json:"shoeComps"`
-	
-	ModelComps []*RenderModelComp `bson:"modelComps" json:"modelComps"`
-
-	MaxSamples int32   `bson:"maxSamples" json:"maxSamples"`
-	Exposure   float32 `bson:"exposure" json:"exposure"`
-}
-
-type RenderSetting struct {
-	MaxSamples int32   `bson:"maxSamples" json:"maxSamples"` //32
-	Exposure   float32 `bson:"exposure" json:"exposure"`     //1.2
-}
-
-type RenderCamera struct {
-	Thumbnail *OssType       `bson:"thumbnail" json:"thumbnail"` //
-	Position  Vec3Obj        `bson:"position" json:"position"`   //
-	Fov       float32        `bson:"fov" json:"fov"`             //45
-	Direction Vec3Obj        `bson:"direction" json:"direction"`
-	Viewport  CameraViewPort `bson:"viewport" json:"viewport"`
-}
-
-type CameraViewPort struct {
-	Width  int32 `bson:"width" json:"width"`
-	Height int32 `bson:"height" json:"height"`
-}
-
-type SunLight struct {
-	Type            string  `bson:"type" json:"type"`
-	Intensity       float32 `bson:"intensity" json:"intensity"`
-	Direction       Vec3Obj `bson:"direction" json:"direction"`
-	AngularDiameter float32 `bson:"angularDiameter" json:"angularDiameter"`
-	Color           Vect3   `bson:"color" json:"color"`
-}
-
-type RenderEnv struct {
-	Color     Vect3   `bson:"color" json:"color"`
-	Rotation  float32 `bson:"rotation" json:"rotation"`
-	Intensity float32 `bson:"intensity" json:"intensity"`
-	FilePath  string  `bson:"filePath" json:"filePath"`
-	Visiable  bool    `bson:"visiable" json:"visiable"`
-}
-
-type Vec3Obj struct {
-	X float64 `bson:"x" json:"x"`
-	Y float64 `bson:"y" json:"y"`
-	Z float64 `bson:"z" json:"z"`
-}
-type Vec4Obj struct {
-	X float64 `bson:"x" json:"x"`
-	Y float64 `bson:"y" json:"y"`
-	Z float64 `bson:"z" json:"z"`
-	W float64 `bson:"w" json:"w"`
-}
-
-type RenderMatParam struct {
-	Name  string      `bson:"name" json:"name"`
-	Type  string      `bson:"type" json:"type"`
-	Value interface{} `bson:"value" json:"value"`
-}
-
-type RenderMat struct {
-	Name       string            `bson:"name" json:"name"`
-	Type       string            `bson:"type" json:"type"`
-	Parameters []*RenderMatParam `bson:"parameters" json:"parameters"`
-}
-
-type RenderGroup struct {
-	Name      string       `bson:"name" json:"name"`
-	Position  Vec3Obj      `bson:"position" json:"position"`
-	Rotation  Vec4Obj      `bson:"rotation" json:"rotation"`
-	Scale     Vec3Obj      `bson:"scale" json:"scale"`
-	Materials []*RenderMat `bson:"materials" json:"materials"`
-	FilePath  string       `bson:"filePath" json:"filePath"`
-}
-
-type RenderConf struct {
-	Setting    *RenderSetting `bson:"setting" json:"setting"`
-	Camera     *RenderCamera  `bson:"camera" json:"camera"`
-	Lights     []interface{}  `bson:"lights" json:"lights"`
-	Enviroment *RenderEnv     `bson:"enviroment" json:"enviroment"`
-	Groups     []*RenderGroup `bson:"groups" json:"groups"`
-}
-
-type TaskConvMesh2Osgjs struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId string             `bson:"userId,omitempty" json:"userId"`
-	MeshId string             `bson:"meshId,omitempty" json:"meshId"` //模型meshId
-
-	Collecton      string    `bson:"collection,omitempty" json:"collection"`         //数据库表的名字
-	FbxFile        *OssType  `bson:"fbxFile,omitempty" json:"fbxFile"`               //模型文件字段名字
-	OsgjsFieldName string    `bson:"osgjsFieldName,omitempty" json:"osgjsFieldName"` //模型文件字段名字
-	CreateTime     time.Time `bson:"createTime,omitempty" json:"createTime"`         //创建时间
-
-	WorkerId string `bson:"workerId,omitempty" json:"workerId"` //分配的工作ID,可根据此Id取消worker的执行
-}
-
-type TaskConvHdr struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     string             `bson:"userId,omitempty" json:"userId"`
-	Env3dId    string             `bson:"env3dId,omitempty" json:"env3dId"`       //模型meshId
-	Collecton  string             `bson:"collection,omitempty" json:"collection"` //数据库表的名字
-	HdrFile    *OssType           `bson:"hdrFile,omitempty" json:"hdrFile"`       //模型文件字段名字
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"` //创建时间
-	WorkerId   string             `bson:"workerId,omitempty" json:"workerId"`     //分配的工作ID,可根据此Id取消worker的执行
-}
-
-type TaskCreateShadow struct {
-	Id              primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	CreateTime      time.Time          `bson:"createTime,omitempty" json:"createTime"` //创建时间
-	UserId          string             `bson:"userId,omitempty" json:"userId"`
-	MeshId          string             `bson:"meshId,omitempty" json:"meshId"`                   //模型meshId
-	Collecton       string             `bson:"collection,omitempty" json:"collection"`           //数据库表的名字
-	FbxFile         *OssType           `bson:"fbxFile,omitempty" json:"fbxFile"`                 //模型文件字段名字
-	ShadowFieldName string             `bson:"shadowFieldName,omitempty" json:"shodowFieldName"` //模型文件字段名字
-}
-
-type WorkerRequest struct {
-	Name           string    `json:"name"`
-	UserId         string    `json:"userId"`
-	TaskId         string    `json:"taskId"`
-	MainId         string    `json:"mainId"`
-	TaskCollection string    `json:"taskCollection"`
-	WorkerType     string    `json:"workerType"`
-	CreateTime     time.Time `json:"createTime"`
-}
-
-type WorkerResponse struct {
-	ErrorNo   int    `json:"errorNo"`
-	ErrorDesc string `json:"errorDesc"`
-	Result    struct {
-		WorkingId string `json:"workingId"`
-	} `json:"result"`
-}

+ 0 - 26
tree/assetcenter/db/model/user-qiye.go

@@ -1,26 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type UserPost struct { //人员职位
-	Id        primitive.ObjectID `bson:"_id,omitempty" json:"_id"`                       //职位ID
-	Name      string             `bson:"name,omitempty" json:"name,omitempty"`           //职位名称唯一、不能重复
-	TreeLevel int32              `bson:"treeLevel,omitempty" json:"treeLevel,omitempty"` //职位等级
-
-	Parent primitive.ObjectID `bson:"parent,omitempty" json:"parent"` //父级职
-}
-
-//联系我们
-type ContentInfo struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Phone      string             `bson:"phone,omitempty" json:"phone"`
-	Company    string             `bson:"company,omitempty" json:"company"`
-	POST       string             `bson:"post,omitempty" json:"post"`
-	City       string             `bson:"city,omitempty" json:"city"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-}

+ 0 - 85
tree/assetcenter/db/model/user-role.go

@@ -1,85 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-//企业账户的角色列表
-type FilterTime struct {
-	Year    int32
-	Seasons []int32
-}
-
-//企业账户的角色列表
-type FilterCategory struct {
-	Category1 string
-	Category2 []string
-}
-
-type LibFilter struct {
-	Values []string `bson:"values,omitempty" json:"values"` //企业类型["设计中心(企业平台)-运动鞋设计部(运动鞋设计部)-小组(设计1小组)-个人"]
-	CateId string   `bson:"cateId,omitempty" json:"cateId"` //年限
-	IsAll  *bool    `bson:"isAll,omitempty" json:"isAll"`   //性别
-}
-
-type MatFilter struct {
-	QiyeFrom   []string          //企业类型["设计中心(企业平台)-运动鞋设计部(运动鞋设计部)-小组(设计1小组)-个人"]
-	YearSeason []*FilterTime     //年限
-	Category   []*FilterCategory //分类
-}
-
-type TeamResFilter struct {
-	ShoeCategoryIds     []*LibFilter `bson:"shoeCategoryIds,omitempty" json:"shoeCategoryIds"`         //分配的分类列表
-	MatCategoryIds      []*LibFilter `bson:"matCategoryIds,omitempty" json:"matCategoryIds"`           //分配的分类列表
-	SoleCategoryIds     []*LibFilter `bson:"soleCategoryIds,omitempty" json:"soleCategoryIds"`         //分配的分类列表
-	HeelCategoryIds     []*LibFilter `bson:"heelCategoryIds,omitempty" json:"heelCategoryIds"`         //分配的分类列表
-	DecorateCategoryIds []*LibFilter `bson:"decorateCategoryIds,omitempty" json:"decorateCategoryIds"` //分配的分类列表
-}
-
-type QiyeRole struct {
-	Id     primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId string             `bson:"userId,omitempty" json:"userId"`         //企业主账户id
-	Name   string             `bson:"name, omitempty" json:"name,omitempty"`  //角色名字
-	Perms  []string           `bson:"perms,omitempty" json:"perms,omitempty"` //权限名字列表
-}
-
-type Team struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id,omitempty"`
-	UserId     string             `bson:"userId,omitempty" json:"userId,omitempty"` //企业主账户id
-	Name       string             `bson:"name" json:"name"`                         //角色名字
-	UserCount  int32              `bson:"userCount" json:"userCount"`               //用户个数
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime,omitempty"`
-	Filter     *TeamResFilter     `bson:"filters" json:"filters"`                       //资源名字列表
-	LeaderId   string             `bson:"leaderId,omitempty" json:"leaderId,omitempty"` //leaderId
-}
-
-type ResCategory struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Type       string             `bson:"type,omitempty" json:"type"`
-	UserId     string             `bson:"userId,omitempty" json:"userId"`
-	Parent     string             `bson:"parent,omitempty" json:"parent"`
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Value      string             `bson:"value,omitempty" json:"value"`
-	Level      *int32             `bson:"level,omitempty" json:"level"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	OrderId    int64              `bson:"orderId,omitempty" json:"orderId"`
-}
-
-type LibCategory struct {
-	Id          primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Type        string             `bson:"type,omitempty" json:"type"`
-	UserId      string             `bson:"userId,omitempty" json:"userId"`
-	CategoryIds []string           `bson:"categoryIds,omitempty" json:"categoryIds"`
-	CreateTime  time.Time          `bson:"createTime,omitempty" json:"createTime"`
-	UpdateTime  time.Time          `bson:"updateTime,omitempty" json:"updateTime"`
-}
-
-type Role struct {
-	Id         primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	UserId     string             `bson:"userId,omitempty" json:"userId"` //主账号Id
-	Name       string             `bson:"name,omitempty" json:"name"`
-	Perms      []string           `bson:"perms,omitempty" json:"perms"`
-	CreateTime time.Time          `bson:"createTime,omitempty" json:"createTime"`
-}

+ 0 - 91
tree/assetcenter/db/model/user.go

@@ -1,91 +0,0 @@
-package model
-
-import (
-	"time"
-
-	"go.mongodb.org/mongo-driver/bson/primitive"
-)
-
-type Sass struct {
-	Title  string
-	Level  int32
-	Status string //使用中
-
-	Exp time.Time
-}
-
-type EnvTheme struct {
-	Id string `bson:"id,omitempty" json:"id"`
-	// Options    *Evn3dOption     `bson:"options,omitempty" json:"options"`
-	ToneMap *ToneMap `bson:"toneMap,omitempty" json:"toneMap"`
-	// Background *SceneBackground `bson:"background,omitempty" json:"background"`
-}
-
-type EditorSetting struct {
-	Themes         []*EnvTheme `bson:"themes,omitempty" json:"themes"`
-	ModelBaseColor *Vect3      `bson:"modelBaseColor,omitempty" json:"modelBaseColor"`
-	DefaultEnv3dId string      `bson:"defaultEnv3dId,omitempty" json:"defaultEnv3dId"`
-}
-
-type User struct {
-	Id       primitive.ObjectID `bson:"_id,omitempty" json:"_id"`
-	Phone    string             `bson:"phone,omitempty" json:"phone"`
-	Password string             `bson:"password,omitempty" json:"password"`
-	Name     string             `bson:"name,omitempty" json:"name"`
-	Company  string             `bson:"company,omitempty" json:"company"`
-	Wechat   string             `bson:"wechat,omitempty" json:"wechat"`
-	City     string             `bson:"city,omitempty" json:"city"`
-	Alipay   string             `bson:"alipay,omitempty" json:"alipay,omitempty"`
-	Avatar   string             `bson:"avatar,omitempty" json:"avatar,omitempty"`
-
-	Desc string `bson:"desc,omitempty" json:"desc"`
-
-	CreateTime      time.Time      `bson:"createTime,omitempty" json:"createTime,omitempty"`
-	Email           string         `bson:"email" json:"email,omitempty"`
-	LastLogin       time.Time      `bson:"lastLogin,omitempty" json:"lastLogin,omitempty"`
-	Saas            *Sass          `bson:"saas,omitempty" json:"saas,omitempty"`
-	EditorSet       *EditorSetting `bson:"editorSet,omitempty" json:"editorSet,omitempty"`
-	CanDeployDesign *bool          `bson:"canDeployDesign,omitempty" json:"canDeployDesign,omitempty"`
-
-	Parent     string    `bson:"parent,omitempty" json:"parent,omitempty"` //主账号ID
-	State      int32     `bson:"state,omitempty" json:"state,omitempty"`   //-1 用户已禁用
-	Roles      []string  `bson:"roles,omitempty" json:"roles,omitempty"`   //-1 用户已禁用
-	Qiye       *QiyeInfo `bson:"qiye,omitempty" json:"qiye,omitempty"`     //企业信息
-	IsPlatform *bool     `bson:"isPlatform" json:"isPlatform,omitempty"`
-	TeamId     string    `bson:"teamId,omitempty" json:"teamId,omitempty"` //用户团队Id
-	// Cameras    []*SceneCamera `bson:"cameras,omitempty" json:"cameras"`         //用户的相机设置
-}
-
-type QiyeInfo struct {
-	Name    string `bson:"name,omitempty" json:"name,omitempty"`       //名字
-	Logo    string `bson:"logo,omitempty" json:"logo,omitempty"`       //logo
-	Address string `bson:"address,omitempty" json:"address,omitempty"` //地址
-}
-
-func (u *User) GetID() string {
-	return u.Id.Hex()
-}
-
-type SubAccount struct {
-	Name       string    `bson:"name,omitempty" json:"name,omitempty"`
-	Phone      string    `bson:"phone,omitempty" json:"phone,omitempty"`
-	Password   string    `bson:"password,omitempty" json:"password,omitempty"`
-	CreateTime time.Time `bson:"createTime,omitempty" json:"createTime,omitempty"`
-	LastLogin  time.Time `bson:"lastLogin,omitempty" json:"lastLogin,omitempty"`
-	UserId     string    `bson:"userId,omitempty" json:"userId,omitempty"`
-	RoleIds    []string  `bson:"roles,omitempty" json:"roles,omitempty"`   //用户角色
-	TeamId     string    `bson:"teamId,omitempty" json:"teamId,omitempty"` //用户团队Id
-}
-
-type UserParent struct {
-}
-
-type Material1 struct {
-	A    int
-	Type int
-}
-
-type Material2 struct {
-	B    int32
-	Type int
-}

+ 0 - 14
tree/assetcenter/db/redis.go

@@ -1,14 +0,0 @@
-package db
-
-import (
-	"github.com/go-redis/redis/v8"
-	"infish.cn/comm"
-)
-
-func NewRedisClient(bus *comm.NatsBus) *redis.Client {
-	client, err := bus.NewRedisFromConfig("redis")
-	if err != nil {
-		return nil
-	}
-	return client
-}

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor