108 lines
21 KiB
Go
108 lines
21 KiB
Go
package logic
|
||
|
||
import (
|
||
"encoding/json"
|
||
"fmt"
|
||
"fusenapi/constants"
|
||
"fusenapi/utils/auth"
|
||
"fusenapi/utils/basic"
|
||
"fusenapi/utils/curl"
|
||
"github.com/google/uuid"
|
||
"strings"
|
||
"sync"
|
||
"time"
|
||
|
||
"context"
|
||
|
||
"fusenapi/server/collection/internal/svc"
|
||
"fusenapi/server/collection/internal/types"
|
||
|
||
"github.com/zeromicro/go-zero/core/logx"
|
||
)
|
||
|
||
type TestAiLogic struct {
|
||
logx.Logger
|
||
ctx context.Context
|
||
svcCtx *svc.ServiceContext
|
||
}
|
||
|
||
func NewTestAiLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TestAiLogic {
|
||
return &TestAiLogic{
|
||
Logger: logx.WithContext(ctx),
|
||
ctx: ctx,
|
||
svcCtx: svcCtx,
|
||
}
|
||
}
|
||
|
||
// 处理进入前逻辑w,r
|
||
// func (l *TestAiLogic) BeforeLogic(w http.ResponseWriter, r *http.Request) {
|
||
// }
|
||
var data = `{"module_data":{"groupOptions":{"fill_1":{"list":[{"id":"442c4e24-53ae-2a76-8e6b-7550e2747369","tag":""},{"id":"646004b2-ad82-761f-c939-b85f96f97f9a","tag":""},{"id":"b6e4ab68-b36a-9534-d53f-722c93d54657","tag":""},{"id":"280ced37-6725-562f-4272-79bacfcadb12","tag":""},{"id":"a6aac5c1-8e54-c0f1-5749-9847f0fe497e","tag":""},{"id":"2b2eac02-37ae-0b1e-898e-d9e3166dfc9a","tag":""},{"id":"88181235-0317-fe9e-b202-cc7938acd449","tag":""},{"id":"93aba661-9260-8420-4adc-feef1657f4e3","tag":""},{"id":"50dec384-7501-dfdd-9c65-ddf3142540af","tag":""},{"id":"d8337893-bfab-0e43-2ef2-2606d1612fec","tag":""},{"id":"508859ae-cc8f-0b19-3554-c7632838d3fc","tag":""},{"id":"d5d3a1cb-2b13-2345-088d-b9163edf8aa6","tag":"","type":"color"}],"tag":"","title":"主色","value":"#E71F18"},"fill_2":{"list":[],"tag":"","title":"副色","value":"#000"},"fill_3":{"list":[],"tag":"","title":"备选色","value":"#000"},"fill_4":{"list":[{"id":"dbc50336-de0c-4b4a-f0aa-1a6444a3f615","tag":"","type":"color"},{"id":"cd0bf3b0-761f-e5b4-d7b6-f63fc54baa77","tag":"","type":"color"}],"tag":"","title":"固定色A","value":"#FFFFFF"},"material_1":{"id":"material_1","list":[{"id":"9baa3b65-c4f0-ebd8-866f-7e8d8e26e462","tag":"Logo"},{"id":"d9634ebf-78e2-3ead-30c5-cd545c3bfdaa","tag":"Logo"}],"tag":"Logo","title":"LOGO分组","value":""},"text_1":{"id":"text_1","list":[],"tag":"Slogan","title":"Slogan分组","value":"The ultimate experience"},"text_2":{"id":"text_2","list":[],"tag":"QRcode","title":"二维码分组","value":"www.fusen.cn"}},"id":1108,"material":"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/a0914c5b48319ebeed923ae780a5f1a00736056e0b5406a60095cfd4010b31d8","materialList":[{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":1024,"id":"cf7caf81-1470-613a-7691-9c5eac710a0e","ifGroupNoBr":false,"lineHeight":1,"material":"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/c83b49a900c3bffff4fbf0d5b8e7d494033b3b793b660ccd1bf98b2558573adb","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"","text":"","title":"底图","type":"background","verticalAlign":"middle","visible":true,"width":1024,"x":0,"y":0,"zIndex":0},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"0991b333-4baf-8fcc-a8bb-aa5546811815","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"","text":"","title":"SVG元素","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":1},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":["b3ce7508-232a-89aa-72fd-dbbacc32f938","37ffcea7-0134-e6ee-014a-f0dddc466cf0","869c16d3-4b82-b052-6def-9162e126c57a"],"height":100,"id":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"","text":"","title":"合图组","type":"combine","verticalAlign":"middle","visible":false,"width":100,"x":0,"y":0,"zIndex":2},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","group":[],"height":100,"id":"b3ce7508-232a-89aa-72fd-dbbacc32f938","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":false,"tag":"Website","text":"www.fusen.cn","title":"网址","type":"text","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":3},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","group":[],"height":100,"id":"37ffcea7-0134-e6ee-014a-f0dddc466cf0","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":false,"tag":"Address","text":"S Halsted St, Chicago, IL 60608 U.S.","title":"地址","type":"text","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":4},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":"f9b30c55-6aa1-0d82-9a85-945fd6b061d7","group":[],"height":100,"id":"869c16d3-4b82-b052-6def-9162e126c57a","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":false,"tag":"Phone","text":"070-6666666","title":"电话","type":"text","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":5},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_4","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"cd0bf3b0-761f-e5b4-d7b6-f63fc54baa77","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M511.2,513.5H24.7V378.9h486.6V513.5z","systemShow":true,"tag":"","text":"","title":"SVG元素_11","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":6},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_4","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"dbc50336-de0c-4b4a-f0aa-1a6444a3f615","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M508.8,593.6l0,138.8l-51-11.2H78l-51,11.2l0-138.8l3.2-1.1v-16.9h475.4l0,16.9L508.8,593.6z","systemShow":true,"tag":"","text":"","title":"SVG元素_12","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":7},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"d5d3a1cb-2b13-2345-088d-b9163edf8aa6","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M508.3,512.2v12.3h-0.5l-2.2,3c0.1,12.4,0.2,24.8,0.3,37.2c-1.2,0.8-2.4,1.6-3.6,2.3c0.1,8.5,0.2,17.1,0.3,25.6c-15.3-5.5-30.7-11-46-16.5c-18.6-0.2-37.2-0.3-55.8-0.5c0-1.5,0-2.9,0.1-4.4c-17.2,0.1-34.4,0.2-51.6,0.2c0,1.3,0,2.7,0,4c-55.4,0.1-110.8,0.1-166.2,0.2c-0.1-1.5-0.1-3-0.2-4.5c-16.5,0.1-33.1,0.1-49.6,0.2c-0.1,1.4-0.1,2.8-0.2,4.2c-18.4,0.2-36.8,0.3-55.2,0.5v-51.8h0v51.8h0v0.4l-45.9,15.7c0.1-8.2,0.1-16.4,0.2-24.6c-1.6-0.9-3.3-1.8-4.9-2.7l-0.2-37.4l-2.2-2.9h-0.3v-12.3H508.3z","systemShow":true,"tag":"","text":"","title":"SVG元素_13","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":8},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"442c4e24-53ae-2a76-8e6b-7550e2747369","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M78,714.4h379.7V942H78V714.4z","systemShow":true,"tag":"","text":"","title":"SVG元素_14","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":9},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"646004b2-ad82-761f-c939-b85f96f97f9a","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M440.6,145.7h70.6V379l-70.6,0V145.7z","systemShow":true,"tag":"","text":"","title":"SVG元素_15","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":10},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"b6e4ab68-b36a-9534-d53f-722c93d54657","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M83.3,85.2c-0.2-21.2-0.4-42.4-0.7-63.7c17.6-0.2,35.1-0.3,52.7-0.5c0.2-2.1,0.4-4.1,0.7-6.2c15.3-0.1,30.6-0.1,45.8-0.2c0.6,2.2,1.1,4.4,1.7,6.7c55.4-0.2,110.9-0.4,166.3-0.7c0.6-1.9,1.1-3.8,1.7-5.7c15.1-0.1,30.1-0.1,45.2-0.2c0.6,2.1,1.2,4.1,1.8,6.2c17.4,0.1,34.8,0.2,52.2,0.3c-0.1,20.9-0.1,41.8-0.2,62.7c-57.4,0.4-114.8,0.7-172.2,1.1c0.2-1.2,0.6-5-1.7-8.8c-0.6-0.9-3.8-5.8-9.1-5.8c-5,0.1-8.4,4.5-9.7,7.7c-1.1,2.9-0.9,5.5-0.6,6.9C199.3,85.1,141.3,85.2,83.3,85.2z","systemShow":true,"tag":"","text":"","title":"SVG元素_16","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":11},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"280ced37-6725-562f-4272-79bacfcadb12","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M83.3,145.8c0-20.4-0.1-40.8-0.1-61.2c58,0.2,116,0.4,174.1,0.6c0.1,1.2,0.5,4.6,3.1,7.6c0.9,1.1,3.4,3.9,7.3,4c4.2,0.1,6.9-2.8,7.6-3.6c2.9-3.2,3-6.9,3-7.9c57.4-0.4,114.8-0.7,172.2-1.1c0,20.6,0,41.3-0.1,61.9C328,145.9,205.7,145.8,83.3,145.8z","systemShow":true,"tag":"","text":"","title":"SVG元素_17","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":12},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"a6aac5c1-8e54-c0f1-5749-9847f0fe497e","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M452.4,942l-17.3,59.9H100.4L82,942c57.6,0,115.2-0.1,172.8-0.1c-0.1,0.6-1.3,6.2,2.7,10.7c0.5,0.6,3.7,4,8.7,3.8c4.1-0.1,7.2-2.5,8.8-4.8c2.8-3.9,2-8.5,2.2-9.7C278.1,935.1,325.5,933.6,452.4,942z","systemShow":true,"tag":"","text":"","title":"SVG元素_18","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":13},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"2b2eac02-37ae-0b1e-898e-d9e3166dfc9a","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M78,379c0.1-78,0.3-155.9,0.4-233.9c20.8,0.2,41.7,0.4,62.5,0.6v2.9h37.4v-2.9h177.5v2.9h37.4v-2.9c21.5,0,43,0,64.5,0c0.9,77.8,1.9,155.5,2.8,233.3C333.1,379,205.6,379,78,379z","systemShow":true,"tag":"","text":"","title":"SVG元素_19","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":14},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"88181235-0317-fe9e-b202-cc7938acd449","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M451.6,145.6c0.1-21,0.1-41.9,0.2-62.9c3.7-19.3,7.4-38.6,11.2-57.9c14.5,0,29,0.1,43.4,0.1c0,40.2,0,80.4,0,120.6C488.2,145.5,469.9,145.5,451.6,145.6z","systemShow":true,"tag":"","text":"","title":"SVG元素_20","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":15},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"93aba661-9260-8420-4adc-feef1657f4e3","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M79,379l-54.4,0V145.7H79V379z","systemShow":true,"tag":"","text":"","title":"SVG元素_21","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":16},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"50dec384-7501-dfdd-9c65-ddf3142540af","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M26.2,145.6c0-39.9,0-79.8,0-119.7c15,0,30-0.1,45-0.1c3.7,19.5,7.4,39,11.2,58.5c-0.1,20.5-0.2,40.9-0.4,61.4C63.4,145.7,44.8,145.7,26.2,145.6z","systemShow":true,"tag":"","text":"","title":"SVG元素_22","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":17},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"d8337893-bfab-0e43-2ef2-2606d1612fec","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M450.3,714.4l58.5,10.7c0.2,66.5,0.3,133,0.5,199.5c-19.7,6.3-39.3,12.7-59,19V714.4z","systemShow":true,"tag":"","text":"","title":"SVG元素_23","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":18},{"QRcodeType":1,"algorithm":{"isLogoSplit":false,"list":[]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"fill_1","material":"","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":100,"id":"508859ae-cc8f-0b19-3554-c7632838d3fc","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"M82.4,943.8c-18.4-6.1-36.7-12.3-55.1-18.4C27.2,858.5,27.1,791.8,27,725l57.3-10.6C83.7,790.8,83.1,867.3,82.4,943.8z","systemShow":true,"tag":"","text":"","title":"SVG元素_24","type":"color","verticalAlign":"middle","visible":true,"width":100,"x":0,"y":0,"zIndex":19},{"QRcodeType":1,"algorithm":{"isLogoSplit":true,"list":[{"id":1,"list":[],"type":0},{"id":5,"list":[],"type":2}]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"material_1","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":83.3582,"id":"9baa3b65-c4f0-ebd8-866f-7e8d8e26e462","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"Logo","text":"","title":"logo","type":"image","verticalAlign":"middle","visible":true,"width":158.1738,"x":114.9929,"y":604.1777,"zIndex":20},{"QRcodeType":1,"algorithm":{"isLogoSplit":true,"list":[{"id":2,"list":[],"type":0},{"id":7,"list":[],"type":2}]},"align":"center","cameraStand":{"x":0,"y":0,"z":0},"fill":"#000000","follow":{"fill":"","material":"material_1","text":"","visible":""},"fontFamily":"Aqum2SmallCaps3","fontSize":20,"fromCombineId":-1,"group":[],"height":99.896,"id":"d9634ebf-78e2-3ead-30c5-cd545c3bfdaa","ifGroupNoBr":false,"lineHeight":1,"material":"","maxNum":50,"opacity":1,"paddingNum":0,"proportion":60,"rotation":0,"svgPath":"","systemShow":true,"tag":"Logo","text":"","title":"logo_25","type":"image","verticalAlign":"middle","visible":true,"width":228.5687,"x":191.3252,"y":809.4954,"zIndex":21}]},"param_data":{"address":"","is_crop":true,"line":"thick","logo_url":"https://s3.us-west-1.amazonaws.com/storage.fusenpack.com/c94100bd48992ea8f88c0bc65571547b2e4bd499a5b15bf0f7ba938e70693614` + "?id={{rand}}" + `","other":"","other1":"","phone":"","qrcode":"","ratio":1,"resolution":"512","shape":"other","slogan":"","template_tag":{"B1":[["#C44137"],["#235C9C"]],"B4":[["#C44137","#235C9C"]],"C1":[["#C44137"],["#235C9C"]],"C2":[["#C44137"],["#235C9C"]],"C3":[["#C44137"],["#235C9C"]],"C5":[["#C44137"],["#235C9C"]],"C6":[["#C44137"],["#235C9C"]]},"template_tag_id":["B1","C1","C2","C3","C5","C6","B4"],"template_tag_selected":{"color":[["#C44137"],["#235C9C"]],"index":0,"template_tag":"C1"},"template_tagid":"C1","version":"2","website":""},"tag_data":[{"fixed":0,"name":"主色","tag":"fill_1","value":""},{"fixed":0,"name":"副色","tag":"fill_2","value":""},{"fixed":0,"name":"备选色","tag":"fill_3","value":""},{"fixed":1,"name":"固定色A","tag":"fill_4","value":"rgba(255,255 ,255,1)"}]}`
|
||
|
||
func (l *TestAiLogic) TestAi(req *types.TestAiReq, userinfo *auth.UserInfo) (resp *basic.Response) {
|
||
return resp.SetStatusWithMessage(basic.CodeOK, "你干嘛,哎哟")
|
||
if req.Num > 100 {
|
||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "num can`t not large than 100")
|
||
}
|
||
defer func() {
|
||
if err := recover(); err != nil {
|
||
logx.Error("测试异常:", err)
|
||
}
|
||
}()
|
||
lenAiHost := len(l.svcCtx.Config.BLMService.Urls)
|
||
if lenAiHost == 0 {
|
||
return resp.SetStatusWithMessage(basic.CodeServiceErr, "ai host list is 0")
|
||
}
|
||
begin := time.Now().UTC().UnixMilli()
|
||
errChan := make(chan string)
|
||
w := sync.WaitGroup{}
|
||
b := -1
|
||
for i := 0; i < req.Num; i++ {
|
||
w.Add(1)
|
||
b++
|
||
if b > lenAiHost-1 {
|
||
b = 0
|
||
}
|
||
go func(hostIndex int) {
|
||
defer func() {
|
||
if err := recover(); err != nil {
|
||
logx.Error("测试异常2:", err)
|
||
}
|
||
}()
|
||
defer w.Done()
|
||
data = strings.ReplaceAll(data, "{{rand}}", uuid.New().String())
|
||
var postMap map[string]interface{}
|
||
if err := json.Unmarshal([]byte(data), &postMap); err != nil {
|
||
errChan <- err.Error()
|
||
return
|
||
}
|
||
var resultBLM constants.BLMServiceUrlResult
|
||
logx.Info("正在请求:" + l.svcCtx.Config.BLMService.Urls[hostIndex])
|
||
err := curl.NewClient(l.ctx, &curl.Config{
|
||
BaseUrl: l.svcCtx.Config.BLMService.Urls[hostIndex],
|
||
Url: constants.BLMServiceUrlLogoCombine,
|
||
RequireTimeout: time.Second * 15,
|
||
}).PostJson(postMap, &resultBLM)
|
||
if err != nil {
|
||
errChan <- err.Error()
|
||
return
|
||
}
|
||
}(b)
|
||
}
|
||
go func() {
|
||
w.Wait()
|
||
close(errChan)
|
||
}()
|
||
for v := range errChan {
|
||
return resp.SetStatusWithMessage(basic.CodeServiceErr, v)
|
||
}
|
||
end := time.Now().UTC().UnixMilli() - begin
|
||
avg := end / int64(req.Num)
|
||
return resp.SetStatus(basic.CodeOK, fmt.Sprintf("总耗时:%d ms,平均耗时%d ms", end, avg))
|
||
}
|
||
|
||
// 处理逻辑后 w,r 如:重定向, resp 必须重新处理
|
||
// func (l *TestAiLogic) AfterLogic(w http.ResponseWriter, r *http.Request, resp *basic.Response) {
|
||
// // httpx.OkJsonCtx(r.Context(), w, resp)
|
||
// }
|