Compare commits
20 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ae9984460f | |||
| e38a1a4480 | |||
| b112f45264 | |||
| 6fad80b5cd | |||
| 1d0e1812c8 | |||
| 40490ffe43 | |||
| 455b6d40de | |||
| 62dcac103f | |||
| 63a83ddd5e | |||
| f8d3d6a0ad | |||
| e2eb27a5ba | |||
| 9fbeddc9f4 | |||
| 289bbe3f0d | |||
| bec6a93b65 | |||
| e2a41fc187 | |||
| c7a04f3857 | |||
| 9c5398071c | |||
| 1f6400ba5d | |||
| afe0c149dd | |||
| 9b9d05a4ac |
+6
-4
@@ -1,14 +1,16 @@
|
|||||||
FROM golang:alpine AS backend-builder
|
FROM golang:latest AS backend-builder
|
||||||
|
RUN apt update
|
||||||
|
RUN apt install -y build-essential
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
COPY . .
|
COPY . .
|
||||||
|
ENV CGO_ENABLED=1
|
||||||
RUN go build -ldflags="-s -w" -o bin/server
|
RUN go build -ldflags="-s -w" -o bin/server
|
||||||
|
|
||||||
RUN apk add --no-cache upx
|
RUN apt install -y upx-ucl
|
||||||
|
|
||||||
RUN upx --best --lzma bin/server
|
RUN upx --best --lzma bin/server
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM golang:latest
|
||||||
COPY --from=backend-builder /build/bin/server /app/server
|
COPY --from=backend-builder /build/bin/server /app/server
|
||||||
COPY static /app/static
|
COPY static /app/static
|
||||||
COPY static/*.so /app/
|
COPY static/*.so /app/
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ require (
|
|||||||
github.com/wenlng/go-captcha-assets v1.0.7
|
github.com/wenlng/go-captcha-assets v1.0.7
|
||||||
github.com/wenlng/go-captcha/v2 v2.0.4
|
github.com/wenlng/go-captcha/v2 v2.0.4
|
||||||
github.com/wneessen/go-mail v0.6.2
|
github.com/wneessen/go-mail v0.6.2
|
||||||
github.com/yalue/onnxruntime_go v1.22.0
|
github.com/yalue/onnxruntime_go v1.9.0
|
||||||
go.uber.org/automaxprocs v1.6.0
|
go.uber.org/automaxprocs v1.6.0
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
golang.org/x/crypto v0.39.0
|
golang.org/x/crypto v0.39.0
|
||||||
@@ -64,7 +64,6 @@ require (
|
|||||||
github.com/go-logr/stdr v1.2.2 // indirect
|
github.com/go-logr/stdr v1.2.2 // indirect
|
||||||
github.com/go-ole/go-ole v1.2.6 // indirect
|
github.com/go-ole/go-ole v1.2.6 // indirect
|
||||||
github.com/go-openapi/inflect v0.19.0 // indirect
|
github.com/go-openapi/inflect v0.19.0 // indirect
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
|
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect
|
||||||
github.com/google/go-cmp v0.6.0 // indirect
|
github.com/google/go-cmp v0.6.0 // indirect
|
||||||
github.com/gorilla/websocket v1.5.3 // indirect
|
github.com/gorilla/websocket v1.5.3 // indirect
|
||||||
@@ -79,18 +78,12 @@ require (
|
|||||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||||
github.com/oklog/ulid/v2 v2.1.1 // indirect
|
github.com/oklog/ulid/v2 v2.1.1 // indirect
|
||||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 // indirect
|
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||||
github.com/sagikazarmark/locafero v0.7.0 // indirect
|
|
||||||
github.com/samber/lo v1.51.0 // indirect
|
github.com/samber/lo v1.51.0 // indirect
|
||||||
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
github.com/shoenig/go-m1cpu v0.1.6 // indirect
|
||||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
|
||||||
github.com/spf13/afero v1.12.0 // indirect
|
|
||||||
github.com/spf13/cast v1.9.2 // indirect
|
github.com/spf13/cast v1.9.2 // indirect
|
||||||
github.com/spf13/pflag v1.0.6 // indirect
|
|
||||||
github.com/subosito/gotenv v1.6.0 // indirect
|
|
||||||
github.com/tidwall/pretty v1.2.0 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
github.com/tklauser/go-sysconf v0.3.12 // indirect
|
||||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||||
|
|||||||
@@ -90,8 +90,6 @@ github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1
|
|||||||
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||||
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
github.com/go-test/deep v1.0.3 h1:ZrJSEWsXzPOxaZnFteGEfooLba+ju3FYIbOrS+rQd68=
|
||||||
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
github.com/go-test/deep v1.0.3/go.mod h1:wGDj63lr65AM2AQyKZd/NYHGb0R+1RLqB8NKt3aSFNA=
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss=
|
|
||||||
github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
|
|
||||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0 h1:EEZqu1PNRSmm+7Cqm9A/8+ObgfbMzhE1ps9Z3LD7HgM=
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0 h1:EEZqu1PNRSmm+7Cqm9A/8+ObgfbMzhE1ps9Z3LD7HgM=
|
||||||
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0/go.mod h1:LHrxY+2IzNTHVTPG/s5yaz1VmXbj+CQ7Hr5SeVkHiTw=
|
github.com/gogf/gf/contrib/nosql/redis/v2 v2.9.0/go.mod h1:LHrxY+2IzNTHVTPG/s5yaz1VmXbj+CQ7Hr5SeVkHiTw=
|
||||||
github.com/gogf/gf/v2 v2.9.0 h1:semN5Q5qGjDQEv4620VzxcJzJlSD07gmyJ9Sy9zfbHk=
|
github.com/gogf/gf/v2 v2.9.0 h1:semN5Q5qGjDQEv4620VzxcJzJlSD07gmyJ9Sy9zfbHk=
|
||||||
@@ -145,8 +143,6 @@ github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNs
|
|||||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||||
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||||
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
|
github.com/pborman/getopt v0.0.0-20170112200414-7148bc3a4c30/go.mod h1:85jBQOZwpVEaDAr341tbn15RS4fCAsIst0qp7i8ex1o=
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
|
|
||||||
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||||
@@ -162,8 +158,6 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
|||||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
|
||||||
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
|
||||||
github.com/sagikazarmark/locafero v0.7.0 h1:5MqpDsTGNDhY8sGp0Aowyf0qKsPrhewaLSsFaodPcyo=
|
|
||||||
github.com/sagikazarmark/locafero v0.7.0/go.mod h1:2za3Cg5rMaTMoG/2Ulr9AwtFaIppKXTRYnozin4aB5k=
|
|
||||||
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
github.com/samber/lo v1.51.0 h1:kysRYLbHy/MB7kQZf5DSN50JHmMsNEdeY24VzJFu7wI=
|
||||||
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
github.com/samber/lo v1.51.0/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||||
github.com/samber/oops v1.19.0 h1:sfZAwC8MmTXBRRyNc4Z1utuTPBx+hFKF5fJ9DEQRZfw=
|
github.com/samber/oops v1.19.0 h1:sfZAwC8MmTXBRRyNc4Z1utuTPBx+hFKF5fJ9DEQRZfw=
|
||||||
@@ -178,16 +172,8 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
|||||||
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
||||||
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
github.com/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||||
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
github.com/shopspring/decimal v1.4.0/go.mod h1:gawqmDU56v4yIKSwfBSFip1HdCCXN8/+DMd9qYNcwME=
|
||||||
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
|
|
||||||
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
|
|
||||||
github.com/spf13/afero v1.12.0 h1:UcOPyRBYczmFn6yvphxkn9ZEOY65cpwGKb5mL36mrqs=
|
|
||||||
github.com/spf13/afero v1.12.0/go.mod h1:ZTlWwG4/ahT8W7T0WQ5uYmjI9duaLQGy3Q2OAl4sk/4=
|
|
||||||
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
|
github.com/spf13/cast v1.9.2 h1:SsGfm7M8QOFtEzumm7UZrZdLLquNdzFYfIbEXntcFbE=
|
||||||
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
github.com/spf13/cast v1.9.2/go.mod h1:jNfB8QC9IA6ZuY2ZjDp0KtFO2LZZlg4S/7bzP6qqeHo=
|
||||||
github.com/spf13/pflag v1.0.6 h1:jFzHGLGAlb3ruxLB8MhbI6A8+AQX/2eW4qeyNZXNp2o=
|
|
||||||
github.com/spf13/pflag v1.0.6/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
|
||||||
github.com/spf13/viper v1.20.1 h1:ZMi+z/lvLyPSCoNtFCpqjy0S4kPbirhpTMwl8BkW9X4=
|
|
||||||
github.com/spf13/viper v1.20.1/go.mod h1:P9Mdzt1zoHIG8m2eZQinpiBjo6kCmZSKBClNNqjJvu4=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||||
@@ -198,8 +184,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
|
|
||||||
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
|
|
||||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
@@ -218,8 +202,8 @@ github.com/wenlng/go-captcha/v2 v2.0.4 h1:5cSUF36ZyA03qeDMjKmeXGpbYJMXEexZIYK3Vg
|
|||||||
github.com/wenlng/go-captcha/v2 v2.0.4/go.mod h1:5hac1em3uXoyC5ipZ0xFv9umNM/waQvYAQdr0cx/h34=
|
github.com/wenlng/go-captcha/v2 v2.0.4/go.mod h1:5hac1em3uXoyC5ipZ0xFv9umNM/waQvYAQdr0cx/h34=
|
||||||
github.com/wneessen/go-mail v0.6.2 h1:c6V7c8D2mz868z9WJ+8zDKtUyLfZ1++uAZmo2GRFji8=
|
github.com/wneessen/go-mail v0.6.2 h1:c6V7c8D2mz868z9WJ+8zDKtUyLfZ1++uAZmo2GRFji8=
|
||||||
github.com/wneessen/go-mail v0.6.2/go.mod h1:L/PYjPK3/2ZlNb2/FjEBIn9n1rUWjW+Toy531oVmeb4=
|
github.com/wneessen/go-mail v0.6.2/go.mod h1:L/PYjPK3/2ZlNb2/FjEBIn9n1rUWjW+Toy531oVmeb4=
|
||||||
github.com/yalue/onnxruntime_go v1.22.0 h1:SzqOfFRRrLRRAFR5VoSxABjTiQSAi8Y4ETYKrMFK1jk=
|
github.com/yalue/onnxruntime_go v1.9.0 h1:AhgkpBjphJZsHT5karKt93xPkPFNP0Iz6ENUbNAFQU4=
|
||||||
github.com/yalue/onnxruntime_go v1.22.0/go.mod h1:b4X26A8pekNb1ACJ58wAXgNKeUCGEAQ9dmACut9Sm/4=
|
github.com/yalue/onnxruntime_go v1.9.0/go.mod h1:b4X26A8pekNb1ACJ58wAXgNKeUCGEAQ9dmACut9Sm/4=
|
||||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package v1
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/gogf/gf/v2/frame/g"
|
"github.com/gogf/gf/v2/frame/g"
|
||||||
|
"github.com/gogf/gf/v2/net/ghttp"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CpTaskLogListReq struct {
|
type CpTaskLogListReq struct {
|
||||||
@@ -10,3 +11,9 @@ type CpTaskLogListReq struct {
|
|||||||
Page int `json:"page" d:"1"`
|
Page int `json:"page" d:"1"`
|
||||||
Size int `json:"size" d:"10"`
|
Size int `json:"size" d:"10"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type CpTaskOCRReq struct {
|
||||||
|
g.Meta `path:"/ocr" method:"post" tags:"CpTask" summary:"OCR识别" auth:"false"`
|
||||||
|
File *ghttp.UploadFile `json:"file"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
}
|
||||||
|
|||||||
@@ -5,9 +5,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
_ "image/jpeg"
|
_ "image/jpeg"
|
||||||
_ "image/png"
|
_ "image/png"
|
||||||
|
"likedream-goframe/internal/framework/logger"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
ort "github.com/yalue/onnxruntime_go"
|
ort "github.com/yalue/onnxruntime_go"
|
||||||
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ImageClassifier struct {
|
type ImageClassifier struct {
|
||||||
@@ -21,7 +26,25 @@ type ImageClassifier struct {
|
|||||||
// NewImageClassifier 创建新的图片分类器
|
// NewImageClassifier 创建新的图片分类器
|
||||||
func NewImageClassifier(modelPath, classesPath string) (*ImageClassifier, error) {
|
func NewImageClassifier(modelPath, classesPath string) (*ImageClassifier, error) {
|
||||||
// 初始化ONNX Runtime
|
// 初始化ONNX Runtime
|
||||||
err := ort.InitializeEnvironment()
|
exePath := strings.ToLower(os.Args[0])
|
||||||
|
// 获取绝对路径
|
||||||
|
absPath, err := filepath.Abs(exePath)
|
||||||
|
dir := filepath.Dir(absPath)
|
||||||
|
systemOS := runtime.GOOS
|
||||||
|
switch systemOS {
|
||||||
|
case "windows":
|
||||||
|
dir = filepath.Join(dir, "onnxruntime.dll")
|
||||||
|
break
|
||||||
|
case "darwin":
|
||||||
|
dir = filepath.Join(dir, "onnxruntime.dylib")
|
||||||
|
break
|
||||||
|
case "linux":
|
||||||
|
dir = filepath.Join(dir, "onnxruntime.so")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
logger.Logger.Info("初始化onnx:", zap.String("绝对路径", absPath), zap.String("父文件夹", dir))
|
||||||
|
ort.SetSharedLibraryPath(dir)
|
||||||
|
err = ort.InitializeEnvironment()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("初始化ONNX Runtime失败: %v", err)
|
return nil, fmt.Errorf("初始化ONNX Runtime失败: %v", err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
package classifier
|
package classifier
|
||||||
|
|
||||||
var imageClassifier, err = NewImageClassifier("./static/model.onnx", "./static/classes.txt")
|
import "likedream-goframe/internal/utils"
|
||||||
|
|
||||||
|
var imageClassifier, _ = NewImageClassifier("static/model.onnx", "static/classes.txt")
|
||||||
|
|
||||||
// 图片数据 & 类别名称
|
// 图片数据 & 类别名称
|
||||||
// return 是否匹配
|
// return 是否匹配
|
||||||
func ClassifyImage(imgData []byte, className string) bool {
|
func ClassifyImage(imgData []byte, className string) bool {
|
||||||
|
if imageClassifier == nil {
|
||||||
|
c, err := NewImageClassifier("static/model.onnx", "static/classes.txt")
|
||||||
|
utils.OkOrPanic(err)
|
||||||
|
imageClassifier = c
|
||||||
|
}
|
||||||
name, _, _ := imageClassifier.PredictFromBytes(imgData)
|
name, _, _ := imageClassifier.PredictFromBytes(imgData)
|
||||||
return className == name
|
return className == name
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -676,7 +676,6 @@ func (c *CpdailySleepCheckTask) Submit(ctx context.Context, form map[string]*gva
|
|||||||
sign := taskhelper.GetSubmitSign(submitData)
|
sign := taskhelper.GetSubmitSign(submitData)
|
||||||
|
|
||||||
submitData["sign"] = gvar.New(sign)
|
submitData["sign"] = gvar.New(sign)
|
||||||
utils.OkOrPanic(errors.NewBusinessError(503, "临时拦截"), oops.WithContext(ctx).Wrap)
|
|
||||||
response, e := c.client.R().
|
response, e := c.client.R().
|
||||||
SetBody(submitData).
|
SetBody(submitData).
|
||||||
WithContext(ctx).
|
WithContext(ctx).
|
||||||
|
|||||||
@@ -2,7 +2,9 @@ package cpdaily
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"io"
|
||||||
v1 "likedream-goframe/internal/api/v1"
|
v1 "likedream-goframe/internal/api/v1"
|
||||||
|
"likedream-goframe/internal/application/classifier"
|
||||||
"likedream-goframe/internal/ent"
|
"likedream-goframe/internal/ent"
|
||||||
"likedream-goframe/internal/service"
|
"likedream-goframe/internal/service"
|
||||||
"likedream-goframe/internal/utils"
|
"likedream-goframe/internal/utils"
|
||||||
@@ -11,6 +13,14 @@ import (
|
|||||||
type CpTaskLogCtrlV1 struct {
|
type CpTaskLogCtrlV1 struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c CpTaskLogCtrlV1) OCR(ctx context.Context, req *v1.CpTaskOCRReq) (res *utils.Response[any], err error) {
|
||||||
|
file, _ := req.File.Open()
|
||||||
|
defer file.Close()
|
||||||
|
bytes, _ := io.ReadAll(file)
|
||||||
|
result := classifier.ClassifyImage(bytes, req.Name)
|
||||||
|
return utils.SuccessWithData[any](result), nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c CpTaskLogCtrlV1) List(ctx context.Context, req *v1.CpTaskLogListReq) (res *utils.Response[[]*ent.CpTaskLog], err error) {
|
func (c CpTaskLogCtrlV1) List(ctx context.Context, req *v1.CpTaskLogListReq) (res *utils.Response[[]*ent.CpTaskLog], err error) {
|
||||||
defer utils.Pass(&err)
|
defer utils.Pass(&err)
|
||||||
return service.Global.CpTaskLog.List(ctx, req), nil
|
return service.Global.CpTaskLog.List(ctx, req), nil
|
||||||
|
|||||||
@@ -9,4 +9,6 @@ import (
|
|||||||
|
|
||||||
type ICpTaskLogCtrlV1 interface {
|
type ICpTaskLogCtrlV1 interface {
|
||||||
List(ctx context.Context, req *v1.CpTaskLogListReq) (res *utils.Response[[]*ent.CpTaskLog], err error)
|
List(ctx context.Context, req *v1.CpTaskLogListReq) (res *utils.Response[[]*ent.CpTaskLog], err error)
|
||||||
|
|
||||||
|
OCR(ctx context.Context, req *v1.CpTaskOCRReq) (res *utils.Response[any], err error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
|||||||
e = db.Global.CpTaskLog.Create().
|
e = db.Global.CpTaskLog.Create().
|
||||||
SetCpTaskID(taskPayload.CpTaskID).
|
SetCpTaskID(taskPayload.CpTaskID).
|
||||||
SetCpUserID(targetTask.Edges.CpUser.ID).
|
SetCpUserID(targetTask.Edges.CpUser.ID).
|
||||||
SetSystemUserID(targetTask.Edges.CpUser.Edges.Sysuser.ID).
|
SetSystemUserID(targetTask.Edges.SysUser.ID).
|
||||||
SetIsSuccess(false).
|
SetIsSuccess(false).
|
||||||
SetRealName("").
|
SetRealName("").
|
||||||
SetErrorMessage(errorMessage).
|
SetErrorMessage(errorMessage).
|
||||||
@@ -127,7 +127,6 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
|||||||
}
|
}
|
||||||
|
|
||||||
submitForm := taskExecutor.FillCustomForm(ctx, cpdailyRealTask, customFormItems, deviceID, targetTask.Edges.CpUser.Username)
|
submitForm := taskExecutor.FillCustomForm(ctx, cpdailyRealTask, customFormItems, deviceID, targetTask.Edges.CpUser.Username)
|
||||||
|
|
||||||
taskExecutor.Submit(ctx, submitForm, targetTask.Edges.CpUser.Username, deviceID)
|
taskExecutor.Submit(ctx, submitForm, targetTask.Edges.CpUser.Username, deviceID)
|
||||||
|
|
||||||
db.Global.CpTask.UpdateOneID(taskPayload.CpTaskID).SetTaskStatus(cptask.TaskStatusDone).AddSuccessCount(1).ExecX(ctx)
|
db.Global.CpTask.UpdateOneID(taskPayload.CpTaskID).SetTaskStatus(cptask.TaskStatusDone).AddSuccessCount(1).ExecX(ctx)
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ func (ts *TaskScanner) scanCpdailyTask() {
|
|||||||
queue.AddTask(ts.ctx, asynq.NewTask(cst.TaskCpdaily, payloadWriter.Bytes()),
|
queue.AddTask(ts.ctx, asynq.NewTask(cst.TaskCpdaily, payloadWriter.Bytes()),
|
||||||
asynq.TaskID(fmt.Sprintf("cpdaily:task:%d", task.ID)),
|
asynq.TaskID(fmt.Sprintf("cpdaily:task:%d", task.ID)),
|
||||||
asynq.MaxRetry(3),
|
asynq.MaxRetry(3),
|
||||||
asynq.Unique(10*time.Minute),
|
asynq.Unique(1*time.Minute),
|
||||||
asynq.ProcessAt(execTime),
|
asynq.ProcessAt(execTime),
|
||||||
asynq.Deadline(execTime.Add(12*time.Minute)),
|
asynq.Deadline(execTime.Add(12*time.Minute)),
|
||||||
asynq.Queue(cst.TaskQueueCpdaily),
|
asynq.Queue(cst.TaskQueueCpdaily),
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ func Pass(err *error) {
|
|||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
e, ok := errorx.ErrorFromPanic(r)
|
e, ok := errorx.ErrorFromPanic(r)
|
||||||
if ok {
|
if ok {
|
||||||
*err = e
|
*err = oops.Wrap(e)
|
||||||
} else {
|
} else {
|
||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ func HandleError(f func(error)) {
|
|||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
e, ok := errorx.ErrorFromPanic(r)
|
e, ok := errorx.ErrorFromPanic(r)
|
||||||
if ok {
|
if ok {
|
||||||
f(e)
|
f(oops.Wrap(e))
|
||||||
} else {
|
} else {
|
||||||
panic(r)
|
panic(r)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user