Compare commits
53 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 948d118a4f | |||
| 618d6384d9 | |||
| face5ca364 | |||
| d3869f68f8 | |||
| 97ab3a7a1d | |||
| 6cc4582c87 | |||
| 4941d4eb8a | |||
| 11a16a65a0 | |||
| 71f992544e | |||
| 6320d6eb17 | |||
| 6840b69f1a | |||
| 1ae2601209 | |||
| 07444f70df | |||
| 1bc04c74f3 | |||
| dcb5cd8a4e | |||
| 0d7d4c11a0 | |||
| e4d07874eb | |||
| ae9984460f | |||
| e38a1a4480 | |||
| b112f45264 | |||
| 6fad80b5cd | |||
| 1d0e1812c8 | |||
| 40490ffe43 | |||
| 455b6d40de | |||
| 62dcac103f | |||
| 63a83ddd5e | |||
| f8d3d6a0ad | |||
| e2eb27a5ba | |||
| 9fbeddc9f4 | |||
| 289bbe3f0d | |||
| bec6a93b65 | |||
| e2a41fc187 | |||
| c7a04f3857 | |||
| 9c5398071c | |||
| 1f6400ba5d | |||
| afe0c149dd | |||
| 9b9d05a4ac | |||
| f59cb29e4d | |||
| f71ee4fab4 | |||
| 6390831f16 | |||
| da2fd3111b | |||
| 02f97fb4a4 | |||
| ceee685b80 | |||
| 132472de12 | |||
| 7d8c14a045 | |||
| 25d190c498 | |||
| f1dfa61578 | |||
| 2c0026267e | |||
| ab84984fb0 | |||
| 4f6e516ade | |||
| c9aeb90209 | |||
| 2125fd4bde | |||
| 41dfe9ff54 |
@@ -29,7 +29,7 @@ jobs:
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.actor }}
|
||||
username: ${{ secrets.USERNAME }}
|
||||
password: ${{ secrets.PASSWORD }}
|
||||
- name: Extract metadata for Docker
|
||||
id: meta
|
||||
|
||||
+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
|
||||
COPY . .
|
||||
|
||||
ENV CGO_ENABLED=1
|
||||
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
|
||||
|
||||
FROM alpine:latest
|
||||
FROM golang:latest
|
||||
COPY --from=backend-builder /build/bin/server /app/server
|
||||
COPY static /app/static
|
||||
COPY static/*.so /app/
|
||||
|
||||
+6
-1
@@ -37,4 +37,9 @@ fromName = "今日校园系统"
|
||||
accessKey = "dzckoE1UlZe8XFItWQDI"
|
||||
secretKey = "f8UZdnDohtwZk5HInT1Cw1QCztSGnFuPPqfSSjzu"
|
||||
baseUrl = "http://s3.out"
|
||||
bucket = "likedream"
|
||||
bucket = "likedream"
|
||||
|
||||
[cpdaily]
|
||||
appVersion = "5.7.0"
|
||||
systemVersion = "iOS 17"
|
||||
calVersion = "3.0.0"
|
||||
@@ -9,6 +9,7 @@ require (
|
||||
github.com/aws/aws-sdk-go-v2 v1.36.6
|
||||
github.com/aws/aws-sdk-go-v2/credentials v1.17.71
|
||||
github.com/aws/aws-sdk-go-v2/service/s3 v1.84.1
|
||||
github.com/breml/rootcerts v0.3.3
|
||||
github.com/bytedance/sonic v1.14.0
|
||||
github.com/deatil/go-cryptobin v1.1.1005
|
||||
github.com/go-sql-driver/mysql v1.9.3
|
||||
@@ -20,14 +21,14 @@ require (
|
||||
github.com/joomcode/errorx v1.2.0
|
||||
github.com/redis/go-redis/v9 v9.11.0
|
||||
github.com/samber/oops v1.19.0
|
||||
github.com/shirou/gopsutil/v3 v3.24.5
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
github.com/spf13/viper v1.20.1
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/tidwall/match v1.1.1
|
||||
github.com/wenlng/go-captcha-assets v1.0.7
|
||||
github.com/wenlng/go-captcha/v2 v2.0.4
|
||||
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/zap v1.27.0
|
||||
golang.org/x/crypto v0.39.0
|
||||
@@ -61,14 +62,15 @@ require (
|
||||
github.com/fsnotify/fsnotify v1.8.0 // indirect
|
||||
github.com/go-logr/logr v1.4.2 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.6 // 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/google/go-cmp v0.6.0 // indirect
|
||||
github.com/gorilla/websocket v1.5.3 // indirect
|
||||
github.com/grokify/html-strip-tags-go v0.1.0 // indirect
|
||||
github.com/hashicorp/hcl/v2 v2.18.1 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
|
||||
github.com/magiconair/properties v1.8.9 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||
@@ -76,18 +78,17 @@ require (
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
github.com/oklog/ulid/v2 v2.1.1 // 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/rivo/uniseg v0.4.7 // 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/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.12.0 // indirect
|
||||
github.com/shoenig/go-m1cpu v0.1.6 // 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/tklauser/go-sysconf v0.3.12 // indirect
|
||||
github.com/tklauser/numcpus v0.6.1 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/yusufpapurcu/wmi v1.2.4 // indirect
|
||||
github.com/zclconf/go-cty v1.14.4 // indirect
|
||||
github.com/zclconf/go-cty-yaml v1.1.0 // indirect
|
||||
go.opentelemetry.io/otel v1.32.0 // indirect
|
||||
|
||||
@@ -44,6 +44,8 @@ github.com/aws/smithy-go v1.22.4 h1:uqXzVZNuNexwc/xrh6Tb56u89WDlJY6HS+KC0S4QSjw=
|
||||
github.com/aws/smithy-go v1.22.4/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI=
|
||||
github.com/bmatcuk/doublestar v1.3.4 h1:gPypJ5xD31uhX6Tf54sDPUOBXTqKH4c9aPY66CyQrS0=
|
||||
github.com/bmatcuk/doublestar v1.3.4/go.mod h1:wiQtGV+rzVYxB7WIlirSN++5HPtPlXEo9MEoZQC/PmE=
|
||||
github.com/breml/rootcerts v0.3.3 h1://GnaRtQ/9BY2+GtMk2wtWxVdCRysiaPr5/xBwl7NKw=
|
||||
github.com/breml/rootcerts v0.3.3/go.mod h1:S/PKh+4d1HUn4HQovEB8hPJZO6pUZYrIhmXBhsegfXw=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs=
|
||||
github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c=
|
||||
github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA=
|
||||
@@ -80,14 +82,14 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY=
|
||||
github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
|
||||
github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||
github.com/go-ole/go-ole v1.2.6 h1:/Fpf6oFPoeFik9ty7siob0G6Ke8QvQEuVcuChpwXzpY=
|
||||
github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0=
|
||||
github.com/go-openapi/inflect v0.19.0 h1:9jCH9scKIbHeV9m12SmPilScz6krDxKRasNNSNPXu/4=
|
||||
github.com/go-openapi/inflect v0.19.0/go.mod h1:lHpZVlpIQqLyKwJ4N+YSc9hchQy/i12fJykb83CRBH4=
|
||||
github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo=
|
||||
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/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/go.mod h1:LHrxY+2IzNTHVTPG/s5yaz1VmXbj+CQ7Hr5SeVkHiTw=
|
||||
github.com/gogf/gf/v2 v2.9.0 h1:semN5Q5qGjDQEv4620VzxcJzJlSD07gmyJ9Sy9zfbHk=
|
||||
@@ -96,6 +98,7 @@ github.com/golang-jwt/jwt/v5 v5.2.2 h1:Rl4B7itRWVtYIHFrSNd7vhTiz9UpLdi6gZhZ3wEeD
|
||||
github.com/golang-jwt/jwt/v5 v5.2.2/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g=
|
||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||
@@ -119,6 +122,8 @@ github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
|
||||
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4=
|
||||
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I=
|
||||
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
|
||||
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
|
||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||
@@ -138,10 +143,10 @@ 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/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
|
||||
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/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/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
|
||||
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
|
||||
github.com/redis/go-redis/v9 v9.11.0 h1:E3S08Gl/nJNn5vkxd2i78wZxWAPNZgUNTp8WIJUAiIs=
|
||||
@@ -153,26 +158,22 @@ 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/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/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/go.mod h1:4+MXEGsJzbKGaUEQFKBq2xtfuznW9oz/WrgyzMzRoM0=
|
||||
github.com/samber/oops v1.19.0 h1:sfZAwC8MmTXBRRyNc4Z1utuTPBx+hFKF5fJ9DEQRZfw=
|
||||
github.com/samber/oops v1.19.0/go.mod h1:+f+61dbiMxEMQ8gw/zTxW2pk+YGobaDM4glEHQtPOww=
|
||||
github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8=
|
||||
github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I=
|
||||
github.com/shirou/gopsutil/v3 v3.24.5 h1:i0t8kL+kQTvpAYToeuiVk3TgDeKOFioZO3Ztz/iZ9pI=
|
||||
github.com/shirou/gopsutil/v3 v3.24.5/go.mod h1:bsoOS1aStSs9ErQ1WWfxllSeS1K5D+U30r2NfcubMVk=
|
||||
github.com/shoenig/go-m1cpu v0.1.6 h1:nxdKQNcEB6vzgA2E2bvzKIYRuNj7XNJ4S/aRSwKzFtM=
|
||||
github.com/shoenig/go-m1cpu v0.1.6/go.mod h1:1JJMcUBvfNwpq05QDQVAnx3gUHr9IYF7GNg9SUEw2VQ=
|
||||
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/shopspring/decimal v1.4.0 h1:bxl37RwXBklmTi0C79JfXCEBD1cqqHt0bbgBAGFp81k=
|
||||
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/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.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
@@ -183,14 +184,16 @@ 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.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
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/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tklauser/go-sysconf v0.3.12 h1:0QaGUFOdQaIVdPgfITYzaTegZvdCjmYO52cSFAEVmqU=
|
||||
github.com/tklauser/go-sysconf v0.3.12/go.mod h1:Ho14jnntGE1fpdOqQEEaiKRpvIavV0hSfmBq8nJbHYI=
|
||||
github.com/tklauser/numcpus v0.6.1 h1:ng9scYS7az0Bk4OZLvrNXNSAO2Pxr1XXRAPyjhIx+Fk=
|
||||
github.com/tklauser/numcpus v0.6.1/go.mod h1:1XfjsgE2zo8GVw7POkMbHENHzVg3GzmoZ9fESEdAacY=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/wenlng/go-captcha-assets v1.0.7 h1:tfF84A4un/i4p+TbRVHDqDPeQeatvddOfB2xbKvLVq8=
|
||||
@@ -199,9 +202,11 @@ 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/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/yalue/onnxruntime_go v1.22.0 h1:SzqOfFRRrLRRAFR5VoSxABjTiQSAi8Y4ETYKrMFK1jk=
|
||||
github.com/yalue/onnxruntime_go v1.22.0/go.mod h1:b4X26A8pekNb1ACJ58wAXgNKeUCGEAQ9dmACut9Sm/4=
|
||||
github.com/yalue/onnxruntime_go v1.9.0 h1:AhgkpBjphJZsHT5karKt93xPkPFNP0Iz6ENUbNAFQU4=
|
||||
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/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
|
||||
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
|
||||
github.com/zclconf/go-cty v1.14.4 h1:uXXczd9QDGsgu0i/QFR/hzI5NYCHLf6NQw/atrbnhq8=
|
||||
github.com/zclconf/go-cty v1.14.4/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgrPIxfnZE=
|
||||
github.com/zclconf/go-cty-yaml v1.1.0 h1:nP+jp0qPHv2IhUVqmQSzjvqAWcObN0KBkUl2rWBdig0=
|
||||
@@ -265,7 +270,9 @@ golang.org/x/sync v0.11.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
|
||||
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
|
||||
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201204225414-ed752295db88/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
@@ -273,6 +280,7 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
@@ -313,6 +321,7 @@ golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxb
|
||||
golang.org/x/tools v0.34.0 h1:qIpSLOxeCYGg9TrcJokLBG4KFA6d795g0xkBkiESGlo=
|
||||
golang.org/x/tools v0.34.0/go.mod h1:pAP9OwEaY1CAW3HOmg3hLZC5Z0CCmzjAF2UQMSqNARg=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY=
|
||||
google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
|
||||
@@ -52,6 +52,7 @@ func StartServer(ctx context.Context) {
|
||||
cpdailyGroup.Bind(cpdaily.NewCpUserCtrlV1())
|
||||
cpdailyGroup.Bind(cpdaily.NewCpTaskCtrlV1())
|
||||
cpdailyGroup.Bind(cpdaily.NewCpImageCtrlV1())
|
||||
cpdailyGroup.Bind(cpdaily.NewCpTaskLogCtrlV1())
|
||||
})
|
||||
|
||||
s.SetPort(port.Int())
|
||||
|
||||
@@ -9,8 +9,8 @@ import (
|
||||
|
||||
type GetRecentTasksReq struct {
|
||||
g.Meta `path:"/task/recent" method:"get" tags:"CpTask" summary:"获取最近任务"`
|
||||
UserId int64 `json:"userId"`
|
||||
Type string `json:"type"`
|
||||
UserId int64 `json:"userId"`
|
||||
Type cptask.TaskType `json:"type"`
|
||||
}
|
||||
|
||||
type AddTaskReq struct {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
type CpTaskLogListReq struct {
|
||||
g.Meta `path:"/taskLog" method:"get" tags:"CpTaskLog" summary:"获取cp任务日志"`
|
||||
TaskID int64 `json:"task_id"`
|
||||
Page int `json:"page" d:"1"`
|
||||
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"`
|
||||
}
|
||||
@@ -31,6 +31,7 @@ type MenuAddReq struct {
|
||||
Route string `json:"route"`
|
||||
Component string `json:"component"`
|
||||
Hidden bool `json:"hidden"`
|
||||
KeepAlive bool `json:"keepAlive"`
|
||||
Icon string `json:"icon"`
|
||||
Order uint `json:"order"`
|
||||
ParentId int64 `json:"parentId"`
|
||||
|
||||
@@ -16,6 +16,7 @@ type UserMenuRes struct {
|
||||
Route string `json:"route"`
|
||||
Component string `json:"component"`
|
||||
Hidden bool `json:"hidden"`
|
||||
KeepAlive bool `json:"keepAlive"`
|
||||
Icon string `json:"icon"`
|
||||
Children []*UserMenuRes `json:"children"`
|
||||
Order uint `json:"order"`
|
||||
|
||||
@@ -5,9 +5,14 @@ import (
|
||||
"fmt"
|
||||
_ "image/jpeg"
|
||||
_ "image/png"
|
||||
"likedream-goframe/internal/framework/logger"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
ort "github.com/yalue/onnxruntime_go"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
type ImageClassifier struct {
|
||||
@@ -21,8 +26,26 @@ type ImageClassifier struct {
|
||||
// NewImageClassifier 创建新的图片分类器
|
||||
func NewImageClassifier(modelPath, classesPath string) (*ImageClassifier, error) {
|
||||
// 初始化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
|
||||
}
|
||||
ort.SetSharedLibraryPath(dir)
|
||||
err = ort.InitializeEnvironment()
|
||||
if err != nil {
|
||||
logger.Logger.Info("初始化onnx:", zap.String("绝对路径", absPath), zap.String("父文件夹", dir))
|
||||
return nil, fmt.Errorf("初始化ONNX Runtime失败: %v", err)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
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 是否匹配
|
||||
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)
|
||||
return className == name
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ func UploadImageFromStorage(ctx context.Context, host string, imageId uuid.UUID,
|
||||
utils.OkOrPanic(errors.NewBusinessError(503, "上传图片失败: "+utils.ReadString(resp.Body)), oops.WithContext(ctx).With("response", utils.ReadString(resp.Body)).Wrap)
|
||||
}
|
||||
|
||||
previewUrl := GetPreviewUrlAsync(ctx, host, targetImage.Key, taskType, client)
|
||||
previewUrl := GetPreviewUrlAsync(ctx, host, imageUploadPolicy.FileName, taskType, client)
|
||||
|
||||
return previewUrl
|
||||
}
|
||||
|
||||
@@ -174,9 +174,9 @@ func (c *CpdailyCasLogin) Login(ctx context.Context, schoolDetail *school.School
|
||||
if saltValue != "" {
|
||||
salt = saltValue
|
||||
} else {
|
||||
saltMatches := saltRegexp.FindAllString(string(loginPageBytes), -1)
|
||||
if len(saltMatches) > 0 {
|
||||
salt = saltMatches[0]
|
||||
saltMatches := saltRegexp.FindStringSubmatch(string(loginPageBytes))
|
||||
if len(saltMatches) > 1 {
|
||||
salt = saltMatches[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -237,6 +237,7 @@ func (c *CpdailyCasLogin) Login(ctx context.Context, schoolDetail *school.School
|
||||
if isCasNeedKickOut(doc) {
|
||||
kickoutResponse := submitCasKickOut(ctx, loginResponseUrl.String(), doc, c.client)
|
||||
handleCasLoginSuccess(ctx, kickoutResponse, schoolDetail, username, password, c.client)
|
||||
return
|
||||
}
|
||||
|
||||
message := getCasErrorMessage(doc)
|
||||
|
||||
@@ -2,13 +2,14 @@ package login
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/samber/oops"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/tidwall/gjson"
|
||||
"io"
|
||||
"likedream-goframe/internal/application/httpclient"
|
||||
"likedream-goframe/internal/cst"
|
||||
"likedream-goframe/internal/utils"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/samber/oops"
|
||||
"github.com/tidwall/gjson"
|
||||
"resty.dev/v3"
|
||||
)
|
||||
|
||||
@@ -28,7 +29,7 @@ func ResolveOcrCaptcha(ctx context.Context, url string, client *resty.Client) st
|
||||
_ = captchaResponse.Body.Close()
|
||||
}()
|
||||
|
||||
ocrUrl := viper.GetString(cst.ConfigOcrServerUrl)
|
||||
ocrUrl := g.Cfg().MustGetWithEnv(ctx, cst.ConfigOcrServerUrl).String()
|
||||
|
||||
ocrResponse, err := httpclient.Common.R().
|
||||
SetMultipartFields(&resty.MultipartField{
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
package school
|
||||
|
||||
import "C"
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/samber/oops"
|
||||
"github.com/tidwall/gjson"
|
||||
cryptoutil2 "likedream-goframe/internal/application/cpdaily/cryptoutil"
|
||||
"likedream-goframe/internal/application/httpclient"
|
||||
"likedream-goframe/internal/common/errors"
|
||||
"likedream-goframe/internal/utils"
|
||||
|
||||
"github.com/bytedance/sonic"
|
||||
"github.com/samber/oops"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
func GetSchoolList(ctx context.Context) []CpdailySchoolBriefInfo {
|
||||
@@ -50,7 +52,7 @@ func GetSchoolList(ctx context.Context) []CpdailySchoolBriefInfo {
|
||||
}
|
||||
|
||||
func GetSchoolDetail(ctx context.Context, tenantId string) SchoolDetailInfo {
|
||||
response, err := httpclient.Cpdaily.R().
|
||||
response, err := httpclient.Cpdaily.R().Clone(ctx).
|
||||
SetHeaders(map[string]string{
|
||||
"deviceType": "2",
|
||||
"CpdailyClientType": "CPDAILY",
|
||||
|
||||
@@ -10,14 +10,13 @@ import (
|
||||
"likedream-goframe/internal/utils"
|
||||
)
|
||||
|
||||
func GetCpdailyTaskService(ctx context.Context, Type string, cookie string, schoolId string) CpdailyTask {
|
||||
func GetCpdailyTaskService(ctx context.Context, Type cptask.TaskType, cookie string, schoolId string) CpdailyTask {
|
||||
detail := school.GetSchoolDetail(ctx, schoolId)
|
||||
cookieJar := cookiejar.NewPersistCookieJar()
|
||||
cookieJar.Deserialize(cookie)
|
||||
client := httpclient.Cpdaily.Clone(ctx)
|
||||
client.SetCookieJar(cookieJar)
|
||||
//todo 验证cookie是否有效
|
||||
switch cptask.TaskType(Type) {
|
||||
switch Type {
|
||||
case cptask.TaskTypeCollection:
|
||||
return NewCollectionTask(client, detail.WecloudUrl)
|
||||
case cptask.TaskTypeSign:
|
||||
|
||||
@@ -101,7 +101,14 @@ func (c *CpdailyCollectionTask) GetRecentTaskTitle(ctx context.Context) []string
|
||||
for title := range titleSet {
|
||||
titles = append(titles, title)
|
||||
}
|
||||
|
||||
if len(titles) == 0 {
|
||||
utils.OkOrPanic(errors.NewBusinessError(503, "没有查询到信息收集任务"), func(err error) error {
|
||||
return oops.
|
||||
With("host", c.host).
|
||||
In("CpdailyCollectionTask.Count").
|
||||
Wrap(err)
|
||||
})
|
||||
}
|
||||
return titles
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"context"
|
||||
"fmt"
|
||||
"likedream-goframe/internal/application/cpdaily"
|
||||
@@ -14,6 +13,7 @@ import (
|
||||
"likedream-goframe/internal/common/errors"
|
||||
"likedream-goframe/internal/utils"
|
||||
"math/rand/v2"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -111,7 +111,14 @@ func (c *CpdailyAutoSignTask) GetRecentTaskTitle(ctx context.Context) []string {
|
||||
for title := range titleSet {
|
||||
titles = append(titles, title)
|
||||
}
|
||||
|
||||
if len(titles) == 0 {
|
||||
utils.OkOrPanic(errors.NewBusinessError(503, "没有查询到签到任务"), func(err error) error {
|
||||
return oops.
|
||||
With("host", c.host).
|
||||
In("CpdailySignTask.Count").
|
||||
Wrap(err)
|
||||
})
|
||||
}
|
||||
return titles
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,16 @@ func (c *CpdailySleepCheckTask) queryTitleByYearMonth(ctx context.Context, year,
|
||||
})
|
||||
}
|
||||
|
||||
if len(titles) == 0 {
|
||||
utils.OkOrPanic(errors.NewBusinessError(503, "没有查询到查寝任务"), func(err error) error {
|
||||
return oops.
|
||||
With("host", c.host).
|
||||
With("year", year).
|
||||
With("month", month).
|
||||
In("CpdailySleepCheckTask.Count").
|
||||
Wrap(err)
|
||||
})
|
||||
}
|
||||
return titles
|
||||
}
|
||||
|
||||
@@ -575,7 +585,7 @@ func (c *CpdailySleepCheckTask) FillCustomForm(ctx context.Context, form map[str
|
||||
|
||||
previewUrl := imageuploader.UploadImageFromStorage(ctx, c.host, imageId, types.TaskTypeSleepCheck, c.client)
|
||||
|
||||
resultForm["signImg"] = gvar.New(previewUrl)
|
||||
resultForm["signPhotoUrl"] = gvar.New(previewUrl)
|
||||
}
|
||||
|
||||
// 判断是否存在二维码查寝
|
||||
@@ -595,9 +605,9 @@ func (c *CpdailySleepCheckTask) FillCustomForm(ctx context.Context, form map[str
|
||||
} else {
|
||||
// 否则,填充查寝其他参数
|
||||
if signInstanceWidVar := rows["signInstanceWid"]; signInstanceWidVar != nil {
|
||||
resultForm["signInstanceWid"] = gvar.New(signInstanceWidVar.String())
|
||||
resultForm["SignInstanceWid"] = gvar.New(signInstanceWidVar.String())
|
||||
} else {
|
||||
resultForm["signInstanceWid"] = gvar.New("")
|
||||
resultForm["SignInstanceWid"] = gvar.New("")
|
||||
}
|
||||
|
||||
// 查找 isMalposition 参数
|
||||
@@ -666,7 +676,6 @@ func (c *CpdailySleepCheckTask) Submit(ctx context.Context, form map[string]*gva
|
||||
sign := taskhelper.GetSubmitSign(submitData)
|
||||
|
||||
submitData["sign"] = gvar.New(sign)
|
||||
|
||||
response, e := c.client.R().
|
||||
SetBody(submitData).
|
||||
WithContext(ctx).
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package httpclient
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"likedream-goframe/internal/utils"
|
||||
"time"
|
||||
|
||||
"resty.dev/v3"
|
||||
@@ -10,4 +12,14 @@ var Cpdaily = resty.New().
|
||||
SetCookieJar(nil).
|
||||
SetTimeout(30 * time.Second).
|
||||
SetDoNotParseResponse(true).
|
||||
SetProxy("http://127.0.0.1:9000")
|
||||
SetTLSClientConfig(&tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
|
||||
func init() {
|
||||
if !utils.IsDebug() {
|
||||
Cpdaily.SetDebug(false)
|
||||
} else {
|
||||
Cpdaily.SetProxy("http://127.0.0.1:9000")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package errors
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestBusinessError(t *testing.T) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
of, b := Of[*BusinessError](err.(error))
|
||||
t.Log(of, b)
|
||||
t.Log("ok")
|
||||
}
|
||||
}()
|
||||
err := NewBusinessError(503, "调试错误")
|
||||
panic(err)
|
||||
}
|
||||
func Of[T error](input error) (T, bool) {
|
||||
var ret T
|
||||
if errors.As(input, &ret) {
|
||||
return ret, true
|
||||
}
|
||||
|
||||
return ret, false
|
||||
}
|
||||
@@ -23,7 +23,7 @@ func (a AgentCtrlV1) List(ctx context.Context, req *v1.AgentListReq) (res *utils
|
||||
// Add 添加下级代理
|
||||
func (a AgentCtrlV1) Add(ctx context.Context, req *v1.AgentAddReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.Agent.Add(ctx, req), nil
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
// Ban 禁用代理
|
||||
|
||||
@@ -8,57 +8,57 @@ import (
|
||||
"likedream-goframe/internal/utils"
|
||||
)
|
||||
|
||||
type CpTaskServiceV1 struct {
|
||||
type CpTaskCtrlV1 struct {
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) List(ctx context.Context, req *v1.CpTaskListReq) (res *utils.Response[[]*ent.CpTask], err error) {
|
||||
func (c CpTaskCtrlV1) List(ctx context.Context, req *v1.CpTaskListReq) (res *utils.Response[[]*ent.CpTask], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.List(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) GetRecentTasks(ctx context.Context, req *v1.GetRecentTasksReq) (res *utils.Response[[]string], err error) {
|
||||
func (c CpTaskCtrlV1) GetRecentTasks(ctx context.Context, req *v1.GetRecentTasksReq) (res *utils.Response[[]string], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.GetRecentTasks(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) AddTask(ctx context.Context, req *v1.AddTaskReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) AddTask(ctx context.Context, req *v1.AddTaskReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.AddTask(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) TaskFormData(ctx context.Context, req *v1.GetCpTaskFormReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) TaskFormData(ctx context.Context, req *v1.GetCpTaskFormReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.TaskFormData(ctx, req), nil
|
||||
}
|
||||
func (c CpTaskServiceV1) PutFormData(ctx context.Context, req *v1.PutCpTaskFormReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) PutFormData(ctx context.Context, req *v1.PutCpTaskFormReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.PutTaskFormData(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) TaskExecute(ctx context.Context, req *v1.GetCpTaskExecuteReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) TaskExecute(ctx context.Context, req *v1.GetCpTaskExecuteReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.TaskExecute(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) PostExecute(ctx context.Context, req *v1.PostCpTaskExecuteReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) PostExecute(ctx context.Context, req *v1.PostCpTaskExecuteReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.PostExecute(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) Delete(ctx context.Context, req *v1.DeleteTaskReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) Delete(ctx context.Context, req *v1.DeleteTaskReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.Delete(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) ExecuteNow(ctx context.Context, req *v1.ExecuteNowReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) ExecuteNow(ctx context.Context, req *v1.ExecuteNowReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.ExecuteNow(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpTaskServiceV1) PauseTask(ctx context.Context, req *v1.PauseTaskReq) (res *utils.Response[any], err error) {
|
||||
func (c CpTaskCtrlV1) PauseTask(ctx context.Context, req *v1.PauseTaskReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTask.PauseTask(ctx, req), nil
|
||||
}
|
||||
func NewCpTaskCtrlV1() ICpTaskCtrlV1 {
|
||||
return &CpTaskServiceV1{}
|
||||
return &CpTaskCtrlV1{}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package cpdaily
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
v1 "likedream-goframe/internal/api/v1"
|
||||
"likedream-goframe/internal/application/classifier"
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/service"
|
||||
"likedream-goframe/internal/utils"
|
||||
)
|
||||
|
||||
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) {
|
||||
defer utils.Pass(&err)
|
||||
return service.Global.CpTaskLog.List(ctx, req), nil
|
||||
}
|
||||
|
||||
func NewCpTaskLogCtrlV1() ICpTaskLogCtrlV1 {
|
||||
return &CpTaskLogCtrlV1{}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cpdaily
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "likedream-goframe/internal/api/v1"
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/utils"
|
||||
)
|
||||
|
||||
type ICpTaskLogCtrlV1 interface {
|
||||
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)
|
||||
}
|
||||
@@ -2,13 +2,9 @@ package cpdaily
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
v1 "likedream-goframe/internal/api/v1"
|
||||
"likedream-goframe/internal/application/filestorage"
|
||||
"likedream-goframe/internal/service"
|
||||
"likedream-goframe/internal/utils"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/samber/oops"
|
||||
)
|
||||
|
||||
type CpImageCtrlV1 struct {
|
||||
@@ -16,27 +12,12 @@ type CpImageCtrlV1 struct {
|
||||
|
||||
func (c CpImageCtrlV1) Upload(ctx context.Context, req *v1.UploadImageReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
file := req.File
|
||||
open, err := file.Open()
|
||||
utils.OkOrPanic(err, oops.WithContext(ctx).Wrap)
|
||||
key := utils.GenerateFileName("cpdaily/")
|
||||
size := filestorage.GlobalS3.UploadFile(ctx, key, open)
|
||||
return utils.SuccessWithData[any](v1.UploadImageRes{
|
||||
FileKey: key,
|
||||
FileSize: size,
|
||||
}), nil
|
||||
return service.Global.CpImage.Upload(ctx, req), nil
|
||||
}
|
||||
|
||||
func (c CpImageCtrlV1) Preview(ctx context.Context, req *v1.PreviewImageReq) (res *utils.Response[any], err error) {
|
||||
defer utils.Pass(&err)
|
||||
key := req.Key
|
||||
file := filestorage.GlobalS3.GetFile(ctx, key)
|
||||
r := g.RequestFromCtx(ctx)
|
||||
r.Response.Header().Set("Content-Type", "image/png")
|
||||
// 将文件写入
|
||||
io.Copy(r.Response.Writer, file)
|
||||
r.Exit()
|
||||
return nil, nil
|
||||
return service.Global.CpImage.Preview(ctx, req), nil
|
||||
}
|
||||
|
||||
func NewCpImageCtrlV1() ICpImageCtrlV1 {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package cst
|
||||
|
||||
const (
|
||||
BasePointCpdaily = 1
|
||||
)
|
||||
@@ -575,7 +575,8 @@ func (c *CpSchoolClient) QueryCpusers(_m *CpSchool) *CpUserQuery {
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CpSchoolClient) Hooks() []Hook {
|
||||
return c.hooks.CpSchool
|
||||
hooks := c.hooks.CpSchool
|
||||
return append(hooks[:len(hooks):len(hooks)], cpschool.Hooks[:]...)
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
@@ -765,7 +766,8 @@ func (c *CpTaskClient) QueryCpTaskLogs(_m *CpTask) *CpTaskLogQuery {
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CpTaskClient) Hooks() []Hook {
|
||||
return c.hooks.CpTask
|
||||
hooks := c.hooks.CpTask
|
||||
return append(hooks[:len(hooks):len(hooks)], cptask.Hooks[:]...)
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
@@ -955,7 +957,8 @@ func (c *CpTaskLogClient) QueryCpUser(_m *CpTaskLog) *CpUserQuery {
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CpTaskLogClient) Hooks() []Hook {
|
||||
return c.hooks.CpTaskLog
|
||||
hooks := c.hooks.CpTaskLog
|
||||
return append(hooks[:len(hooks):len(hooks)], cptasklog.Hooks[:]...)
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
@@ -1164,7 +1167,8 @@ func (c *CpUserClient) QuerySchool(_m *CpUser) *CpSchoolQuery {
|
||||
|
||||
// Hooks returns the client hooks.
|
||||
func (c *CpUserClient) Hooks() []Hook {
|
||||
return c.hooks.CpUser
|
||||
hooks := c.hooks.CpUser
|
||||
return append(hooks[:len(hooks):len(hooks)], cpuser.Hooks[:]...)
|
||||
}
|
||||
|
||||
// Interceptors returns the client interceptors.
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -75,6 +76,8 @@ var (
|
||||
DefaultCreateTime func() *ent2.CustomTime
|
||||
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
|
||||
DefaultUpdateTime func() *ent2.CustomTime
|
||||
// DefaultImageID holds the default value on creation for the "image_id" field.
|
||||
DefaultImageID func() uuid.UUID
|
||||
// KeyValidator is a validator for the "key" field. It is called by the builders before save.
|
||||
KeyValidator func(string) error
|
||||
// UserIDValidator is a validator for the "user_id" field. It is called by the builders before save.
|
||||
|
||||
@@ -42,6 +42,14 @@ func (_c *CpImageCreate) SetImageID(v uuid.UUID) *CpImageCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableImageID sets the "image_id" field if the given value is not nil.
|
||||
func (_c *CpImageCreate) SetNillableImageID(v *uuid.UUID) *CpImageCreate {
|
||||
if v != nil {
|
||||
_c.SetImageID(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetKey sets the "key" field.
|
||||
func (_c *CpImageCreate) SetKey(v string) *CpImageCreate {
|
||||
_c.mutation.SetKey(v)
|
||||
@@ -122,6 +130,13 @@ func (_c *CpImageCreate) defaults() error {
|
||||
v := cpimage.DefaultUpdateTime()
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.ImageID(); !ok {
|
||||
if cpimage.DefaultImageID == nil {
|
||||
return fmt.Errorf("ent: uninitialized cpimage.DefaultImageID (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cpimage.DefaultImageID()
|
||||
_c.mutation.SetImageID(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ package ent
|
||||
import (
|
||||
"fmt"
|
||||
"likedream-goframe/internal/ent/cpschool"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -16,6 +17,10 @@ type CpSchool struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID string `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime *ent2.CustomTime `json:"updateTime"`
|
||||
// Name holds the value of the "name" field.
|
||||
Name string `json:"name,omitempty"`
|
||||
// NamePinyin holds the value of the "name_pinyin" field.
|
||||
@@ -52,6 +57,8 @@ func (*CpSchool) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cpschool.FieldCreateTime, cpschool.FieldUpdateTime:
|
||||
values[i] = new(ent2.CustomTime)
|
||||
case cpschool.FieldID, cpschool.FieldName, cpschool.FieldNamePinyin, cpschool.FieldIconImg:
|
||||
values[i] = new(sql.NullString)
|
||||
default:
|
||||
@@ -75,6 +82,18 @@ func (_m *CpSchool) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.ID = value.String
|
||||
}
|
||||
case cpschool.FieldCreateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.CreateTime = value
|
||||
}
|
||||
case cpschool.FieldUpdateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.UpdateTime = value
|
||||
}
|
||||
case cpschool.FieldName:
|
||||
if value, ok := values[i].(*sql.NullString); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field name", values[i])
|
||||
@@ -134,6 +153,12 @@ func (_m *CpSchool) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CpSchool(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CreateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("update_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UpdateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("name=")
|
||||
builder.WriteString(_m.Name)
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
package cpschool
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -12,6 +15,10 @@ const (
|
||||
Label = "cp_school"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldName holds the string denoting the name field in the database.
|
||||
FieldName = "name"
|
||||
// FieldNamePinyin holds the string denoting the name_pinyin field in the database.
|
||||
@@ -34,6 +41,8 @@ const (
|
||||
// Columns holds all SQL columns for cpschool fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldName,
|
||||
FieldNamePinyin,
|
||||
FieldIconImg,
|
||||
@@ -49,6 +58,19 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "likedream-goframe/internal/ent/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() *ent2.CustomTime
|
||||
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
|
||||
DefaultUpdateTime func() *ent2.CustomTime
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the CpSchool queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
@@ -57,6 +79,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdateTime orders the results by the update_time field.
|
||||
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByName orders the results by the name field.
|
||||
func ByName(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldName, opts...).ToFunc()
|
||||
|
||||
@@ -5,6 +5,7 @@ package cpschool
|
||||
import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -65,6 +66,16 @@ func IDContainsFold(id string) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldContainsFold(FieldID, id))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// Name applies equality check predicate on the "name" field. It's identical to NameEQ.
|
||||
func Name(v string) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldName, v))
|
||||
@@ -80,6 +91,146 @@ func IconImg(v string) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldIconImg, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...*ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeContains applies the Contains predicate on the "create_time" field.
|
||||
func CreateTimeContains(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldContains(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasPrefix applies the HasPrefix predicate on the "create_time" field.
|
||||
func CreateTimeHasPrefix(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldHasPrefix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasSuffix applies the HasSuffix predicate on the "create_time" field.
|
||||
func CreateTimeHasSuffix(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldHasSuffix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeEqualFold applies the EqualFold predicate on the "create_time" field.
|
||||
func CreateTimeEqualFold(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldEqualFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeContainsFold applies the ContainsFold predicate on the "create_time" field.
|
||||
func CreateTimeContainsFold(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldContainsFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldNEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...*ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldNotIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldGT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldGTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldLT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v *ent2.CustomTime) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldLTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeContains applies the Contains predicate on the "update_time" field.
|
||||
func UpdateTimeContains(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldContains(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasPrefix applies the HasPrefix predicate on the "update_time" field.
|
||||
func UpdateTimeHasPrefix(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldHasPrefix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasSuffix applies the HasSuffix predicate on the "update_time" field.
|
||||
func UpdateTimeHasSuffix(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldHasSuffix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEqualFold applies the EqualFold predicate on the "update_time" field.
|
||||
func UpdateTimeEqualFold(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldEqualFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeContainsFold applies the ContainsFold predicate on the "update_time" field.
|
||||
func UpdateTimeContainsFold(v *ent2.CustomTime) predicate.CpSchool {
|
||||
vc := v.String()
|
||||
return predicate.CpSchool(sql.FieldContainsFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// NameEQ applies the EQ predicate on the "name" field.
|
||||
func NameEQ(v string) predicate.CpSchool {
|
||||
return predicate.CpSchool(sql.FieldEQ(FieldName, v))
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"fmt"
|
||||
"likedream-goframe/internal/ent/cpschool"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
@@ -23,6 +24,18 @@ type CpSchoolCreate struct {
|
||||
conflict []sql.ConflictOption
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (_c *CpSchoolCreate) SetCreateTime(v *ent2.CustomTime) *CpSchoolCreate {
|
||||
_c.mutation.SetCreateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_c *CpSchoolCreate) SetUpdateTime(v *ent2.CustomTime) *CpSchoolCreate {
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_c *CpSchoolCreate) SetName(v string) *CpSchoolCreate {
|
||||
_c.mutation.SetName(v)
|
||||
@@ -77,6 +90,9 @@ func (_c *CpSchoolCreate) Mutation() *CpSchoolMutation {
|
||||
|
||||
// Save creates the CpSchool in the database.
|
||||
func (_c *CpSchoolCreate) Save(ctx context.Context) (*CpSchool, error) {
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
@@ -102,8 +118,33 @@ func (_c *CpSchoolCreate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *CpSchoolCreate) defaults() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
if cpschool.DefaultCreateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cpschool.DefaultCreateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cpschool.DefaultCreateTime()
|
||||
_c.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
if cpschool.DefaultUpdateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cpschool.DefaultUpdateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cpschool.DefaultUpdateTime()
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *CpSchoolCreate) check() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CpSchool.create_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CpSchool.update_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Name(); !ok {
|
||||
return &ValidationError{Name: "name", err: errors.New(`ent: missing required field "CpSchool.name"`)}
|
||||
}
|
||||
@@ -147,6 +188,14 @@ func (_c *CpSchoolCreate) createSpec() (*CpSchool, *sqlgraph.CreateSpec) {
|
||||
_node.ID = id
|
||||
_spec.ID.Value = id
|
||||
}
|
||||
if value, ok := _c.mutation.CreateTime(); ok {
|
||||
_spec.SetField(cpschool.FieldCreateTime, field.TypeString, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cpschool.FieldUpdateTime, field.TypeString, value)
|
||||
_node.UpdateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.Name(); ok {
|
||||
_spec.SetField(cpschool.FieldName, field.TypeString, value)
|
||||
_node.Name = value
|
||||
@@ -183,7 +232,7 @@ func (_c *CpSchoolCreate) createSpec() (*CpSchool, *sqlgraph.CreateSpec) {
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.CpSchool.Create().
|
||||
// SetName(v).
|
||||
// SetCreateTime(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -192,7 +241,7 @@ func (_c *CpSchoolCreate) createSpec() (*CpSchool, *sqlgraph.CreateSpec) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpSchoolUpsert) {
|
||||
// SetName(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpSchoolCreate) OnConflict(opts ...sql.ConflictOption) *CpSchoolUpsertOne {
|
||||
@@ -228,6 +277,18 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpSchoolUpsert) SetUpdateTime(v *ent2.CustomTime) *CpSchoolUpsert {
|
||||
u.Set(cpschool.FieldUpdateTime, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpSchoolUpsert) UpdateUpdateTime() *CpSchoolUpsert {
|
||||
u.SetExcluded(cpschool.FieldUpdateTime)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (u *CpSchoolUpsert) SetName(v string) *CpSchoolUpsert {
|
||||
u.Set(cpschool.FieldName, v)
|
||||
@@ -287,6 +348,9 @@ func (u *CpSchoolUpsertOne) UpdateNewValues() *CpSchoolUpsertOne {
|
||||
if _, exists := u.create.mutation.ID(); exists {
|
||||
s.SetIgnore(cpschool.FieldID)
|
||||
}
|
||||
if _, exists := u.create.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cpschool.FieldCreateTime)
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
@@ -318,6 +382,20 @@ func (u *CpSchoolUpsertOne) Update(set func(*CpSchoolUpsert)) *CpSchoolUpsertOne
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpSchoolUpsertOne) SetUpdateTime(v *ent2.CustomTime) *CpSchoolUpsertOne {
|
||||
return u.Update(func(s *CpSchoolUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpSchoolUpsertOne) UpdateUpdateTime() *CpSchoolUpsertOne {
|
||||
return u.Update(func(s *CpSchoolUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (u *CpSchoolUpsertOne) SetName(v string) *CpSchoolUpsertOne {
|
||||
return u.Update(func(s *CpSchoolUpsert) {
|
||||
@@ -424,6 +502,7 @@ func (_c *CpSchoolCreateBulk) Save(ctx context.Context) ([]*CpSchool, error) {
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CpSchoolMutation)
|
||||
if !ok {
|
||||
@@ -502,7 +581,7 @@ func (_c *CpSchoolCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpSchoolUpsert) {
|
||||
// SetName(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpSchoolCreateBulk) OnConflict(opts ...sql.ConflictOption) *CpSchoolUpsertBulk {
|
||||
@@ -549,6 +628,9 @@ func (u *CpSchoolUpsertBulk) UpdateNewValues() *CpSchoolUpsertBulk {
|
||||
if _, exists := b.mutation.ID(); exists {
|
||||
s.SetIgnore(cpschool.FieldID)
|
||||
}
|
||||
if _, exists := b.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cpschool.FieldCreateTime)
|
||||
}
|
||||
}
|
||||
}))
|
||||
return u
|
||||
@@ -581,6 +663,20 @@ func (u *CpSchoolUpsertBulk) Update(set func(*CpSchoolUpsert)) *CpSchoolUpsertBu
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpSchoolUpsertBulk) SetUpdateTime(v *ent2.CustomTime) *CpSchoolUpsertBulk {
|
||||
return u.Update(func(s *CpSchoolUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpSchoolUpsertBulk) UpdateUpdateTime() *CpSchoolUpsertBulk {
|
||||
return u.Update(func(s *CpSchoolUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (u *CpSchoolUpsertBulk) SetName(v string) *CpSchoolUpsertBulk {
|
||||
return u.Update(func(s *CpSchoolUpsert) {
|
||||
|
||||
@@ -307,12 +307,12 @@ func (_q *CpSchoolQuery) WithCpusers(opts ...func(*CpUserQuery)) *CpSchoolQuery
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CpSchool.Query().
|
||||
// GroupBy(cpschool.FieldName).
|
||||
// GroupBy(cpschool.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpSchoolQuery) GroupBy(field string, fields ...string) *CpSchoolGroupBy {
|
||||
@@ -330,11 +330,11 @@ func (_q *CpSchoolQuery) GroupBy(field string, fields ...string) *CpSchoolGroupB
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// Name string `json:"name,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// }
|
||||
//
|
||||
// client.CpSchool.Query().
|
||||
// Select(cpschool.FieldName).
|
||||
// Select(cpschool.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpSchoolQuery) Select(fields ...string) *CpSchoolSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -30,6 +31,12 @@ func (_u *CpSchoolUpdate) Where(ps ...predicate.CpSchool) *CpSchoolUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpSchoolUpdate) SetUpdateTime(v *ent2.CustomTime) *CpSchoolUpdate {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *CpSchoolUpdate) SetName(v string) *CpSchoolUpdate {
|
||||
_u.mutation.SetName(v)
|
||||
@@ -161,6 +168,9 @@ func (_u *CpSchoolUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cpschool.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(cpschool.FieldName, field.TypeString, value)
|
||||
}
|
||||
@@ -245,6 +255,12 @@ type CpSchoolUpdateOne struct {
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpSchoolUpdateOne) SetUpdateTime(v *ent2.CustomTime) *CpSchoolUpdateOne {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (_u *CpSchoolUpdateOne) SetName(v string) *CpSchoolUpdateOne {
|
||||
_u.mutation.SetName(v)
|
||||
@@ -406,6 +422,9 @@ func (_u *CpSchoolUpdateOne) sqlSave(ctx context.Context) (_node *CpSchool, err
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cpschool.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Name(); ok {
|
||||
_spec.SetField(cpschool.FieldName, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cptask"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -18,6 +19,10 @@ type CpTask struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime *ent2.CustomTime `json:"updateTime"`
|
||||
// CpUserID holds the value of the "cp_user_id" field.
|
||||
CpUserID int64 `json:"cp_user_id,omitempty"`
|
||||
// UserID holds the value of the "user_id" field.
|
||||
@@ -100,6 +105,8 @@ func (*CpTask) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cptask.FieldCreateTime, cptask.FieldUpdateTime:
|
||||
values[i] = new(ent2.CustomTime)
|
||||
case cptask.FieldID, cptask.FieldCpUserID, cptask.FieldUserID, cptask.FieldFrequency, cptask.FieldSuccessCount, cptask.FieldExecuteHour, cptask.FieldExecuteMinute, cptask.FieldNextExecuteTime:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case cptask.FieldTaskType, cptask.FieldTitle, cptask.FieldTaskStatus, cptask.FieldFormData, cptask.FieldStep, cptask.FieldNotificationType:
|
||||
@@ -125,6 +132,18 @@ func (_m *CpTask) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int64(value.Int64)
|
||||
case cptask.FieldCreateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.CreateTime = value
|
||||
}
|
||||
case cptask.FieldUpdateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.UpdateTime = value
|
||||
}
|
||||
case cptask.FieldCpUserID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cp_user_id", values[i])
|
||||
@@ -257,6 +276,12 @@ func (_m *CpTask) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CpTask(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CreateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("update_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UpdateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cp_user_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CpUserID))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -4,7 +4,9 @@ package cptask
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -14,6 +16,10 @@ const (
|
||||
Label = "cp_task"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldCpUserID holds the string denoting the cp_user_id field in the database.
|
||||
FieldCpUserID = "cp_user_id"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
@@ -74,6 +80,8 @@ const (
|
||||
// Columns holds all SQL columns for cptask fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldCpUserID,
|
||||
FieldUserID,
|
||||
FieldTaskType,
|
||||
@@ -99,7 +107,17 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "likedream-goframe/internal/ent/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() *ent2.CustomTime
|
||||
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
|
||||
DefaultUpdateTime func() *ent2.CustomTime
|
||||
// TitleValidator is a validator for the "title" field. It is called by the builders before save.
|
||||
TitleValidator func(string) error
|
||||
// DefaultFrequency holds the default value on creation for the "frequency" field.
|
||||
@@ -142,6 +160,7 @@ const (
|
||||
TaskStatusDone TaskStatus = "done"
|
||||
TaskStatusFail TaskStatus = "fail"
|
||||
TaskStatusPause TaskStatus = "pause"
|
||||
TaskStatusQueue TaskStatus = "queue"
|
||||
TaskStatusUnknown TaskStatus = "unknown"
|
||||
)
|
||||
|
||||
@@ -152,7 +171,7 @@ func (ts TaskStatus) String() string {
|
||||
// TaskStatusValidator is a validator for the "task_status" field enum values. It is called by the builders before save.
|
||||
func TaskStatusValidator(ts TaskStatus) error {
|
||||
switch ts {
|
||||
case TaskStatusNotStart, TaskStatusDoing, TaskStatusDone, TaskStatusFail, TaskStatusPause, TaskStatusUnknown:
|
||||
case TaskStatusNotStart, TaskStatusDoing, TaskStatusDone, TaskStatusFail, TaskStatusPause, TaskStatusQueue, TaskStatusUnknown:
|
||||
return nil
|
||||
default:
|
||||
return fmt.Errorf("cptask: invalid enum value for task_status field: %q", ts)
|
||||
@@ -215,6 +234,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdateTime orders the results by the update_time field.
|
||||
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCpUserID orders the results by the cp_user_id field.
|
||||
func ByCpUserID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCpUserID, opts...).ToFunc()
|
||||
|
||||
@@ -5,6 +5,7 @@ package cptask
|
||||
import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -55,6 +56,16 @@ func IDLTE(id int64) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// CpUserID applies equality check predicate on the "cp_user_id" field. It's identical to CpUserIDEQ.
|
||||
func CpUserID(v int64) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldCpUserID, v))
|
||||
@@ -100,6 +111,146 @@ func NextExecuteTime(v int64) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldNextExecuteTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...*ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeContains applies the Contains predicate on the "create_time" field.
|
||||
func CreateTimeContains(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldContains(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasPrefix applies the HasPrefix predicate on the "create_time" field.
|
||||
func CreateTimeHasPrefix(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldHasPrefix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasSuffix applies the HasSuffix predicate on the "create_time" field.
|
||||
func CreateTimeHasSuffix(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldHasSuffix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeEqualFold applies the EqualFold predicate on the "create_time" field.
|
||||
func CreateTimeEqualFold(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldEqualFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeContainsFold applies the ContainsFold predicate on the "create_time" field.
|
||||
func CreateTimeContainsFold(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldContainsFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldNEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...*ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldNotIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldGT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldGTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldLT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v *ent2.CustomTime) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldLTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeContains applies the Contains predicate on the "update_time" field.
|
||||
func UpdateTimeContains(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldContains(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasPrefix applies the HasPrefix predicate on the "update_time" field.
|
||||
func UpdateTimeHasPrefix(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldHasPrefix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasSuffix applies the HasSuffix predicate on the "update_time" field.
|
||||
func UpdateTimeHasSuffix(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldHasSuffix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEqualFold applies the EqualFold predicate on the "update_time" field.
|
||||
func UpdateTimeEqualFold(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldEqualFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeContainsFold applies the ContainsFold predicate on the "update_time" field.
|
||||
func UpdateTimeContainsFold(v *ent2.CustomTime) predicate.CpTask {
|
||||
vc := v.String()
|
||||
return predicate.CpTask(sql.FieldContainsFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// CpUserIDEQ applies the EQ predicate on the "cp_user_id" field.
|
||||
func CpUserIDEQ(v int64) predicate.CpTask {
|
||||
return predicate.CpTask(sql.FieldEQ(FieldCpUserID, v))
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cptasklog"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -24,6 +25,18 @@ type CpTaskCreate struct {
|
||||
conflict []sql.ConflictOption
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (_c *CpTaskCreate) SetCreateTime(v *ent2.CustomTime) *CpTaskCreate {
|
||||
_c.mutation.SetCreateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_c *CpTaskCreate) SetUpdateTime(v *ent2.CustomTime) *CpTaskCreate {
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (_c *CpTaskCreate) SetCpUserID(v int64) *CpTaskCreate {
|
||||
_c.mutation.SetCpUserID(v)
|
||||
@@ -188,7 +201,9 @@ func (_c *CpTaskCreate) Mutation() *CpTaskMutation {
|
||||
|
||||
// Save creates the CpTask in the database.
|
||||
func (_c *CpTaskCreate) Save(ctx context.Context) (*CpTask, error) {
|
||||
_c.defaults()
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
@@ -215,7 +230,21 @@ func (_c *CpTaskCreate) ExecX(ctx context.Context) {
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *CpTaskCreate) defaults() {
|
||||
func (_c *CpTaskCreate) defaults() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
if cptask.DefaultCreateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cptask.DefaultCreateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cptask.DefaultCreateTime()
|
||||
_c.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
if cptask.DefaultUpdateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cptask.DefaultUpdateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cptask.DefaultUpdateTime()
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.Frequency(); !ok {
|
||||
v := cptask.DefaultFrequency
|
||||
_c.mutation.SetFrequency(v)
|
||||
@@ -224,10 +253,17 @@ func (_c *CpTaskCreate) defaults() {
|
||||
v := cptask.DefaultSuccessCount
|
||||
_c.mutation.SetSuccessCount(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *CpTaskCreate) check() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CpTask.create_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CpTask.update_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.CpUserID(); !ok {
|
||||
return &ValidationError{Name: "cp_user_id", err: errors.New(`ent: missing required field "CpTask.cp_user_id"`)}
|
||||
}
|
||||
@@ -314,6 +350,14 @@ func (_c *CpTaskCreate) createSpec() (*CpTask, *sqlgraph.CreateSpec) {
|
||||
)
|
||||
_spec.Schema = _c.schemaConfig.CpTask
|
||||
_spec.OnConflict = _c.conflict
|
||||
if value, ok := _c.mutation.CreateTime(); ok {
|
||||
_spec.SetField(cptask.FieldCreateTime, field.TypeString, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cptask.FieldUpdateTime, field.TypeString, value)
|
||||
_node.UpdateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.TaskType(); ok {
|
||||
_spec.SetField(cptask.FieldTaskType, field.TypeEnum, value)
|
||||
_node.TaskType = value
|
||||
@@ -418,7 +462,7 @@ func (_c *CpTaskCreate) createSpec() (*CpTask, *sqlgraph.CreateSpec) {
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.CpTask.Create().
|
||||
// SetCpUserID(v).
|
||||
// SetCreateTime(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -427,7 +471,7 @@ func (_c *CpTaskCreate) createSpec() (*CpTask, *sqlgraph.CreateSpec) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpTaskUpsert) {
|
||||
// SetCpUserID(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpTaskCreate) OnConflict(opts ...sql.ConflictOption) *CpTaskUpsertOne {
|
||||
@@ -463,6 +507,18 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpTaskUpsert) SetUpdateTime(v *ent2.CustomTime) *CpTaskUpsert {
|
||||
u.Set(cptask.FieldUpdateTime, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpTaskUpsert) UpdateUpdateTime() *CpTaskUpsert {
|
||||
u.SetExcluded(cptask.FieldUpdateTime)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (u *CpTaskUpsert) SetCpUserID(v int64) *CpTaskUpsert {
|
||||
u.Set(cptask.FieldCpUserID, v)
|
||||
@@ -683,6 +739,11 @@ func (u *CpTaskUpsert) ClearNextExecuteTime() *CpTaskUpsert {
|
||||
// Exec(ctx)
|
||||
func (u *CpTaskUpsertOne) UpdateNewValues() *CpTaskUpsertOne {
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
||||
if _, exists := u.create.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cptask.FieldCreateTime)
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -713,6 +774,20 @@ func (u *CpTaskUpsertOne) Update(set func(*CpTaskUpsert)) *CpTaskUpsertOne {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpTaskUpsertOne) SetUpdateTime(v *ent2.CustomTime) *CpTaskUpsertOne {
|
||||
return u.Update(func(s *CpTaskUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpTaskUpsertOne) UpdateUpdateTime() *CpTaskUpsertOne {
|
||||
return u.Update(func(s *CpTaskUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (u *CpTaskUpsertOne) SetCpUserID(v int64) *CpTaskUpsertOne {
|
||||
return u.Update(func(s *CpTaskUpsert) {
|
||||
@@ -1093,7 +1168,7 @@ func (_c *CpTaskCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpTaskUpsert) {
|
||||
// SetCpUserID(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpTaskCreateBulk) OnConflict(opts ...sql.ConflictOption) *CpTaskUpsertBulk {
|
||||
@@ -1132,6 +1207,13 @@ type CpTaskUpsertBulk struct {
|
||||
// Exec(ctx)
|
||||
func (u *CpTaskUpsertBulk) UpdateNewValues() *CpTaskUpsertBulk {
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
||||
for _, b := range u.create.builders {
|
||||
if _, exists := b.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cptask.FieldCreateTime)
|
||||
}
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -1162,6 +1244,20 @@ func (u *CpTaskUpsertBulk) Update(set func(*CpTaskUpsert)) *CpTaskUpsertBulk {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpTaskUpsertBulk) SetUpdateTime(v *ent2.CustomTime) *CpTaskUpsertBulk {
|
||||
return u.Update(func(s *CpTaskUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpTaskUpsertBulk) UpdateUpdateTime() *CpTaskUpsertBulk {
|
||||
return u.Update(func(s *CpTaskUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (u *CpTaskUpsertBulk) SetCpUserID(v int64) *CpTaskUpsertBulk {
|
||||
return u.Update(func(s *CpTaskUpsert) {
|
||||
|
||||
@@ -385,12 +385,12 @@ func (_q *CpTaskQuery) WithCpTaskLogs(opts ...func(*CpTaskLogQuery)) *CpTaskQuer
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CpUserID int64 `json:"cp_user_id,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CpTask.Query().
|
||||
// GroupBy(cptask.FieldCpUserID).
|
||||
// GroupBy(cptask.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpTaskQuery) GroupBy(field string, fields ...string) *CpTaskGroupBy {
|
||||
@@ -408,11 +408,11 @@ func (_q *CpTaskQuery) GroupBy(field string, fields ...string) *CpTaskGroupBy {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CpUserID int64 `json:"cp_user_id,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// }
|
||||
//
|
||||
// client.CpTask.Query().
|
||||
// Select(cptask.FieldCpUserID).
|
||||
// Select(cptask.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpTaskQuery) Select(fields ...string) *CpTaskSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -32,6 +33,12 @@ func (_u *CpTaskUpdate) Where(ps ...predicate.CpTask) *CpTaskUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpTaskUpdate) SetUpdateTime(v *ent2.CustomTime) *CpTaskUpdate {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (_u *CpTaskUpdate) SetCpUserID(v int64) *CpTaskUpdate {
|
||||
_u.mutation.SetCpUserID(v)
|
||||
@@ -423,6 +430,9 @@ func (_u *CpTaskUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cptask.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TaskType(); ok {
|
||||
_spec.SetField(cptask.FieldTaskType, field.TypeEnum, value)
|
||||
}
|
||||
@@ -617,6 +627,12 @@ type CpTaskUpdateOne struct {
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpTaskUpdateOne) SetUpdateTime(v *ent2.CustomTime) *CpTaskUpdateOne {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (_u *CpTaskUpdateOne) SetCpUserID(v int64) *CpTaskUpdateOne {
|
||||
_u.mutation.SetCpUserID(v)
|
||||
@@ -1038,6 +1054,9 @@ func (_u *CpTaskUpdateOne) sqlSave(ctx context.Context) (_node *CpTask, err erro
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cptask.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.TaskType(); ok {
|
||||
_spec.SetField(cptask.FieldTaskType, field.TypeEnum, value)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cptasklog"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -19,6 +20,10 @@ type CpTaskLog struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime *ent2.CustomTime `json:"updateTime"`
|
||||
// CpTaskID holds the value of the "cp_task_id" field.
|
||||
CpTaskID int64 `json:"cp_task_id,omitempty"`
|
||||
// SystemUserID holds the value of the "system_user_id" field.
|
||||
@@ -88,6 +93,8 @@ func (*CpTaskLog) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cptasklog.FieldCreateTime, cptasklog.FieldUpdateTime:
|
||||
values[i] = new(ent2.CustomTime)
|
||||
case cptasklog.FieldIsSuccess:
|
||||
values[i] = new(sql.NullBool)
|
||||
case cptasklog.FieldID, cptasklog.FieldCpTaskID, cptasklog.FieldSystemUserID, cptasklog.FieldCpUserID:
|
||||
@@ -115,6 +122,18 @@ func (_m *CpTaskLog) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int64(value.Int64)
|
||||
case cptasklog.FieldCreateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.CreateTime = value
|
||||
}
|
||||
case cptasklog.FieldUpdateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.UpdateTime = value
|
||||
}
|
||||
case cptasklog.FieldCpTaskID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field cp_task_id", values[i])
|
||||
@@ -202,6 +221,12 @@ func (_m *CpTaskLog) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CpTaskLog(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CreateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("update_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UpdateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("cp_task_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CpTaskID))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
package cptasklog
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -12,6 +15,10 @@ const (
|
||||
Label = "cp_task_log"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldCpTaskID holds the string denoting the cp_task_id field in the database.
|
||||
FieldCpTaskID = "cp_task_id"
|
||||
// FieldSystemUserID holds the string denoting the system_user_id field in the database.
|
||||
@@ -58,6 +65,8 @@ const (
|
||||
// Columns holds all SQL columns for cptasklog fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldCpTaskID,
|
||||
FieldSystemUserID,
|
||||
FieldCpUserID,
|
||||
@@ -76,6 +85,19 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "likedream-goframe/internal/ent/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() *ent2.CustomTime
|
||||
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
|
||||
DefaultUpdateTime func() *ent2.CustomTime
|
||||
)
|
||||
|
||||
// OrderOption defines the ordering options for the CpTaskLog queries.
|
||||
type OrderOption func(*sql.Selector)
|
||||
|
||||
@@ -84,6 +106,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdateTime orders the results by the update_time field.
|
||||
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCpTaskID orders the results by the cp_task_id field.
|
||||
func ByCpTaskID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCpTaskID, opts...).ToFunc()
|
||||
|
||||
@@ -5,6 +5,7 @@ package cptasklog
|
||||
import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -55,6 +56,16 @@ func IDLTE(id int64) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// CpTaskID applies equality check predicate on the "cp_task_id" field. It's identical to CpTaskIDEQ.
|
||||
func CpTaskID(v int64) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldCpTaskID, v))
|
||||
@@ -85,6 +96,146 @@ func RealName(v string) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldRealName, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...*ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeContains applies the Contains predicate on the "create_time" field.
|
||||
func CreateTimeContains(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldContains(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasPrefix applies the HasPrefix predicate on the "create_time" field.
|
||||
func CreateTimeHasPrefix(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldHasPrefix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasSuffix applies the HasSuffix predicate on the "create_time" field.
|
||||
func CreateTimeHasSuffix(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldHasSuffix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeEqualFold applies the EqualFold predicate on the "create_time" field.
|
||||
func CreateTimeEqualFold(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldEqualFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeContainsFold applies the ContainsFold predicate on the "create_time" field.
|
||||
func CreateTimeContainsFold(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldContainsFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldNEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...*ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldNotIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldGT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldGTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldLT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldLTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeContains applies the Contains predicate on the "update_time" field.
|
||||
func UpdateTimeContains(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldContains(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasPrefix applies the HasPrefix predicate on the "update_time" field.
|
||||
func UpdateTimeHasPrefix(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldHasPrefix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasSuffix applies the HasSuffix predicate on the "update_time" field.
|
||||
func UpdateTimeHasSuffix(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldHasSuffix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEqualFold applies the EqualFold predicate on the "update_time" field.
|
||||
func UpdateTimeEqualFold(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldEqualFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeContainsFold applies the ContainsFold predicate on the "update_time" field.
|
||||
func UpdateTimeContainsFold(v *ent2.CustomTime) predicate.CpTaskLog {
|
||||
vc := v.String()
|
||||
return predicate.CpTaskLog(sql.FieldContainsFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// CpTaskIDEQ applies the EQ predicate on the "cp_task_id" field.
|
||||
func CpTaskIDEQ(v int64) predicate.CpTaskLog {
|
||||
return predicate.CpTaskLog(sql.FieldEQ(FieldCpTaskID, v))
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cptasklog"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -24,6 +25,18 @@ type CpTaskLogCreate struct {
|
||||
conflict []sql.ConflictOption
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (_c *CpTaskLogCreate) SetCreateTime(v *ent2.CustomTime) *CpTaskLogCreate {
|
||||
_c.mutation.SetCreateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_c *CpTaskLogCreate) SetUpdateTime(v *ent2.CustomTime) *CpTaskLogCreate {
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (_c *CpTaskLogCreate) SetCpTaskID(v int64) *CpTaskLogCreate {
|
||||
_c.mutation.SetCpTaskID(v)
|
||||
@@ -98,6 +111,9 @@ func (_c *CpTaskLogCreate) Mutation() *CpTaskLogMutation {
|
||||
|
||||
// Save creates the CpTaskLog in the database.
|
||||
func (_c *CpTaskLogCreate) Save(ctx context.Context) (*CpTaskLog, error) {
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
@@ -123,8 +139,33 @@ func (_c *CpTaskLogCreate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *CpTaskLogCreate) defaults() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
if cptasklog.DefaultCreateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cptasklog.DefaultCreateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cptasklog.DefaultCreateTime()
|
||||
_c.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
if cptasklog.DefaultUpdateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cptasklog.DefaultUpdateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cptasklog.DefaultUpdateTime()
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *CpTaskLogCreate) check() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CpTaskLog.create_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CpTaskLog.update_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.CpTaskID(); !ok {
|
||||
return &ValidationError{Name: "cp_task_id", err: errors.New(`ent: missing required field "CpTaskLog.cp_task_id"`)}
|
||||
}
|
||||
@@ -174,6 +215,14 @@ func (_c *CpTaskLogCreate) createSpec() (*CpTaskLog, *sqlgraph.CreateSpec) {
|
||||
)
|
||||
_spec.Schema = _c.schemaConfig.CpTaskLog
|
||||
_spec.OnConflict = _c.conflict
|
||||
if value, ok := _c.mutation.CreateTime(); ok {
|
||||
_spec.SetField(cptasklog.FieldCreateTime, field.TypeString, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cptasklog.FieldUpdateTime, field.TypeString, value)
|
||||
_node.UpdateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.IsSuccess(); ok {
|
||||
_spec.SetField(cptasklog.FieldIsSuccess, field.TypeBool, value)
|
||||
_node.IsSuccess = value
|
||||
@@ -247,7 +296,7 @@ func (_c *CpTaskLogCreate) createSpec() (*CpTaskLog, *sqlgraph.CreateSpec) {
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.CpTaskLog.Create().
|
||||
// SetCpTaskID(v).
|
||||
// SetCreateTime(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -256,7 +305,7 @@ func (_c *CpTaskLogCreate) createSpec() (*CpTaskLog, *sqlgraph.CreateSpec) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpTaskLogUpsert) {
|
||||
// SetCpTaskID(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpTaskLogCreate) OnConflict(opts ...sql.ConflictOption) *CpTaskLogUpsertOne {
|
||||
@@ -292,6 +341,18 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpTaskLogUpsert) SetUpdateTime(v *ent2.CustomTime) *CpTaskLogUpsert {
|
||||
u.Set(cptasklog.FieldUpdateTime, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpTaskLogUpsert) UpdateUpdateTime() *CpTaskLogUpsert {
|
||||
u.SetExcluded(cptasklog.FieldUpdateTime)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (u *CpTaskLogUpsert) SetCpTaskID(v int64) *CpTaskLogUpsert {
|
||||
u.Set(cptasklog.FieldCpTaskID, v)
|
||||
@@ -386,6 +447,11 @@ func (u *CpTaskLogUpsert) ClearRealName() *CpTaskLogUpsert {
|
||||
// Exec(ctx)
|
||||
func (u *CpTaskLogUpsertOne) UpdateNewValues() *CpTaskLogUpsertOne {
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
||||
if _, exists := u.create.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cptasklog.FieldCreateTime)
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -416,6 +482,20 @@ func (u *CpTaskLogUpsertOne) Update(set func(*CpTaskLogUpsert)) *CpTaskLogUpsert
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpTaskLogUpsertOne) SetUpdateTime(v *ent2.CustomTime) *CpTaskLogUpsertOne {
|
||||
return u.Update(func(s *CpTaskLogUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpTaskLogUpsertOne) UpdateUpdateTime() *CpTaskLogUpsertOne {
|
||||
return u.Update(func(s *CpTaskLogUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (u *CpTaskLogUpsertOne) SetCpTaskID(v int64) *CpTaskLogUpsertOne {
|
||||
return u.Update(func(s *CpTaskLogUpsert) {
|
||||
@@ -566,6 +646,7 @@ func (_c *CpTaskLogCreateBulk) Save(ctx context.Context) ([]*CpTaskLog, error) {
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CpTaskLogMutation)
|
||||
if !ok {
|
||||
@@ -648,7 +729,7 @@ func (_c *CpTaskLogCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpTaskLogUpsert) {
|
||||
// SetCpTaskID(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpTaskLogCreateBulk) OnConflict(opts ...sql.ConflictOption) *CpTaskLogUpsertBulk {
|
||||
@@ -687,6 +768,13 @@ type CpTaskLogUpsertBulk struct {
|
||||
// Exec(ctx)
|
||||
func (u *CpTaskLogUpsertBulk) UpdateNewValues() *CpTaskLogUpsertBulk {
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
||||
for _, b := range u.create.builders {
|
||||
if _, exists := b.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cptasklog.FieldCreateTime)
|
||||
}
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -717,6 +805,20 @@ func (u *CpTaskLogUpsertBulk) Update(set func(*CpTaskLogUpsert)) *CpTaskLogUpser
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpTaskLogUpsertBulk) SetUpdateTime(v *ent2.CustomTime) *CpTaskLogUpsertBulk {
|
||||
return u.Update(func(s *CpTaskLogUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpTaskLogUpsertBulk) UpdateUpdateTime() *CpTaskLogUpsertBulk {
|
||||
return u.Update(func(s *CpTaskLogUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (u *CpTaskLogUpsertBulk) SetCpTaskID(v int64) *CpTaskLogUpsertBulk {
|
||||
return u.Update(func(s *CpTaskLogUpsert) {
|
||||
|
||||
@@ -383,12 +383,12 @@ func (_q *CpTaskLogQuery) WithCpUser(opts ...func(*CpUserQuery)) *CpTaskLogQuery
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CpTaskID int64 `json:"cp_task_id,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CpTaskLog.Query().
|
||||
// GroupBy(cptasklog.FieldCpTaskID).
|
||||
// GroupBy(cptasklog.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpTaskLogQuery) GroupBy(field string, fields ...string) *CpTaskLogGroupBy {
|
||||
@@ -406,11 +406,11 @@ func (_q *CpTaskLogQuery) GroupBy(field string, fields ...string) *CpTaskLogGrou
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// CpTaskID int64 `json:"cp_task_id,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// }
|
||||
//
|
||||
// client.CpTaskLog.Query().
|
||||
// Select(cptasklog.FieldCpTaskID).
|
||||
// Select(cptasklog.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpTaskLogQuery) Select(fields ...string) *CpTaskLogSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -32,6 +33,12 @@ func (_u *CpTaskLogUpdate) Where(ps ...predicate.CpTaskLog) *CpTaskLogUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpTaskLogUpdate) SetUpdateTime(v *ent2.CustomTime) *CpTaskLogUpdate {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (_u *CpTaskLogUpdate) SetCpTaskID(v int64) *CpTaskLogUpdate {
|
||||
_u.mutation.SetCpTaskID(v)
|
||||
@@ -225,6 +232,9 @@ func (_u *CpTaskLogUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cptasklog.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.IsSuccess(); ok {
|
||||
_spec.SetField(cptasklog.FieldIsSuccess, field.TypeBool, value)
|
||||
}
|
||||
@@ -357,6 +367,12 @@ type CpTaskLogUpdateOne struct {
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpTaskLogUpdateOne) SetUpdateTime(v *ent2.CustomTime) *CpTaskLogUpdateOne {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (_u *CpTaskLogUpdateOne) SetCpTaskID(v int64) *CpTaskLogUpdateOne {
|
||||
_u.mutation.SetCpTaskID(v)
|
||||
@@ -580,6 +596,9 @@ func (_u *CpTaskLogUpdateOne) sqlSave(ctx context.Context) (_node *CpTaskLog, er
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cptasklog.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.IsSuccess(); ok {
|
||||
_spec.SetField(cptasklog.FieldIsSuccess, field.TypeBool, value)
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cpschool"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
"strings"
|
||||
|
||||
"entgo.io/ent"
|
||||
@@ -18,6 +19,10 @@ type CpUser struct {
|
||||
config `json:"-"`
|
||||
// ID of the ent.
|
||||
ID int64 `json:"id,omitempty"`
|
||||
// CreateTime holds the value of the "create_time" field.
|
||||
CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// UpdateTime holds the value of the "update_time" field.
|
||||
UpdateTime *ent2.CustomTime `json:"updateTime"`
|
||||
// UserID holds the value of the "user_id" field.
|
||||
UserID int64 `json:"user_id,omitempty"`
|
||||
// Username holds the value of the "username" field.
|
||||
@@ -102,6 +107,8 @@ func (*CpUser) scanValues(columns []string) ([]any, error) {
|
||||
values := make([]any, len(columns))
|
||||
for i := range columns {
|
||||
switch columns[i] {
|
||||
case cpuser.FieldCreateTime, cpuser.FieldUpdateTime:
|
||||
values[i] = new(ent2.CustomTime)
|
||||
case cpuser.FieldID, cpuser.FieldUserID:
|
||||
values[i] = new(sql.NullInt64)
|
||||
case cpuser.FieldUsername, cpuser.FieldPassword, cpuser.FieldSchoolID, cpuser.FieldEmail, cpuser.FieldMobileCode, cpuser.FieldCookie, cpuser.FieldMobileType:
|
||||
@@ -127,6 +134,18 @@ func (_m *CpUser) assignValues(columns []string, values []any) error {
|
||||
return fmt.Errorf("unexpected type %T for field id", value)
|
||||
}
|
||||
_m.ID = int64(value.Int64)
|
||||
case cpuser.FieldCreateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field create_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.CreateTime = value
|
||||
}
|
||||
case cpuser.FieldUpdateTime:
|
||||
if value, ok := values[i].(*ent2.CustomTime); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field update_time", values[i])
|
||||
} else if value != nil {
|
||||
_m.UpdateTime = value
|
||||
}
|
||||
case cpuser.FieldUserID:
|
||||
if value, ok := values[i].(*sql.NullInt64); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field user_id", values[i])
|
||||
@@ -231,6 +250,12 @@ func (_m *CpUser) String() string {
|
||||
var builder strings.Builder
|
||||
builder.WriteString("CpUser(")
|
||||
builder.WriteString(fmt.Sprintf("id=%v, ", _m.ID))
|
||||
builder.WriteString("create_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.CreateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("update_time=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UpdateTime))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("user_id=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.UserID))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -4,7 +4,9 @@ package cpuser
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
)
|
||||
@@ -14,6 +16,10 @@ const (
|
||||
Label = "cp_user"
|
||||
// FieldID holds the string denoting the id field in the database.
|
||||
FieldID = "id"
|
||||
// FieldCreateTime holds the string denoting the create_time field in the database.
|
||||
FieldCreateTime = "create_time"
|
||||
// FieldUpdateTime holds the string denoting the update_time field in the database.
|
||||
FieldUpdateTime = "update_time"
|
||||
// FieldUserID holds the string denoting the user_id field in the database.
|
||||
FieldUserID = "user_id"
|
||||
// FieldUsername holds the string denoting the username field in the database.
|
||||
@@ -73,6 +79,8 @@ const (
|
||||
// Columns holds all SQL columns for cpuser fields.
|
||||
var Columns = []string{
|
||||
FieldID,
|
||||
FieldCreateTime,
|
||||
FieldUpdateTime,
|
||||
FieldUserID,
|
||||
FieldUsername,
|
||||
FieldPassword,
|
||||
@@ -93,7 +101,17 @@ func ValidColumn(column string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// Note that the variables below are initialized by the runtime
|
||||
// package on the initialization of the application. Therefore,
|
||||
// it should be imported in the main as follows:
|
||||
//
|
||||
// import _ "likedream-goframe/internal/ent/runtime"
|
||||
var (
|
||||
Hooks [1]ent.Hook
|
||||
// DefaultCreateTime holds the default value on creation for the "create_time" field.
|
||||
DefaultCreateTime func() *ent2.CustomTime
|
||||
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
|
||||
DefaultUpdateTime func() *ent2.CustomTime
|
||||
// UsernameValidator is a validator for the "username" field. It is called by the builders before save.
|
||||
UsernameValidator func(string) error
|
||||
// PasswordValidator is a validator for the "password" field. It is called by the builders before save.
|
||||
@@ -133,6 +151,16 @@ func ByID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldID, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByCreateTime orders the results by the create_time field.
|
||||
func ByCreateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldCreateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUpdateTime orders the results by the update_time field.
|
||||
func ByUpdateTime(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUpdateTime, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByUserID orders the results by the user_id field.
|
||||
func ByUserID(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldUserID, opts...).ToFunc()
|
||||
|
||||
@@ -5,6 +5,7 @@ package cpuser
|
||||
import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -55,6 +56,16 @@ func IDLTE(id int64) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldLTE(FieldID, id))
|
||||
}
|
||||
|
||||
// CreateTime applies equality check predicate on the "create_time" field. It's identical to CreateTimeEQ.
|
||||
func CreateTime(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTime applies equality check predicate on the "update_time" field. It's identical to UpdateTimeEQ.
|
||||
func UpdateTime(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UserID applies equality check predicate on the "user_id" field. It's identical to UserIDEQ.
|
||||
func UserID(v int64) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldUserID, v))
|
||||
@@ -90,6 +101,146 @@ func Cookie(v string) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldCookie, v))
|
||||
}
|
||||
|
||||
// CreateTimeEQ applies the EQ predicate on the "create_time" field.
|
||||
func CreateTimeEQ(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeNEQ applies the NEQ predicate on the "create_time" field.
|
||||
func CreateTimeNEQ(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldNEQ(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeIn applies the In predicate on the "create_time" field.
|
||||
func CreateTimeIn(vs ...*ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeNotIn applies the NotIn predicate on the "create_time" field.
|
||||
func CreateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldNotIn(FieldCreateTime, vs...))
|
||||
}
|
||||
|
||||
// CreateTimeGT applies the GT predicate on the "create_time" field.
|
||||
func CreateTimeGT(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldGT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeGTE applies the GTE predicate on the "create_time" field.
|
||||
func CreateTimeGTE(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldGTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLT applies the LT predicate on the "create_time" field.
|
||||
func CreateTimeLT(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldLT(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeLTE applies the LTE predicate on the "create_time" field.
|
||||
func CreateTimeLTE(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldLTE(FieldCreateTime, v))
|
||||
}
|
||||
|
||||
// CreateTimeContains applies the Contains predicate on the "create_time" field.
|
||||
func CreateTimeContains(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldContains(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasPrefix applies the HasPrefix predicate on the "create_time" field.
|
||||
func CreateTimeHasPrefix(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldHasPrefix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeHasSuffix applies the HasSuffix predicate on the "create_time" field.
|
||||
func CreateTimeHasSuffix(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldHasSuffix(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeEqualFold applies the EqualFold predicate on the "create_time" field.
|
||||
func CreateTimeEqualFold(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldEqualFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// CreateTimeContainsFold applies the ContainsFold predicate on the "create_time" field.
|
||||
func CreateTimeContainsFold(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldContainsFold(FieldCreateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEQ applies the EQ predicate on the "update_time" field.
|
||||
func UpdateTimeEQ(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeNEQ applies the NEQ predicate on the "update_time" field.
|
||||
func UpdateTimeNEQ(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldNEQ(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeIn applies the In predicate on the "update_time" field.
|
||||
func UpdateTimeIn(vs ...*ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeNotIn applies the NotIn predicate on the "update_time" field.
|
||||
func UpdateTimeNotIn(vs ...*ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldNotIn(FieldUpdateTime, vs...))
|
||||
}
|
||||
|
||||
// UpdateTimeGT applies the GT predicate on the "update_time" field.
|
||||
func UpdateTimeGT(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldGT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeGTE applies the GTE predicate on the "update_time" field.
|
||||
func UpdateTimeGTE(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldGTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLT applies the LT predicate on the "update_time" field.
|
||||
func UpdateTimeLT(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldLT(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeLTE applies the LTE predicate on the "update_time" field.
|
||||
func UpdateTimeLTE(v *ent2.CustomTime) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldLTE(FieldUpdateTime, v))
|
||||
}
|
||||
|
||||
// UpdateTimeContains applies the Contains predicate on the "update_time" field.
|
||||
func UpdateTimeContains(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldContains(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasPrefix applies the HasPrefix predicate on the "update_time" field.
|
||||
func UpdateTimeHasPrefix(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldHasPrefix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeHasSuffix applies the HasSuffix predicate on the "update_time" field.
|
||||
func UpdateTimeHasSuffix(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldHasSuffix(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeEqualFold applies the EqualFold predicate on the "update_time" field.
|
||||
func UpdateTimeEqualFold(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldEqualFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UpdateTimeContainsFold applies the ContainsFold predicate on the "update_time" field.
|
||||
func UpdateTimeContainsFold(v *ent2.CustomTime) predicate.CpUser {
|
||||
vc := v.String()
|
||||
return predicate.CpUser(sql.FieldContainsFold(FieldUpdateTime, vc))
|
||||
}
|
||||
|
||||
// UserIDEQ applies the EQ predicate on the "user_id" field.
|
||||
func UserIDEQ(v int64) predicate.CpUser {
|
||||
return predicate.CpUser(sql.FieldEQ(FieldUserID, v))
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"likedream-goframe/internal/ent/cptasklog"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -25,6 +26,18 @@ type CpUserCreate struct {
|
||||
conflict []sql.ConflictOption
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (_c *CpUserCreate) SetCreateTime(v *ent2.CustomTime) *CpUserCreate {
|
||||
_c.mutation.SetCreateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_c *CpUserCreate) SetUpdateTime(v *ent2.CustomTime) *CpUserCreate {
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_c *CpUserCreate) SetUserID(v int64) *CpUserCreate {
|
||||
_c.mutation.SetUserID(v)
|
||||
@@ -150,6 +163,9 @@ func (_c *CpUserCreate) Mutation() *CpUserMutation {
|
||||
|
||||
// Save creates the CpUser in the database.
|
||||
func (_c *CpUserCreate) Save(ctx context.Context) (*CpUser, error) {
|
||||
if err := _c.defaults(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
@@ -175,8 +191,33 @@ func (_c *CpUserCreate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_c *CpUserCreate) defaults() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
if cpuser.DefaultCreateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cpuser.DefaultCreateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cpuser.DefaultCreateTime()
|
||||
_c.mutation.SetCreateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
if cpuser.DefaultUpdateTime == nil {
|
||||
return fmt.Errorf("ent: uninitialized cpuser.DefaultUpdateTime (forgotten import ent/runtime?)")
|
||||
}
|
||||
v := cpuser.DefaultUpdateTime()
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *CpUserCreate) check() error {
|
||||
if _, ok := _c.mutation.CreateTime(); !ok {
|
||||
return &ValidationError{Name: "create_time", err: errors.New(`ent: missing required field "CpUser.create_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UpdateTime(); !ok {
|
||||
return &ValidationError{Name: "update_time", err: errors.New(`ent: missing required field "CpUser.update_time"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.UserID(); !ok {
|
||||
return &ValidationError{Name: "user_id", err: errors.New(`ent: missing required field "CpUser.user_id"`)}
|
||||
}
|
||||
@@ -246,6 +287,14 @@ func (_c *CpUserCreate) createSpec() (*CpUser, *sqlgraph.CreateSpec) {
|
||||
)
|
||||
_spec.Schema = _c.schemaConfig.CpUser
|
||||
_spec.OnConflict = _c.conflict
|
||||
if value, ok := _c.mutation.CreateTime(); ok {
|
||||
_spec.SetField(cpuser.FieldCreateTime, field.TypeString, value)
|
||||
_node.CreateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cpuser.FieldUpdateTime, field.TypeString, value)
|
||||
_node.UpdateTime = value
|
||||
}
|
||||
if value, ok := _c.mutation.Username(); ok {
|
||||
_spec.SetField(cpuser.FieldUsername, field.TypeString, value)
|
||||
_node.Username = value
|
||||
@@ -347,7 +396,7 @@ func (_c *CpUserCreate) createSpec() (*CpUser, *sqlgraph.CreateSpec) {
|
||||
// of the `INSERT` statement. For example:
|
||||
//
|
||||
// client.CpUser.Create().
|
||||
// SetUserID(v).
|
||||
// SetCreateTime(v).
|
||||
// OnConflict(
|
||||
// // Update the row with the new values
|
||||
// // the was proposed for insertion.
|
||||
@@ -356,7 +405,7 @@ func (_c *CpUserCreate) createSpec() (*CpUser, *sqlgraph.CreateSpec) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpUserUpsert) {
|
||||
// SetUserID(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpUserCreate) OnConflict(opts ...sql.ConflictOption) *CpUserUpsertOne {
|
||||
@@ -392,6 +441,18 @@ type (
|
||||
}
|
||||
)
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpUserUpsert) SetUpdateTime(v *ent2.CustomTime) *CpUserUpsert {
|
||||
u.Set(cpuser.FieldUpdateTime, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpUserUpsert) UpdateUpdateTime() *CpUserUpsert {
|
||||
u.SetExcluded(cpuser.FieldUpdateTime)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (u *CpUserUpsert) SetUserID(v int64) *CpUserUpsert {
|
||||
u.Set(cpuser.FieldUserID, v)
|
||||
@@ -516,6 +577,11 @@ func (u *CpUserUpsert) UpdateMobileType() *CpUserUpsert {
|
||||
// Exec(ctx)
|
||||
func (u *CpUserUpsertOne) UpdateNewValues() *CpUserUpsertOne {
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
||||
if _, exists := u.create.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cpuser.FieldCreateTime)
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -546,6 +612,20 @@ func (u *CpUserUpsertOne) Update(set func(*CpUserUpsert)) *CpUserUpsertOne {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpUserUpsertOne) SetUpdateTime(v *ent2.CustomTime) *CpUserUpsertOne {
|
||||
return u.Update(func(s *CpUserUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpUserUpsertOne) UpdateUpdateTime() *CpUserUpsertOne {
|
||||
return u.Update(func(s *CpUserUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (u *CpUserUpsertOne) SetUserID(v int64) *CpUserUpsertOne {
|
||||
return u.Update(func(s *CpUserUpsert) {
|
||||
@@ -731,6 +811,7 @@ func (_c *CpUserCreateBulk) Save(ctx context.Context) ([]*CpUser, error) {
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*CpUserMutation)
|
||||
if !ok {
|
||||
@@ -813,7 +894,7 @@ func (_c *CpUserCreateBulk) ExecX(ctx context.Context) {
|
||||
// // Override some of the fields with custom
|
||||
// // update values.
|
||||
// Update(func(u *ent.CpUserUpsert) {
|
||||
// SetUserID(v+v).
|
||||
// SetCreateTime(v+v).
|
||||
// }).
|
||||
// Exec(ctx)
|
||||
func (_c *CpUserCreateBulk) OnConflict(opts ...sql.ConflictOption) *CpUserUpsertBulk {
|
||||
@@ -852,6 +933,13 @@ type CpUserUpsertBulk struct {
|
||||
// Exec(ctx)
|
||||
func (u *CpUserUpsertBulk) UpdateNewValues() *CpUserUpsertBulk {
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWithNewValues())
|
||||
u.create.conflict = append(u.create.conflict, sql.ResolveWith(func(s *sql.UpdateSet) {
|
||||
for _, b := range u.create.builders {
|
||||
if _, exists := b.mutation.CreateTime(); exists {
|
||||
s.SetIgnore(cpuser.FieldCreateTime)
|
||||
}
|
||||
}
|
||||
}))
|
||||
return u
|
||||
}
|
||||
|
||||
@@ -882,6 +970,20 @@ func (u *CpUserUpsertBulk) Update(set func(*CpUserUpsert)) *CpUserUpsertBulk {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (u *CpUserUpsertBulk) SetUpdateTime(v *ent2.CustomTime) *CpUserUpsertBulk {
|
||||
return u.Update(func(s *CpUserUpsert) {
|
||||
s.SetUpdateTime(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateUpdateTime sets the "update_time" field to the value that was provided on create.
|
||||
func (u *CpUserUpsertBulk) UpdateUpdateTime() *CpUserUpsertBulk {
|
||||
return u.Update(func(s *CpUserUpsert) {
|
||||
s.UpdateUpdateTime()
|
||||
})
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (u *CpUserUpsertBulk) SetUserID(v int64) *CpUserUpsertBulk {
|
||||
return u.Update(func(s *CpUserUpsert) {
|
||||
|
||||
@@ -425,12 +425,12 @@ func (_q *CpUserQuery) WithSchool(opts ...func(*CpSchoolQuery)) *CpUserQuery {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// UserID int64 `json:"user_id,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// Count int `json:"count,omitempty"`
|
||||
// }
|
||||
//
|
||||
// client.CpUser.Query().
|
||||
// GroupBy(cpuser.FieldUserID).
|
||||
// GroupBy(cpuser.FieldCreateTime).
|
||||
// Aggregate(ent.Count()).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpUserQuery) GroupBy(field string, fields ...string) *CpUserGroupBy {
|
||||
@@ -448,11 +448,11 @@ func (_q *CpUserQuery) GroupBy(field string, fields ...string) *CpUserGroupBy {
|
||||
// Example:
|
||||
//
|
||||
// var v []struct {
|
||||
// UserID int64 `json:"user_id,omitempty"`
|
||||
// CreateTime *ent2.CustomTime `json:"createTime"`
|
||||
// }
|
||||
//
|
||||
// client.CpUser.Query().
|
||||
// Select(cpuser.FieldUserID).
|
||||
// Select(cpuser.FieldCreateTime).
|
||||
// Scan(ctx, &v)
|
||||
func (_q *CpUserQuery) Select(fields ...string) *CpUserSelect {
|
||||
_q.ctx.Fields = append(_q.ctx.Fields, fields...)
|
||||
|
||||
@@ -13,6 +13,7 @@ import (
|
||||
"likedream-goframe/internal/ent/internal"
|
||||
"likedream-goframe/internal/ent/predicate"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -33,6 +34,12 @@ func (_u *CpUserUpdate) Where(ps ...predicate.CpUser) *CpUserUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpUserUpdate) SetUpdateTime(v *ent2.CustomTime) *CpUserUpdate {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_u *CpUserUpdate) SetUserID(v int64) *CpUserUpdate {
|
||||
_u.mutation.SetUserID(v)
|
||||
@@ -344,6 +351,9 @@ func (_u *CpUserUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cpuser.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Username(); ok {
|
||||
_spec.SetField(cpuser.FieldUsername, field.TypeString, value)
|
||||
}
|
||||
@@ -553,6 +563,12 @@ type CpUserUpdateOne struct {
|
||||
modifiers []func(*sql.UpdateBuilder)
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (_u *CpUserUpdateOne) SetUpdateTime(v *ent2.CustomTime) *CpUserUpdateOne {
|
||||
_u.mutation.SetUpdateTime(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (_u *CpUserUpdateOne) SetUserID(v int64) *CpUserUpdateOne {
|
||||
_u.mutation.SetUserID(v)
|
||||
@@ -894,6 +910,9 @@ func (_u *CpUserUpdateOne) sqlSave(ctx context.Context) (_node *CpUser, err erro
|
||||
}
|
||||
}
|
||||
}
|
||||
if value, ok := _u.mutation.UpdateTime(); ok {
|
||||
_spec.SetField(cpuser.FieldUpdateTime, field.TypeString, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Username(); ok {
|
||||
_spec.SetField(cpuser.FieldUsername, field.TypeString, value)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "CpSchool",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
cpschool.FieldCreateTime: {Type: field.TypeString, Column: cpschool.FieldCreateTime},
|
||||
cpschool.FieldUpdateTime: {Type: field.TypeString, Column: cpschool.FieldUpdateTime},
|
||||
cpschool.FieldName: {Type: field.TypeString, Column: cpschool.FieldName},
|
||||
cpschool.FieldNamePinyin: {Type: field.TypeString, Column: cpschool.FieldNamePinyin},
|
||||
cpschool.FieldIconImg: {Type: field.TypeString, Column: cpschool.FieldIconImg},
|
||||
@@ -72,6 +74,8 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "CpTask",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
cptask.FieldCreateTime: {Type: field.TypeString, Column: cptask.FieldCreateTime},
|
||||
cptask.FieldUpdateTime: {Type: field.TypeString, Column: cptask.FieldUpdateTime},
|
||||
cptask.FieldCpUserID: {Type: field.TypeInt64, Column: cptask.FieldCpUserID},
|
||||
cptask.FieldUserID: {Type: field.TypeInt64, Column: cptask.FieldUserID},
|
||||
cptask.FieldTaskType: {Type: field.TypeEnum, Column: cptask.FieldTaskType},
|
||||
@@ -98,6 +102,8 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "CpTaskLog",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
cptasklog.FieldCreateTime: {Type: field.TypeString, Column: cptasklog.FieldCreateTime},
|
||||
cptasklog.FieldUpdateTime: {Type: field.TypeString, Column: cptasklog.FieldUpdateTime},
|
||||
cptasklog.FieldCpTaskID: {Type: field.TypeInt64, Column: cptasklog.FieldCpTaskID},
|
||||
cptasklog.FieldSystemUserID: {Type: field.TypeInt64, Column: cptasklog.FieldSystemUserID},
|
||||
cptasklog.FieldCpUserID: {Type: field.TypeInt64, Column: cptasklog.FieldCpUserID},
|
||||
@@ -117,6 +123,8 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
},
|
||||
Type: "CpUser",
|
||||
Fields: map[string]*sqlgraph.FieldSpec{
|
||||
cpuser.FieldCreateTime: {Type: field.TypeString, Column: cpuser.FieldCreateTime},
|
||||
cpuser.FieldUpdateTime: {Type: field.TypeString, Column: cpuser.FieldUpdateTime},
|
||||
cpuser.FieldUserID: {Type: field.TypeInt64, Column: cpuser.FieldUserID},
|
||||
cpuser.FieldUsername: {Type: field.TypeString, Column: cpuser.FieldUsername},
|
||||
cpuser.FieldPassword: {Type: field.TypeString, Column: cpuser.FieldPassword},
|
||||
@@ -186,6 +194,7 @@ var schemaGraph = func() *sqlgraph.Schema {
|
||||
sysmenu.FieldPermission: {Type: field.TypeString, Column: sysmenu.FieldPermission},
|
||||
sysmenu.FieldRoute: {Type: field.TypeString, Column: sysmenu.FieldRoute},
|
||||
sysmenu.FieldComponent: {Type: field.TypeString, Column: sysmenu.FieldComponent},
|
||||
sysmenu.FieldKeepAlive: {Type: field.TypeBool, Column: sysmenu.FieldKeepAlive},
|
||||
sysmenu.FieldHidden: {Type: field.TypeBool, Column: sysmenu.FieldHidden},
|
||||
sysmenu.FieldIcon: {Type: field.TypeString, Column: sysmenu.FieldIcon},
|
||||
sysmenu.FieldOrder: {Type: field.TypeUint, Column: sysmenu.FieldOrder},
|
||||
@@ -767,6 +776,16 @@ func (f *CpSchoolFilter) WhereID(p entql.StringP) {
|
||||
f.Where(p.Field(cpschool.FieldID))
|
||||
}
|
||||
|
||||
// WhereCreateTime applies the entql string predicate on the create_time field.
|
||||
func (f *CpSchoolFilter) WhereCreateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cpschool.FieldCreateTime))
|
||||
}
|
||||
|
||||
// WhereUpdateTime applies the entql string predicate on the update_time field.
|
||||
func (f *CpSchoolFilter) WhereUpdateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cpschool.FieldUpdateTime))
|
||||
}
|
||||
|
||||
// WhereName applies the entql string predicate on the name field.
|
||||
func (f *CpSchoolFilter) WhereName(p entql.StringP) {
|
||||
f.Where(p.Field(cpschool.FieldName))
|
||||
@@ -836,6 +855,16 @@ func (f *CpTaskFilter) WhereID(p entql.Int64P) {
|
||||
f.Where(p.Field(cptask.FieldID))
|
||||
}
|
||||
|
||||
// WhereCreateTime applies the entql string predicate on the create_time field.
|
||||
func (f *CpTaskFilter) WhereCreateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cptask.FieldCreateTime))
|
||||
}
|
||||
|
||||
// WhereUpdateTime applies the entql string predicate on the update_time field.
|
||||
func (f *CpTaskFilter) WhereUpdateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cptask.FieldUpdateTime))
|
||||
}
|
||||
|
||||
// WhereCpUserID applies the entql int64 predicate on the cp_user_id field.
|
||||
func (f *CpTaskFilter) WhereCpUserID(p entql.Int64P) {
|
||||
f.Where(p.Field(cptask.FieldCpUserID))
|
||||
@@ -983,6 +1012,16 @@ func (f *CpTaskLogFilter) WhereID(p entql.Int64P) {
|
||||
f.Where(p.Field(cptasklog.FieldID))
|
||||
}
|
||||
|
||||
// WhereCreateTime applies the entql string predicate on the create_time field.
|
||||
func (f *CpTaskLogFilter) WhereCreateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cptasklog.FieldCreateTime))
|
||||
}
|
||||
|
||||
// WhereUpdateTime applies the entql string predicate on the update_time field.
|
||||
func (f *CpTaskLogFilter) WhereUpdateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cptasklog.FieldUpdateTime))
|
||||
}
|
||||
|
||||
// WhereCpTaskID applies the entql int64 predicate on the cp_task_id field.
|
||||
func (f *CpTaskLogFilter) WhereCpTaskID(p entql.Int64P) {
|
||||
f.Where(p.Field(cptasklog.FieldCpTaskID))
|
||||
@@ -1095,6 +1134,16 @@ func (f *CpUserFilter) WhereID(p entql.Int64P) {
|
||||
f.Where(p.Field(cpuser.FieldID))
|
||||
}
|
||||
|
||||
// WhereCreateTime applies the entql string predicate on the create_time field.
|
||||
func (f *CpUserFilter) WhereCreateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cpuser.FieldCreateTime))
|
||||
}
|
||||
|
||||
// WhereUpdateTime applies the entql string predicate on the update_time field.
|
||||
func (f *CpUserFilter) WhereUpdateTime(p entql.StringP) {
|
||||
f.Where(p.Field(cpuser.FieldUpdateTime))
|
||||
}
|
||||
|
||||
// WhereUserID applies the entql int64 predicate on the user_id field.
|
||||
func (f *CpUserFilter) WhereUserID(p entql.Int64P) {
|
||||
f.Where(p.Field(cpuser.FieldUserID))
|
||||
@@ -1477,6 +1526,11 @@ func (f *SysMenuFilter) WhereComponent(p entql.StringP) {
|
||||
f.Where(p.Field(sysmenu.FieldComponent))
|
||||
}
|
||||
|
||||
// WhereKeepAlive applies the entql bool predicate on the keep_alive field.
|
||||
func (f *SysMenuFilter) WhereKeepAlive(p entql.BoolP) {
|
||||
f.Where(p.Field(sysmenu.FieldKeepAlive))
|
||||
}
|
||||
|
||||
// WhereHidden applies the entql bool predicate on the hidden field.
|
||||
func (f *SysMenuFilter) WhereHidden(p entql.BoolP) {
|
||||
f.Where(p.Field(sysmenu.FieldHidden))
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -30,13 +30,15 @@ var (
|
||||
Symbol: "cp_image_sys_user_images",
|
||||
Columns: []*schema.Column{CpImageColumns[7]},
|
||||
RefColumns: []*schema.Column{SysUserColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// CpSchoolsColumns holds the columns for the "cp_schools" table.
|
||||
CpSchoolsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeString, Unique: true},
|
||||
{Name: "create_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "update_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "name", Type: field.TypeString},
|
||||
{Name: "name_pinyin", Type: field.TypeString},
|
||||
{Name: "icon_img", Type: field.TypeString, Nullable: true},
|
||||
@@ -50,10 +52,12 @@ var (
|
||||
// CpTasksColumns holds the columns for the "cp_tasks" table.
|
||||
CpTasksColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||
{Name: "create_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "update_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "task_type", Type: field.TypeEnum, Enums: []string{"collection", "sign", "sleep_check"}},
|
||||
{Name: "title", Type: field.TypeString},
|
||||
{Name: "frequency", Type: field.TypeInt, Default: 0},
|
||||
{Name: "task_status", Type: field.TypeEnum, Enums: []string{"not_start", "doing", "done", "fail", "pause", "unknown"}},
|
||||
{Name: "task_status", Type: field.TypeEnum, Enums: []string{"not_start", "doing", "done", "fail", "pause", "queue", "unknown"}},
|
||||
{Name: "success_count", Type: field.TypeInt, Default: 0},
|
||||
{Name: "form_data", Type: field.TypeString, Nullable: true, Size: 2147483647},
|
||||
{Name: "step", Type: field.TypeEnum, Enums: []string{"form", "execute", "complete"}},
|
||||
@@ -72,21 +76,23 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cp_tasks_cp_users_cptasks",
|
||||
Columns: []*schema.Column{CpTasksColumns[12]},
|
||||
Columns: []*schema.Column{CpTasksColumns[14]},
|
||||
RefColumns: []*schema.Column{CpUsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "cp_tasks_sys_user_cp_task",
|
||||
Columns: []*schema.Column{CpTasksColumns[13]},
|
||||
Columns: []*schema.Column{CpTasksColumns[15]},
|
||||
RefColumns: []*schema.Column{SysUserColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// CpTaskLogsColumns holds the columns for the "cp_task_logs" table.
|
||||
CpTaskLogsColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||
{Name: "create_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "update_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "is_success", Type: field.TypeBool},
|
||||
{Name: "error_message", Type: field.TypeString, Nullable: true},
|
||||
{Name: "real_name", Type: field.TypeString, Nullable: true},
|
||||
@@ -102,27 +108,29 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cp_task_logs_cp_tasks_cp_task_logs",
|
||||
Columns: []*schema.Column{CpTaskLogsColumns[4]},
|
||||
Columns: []*schema.Column{CpTaskLogsColumns[6]},
|
||||
RefColumns: []*schema.Column{CpTasksColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "cp_task_logs_cp_users_cp_task_logs",
|
||||
Columns: []*schema.Column{CpTaskLogsColumns[5]},
|
||||
Columns: []*schema.Column{CpTaskLogsColumns[7]},
|
||||
RefColumns: []*schema.Column{CpUsersColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
{
|
||||
Symbol: "cp_task_logs_sys_user_cp_task_logs",
|
||||
Columns: []*schema.Column{CpTaskLogsColumns[6]},
|
||||
Columns: []*schema.Column{CpTaskLogsColumns[8]},
|
||||
RefColumns: []*schema.Column{SysUserColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
// CpUsersColumns holds the columns for the "cp_users" table.
|
||||
CpUsersColumns = []*schema.Column{
|
||||
{Name: "id", Type: field.TypeInt64, Increment: true},
|
||||
{Name: "create_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "update_time", Type: field.TypeString, SchemaType: map[string]string{"mysql": "datetime", "postgres": "timestamp", "sqlite3": "datetime"}},
|
||||
{Name: "username", Type: field.TypeString},
|
||||
{Name: "password", Type: field.TypeString},
|
||||
{Name: "email", Type: field.TypeString, Nullable: true},
|
||||
@@ -140,15 +148,15 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "cp_users_cp_schools_cpusers",
|
||||
Columns: []*schema.Column{CpUsersColumns[7]},
|
||||
Columns: []*schema.Column{CpUsersColumns[9]},
|
||||
RefColumns: []*schema.Column{CpSchoolsColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
},
|
||||
{
|
||||
Symbol: "cp_users_sys_user_cpuser",
|
||||
Columns: []*schema.Column{CpUsersColumns[8]},
|
||||
Columns: []*schema.Column{CpUsersColumns[10]},
|
||||
RefColumns: []*schema.Column{SysUserColumns[0]},
|
||||
OnDelete: schema.NoAction,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -171,7 +179,7 @@ var (
|
||||
Symbol: "sys_agent_sys_user_agent",
|
||||
Columns: []*schema.Column{SysAgentColumns[5]},
|
||||
RefColumns: []*schema.Column{SysUserColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
OnDelete: schema.Cascade,
|
||||
},
|
||||
},
|
||||
}
|
||||
@@ -226,6 +234,7 @@ var (
|
||||
{Name: "permission", Type: field.TypeString},
|
||||
{Name: "route", Type: field.TypeString, Nullable: true},
|
||||
{Name: "component", Type: field.TypeString, Nullable: true},
|
||||
{Name: "keep_alive", Type: field.TypeBool, Default: false},
|
||||
{Name: "hidden", Type: field.TypeBool, Default: false},
|
||||
{Name: "icon", Type: field.TypeString, Nullable: true},
|
||||
{Name: "order", Type: field.TypeUint},
|
||||
@@ -239,7 +248,7 @@ var (
|
||||
ForeignKeys: []*schema.ForeignKey{
|
||||
{
|
||||
Symbol: "sys_menu_sys_menu_children",
|
||||
Columns: []*schema.Column{SysMenuColumns[13]},
|
||||
Columns: []*schema.Column{SysMenuColumns[14]},
|
||||
RefColumns: []*schema.Column{SysMenuColumns[0]},
|
||||
OnDelete: schema.SetNull,
|
||||
},
|
||||
|
||||
+491
-5
@@ -794,6 +794,8 @@ type CpSchoolMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *string
|
||||
create_time **ent2.CustomTime
|
||||
update_time **ent2.CustomTime
|
||||
name *string
|
||||
name_pinyin *string
|
||||
icon_img *string
|
||||
@@ -910,6 +912,78 @@ func (m *CpSchoolMutation) IDs(ctx context.Context) ([]string, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (m *CpSchoolMutation) SetCreateTime(et *ent2.CustomTime) {
|
||||
m.create_time = &et
|
||||
}
|
||||
|
||||
// CreateTime returns the value of the "create_time" field in the mutation.
|
||||
func (m *CpSchoolMutation) CreateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.create_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldCreateTime returns the old "create_time" field's value of the CpSchool entity.
|
||||
// If the CpSchool object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpSchoolMutation) OldCreateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldCreateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldCreateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldCreateTime: %w", err)
|
||||
}
|
||||
return oldValue.CreateTime, nil
|
||||
}
|
||||
|
||||
// ResetCreateTime resets all changes to the "create_time" field.
|
||||
func (m *CpSchoolMutation) ResetCreateTime() {
|
||||
m.create_time = nil
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (m *CpSchoolMutation) SetUpdateTime(et *ent2.CustomTime) {
|
||||
m.update_time = &et
|
||||
}
|
||||
|
||||
// UpdateTime returns the value of the "update_time" field in the mutation.
|
||||
func (m *CpSchoolMutation) UpdateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.update_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUpdateTime returns the old "update_time" field's value of the CpSchool entity.
|
||||
// If the CpSchool object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpSchoolMutation) OldUpdateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUpdateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err)
|
||||
}
|
||||
return oldValue.UpdateTime, nil
|
||||
}
|
||||
|
||||
// ResetUpdateTime resets all changes to the "update_time" field.
|
||||
func (m *CpSchoolMutation) ResetUpdateTime() {
|
||||
m.update_time = nil
|
||||
}
|
||||
|
||||
// SetName sets the "name" field.
|
||||
func (m *CpSchoolMutation) SetName(s string) {
|
||||
m.name = &s
|
||||
@@ -1119,7 +1193,13 @@ func (m *CpSchoolMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *CpSchoolMutation) Fields() []string {
|
||||
fields := make([]string, 0, 3)
|
||||
fields := make([]string, 0, 5)
|
||||
if m.create_time != nil {
|
||||
fields = append(fields, cpschool.FieldCreateTime)
|
||||
}
|
||||
if m.update_time != nil {
|
||||
fields = append(fields, cpschool.FieldUpdateTime)
|
||||
}
|
||||
if m.name != nil {
|
||||
fields = append(fields, cpschool.FieldName)
|
||||
}
|
||||
@@ -1137,6 +1217,10 @@ func (m *CpSchoolMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *CpSchoolMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case cpschool.FieldCreateTime:
|
||||
return m.CreateTime()
|
||||
case cpschool.FieldUpdateTime:
|
||||
return m.UpdateTime()
|
||||
case cpschool.FieldName:
|
||||
return m.Name()
|
||||
case cpschool.FieldNamePinyin:
|
||||
@@ -1152,6 +1236,10 @@ func (m *CpSchoolMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *CpSchoolMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case cpschool.FieldCreateTime:
|
||||
return m.OldCreateTime(ctx)
|
||||
case cpschool.FieldUpdateTime:
|
||||
return m.OldUpdateTime(ctx)
|
||||
case cpschool.FieldName:
|
||||
return m.OldName(ctx)
|
||||
case cpschool.FieldNamePinyin:
|
||||
@@ -1167,6 +1255,20 @@ func (m *CpSchoolMutation) OldField(ctx context.Context, name string) (ent.Value
|
||||
// type.
|
||||
func (m *CpSchoolMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case cpschool.FieldCreateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetCreateTime(v)
|
||||
return nil
|
||||
case cpschool.FieldUpdateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUpdateTime(v)
|
||||
return nil
|
||||
case cpschool.FieldName:
|
||||
v, ok := value.(string)
|
||||
if !ok {
|
||||
@@ -1246,6 +1348,12 @@ func (m *CpSchoolMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *CpSchoolMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case cpschool.FieldCreateTime:
|
||||
m.ResetCreateTime()
|
||||
return nil
|
||||
case cpschool.FieldUpdateTime:
|
||||
m.ResetUpdateTime()
|
||||
return nil
|
||||
case cpschool.FieldName:
|
||||
m.ResetName()
|
||||
return nil
|
||||
@@ -1349,6 +1457,8 @@ type CpTaskMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int64
|
||||
create_time **ent2.CustomTime
|
||||
update_time **ent2.CustomTime
|
||||
task_type *cptask.TaskType
|
||||
title *string
|
||||
frequency *int
|
||||
@@ -1476,6 +1586,78 @@ func (m *CpTaskMutation) IDs(ctx context.Context) ([]int64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (m *CpTaskMutation) SetCreateTime(et *ent2.CustomTime) {
|
||||
m.create_time = &et
|
||||
}
|
||||
|
||||
// CreateTime returns the value of the "create_time" field in the mutation.
|
||||
func (m *CpTaskMutation) CreateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.create_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldCreateTime returns the old "create_time" field's value of the CpTask entity.
|
||||
// If the CpTask object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpTaskMutation) OldCreateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldCreateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldCreateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldCreateTime: %w", err)
|
||||
}
|
||||
return oldValue.CreateTime, nil
|
||||
}
|
||||
|
||||
// ResetCreateTime resets all changes to the "create_time" field.
|
||||
func (m *CpTaskMutation) ResetCreateTime() {
|
||||
m.create_time = nil
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (m *CpTaskMutation) SetUpdateTime(et *ent2.CustomTime) {
|
||||
m.update_time = &et
|
||||
}
|
||||
|
||||
// UpdateTime returns the value of the "update_time" field in the mutation.
|
||||
func (m *CpTaskMutation) UpdateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.update_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUpdateTime returns the old "update_time" field's value of the CpTask entity.
|
||||
// If the CpTask object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpTaskMutation) OldUpdateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUpdateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err)
|
||||
}
|
||||
return oldValue.UpdateTime, nil
|
||||
}
|
||||
|
||||
// ResetUpdateTime resets all changes to the "update_time" field.
|
||||
func (m *CpTaskMutation) ResetUpdateTime() {
|
||||
m.update_time = nil
|
||||
}
|
||||
|
||||
// SetCpUserID sets the "cp_user_id" field.
|
||||
func (m *CpTaskMutation) SetCpUserID(i int64) {
|
||||
m.cp_user = &i
|
||||
@@ -2254,7 +2436,13 @@ func (m *CpTaskMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *CpTaskMutation) Fields() []string {
|
||||
fields := make([]string, 0, 13)
|
||||
fields := make([]string, 0, 15)
|
||||
if m.create_time != nil {
|
||||
fields = append(fields, cptask.FieldCreateTime)
|
||||
}
|
||||
if m.update_time != nil {
|
||||
fields = append(fields, cptask.FieldUpdateTime)
|
||||
}
|
||||
if m.cp_user != nil {
|
||||
fields = append(fields, cptask.FieldCpUserID)
|
||||
}
|
||||
@@ -2302,6 +2490,10 @@ func (m *CpTaskMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *CpTaskMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case cptask.FieldCreateTime:
|
||||
return m.CreateTime()
|
||||
case cptask.FieldUpdateTime:
|
||||
return m.UpdateTime()
|
||||
case cptask.FieldCpUserID:
|
||||
return m.CpUserID()
|
||||
case cptask.FieldUserID:
|
||||
@@ -2337,6 +2529,10 @@ func (m *CpTaskMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *CpTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case cptask.FieldCreateTime:
|
||||
return m.OldCreateTime(ctx)
|
||||
case cptask.FieldUpdateTime:
|
||||
return m.OldUpdateTime(ctx)
|
||||
case cptask.FieldCpUserID:
|
||||
return m.OldCpUserID(ctx)
|
||||
case cptask.FieldUserID:
|
||||
@@ -2372,6 +2568,20 @@ func (m *CpTaskMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
// type.
|
||||
func (m *CpTaskMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case cptask.FieldCreateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetCreateTime(v)
|
||||
return nil
|
||||
case cptask.FieldUpdateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUpdateTime(v)
|
||||
return nil
|
||||
case cptask.FieldCpUserID:
|
||||
v, ok := value.(int64)
|
||||
if !ok {
|
||||
@@ -2602,6 +2812,12 @@ func (m *CpTaskMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *CpTaskMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case cptask.FieldCreateTime:
|
||||
m.ResetCreateTime()
|
||||
return nil
|
||||
case cptask.FieldUpdateTime:
|
||||
m.ResetUpdateTime()
|
||||
return nil
|
||||
case cptask.FieldCpUserID:
|
||||
m.ResetCpUserID()
|
||||
return nil
|
||||
@@ -2771,6 +2987,8 @@ type CpTaskLogMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int64
|
||||
create_time **ent2.CustomTime
|
||||
update_time **ent2.CustomTime
|
||||
is_success *bool
|
||||
error_message *string
|
||||
real_name *string
|
||||
@@ -2884,6 +3102,78 @@ func (m *CpTaskLogMutation) IDs(ctx context.Context) ([]int64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (m *CpTaskLogMutation) SetCreateTime(et *ent2.CustomTime) {
|
||||
m.create_time = &et
|
||||
}
|
||||
|
||||
// CreateTime returns the value of the "create_time" field in the mutation.
|
||||
func (m *CpTaskLogMutation) CreateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.create_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldCreateTime returns the old "create_time" field's value of the CpTaskLog entity.
|
||||
// If the CpTaskLog object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpTaskLogMutation) OldCreateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldCreateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldCreateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldCreateTime: %w", err)
|
||||
}
|
||||
return oldValue.CreateTime, nil
|
||||
}
|
||||
|
||||
// ResetCreateTime resets all changes to the "create_time" field.
|
||||
func (m *CpTaskLogMutation) ResetCreateTime() {
|
||||
m.create_time = nil
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (m *CpTaskLogMutation) SetUpdateTime(et *ent2.CustomTime) {
|
||||
m.update_time = &et
|
||||
}
|
||||
|
||||
// UpdateTime returns the value of the "update_time" field in the mutation.
|
||||
func (m *CpTaskLogMutation) UpdateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.update_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUpdateTime returns the old "update_time" field's value of the CpTaskLog entity.
|
||||
// If the CpTaskLog object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpTaskLogMutation) OldUpdateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUpdateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err)
|
||||
}
|
||||
return oldValue.UpdateTime, nil
|
||||
}
|
||||
|
||||
// ResetUpdateTime resets all changes to the "update_time" field.
|
||||
func (m *CpTaskLogMutation) ResetUpdateTime() {
|
||||
m.update_time = nil
|
||||
}
|
||||
|
||||
// SetCpTaskID sets the "cp_task_id" field.
|
||||
func (m *CpTaskLogMutation) SetCpTaskID(i int64) {
|
||||
m.cp_task = &i
|
||||
@@ -3241,7 +3531,13 @@ func (m *CpTaskLogMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *CpTaskLogMutation) Fields() []string {
|
||||
fields := make([]string, 0, 6)
|
||||
fields := make([]string, 0, 8)
|
||||
if m.create_time != nil {
|
||||
fields = append(fields, cptasklog.FieldCreateTime)
|
||||
}
|
||||
if m.update_time != nil {
|
||||
fields = append(fields, cptasklog.FieldUpdateTime)
|
||||
}
|
||||
if m.cp_task != nil {
|
||||
fields = append(fields, cptasklog.FieldCpTaskID)
|
||||
}
|
||||
@@ -3268,6 +3564,10 @@ func (m *CpTaskLogMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *CpTaskLogMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case cptasklog.FieldCreateTime:
|
||||
return m.CreateTime()
|
||||
case cptasklog.FieldUpdateTime:
|
||||
return m.UpdateTime()
|
||||
case cptasklog.FieldCpTaskID:
|
||||
return m.CpTaskID()
|
||||
case cptasklog.FieldSystemUserID:
|
||||
@@ -3289,6 +3589,10 @@ func (m *CpTaskLogMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *CpTaskLogMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case cptasklog.FieldCreateTime:
|
||||
return m.OldCreateTime(ctx)
|
||||
case cptasklog.FieldUpdateTime:
|
||||
return m.OldUpdateTime(ctx)
|
||||
case cptasklog.FieldCpTaskID:
|
||||
return m.OldCpTaskID(ctx)
|
||||
case cptasklog.FieldSystemUserID:
|
||||
@@ -3310,6 +3614,20 @@ func (m *CpTaskLogMutation) OldField(ctx context.Context, name string) (ent.Valu
|
||||
// type.
|
||||
func (m *CpTaskLogMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case cptasklog.FieldCreateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetCreateTime(v)
|
||||
return nil
|
||||
case cptasklog.FieldUpdateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUpdateTime(v)
|
||||
return nil
|
||||
case cptasklog.FieldCpTaskID:
|
||||
v, ok := value.(int64)
|
||||
if !ok {
|
||||
@@ -3419,6 +3737,12 @@ func (m *CpTaskLogMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *CpTaskLogMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case cptasklog.FieldCreateTime:
|
||||
m.ResetCreateTime()
|
||||
return nil
|
||||
case cptasklog.FieldUpdateTime:
|
||||
m.ResetUpdateTime()
|
||||
return nil
|
||||
case cptasklog.FieldCpTaskID:
|
||||
m.ResetCpTaskID()
|
||||
return nil
|
||||
@@ -3557,6 +3881,8 @@ type CpUserMutation struct {
|
||||
op Op
|
||||
typ string
|
||||
id *int64
|
||||
create_time **ent2.CustomTime
|
||||
update_time **ent2.CustomTime
|
||||
username *string
|
||||
password *string
|
||||
email *string
|
||||
@@ -3677,6 +4003,78 @@ func (m *CpUserMutation) IDs(ctx context.Context) ([]int64, error) {
|
||||
}
|
||||
}
|
||||
|
||||
// SetCreateTime sets the "create_time" field.
|
||||
func (m *CpUserMutation) SetCreateTime(et *ent2.CustomTime) {
|
||||
m.create_time = &et
|
||||
}
|
||||
|
||||
// CreateTime returns the value of the "create_time" field in the mutation.
|
||||
func (m *CpUserMutation) CreateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.create_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldCreateTime returns the old "create_time" field's value of the CpUser entity.
|
||||
// If the CpUser object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpUserMutation) OldCreateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldCreateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldCreateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldCreateTime: %w", err)
|
||||
}
|
||||
return oldValue.CreateTime, nil
|
||||
}
|
||||
|
||||
// ResetCreateTime resets all changes to the "create_time" field.
|
||||
func (m *CpUserMutation) ResetCreateTime() {
|
||||
m.create_time = nil
|
||||
}
|
||||
|
||||
// SetUpdateTime sets the "update_time" field.
|
||||
func (m *CpUserMutation) SetUpdateTime(et *ent2.CustomTime) {
|
||||
m.update_time = &et
|
||||
}
|
||||
|
||||
// UpdateTime returns the value of the "update_time" field in the mutation.
|
||||
func (m *CpUserMutation) UpdateTime() (r *ent2.CustomTime, exists bool) {
|
||||
v := m.update_time
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldUpdateTime returns the old "update_time" field's value of the CpUser entity.
|
||||
// If the CpUser object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *CpUserMutation) OldUpdateTime(ctx context.Context) (v *ent2.CustomTime, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldUpdateTime is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldUpdateTime requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldUpdateTime: %w", err)
|
||||
}
|
||||
return oldValue.UpdateTime, nil
|
||||
}
|
||||
|
||||
// ResetUpdateTime resets all changes to the "update_time" field.
|
||||
func (m *CpUserMutation) ResetUpdateTime() {
|
||||
m.update_time = nil
|
||||
}
|
||||
|
||||
// SetUserID sets the "user_id" field.
|
||||
func (m *CpUserMutation) SetUserID(i int64) {
|
||||
m.sysuser = &i
|
||||
@@ -4213,7 +4611,13 @@ func (m *CpUserMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *CpUserMutation) Fields() []string {
|
||||
fields := make([]string, 0, 8)
|
||||
fields := make([]string, 0, 10)
|
||||
if m.create_time != nil {
|
||||
fields = append(fields, cpuser.FieldCreateTime)
|
||||
}
|
||||
if m.update_time != nil {
|
||||
fields = append(fields, cpuser.FieldUpdateTime)
|
||||
}
|
||||
if m.sysuser != nil {
|
||||
fields = append(fields, cpuser.FieldUserID)
|
||||
}
|
||||
@@ -4246,6 +4650,10 @@ func (m *CpUserMutation) Fields() []string {
|
||||
// schema.
|
||||
func (m *CpUserMutation) Field(name string) (ent.Value, bool) {
|
||||
switch name {
|
||||
case cpuser.FieldCreateTime:
|
||||
return m.CreateTime()
|
||||
case cpuser.FieldUpdateTime:
|
||||
return m.UpdateTime()
|
||||
case cpuser.FieldUserID:
|
||||
return m.UserID()
|
||||
case cpuser.FieldUsername:
|
||||
@@ -4271,6 +4679,10 @@ func (m *CpUserMutation) Field(name string) (ent.Value, bool) {
|
||||
// database failed.
|
||||
func (m *CpUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
|
||||
switch name {
|
||||
case cpuser.FieldCreateTime:
|
||||
return m.OldCreateTime(ctx)
|
||||
case cpuser.FieldUpdateTime:
|
||||
return m.OldUpdateTime(ctx)
|
||||
case cpuser.FieldUserID:
|
||||
return m.OldUserID(ctx)
|
||||
case cpuser.FieldUsername:
|
||||
@@ -4296,6 +4708,20 @@ func (m *CpUserMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
// type.
|
||||
func (m *CpUserMutation) SetField(name string, value ent.Value) error {
|
||||
switch name {
|
||||
case cpuser.FieldCreateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetCreateTime(v)
|
||||
return nil
|
||||
case cpuser.FieldUpdateTime:
|
||||
v, ok := value.(*ent2.CustomTime)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetUpdateTime(v)
|
||||
return nil
|
||||
case cpuser.FieldUserID:
|
||||
v, ok := value.(int64)
|
||||
if !ok {
|
||||
@@ -4425,6 +4851,12 @@ func (m *CpUserMutation) ClearField(name string) error {
|
||||
// It returns an error if the field is not defined in the schema.
|
||||
func (m *CpUserMutation) ResetField(name string) error {
|
||||
switch name {
|
||||
case cpuser.FieldCreateTime:
|
||||
m.ResetCreateTime()
|
||||
return nil
|
||||
case cpuser.FieldUpdateTime:
|
||||
m.ResetUpdateTime()
|
||||
return nil
|
||||
case cpuser.FieldUserID:
|
||||
m.ResetUserID()
|
||||
return nil
|
||||
@@ -6199,6 +6631,7 @@ type SysMenuMutation struct {
|
||||
permission *string
|
||||
route *string
|
||||
component *string
|
||||
keep_alive *bool
|
||||
hidden *bool
|
||||
icon *string
|
||||
_order *uint
|
||||
@@ -6678,6 +7111,42 @@ func (m *SysMenuMutation) ResetComponent() {
|
||||
delete(m.clearedFields, sysmenu.FieldComponent)
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (m *SysMenuMutation) SetKeepAlive(b bool) {
|
||||
m.keep_alive = &b
|
||||
}
|
||||
|
||||
// KeepAlive returns the value of the "keep_alive" field in the mutation.
|
||||
func (m *SysMenuMutation) KeepAlive() (r bool, exists bool) {
|
||||
v := m.keep_alive
|
||||
if v == nil {
|
||||
return
|
||||
}
|
||||
return *v, true
|
||||
}
|
||||
|
||||
// OldKeepAlive returns the old "keep_alive" field's value of the SysMenu entity.
|
||||
// If the SysMenu object wasn't provided to the builder, the object is fetched from the database.
|
||||
// An error is returned if the mutation operation is not UpdateOne, or the database query fails.
|
||||
func (m *SysMenuMutation) OldKeepAlive(ctx context.Context) (v bool, err error) {
|
||||
if !m.op.Is(OpUpdateOne) {
|
||||
return v, errors.New("OldKeepAlive is only allowed on UpdateOne operations")
|
||||
}
|
||||
if m.id == nil || m.oldValue == nil {
|
||||
return v, errors.New("OldKeepAlive requires an ID field in the mutation")
|
||||
}
|
||||
oldValue, err := m.oldValue(ctx)
|
||||
if err != nil {
|
||||
return v, fmt.Errorf("querying old value for OldKeepAlive: %w", err)
|
||||
}
|
||||
return oldValue.KeepAlive, nil
|
||||
}
|
||||
|
||||
// ResetKeepAlive resets all changes to the "keep_alive" field.
|
||||
func (m *SysMenuMutation) ResetKeepAlive() {
|
||||
m.keep_alive = nil
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (m *SysMenuMutation) SetHidden(b bool) {
|
||||
m.hidden = &b
|
||||
@@ -7000,7 +7469,7 @@ func (m *SysMenuMutation) Type() string {
|
||||
// order to get all numeric fields that were incremented/decremented, call
|
||||
// AddedFields().
|
||||
func (m *SysMenuMutation) Fields() []string {
|
||||
fields := make([]string, 0, 12)
|
||||
fields := make([]string, 0, 13)
|
||||
if m.create_time != nil {
|
||||
fields = append(fields, sysmenu.FieldCreateTime)
|
||||
}
|
||||
@@ -7028,6 +7497,9 @@ func (m *SysMenuMutation) Fields() []string {
|
||||
if m.component != nil {
|
||||
fields = append(fields, sysmenu.FieldComponent)
|
||||
}
|
||||
if m.keep_alive != nil {
|
||||
fields = append(fields, sysmenu.FieldKeepAlive)
|
||||
}
|
||||
if m.hidden != nil {
|
||||
fields = append(fields, sysmenu.FieldHidden)
|
||||
}
|
||||
@@ -7063,6 +7535,8 @@ func (m *SysMenuMutation) Field(name string) (ent.Value, bool) {
|
||||
return m.Route()
|
||||
case sysmenu.FieldComponent:
|
||||
return m.Component()
|
||||
case sysmenu.FieldKeepAlive:
|
||||
return m.KeepAlive()
|
||||
case sysmenu.FieldHidden:
|
||||
return m.Hidden()
|
||||
case sysmenu.FieldIcon:
|
||||
@@ -7096,6 +7570,8 @@ func (m *SysMenuMutation) OldField(ctx context.Context, name string) (ent.Value,
|
||||
return m.OldRoute(ctx)
|
||||
case sysmenu.FieldComponent:
|
||||
return m.OldComponent(ctx)
|
||||
case sysmenu.FieldKeepAlive:
|
||||
return m.OldKeepAlive(ctx)
|
||||
case sysmenu.FieldHidden:
|
||||
return m.OldHidden(ctx)
|
||||
case sysmenu.FieldIcon:
|
||||
@@ -7174,6 +7650,13 @@ func (m *SysMenuMutation) SetField(name string, value ent.Value) error {
|
||||
}
|
||||
m.SetComponent(v)
|
||||
return nil
|
||||
case sysmenu.FieldKeepAlive:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
return fmt.Errorf("unexpected type %T for field %s", value, name)
|
||||
}
|
||||
m.SetKeepAlive(v)
|
||||
return nil
|
||||
case sysmenu.FieldHidden:
|
||||
v, ok := value.(bool)
|
||||
if !ok {
|
||||
@@ -7313,6 +7796,9 @@ func (m *SysMenuMutation) ResetField(name string) error {
|
||||
case sysmenu.FieldComponent:
|
||||
m.ResetComponent()
|
||||
return nil
|
||||
case sysmenu.FieldKeepAlive:
|
||||
m.ResetKeepAlive()
|
||||
return nil
|
||||
case sysmenu.FieldHidden:
|
||||
m.ResetHidden()
|
||||
return nil
|
||||
|
||||
@@ -4,7 +4,9 @@ package runtime
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/ent/cpimage"
|
||||
"likedream-goframe/internal/ent/cpschool"
|
||||
"likedream-goframe/internal/ent/cptask"
|
||||
"likedream-goframe/internal/ent/cptasklog"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/schema"
|
||||
"likedream-goframe/internal/ent/sysagent"
|
||||
@@ -14,6 +16,7 @@ import (
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/ent2"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
@@ -36,6 +39,10 @@ func init() {
|
||||
cpimageDescUpdateTime := cpimageMixinFields0[1].Descriptor()
|
||||
// cpimage.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
cpimage.DefaultUpdateTime = cpimageDescUpdateTime.Default.(func() *ent2.CustomTime)
|
||||
// cpimageDescImageID is the schema descriptor for image_id field.
|
||||
cpimageDescImageID := cpimageFields[0].Descriptor()
|
||||
// cpimage.DefaultImageID holds the default value on creation for the image_id field.
|
||||
cpimage.DefaultImageID = cpimageDescImageID.Default.(func() uuid.UUID)
|
||||
// cpimageDescKey is the schema descriptor for key field.
|
||||
cpimageDescKey := cpimageFields[1].Descriptor()
|
||||
// cpimage.KeyValidator is a validator for the "key" field. It is called by the builders before save.
|
||||
@@ -52,8 +59,36 @@ func init() {
|
||||
cpimageDescContentLength := cpimageFields[4].Descriptor()
|
||||
// cpimage.ContentLengthValidator is a validator for the "content_length" field. It is called by the builders before save.
|
||||
cpimage.ContentLengthValidator = cpimageDescContentLength.Validators[0].(func(int64) error)
|
||||
cpschoolMixin := schema.CpSchool{}.Mixin()
|
||||
cpschoolMixinHooks0 := cpschoolMixin[0].Hooks()
|
||||
cpschool.Hooks[0] = cpschoolMixinHooks0[0]
|
||||
cpschoolMixinFields0 := cpschoolMixin[0].Fields()
|
||||
_ = cpschoolMixinFields0
|
||||
cpschoolFields := schema.CpSchool{}.Fields()
|
||||
_ = cpschoolFields
|
||||
// cpschoolDescCreateTime is the schema descriptor for create_time field.
|
||||
cpschoolDescCreateTime := cpschoolMixinFields0[0].Descriptor()
|
||||
// cpschool.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
cpschool.DefaultCreateTime = cpschoolDescCreateTime.Default.(func() *ent2.CustomTime)
|
||||
// cpschoolDescUpdateTime is the schema descriptor for update_time field.
|
||||
cpschoolDescUpdateTime := cpschoolMixinFields0[1].Descriptor()
|
||||
// cpschool.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
cpschool.DefaultUpdateTime = cpschoolDescUpdateTime.Default.(func() *ent2.CustomTime)
|
||||
cptaskMixin := schema.CpTask{}.Mixin()
|
||||
cptaskMixinHooks0 := cptaskMixin[0].Hooks()
|
||||
cptask.Hooks[0] = cptaskMixinHooks0[0]
|
||||
cptaskMixinFields0 := cptaskMixin[0].Fields()
|
||||
_ = cptaskMixinFields0
|
||||
cptaskFields := schema.CpTask{}.Fields()
|
||||
_ = cptaskFields
|
||||
// cptaskDescCreateTime is the schema descriptor for create_time field.
|
||||
cptaskDescCreateTime := cptaskMixinFields0[0].Descriptor()
|
||||
// cptask.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
cptask.DefaultCreateTime = cptaskDescCreateTime.Default.(func() *ent2.CustomTime)
|
||||
// cptaskDescUpdateTime is the schema descriptor for update_time field.
|
||||
cptaskDescUpdateTime := cptaskMixinFields0[1].Descriptor()
|
||||
// cptask.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
cptask.DefaultUpdateTime = cptaskDescUpdateTime.Default.(func() *ent2.CustomTime)
|
||||
// cptaskDescTitle is the schema descriptor for title field.
|
||||
cptaskDescTitle := cptaskFields[3].Descriptor()
|
||||
// cptask.TitleValidator is a validator for the "title" field. It is called by the builders before save.
|
||||
@@ -66,8 +101,36 @@ func init() {
|
||||
cptaskDescSuccessCount := cptaskFields[6].Descriptor()
|
||||
// cptask.DefaultSuccessCount holds the default value on creation for the success_count field.
|
||||
cptask.DefaultSuccessCount = cptaskDescSuccessCount.Default.(int)
|
||||
cptasklogMixin := schema.CpTaskLog{}.Mixin()
|
||||
cptasklogMixinHooks0 := cptasklogMixin[0].Hooks()
|
||||
cptasklog.Hooks[0] = cptasklogMixinHooks0[0]
|
||||
cptasklogMixinFields0 := cptasklogMixin[0].Fields()
|
||||
_ = cptasklogMixinFields0
|
||||
cptasklogFields := schema.CpTaskLog{}.Fields()
|
||||
_ = cptasklogFields
|
||||
// cptasklogDescCreateTime is the schema descriptor for create_time field.
|
||||
cptasklogDescCreateTime := cptasklogMixinFields0[0].Descriptor()
|
||||
// cptasklog.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
cptasklog.DefaultCreateTime = cptasklogDescCreateTime.Default.(func() *ent2.CustomTime)
|
||||
// cptasklogDescUpdateTime is the schema descriptor for update_time field.
|
||||
cptasklogDescUpdateTime := cptasklogMixinFields0[1].Descriptor()
|
||||
// cptasklog.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
cptasklog.DefaultUpdateTime = cptasklogDescUpdateTime.Default.(func() *ent2.CustomTime)
|
||||
cpuserMixin := schema.CpUser{}.Mixin()
|
||||
cpuserMixinHooks0 := cpuserMixin[0].Hooks()
|
||||
cpuser.Hooks[0] = cpuserMixinHooks0[0]
|
||||
cpuserMixinFields0 := cpuserMixin[0].Fields()
|
||||
_ = cpuserMixinFields0
|
||||
cpuserFields := schema.CpUser{}.Fields()
|
||||
_ = cpuserFields
|
||||
// cpuserDescCreateTime is the schema descriptor for create_time field.
|
||||
cpuserDescCreateTime := cpuserMixinFields0[0].Descriptor()
|
||||
// cpuser.DefaultCreateTime holds the default value on creation for the create_time field.
|
||||
cpuser.DefaultCreateTime = cpuserDescCreateTime.Default.(func() *ent2.CustomTime)
|
||||
// cpuserDescUpdateTime is the schema descriptor for update_time field.
|
||||
cpuserDescUpdateTime := cpuserMixinFields0[1].Descriptor()
|
||||
// cpuser.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
cpuser.DefaultUpdateTime = cpuserDescUpdateTime.Default.(func() *ent2.CustomTime)
|
||||
// cpuserDescUsername is the schema descriptor for username field.
|
||||
cpuserDescUsername := cpuserFields[1].Descriptor()
|
||||
// cpuser.UsernameValidator is a validator for the "username" field. It is called by the builders before save.
|
||||
@@ -129,8 +192,12 @@ func init() {
|
||||
sysmenuDescUpdateTime := sysmenuMixinFields0[1].Descriptor()
|
||||
// sysmenu.DefaultUpdateTime holds the default value on creation for the update_time field.
|
||||
sysmenu.DefaultUpdateTime = sysmenuDescUpdateTime.Default.(func() *ent2.CustomTime)
|
||||
// sysmenuDescKeepAlive is the schema descriptor for keep_alive field.
|
||||
sysmenuDescKeepAlive := sysmenuFields[7].Descriptor()
|
||||
// sysmenu.DefaultKeepAlive holds the default value on creation for the keep_alive field.
|
||||
sysmenu.DefaultKeepAlive = sysmenuDescKeepAlive.Default.(bool)
|
||||
// sysmenuDescHidden is the schema descriptor for hidden field.
|
||||
sysmenuDescHidden := sysmenuFields[7].Descriptor()
|
||||
sysmenuDescHidden := sysmenuFields[8].Descriptor()
|
||||
// sysmenu.DefaultHidden holds the default value on creation for the hidden field.
|
||||
sysmenu.DefaultHidden = sysmenuDescHidden.Default.(bool)
|
||||
sysroleMixin := schema.SysRole{}.Mixin()
|
||||
|
||||
@@ -19,7 +19,7 @@ type CpImage struct {
|
||||
// Fields of the CpImage.
|
||||
func (CpImage) Fields() []ent.Field {
|
||||
return []ent.Field{
|
||||
field.UUID("image_id", uuid.New()).Unique().Immutable(),
|
||||
field.UUID("image_id", uuid.New()).Default(uuid.New).Unique().Immutable(),
|
||||
field.String("key").NotEmpty(),
|
||||
field.Int64("user_id").Positive(),
|
||||
field.String("content_type").NotEmpty(),
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/ent/schema/mix"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -26,3 +28,9 @@ func (CpSchool) Edges() []ent.Edge {
|
||||
edge.To("cpusers", CpUser.Type),
|
||||
}
|
||||
}
|
||||
|
||||
func (CpSchool) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mix.MixinTime{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/ent/schema/mix"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
@@ -20,7 +22,7 @@ func (CpTask) Fields() []ent.Field {
|
||||
field.Enum("task_type").Values("collection", "sign", "sleep_check"),
|
||||
field.String("title").NotEmpty(),
|
||||
field.Int("frequency").Default(0),
|
||||
field.Enum("task_status").Values("not_start", "doing", "done", "fail", "pause", "unknown"),
|
||||
field.Enum("task_status").Values("not_start", "doing", "done", "fail", "pause", "queue", "unknown"),
|
||||
field.Int("success_count").Default(0),
|
||||
field.Text("form_data").Optional(),
|
||||
field.Enum("step").Values("form", "execute", "complete"),
|
||||
@@ -36,6 +38,12 @@ func (CpTask) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("cp_user", CpUser.Type).Ref("cptasks").Field("cp_user_id").Unique().Required().Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
edge.From("sys_user", SysUser.Type).Ref("cp_task").Field("user_id").Unique().Required().Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
edge.To("cp_task_logs", CpTaskLog.Type), // 任务拥有的cp任务日志
|
||||
edge.To("cp_task_logs", CpTaskLog.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 任务拥有的cp任务日志
|
||||
}
|
||||
}
|
||||
|
||||
func (CpTask) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mix.MixinTime{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/ent/schema/mix"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
@@ -38,3 +40,9 @@ func (CpTaskLog) Edges() []ent.Edge {
|
||||
Field("cp_user_id").Unique().Required(),
|
||||
}
|
||||
}
|
||||
|
||||
func (CpTaskLog) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mix.MixinTime{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/ent/schema/mix"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema/edge"
|
||||
@@ -30,8 +32,8 @@ func (CpUser) Fields() []ent.Field {
|
||||
func (CpUser) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.To("cptasks", CpTask.Type),
|
||||
edge.From("sysuser", SysUser.Type).Unique().Required().Field("user_id").Ref("cpuser").Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
edge.To("cp_task_logs", CpTaskLog.Type), // 用户拥有的cp任务日志
|
||||
edge.From("sysuser", SysUser.Type).Unique().Required().Field("user_id").Ref("cpuser"),
|
||||
edge.To("cp_task_logs", CpTaskLog.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp任务日志
|
||||
edge.From("school", CpSchool.Type).
|
||||
Ref("cpusers").
|
||||
Field("school_id").
|
||||
@@ -39,3 +41,8 @@ func (CpUser) Edges() []ent.Edge {
|
||||
Required(),
|
||||
}
|
||||
}
|
||||
func (CpUser) Mixin() []ent.Mixin {
|
||||
return []ent.Mixin{
|
||||
mix.MixinTime{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ func (SysAgent) Fields() []ent.Field {
|
||||
// Edges of the SysAgent.
|
||||
func (SysAgent) Edges() []ent.Edge {
|
||||
return []ent.Edge{
|
||||
edge.From("users", SysUser.Type).Ref("agent").Unique(),
|
||||
edge.From("users", SysUser.Type).Ref("agent").Unique().Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"likedream-goframe/internal/ent/schema/mix"
|
||||
|
||||
"entgo.io/ent"
|
||||
"entgo.io/ent/dialect/entsql"
|
||||
"entgo.io/ent/schema"
|
||||
"entgo.io/ent/schema/edge"
|
||||
"entgo.io/ent/schema/field"
|
||||
"likedream-goframe/internal/ent/schema/mix"
|
||||
)
|
||||
|
||||
type SysMenu struct {
|
||||
@@ -23,6 +24,7 @@ func (SysMenu) Fields() []ent.Field {
|
||||
field.String("permission"),
|
||||
field.String("route").Optional(),
|
||||
field.String("component").Optional(),
|
||||
field.Bool("keep_alive").Default(false),
|
||||
field.Bool("hidden").Default(false),
|
||||
field.String("icon").Optional(),
|
||||
field.Uint("order"),
|
||||
|
||||
@@ -46,14 +46,14 @@ func (SysUser) Edges() []ent.Edge {
|
||||
edge.To("children", SysUser.Type).
|
||||
From("parent").
|
||||
Unique(),
|
||||
edge.To("roles", SysRole.Type), // 用户拥有角色
|
||||
edge.To("agent", SysAgent.Type).Unique(), // 用户拥有代理
|
||||
edge.To("images", CpImage.Type), // 用户拥有的图片
|
||||
edge.To("cpuser", CpUser.Type), // 用户拥有的cp用户
|
||||
edge.To("cp_task", CpTask.Type),
|
||||
edge.To("cp_task_logs", CpTaskLog.Type), // 用户拥有的cp任务日志
|
||||
edge.To("created_cards", SysCard.Type), // 用户创建的卡
|
||||
edge.To("used_cards", SysCard.Type), // 用户使用的卡
|
||||
edge.To("roles", SysRole.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有角色
|
||||
edge.To("agent", SysAgent.Type).Unique().Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有代理
|
||||
edge.To("images", CpImage.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的图片
|
||||
edge.To("cpuser", CpUser.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp用户
|
||||
edge.To("cp_task", CpTask.Type).Annotations(entsql.OnDelete(entsql.Cascade)),
|
||||
edge.To("cp_task_logs", CpTaskLog.Type).Annotations(entsql.OnDelete(entsql.Cascade)), // 用户拥有的cp任务日志
|
||||
edge.To("created_cards", SysCard.Type), // 用户创建的卡
|
||||
edge.To("used_cards", SysCard.Type), // 用户使用的卡
|
||||
edge.To("cashback_cards", SysCard.Type),
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -35,6 +35,8 @@ type SysMenu struct {
|
||||
Route string `json:"route,omitempty"`
|
||||
// Component holds the value of the "component" field.
|
||||
Component string `json:"component,omitempty"`
|
||||
// KeepAlive holds the value of the "keep_alive" field.
|
||||
KeepAlive bool `json:"keep_alive,omitempty"`
|
||||
// Hidden holds the value of the "hidden" field.
|
||||
Hidden bool `json:"hidden,omitempty"`
|
||||
// Icon holds the value of the "icon" field.
|
||||
@@ -99,7 +101,7 @@ func (*SysMenu) scanValues(columns []string) ([]any, error) {
|
||||
switch columns[i] {
|
||||
case sysmenu.FieldCreateTime, sysmenu.FieldUpdateTime:
|
||||
values[i] = new(ent2.CustomTime)
|
||||
case sysmenu.FieldHidden:
|
||||
case sysmenu.FieldKeepAlive, sysmenu.FieldHidden:
|
||||
values[i] = new(sql.NullBool)
|
||||
case sysmenu.FieldID, sysmenu.FieldOrder:
|
||||
values[i] = new(sql.NullInt64)
|
||||
@@ -182,6 +184,12 @@ func (_m *SysMenu) assignValues(columns []string, values []any) error {
|
||||
} else if value.Valid {
|
||||
_m.Component = value.String
|
||||
}
|
||||
case sysmenu.FieldKeepAlive:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field keep_alive", values[i])
|
||||
} else if value.Valid {
|
||||
_m.KeepAlive = value.Bool
|
||||
}
|
||||
case sysmenu.FieldHidden:
|
||||
if value, ok := values[i].(*sql.NullBool); !ok {
|
||||
return fmt.Errorf("unexpected type %T for field hidden", values[i])
|
||||
@@ -285,6 +293,9 @@ func (_m *SysMenu) String() string {
|
||||
builder.WriteString("component=")
|
||||
builder.WriteString(_m.Component)
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("keep_alive=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.KeepAlive))
|
||||
builder.WriteString(", ")
|
||||
builder.WriteString("hidden=")
|
||||
builder.WriteString(fmt.Sprintf("%v", _m.Hidden))
|
||||
builder.WriteString(", ")
|
||||
|
||||
@@ -34,6 +34,8 @@ const (
|
||||
FieldRoute = "route"
|
||||
// FieldComponent holds the string denoting the component field in the database.
|
||||
FieldComponent = "component"
|
||||
// FieldKeepAlive holds the string denoting the keep_alive field in the database.
|
||||
FieldKeepAlive = "keep_alive"
|
||||
// FieldHidden holds the string denoting the hidden field in the database.
|
||||
FieldHidden = "hidden"
|
||||
// FieldIcon holds the string denoting the icon field in the database.
|
||||
@@ -75,6 +77,7 @@ var Columns = []string{
|
||||
FieldPermission,
|
||||
FieldRoute,
|
||||
FieldComponent,
|
||||
FieldKeepAlive,
|
||||
FieldHidden,
|
||||
FieldIcon,
|
||||
FieldOrder,
|
||||
@@ -118,6 +121,8 @@ var (
|
||||
DefaultCreateTime func() *ent2.CustomTime
|
||||
// DefaultUpdateTime holds the default value on creation for the "update_time" field.
|
||||
DefaultUpdateTime func() *ent2.CustomTime
|
||||
// DefaultKeepAlive holds the default value on creation for the "keep_alive" field.
|
||||
DefaultKeepAlive bool
|
||||
// DefaultHidden holds the default value on creation for the "hidden" field.
|
||||
DefaultHidden bool
|
||||
)
|
||||
@@ -201,6 +206,11 @@ func ByComponent(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldComponent, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByKeepAlive orders the results by the keep_alive field.
|
||||
func ByKeepAlive(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldKeepAlive, opts...).ToFunc()
|
||||
}
|
||||
|
||||
// ByHidden orders the results by the hidden field.
|
||||
func ByHidden(opts ...sql.OrderTermOption) OrderOption {
|
||||
return sql.OrderByField(FieldHidden, opts...).ToFunc()
|
||||
|
||||
@@ -91,6 +91,11 @@ func Component(v string) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldEQ(FieldComponent, v))
|
||||
}
|
||||
|
||||
// KeepAlive applies equality check predicate on the "keep_alive" field. It's identical to KeepAliveEQ.
|
||||
func KeepAlive(v bool) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldEQ(FieldKeepAlive, v))
|
||||
}
|
||||
|
||||
// Hidden applies equality check predicate on the "hidden" field. It's identical to HiddenEQ.
|
||||
func Hidden(v bool) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldEQ(FieldHidden, v))
|
||||
@@ -686,6 +691,16 @@ func ComponentContainsFold(v string) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldContainsFold(FieldComponent, v))
|
||||
}
|
||||
|
||||
// KeepAliveEQ applies the EQ predicate on the "keep_alive" field.
|
||||
func KeepAliveEQ(v bool) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldEQ(FieldKeepAlive, v))
|
||||
}
|
||||
|
||||
// KeepAliveNEQ applies the NEQ predicate on the "keep_alive" field.
|
||||
func KeepAliveNEQ(v bool) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldNEQ(FieldKeepAlive, v))
|
||||
}
|
||||
|
||||
// HiddenEQ applies the EQ predicate on the "hidden" field.
|
||||
func HiddenEQ(v bool) predicate.SysMenu {
|
||||
return predicate.SysMenu(sql.FieldEQ(FieldHidden, v))
|
||||
|
||||
@@ -101,6 +101,20 @@ func (_c *SysMenuCreate) SetNillableComponent(v *string) *SysMenuCreate {
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (_c *SysMenuCreate) SetKeepAlive(v bool) *SysMenuCreate {
|
||||
_c.mutation.SetKeepAlive(v)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetNillableKeepAlive sets the "keep_alive" field if the given value is not nil.
|
||||
func (_c *SysMenuCreate) SetNillableKeepAlive(v *bool) *SysMenuCreate {
|
||||
if v != nil {
|
||||
_c.SetKeepAlive(*v)
|
||||
}
|
||||
return _c
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (_c *SysMenuCreate) SetHidden(v bool) *SysMenuCreate {
|
||||
_c.mutation.SetHidden(v)
|
||||
@@ -235,6 +249,10 @@ func (_c *SysMenuCreate) defaults() error {
|
||||
v := sysmenu.DefaultUpdateTime()
|
||||
_c.mutation.SetUpdateTime(v)
|
||||
}
|
||||
if _, ok := _c.mutation.KeepAlive(); !ok {
|
||||
v := sysmenu.DefaultKeepAlive
|
||||
_c.mutation.SetKeepAlive(v)
|
||||
}
|
||||
if _, ok := _c.mutation.Hidden(); !ok {
|
||||
v := sysmenu.DefaultHidden
|
||||
_c.mutation.SetHidden(v)
|
||||
@@ -267,6 +285,9 @@ func (_c *SysMenuCreate) check() error {
|
||||
if _, ok := _c.mutation.Permission(); !ok {
|
||||
return &ValidationError{Name: "permission", err: errors.New(`ent: missing required field "SysMenu.permission"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.KeepAlive(); !ok {
|
||||
return &ValidationError{Name: "keep_alive", err: errors.New(`ent: missing required field "SysMenu.keep_alive"`)}
|
||||
}
|
||||
if _, ok := _c.mutation.Hidden(); !ok {
|
||||
return &ValidationError{Name: "hidden", err: errors.New(`ent: missing required field "SysMenu.hidden"`)}
|
||||
}
|
||||
@@ -337,6 +358,10 @@ func (_c *SysMenuCreate) createSpec() (*SysMenu, *sqlgraph.CreateSpec) {
|
||||
_spec.SetField(sysmenu.FieldComponent, field.TypeString, value)
|
||||
_node.Component = value
|
||||
}
|
||||
if value, ok := _c.mutation.KeepAlive(); ok {
|
||||
_spec.SetField(sysmenu.FieldKeepAlive, field.TypeBool, value)
|
||||
_node.KeepAlive = value
|
||||
}
|
||||
if value, ok := _c.mutation.Hidden(); ok {
|
||||
_spec.SetField(sysmenu.FieldHidden, field.TypeBool, value)
|
||||
_node.Hidden = value
|
||||
@@ -567,6 +592,18 @@ func (u *SysMenuUpsert) ClearComponent() *SysMenuUpsert {
|
||||
return u
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (u *SysMenuUpsert) SetKeepAlive(v bool) *SysMenuUpsert {
|
||||
u.Set(sysmenu.FieldKeepAlive, v)
|
||||
return u
|
||||
}
|
||||
|
||||
// UpdateKeepAlive sets the "keep_alive" field to the value that was provided on create.
|
||||
func (u *SysMenuUpsert) UpdateKeepAlive() *SysMenuUpsert {
|
||||
u.SetExcluded(sysmenu.FieldKeepAlive)
|
||||
return u
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (u *SysMenuUpsert) SetHidden(v bool) *SysMenuUpsert {
|
||||
u.Set(sysmenu.FieldHidden, v)
|
||||
@@ -793,6 +830,20 @@ func (u *SysMenuUpsertOne) ClearComponent() *SysMenuUpsertOne {
|
||||
})
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (u *SysMenuUpsertOne) SetKeepAlive(v bool) *SysMenuUpsertOne {
|
||||
return u.Update(func(s *SysMenuUpsert) {
|
||||
s.SetKeepAlive(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateKeepAlive sets the "keep_alive" field to the value that was provided on create.
|
||||
func (u *SysMenuUpsertOne) UpdateKeepAlive() *SysMenuUpsertOne {
|
||||
return u.Update(func(s *SysMenuUpsert) {
|
||||
s.UpdateKeepAlive()
|
||||
})
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (u *SysMenuUpsertOne) SetHidden(v bool) *SysMenuUpsertOne {
|
||||
return u.Update(func(s *SysMenuUpsert) {
|
||||
@@ -1193,6 +1244,20 @@ func (u *SysMenuUpsertBulk) ClearComponent() *SysMenuUpsertBulk {
|
||||
})
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (u *SysMenuUpsertBulk) SetKeepAlive(v bool) *SysMenuUpsertBulk {
|
||||
return u.Update(func(s *SysMenuUpsert) {
|
||||
s.SetKeepAlive(v)
|
||||
})
|
||||
}
|
||||
|
||||
// UpdateKeepAlive sets the "keep_alive" field to the value that was provided on create.
|
||||
func (u *SysMenuUpsertBulk) UpdateKeepAlive() *SysMenuUpsertBulk {
|
||||
return u.Update(func(s *SysMenuUpsert) {
|
||||
s.UpdateKeepAlive()
|
||||
})
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (u *SysMenuUpsertBulk) SetHidden(v bool) *SysMenuUpsertBulk {
|
||||
return u.Update(func(s *SysMenuUpsert) {
|
||||
|
||||
@@ -153,6 +153,20 @@ func (_u *SysMenuUpdate) ClearComponent() *SysMenuUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (_u *SysMenuUpdate) SetKeepAlive(v bool) *SysMenuUpdate {
|
||||
_u.mutation.SetKeepAlive(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableKeepAlive sets the "keep_alive" field if the given value is not nil.
|
||||
func (_u *SysMenuUpdate) SetNillableKeepAlive(v *bool) *SysMenuUpdate {
|
||||
if v != nil {
|
||||
_u.SetKeepAlive(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (_u *SysMenuUpdate) SetHidden(v bool) *SysMenuUpdate {
|
||||
_u.mutation.SetHidden(v)
|
||||
@@ -398,6 +412,9 @@ func (_u *SysMenuUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if _u.mutation.ComponentCleared() {
|
||||
_spec.ClearField(sysmenu.FieldComponent, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.KeepAlive(); ok {
|
||||
_spec.SetField(sysmenu.FieldKeepAlive, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Hidden(); ok {
|
||||
_spec.SetField(sysmenu.FieldHidden, field.TypeBool, value)
|
||||
}
|
||||
@@ -686,6 +703,20 @@ func (_u *SysMenuUpdateOne) ClearComponent() *SysMenuUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetKeepAlive sets the "keep_alive" field.
|
||||
func (_u *SysMenuUpdateOne) SetKeepAlive(v bool) *SysMenuUpdateOne {
|
||||
_u.mutation.SetKeepAlive(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetNillableKeepAlive sets the "keep_alive" field if the given value is not nil.
|
||||
func (_u *SysMenuUpdateOne) SetNillableKeepAlive(v *bool) *SysMenuUpdateOne {
|
||||
if v != nil {
|
||||
_u.SetKeepAlive(*v)
|
||||
}
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetHidden sets the "hidden" field.
|
||||
func (_u *SysMenuUpdateOne) SetHidden(v bool) *SysMenuUpdateOne {
|
||||
_u.mutation.SetHidden(v)
|
||||
@@ -961,6 +992,9 @@ func (_u *SysMenuUpdateOne) sqlSave(ctx context.Context) (_node *SysMenu, err er
|
||||
if _u.mutation.ComponentCleared() {
|
||||
_spec.ClearField(sysmenu.FieldComponent, field.TypeString)
|
||||
}
|
||||
if value, ok := _u.mutation.KeepAlive(); ok {
|
||||
_spec.SetField(sysmenu.FieldKeepAlive, field.TypeBool, value)
|
||||
}
|
||||
if value, ok := _u.mutation.Hidden(); ok {
|
||||
_spec.SetField(sysmenu.FieldHidden, field.TypeBool, value)
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"likedream-goframe/internal/cst"
|
||||
"likedream-goframe/internal/utils"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/redis/go-redis/v9"
|
||||
@@ -25,6 +26,9 @@ func Init(ctx context.Context) {
|
||||
redisUrl := g.Cfg().MustGetWithEnv(ctx, cst.ConfigRedisUrl).String()
|
||||
|
||||
redisOpts, e := redis.ParseURL(redisUrl)
|
||||
redisOpts.DialTimeout = 30 * time.Second
|
||||
redisOpts.ReadTimeout = 30 * time.Second
|
||||
redisOpts.WriteTimeout = 30 * time.Second
|
||||
utils.OkOrPanic(e, oops.WithContext(ctx).
|
||||
With("redisUrl", redisUrl).
|
||||
Wrap)
|
||||
|
||||
@@ -6,14 +6,15 @@ import (
|
||||
"encoding/gob"
|
||||
"likedream-goframe/internal/application/cpdaily/login"
|
||||
"likedream-goframe/internal/application/cpdaily/school"
|
||||
cpdailyTask "likedream-goframe/internal/application/cpdaily/task"
|
||||
task2 "likedream-goframe/internal/application/cpdaily/task"
|
||||
"likedream-goframe/internal/application/cpdaily/task/formtype"
|
||||
errors2 "likedream-goframe/internal/common/errors"
|
||||
"likedream-goframe/internal/db"
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/ent/cptask"
|
||||
"likedream-goframe/internal/ent/cpuser"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/errors"
|
||||
"likedream-goframe/internal/framework/logger"
|
||||
"likedream-goframe/internal/framework/model/email"
|
||||
email2 "likedream-goframe/internal/service/email"
|
||||
"likedream-goframe/internal/utils"
|
||||
@@ -23,6 +24,7 @@ import (
|
||||
"github.com/google/uuid"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/samber/oops"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
var emailService = email2.NewV1()
|
||||
@@ -40,12 +42,9 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
|
||||
// 查询指定的任务和关联今日校园用户
|
||||
targetTask, e := db.Global.CpTask.Query().Where(cptask.ID(taskPayload.CpTaskID)).
|
||||
WithCpUser(func(cuq *ent.CpUserQuery) {
|
||||
cuq.Select(cpuser.FieldSchoolID, cpuser.FieldEmail).
|
||||
WithSysuser(func(suq *ent.SysUserQuery) {
|
||||
suq.Select(sysuser.FieldID, sysuser.FieldEmail)
|
||||
})
|
||||
}).First(ctx)
|
||||
WithCpUser().
|
||||
WithSysUser().
|
||||
First(ctx)
|
||||
if ent.IsNotFound(e) {
|
||||
utils.OkOrPanic(oops.WithContext(ctx).With("task_id", taskPayload.CpTaskID).In("CpdailyTask.ProcessTask").Wrap(e))
|
||||
}
|
||||
@@ -61,6 +60,8 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
|
||||
if e1, ok := utils.Of[*errors.BusinessError](err); ok {
|
||||
errorMessage = e1.Message()
|
||||
} else if e1, ok := utils.Of[*errors2.BusinessError](err); ok {
|
||||
errorMessage = e1.Message
|
||||
} else {
|
||||
errorMessage = "未知的错误导致任务执行失败"
|
||||
}
|
||||
@@ -68,11 +69,11 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
e = db.Global.CpTaskLog.Create().
|
||||
SetCpTaskID(taskPayload.CpTaskID).
|
||||
SetCpUserID(targetTask.Edges.CpUser.ID).
|
||||
SetSystemUserID(targetTask.Edges.CpUser.Edges.Sysuser.ID).
|
||||
SetSystemUserID(targetTask.Edges.SysUser.ID).
|
||||
SetIsSuccess(false).
|
||||
SetRealName("").
|
||||
SetErrorMessage(errorMessage).
|
||||
Exec(ctx)
|
||||
Exec(context.Background())
|
||||
|
||||
utils.LogError(ctx, "创建任务日志失败", oops.With("task_id", taskPayload.CpTaskID).Wrap(e))
|
||||
|
||||
@@ -89,33 +90,16 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
|
||||
// 查询学校详情
|
||||
schoolDetail := school.GetSchoolDetail(ctx, targetTask.Edges.CpUser.SchoolID)
|
||||
|
||||
// 执行登录
|
||||
var loginClient login.CpdailyLogin
|
||||
|
||||
if schoolDetail.IsIap() {
|
||||
loginClient = login.NewIap(ctx)
|
||||
} else {
|
||||
loginClient = login.NewCas(ctx)
|
||||
restyClient := login.GetClient(ctx, targetTask.Edges.CpUser.Cookie)
|
||||
if !login.CookieEnabled(ctx, schoolDetail.WecloudUrl, restyClient) {
|
||||
loginExecutor := login.GetCpdailyLoginBySchoolInfo(ctx, &schoolDetail)
|
||||
loginExecutor.Login(ctx, &schoolDetail, targetTask.Edges.CpUser.Username, targetTask.Edges.CpUser.Password)
|
||||
cookie := loginExecutor.GetCookieString()
|
||||
db.Global.CpUser.UpdateOne(targetTask.Edges.CpUser).SetCookie(cookie).ExecX(ctx)
|
||||
restyClient = login.GetClient(ctx, cookie)
|
||||
}
|
||||
|
||||
loginClient.Login(ctx, &schoolDetail, targetTask.Edges.CpUser.Username, targetTask.Edges.CpUser.Username)
|
||||
|
||||
restyClient := loginClient.GetClient()
|
||||
|
||||
// 获取任务执行handler
|
||||
var taskExecutor cpdailyTask.CpdailyTask
|
||||
|
||||
switch targetTask.TaskType {
|
||||
case cptask.TaskTypeCollection:
|
||||
taskExecutor = cpdailyTask.NewCollectionTask(restyClient, schoolDetail.WecloudUrl)
|
||||
case cptask.TaskTypeSign:
|
||||
taskExecutor = cpdailyTask.NewAutoSignTask(restyClient, schoolDetail.WecloudUrl)
|
||||
case cptask.TaskTypeSleepCheck:
|
||||
taskExecutor = cpdailyTask.NewSleepCheckTask(restyClient, schoolDetail.WecloudUrl)
|
||||
default:
|
||||
utils.OkOrPanic(oops.WithContext(ctx).With("task_id", taskPayload.CpTaskID).In("CpdailyTask.ProcessTask").Errorf("unknown task type: %s", targetTask.TaskType))
|
||||
}
|
||||
taskExecutor := task2.GetCpdailyTaskService(ctx, targetTask.TaskType, targetTask.Edges.CpUser.Cookie, targetTask.Edges.CpUser.SchoolID)
|
||||
|
||||
cpdailyRealTask := taskExecutor.QueryFormByTitle(ctx, targetTask.Title)
|
||||
|
||||
@@ -148,16 +132,17 @@ func (c *CpdailyTaskHandler) ProcessTask(ctx context.Context, task *asynq.Task)
|
||||
}
|
||||
|
||||
submitForm := taskExecutor.FillCustomForm(ctx, cpdailyRealTask, customFormItems, deviceID, targetTask.Edges.CpUser.Username)
|
||||
|
||||
taskExecutor.Submit(ctx, submitForm, targetTask.Edges.CpUser.Username, deviceID)
|
||||
|
||||
db.Global.CpTask.UpdateOneID(taskPayload.CpTaskID).SetTaskStatus(cptask.TaskStatusDone).AddSuccessCount(1).ExecX(ctx)
|
||||
// 任务完成后重置状态为 TaskStatusDone,更新下次执行时间 以便下次继续执行
|
||||
executeTime := utils.GetCpdailyNextExecuteTime(targetTask)
|
||||
db.Global.CpTask.UpdateOneID(taskPayload.CpTaskID).SetTaskStatus(cptask.TaskStatusDone).SetNextExecuteTime(executeTime).AddSuccessCount(1).ExecX(ctx)
|
||||
|
||||
// 创建日志
|
||||
db.Global.CpTaskLog.Create().
|
||||
SetCpTaskID(targetTask.ID).
|
||||
SetCpUserID(targetTask.Edges.CpUser.ID).
|
||||
SetSystemUserID(targetTask.Edges.CpUser.Edges.Sysuser.ID).
|
||||
SetSystemUserID(targetTask.Edges.SysUser.ID).
|
||||
SetIsSuccess(true).
|
||||
SetRealName(realTitle).
|
||||
ExecX(ctx)
|
||||
@@ -207,5 +192,11 @@ func (c *CpdailyTaskHandler) sendTaskNotificationEmail(ctx context.Context, task
|
||||
return // 没有邮箱地址,不发送邮件
|
||||
}
|
||||
|
||||
emailService.SendTaskNotificationEmail(ctx, emailAddr, taskName, status, details)
|
||||
// 发送邮件,捕获可能的错误并忽略,避免影响任务执行主流程
|
||||
e := utils.Catch(func() {
|
||||
emailService.SendTaskNotificationEmail(ctx, emailAddr, taskName, status, details)
|
||||
})
|
||||
if e != nil {
|
||||
logger.Logger.Warn("发送任务通知邮件失败,已忽略", zap.Error(e))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ func (ts *TaskScanner) scanCpdailyTask() {
|
||||
minExecuteTime := currentTime.Add(-30 * time.Minute).Unix()
|
||||
|
||||
allTasks := db.Global.CpTask.Query().
|
||||
Where(cptask.NextExecuteTimeLTE(currentTime.Unix()), cptask.NextExecuteTimeNotNil(), cptask.NextExecuteTimeGT(0)).
|
||||
Select(cptask.FieldID, cptask.FieldExecuteHour, cptask.FieldExecuteMinute).
|
||||
Where(cptask.NextExecuteTimeLTE(currentTime.Unix()), cptask.NextExecuteTimeNotNil(), cptask.NextExecuteTimeGT(0), cptask.StepEQ(cptask.StepComplete), cptask.TaskStatusEQ(cptask.TaskStatusNotStart)).
|
||||
Select(cptask.FieldID, cptask.FieldExecuteHour, cptask.FieldExecuteMinute, cptask.FieldNextExecuteTime).
|
||||
AllX(ts.ctx)
|
||||
|
||||
var failedIDS []int64
|
||||
@@ -117,15 +117,20 @@ func (ts *TaskScanner) scanCpdailyTask() {
|
||||
e = utils.Catch(func() {
|
||||
queue.AddTask(ts.ctx, asynq.NewTask(cst.TaskCpdaily, payloadWriter.Bytes()),
|
||||
asynq.TaskID(fmt.Sprintf("cpdaily:task:%d", task.ID)),
|
||||
asynq.MaxRetry(5),
|
||||
asynq.Unique(10*time.Minute),
|
||||
asynq.MaxRetry(3),
|
||||
asynq.Unique(10*time.Second),
|
||||
asynq.ProcessAt(execTime),
|
||||
asynq.Deadline(execTime.Add(12*time.Minute)),
|
||||
asynq.Queue(cst.TaskQueueCpdaily),
|
||||
)
|
||||
// 更新未开始的任务状态为队列中
|
||||
db.Global.CpTask.Update().Where(cptask.ID(task.ID), cptask.TaskStatusEQ(cptask.TaskStatusNotStart)).SetTaskStatus(cptask.TaskStatusQueue).Exec(ts.ctx)
|
||||
})
|
||||
if e != nil {
|
||||
if errors.Is(e, asynq.ErrDuplicateTask) {
|
||||
// 任务已在队列中,不更新下次执行时间,等任务执行完成后再处理
|
||||
g.Log().Debugf(ts.ctx, "任务ID %d 已在队列中,跳过本次扫描", task.ID)
|
||||
failedIDS = append(failedIDS, task.ID)
|
||||
continue
|
||||
} else if errors.Is(e, context.Canceled) {
|
||||
return
|
||||
@@ -150,8 +155,9 @@ func (ts *TaskScanner) scanCpdailyTask() {
|
||||
}
|
||||
|
||||
// 重置30分钟之前的任务到下次执行时间
|
||||
// 只处理已完成配置且状态为未开始的任务,避免重复处理正在执行或已失败的任务
|
||||
expiredTasks := db.Global.CpTask.Query().
|
||||
Where(cptask.NextExecuteTimeLT(minExecuteTime), cptask.NextExecuteTimeNotNil()).
|
||||
Where(cptask.NextExecuteTimeLT(minExecuteTime), cptask.NextExecuteTimeNotNil(), cptask.NextExecuteTimeGT(0), cptask.StepEQ(cptask.StepComplete), cptask.TaskStatusEQ(cptask.TaskStatusNotStart)).
|
||||
Select(cptask.FieldID, cptask.FieldExecuteHour, cptask.FieldExecuteMinute).
|
||||
AllX(ts.ctx)
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"github.com/gogf/gf/v2/errors/gcode"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/util/gvalid"
|
||||
)
|
||||
|
||||
func ExceptionHandler(r *ghttp.Request) {
|
||||
@@ -50,6 +51,15 @@ func ExceptionHandler(r *ghttp.Request) {
|
||||
code = tmpErr.Code()
|
||||
} else if code == gcode.CodeNil {
|
||||
code = errors.CodeInternal.Code()
|
||||
} else if code == gcode.CodeValidationFailed {
|
||||
// 请求参数校验失败返回第一个错误信息
|
||||
if validationErr, ok := err.(gvalid.Error); ok {
|
||||
if firstErr := validationErr.FirstError(); firstErr != nil {
|
||||
c := errors.CodeParam
|
||||
c.SetMessage(firstErr.Error())
|
||||
code = c.Code()
|
||||
}
|
||||
}
|
||||
}
|
||||
r.Response.ClearBuffer()
|
||||
r.Response.WriteHeader(200)
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/ent/sysrole"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/service/balance"
|
||||
"likedream-goframe/internal/utils"
|
||||
|
||||
"github.com/samber/oops"
|
||||
@@ -21,8 +22,10 @@ func NewV1() *AgentServiceV1 {
|
||||
}
|
||||
|
||||
func (s *AgentServiceV1) List(ctx context.Context, req *v1.AgentListReq) *utils.Response[[]v1.AgentListRes] {
|
||||
query := db.Global.SysUser.Query()
|
||||
query.Where(sysuser.HasParentWith(sysuser.IDEQ(utils.GetUserInfoFromCtx(ctx).ID)))
|
||||
query := db.Global.SysUser.Query().Order(ent.Desc(sysuser.FieldCreateTime))
|
||||
if !utils.IsAdminFromCtx(ctx) {
|
||||
query.Where(sysuser.HasParentWith(sysuser.IDEQ(utils.GetUserInfoFromCtx(ctx).ID)))
|
||||
}
|
||||
if req.Email != "" {
|
||||
query.Where(sysuser.EmailContains(req.Email))
|
||||
}
|
||||
@@ -57,107 +60,40 @@ func (s *AgentServiceV1) List(ctx context.Context, req *v1.AgentListReq) *utils.
|
||||
return utils.SuccessWithTotal[[]v1.AgentListRes](res, total)
|
||||
}
|
||||
|
||||
func (s *AgentServiceV1) Add(ctx context.Context, req *v1.AgentAddReq) *utils.Response[any] {
|
||||
// 参数校验
|
||||
currentUser := utils.GetUserInfoFromCtx(ctx)
|
||||
agent := currentUser.QueryAgent().OnlyX(ctx)
|
||||
if agent.Level >= req.Level {
|
||||
return utils.FailParam("下级代理级别不能高于当前代理级别")
|
||||
}
|
||||
if agent.Rate.Compare(req.Rate) <= 0 {
|
||||
return utils.FailParam("下级代理费率比例不能低于当前代理比例")
|
||||
}
|
||||
tx, err := db.Global.Tx(ctx)
|
||||
utils.OkOrPanic(err, func(err error) error {
|
||||
return oops.
|
||||
WithContext(ctx).
|
||||
With("创建事务失败").
|
||||
Wrap(err)
|
||||
})
|
||||
defer tx.Rollback()
|
||||
user := tx.SysUser.Query().Where(sysuser.IDEQ(currentUser.ID)).OnlyX(ctx)
|
||||
user.Balance = utils.CalculateBalance(user.Balance, req.Rate, req.Balance, req.Rate)
|
||||
if user.Balance.LessThan(decimal.NewFromInt(0)) {
|
||||
return utils.FailParam("余额不足")
|
||||
}
|
||||
// 扣除余额
|
||||
_, err = tx.SysUser.UpdateOne(user).SetBalance(user.Balance).Save(ctx)
|
||||
utils.OkOrPanic(err, func(err error) error {
|
||||
return oops.
|
||||
WithContext(ctx).
|
||||
With("更新用户余额失败").
|
||||
Wrap(err)
|
||||
})
|
||||
// 创建用户
|
||||
tmp := tx.SysUser.Create().
|
||||
SetUsername(req.Username).
|
||||
SetPassword(utils.PasswordBcryptHash(req.Password)).
|
||||
SetEmail(req.Email).
|
||||
SetParent(user)
|
||||
save := tmp.SaveX(ctx)
|
||||
// 关联角色
|
||||
role := tx.SysRole.Query().Where(sysrole.NameEQ(cst.KeyRoleAgent)).AllX(ctx)
|
||||
tx.SysUser.UpdateOne(save).AddRoles(role...).ExecX(ctx)
|
||||
// 创建代理
|
||||
tx.SysAgent.Create().
|
||||
SetLevel(req.Level).
|
||||
SetRate(req.Rate).
|
||||
SaveX(ctx)
|
||||
|
||||
err = tx.Commit()
|
||||
return utils.SuccessWithMsg("")
|
||||
}
|
||||
|
||||
func (s *AgentServiceV1) Ban(ctx context.Context, req *v1.AgentBanReq) *utils.Response[any] {
|
||||
// 参数校验
|
||||
currentUser := utils.GetUserInfoFromCtx(ctx)
|
||||
user := db.Global.SysUser.Query().Where(sysuser.IDEQ(req.ID)).OnlyX(ctx)
|
||||
// 判断是否是自己的下级代理
|
||||
parent := user.QueryParent().OnlyX(ctx)
|
||||
if parent.ID != currentUser.ID {
|
||||
return utils.FailParam("非法的下级代理参数")
|
||||
if !utils.IsAdminFromCtx(ctx) {
|
||||
// 参数校验
|
||||
currentUser := utils.GetUserInfoFromCtx(ctx)
|
||||
// 判断是否是自己的下级代理
|
||||
parent := user.QueryParent().OnlyX(ctx)
|
||||
if parent.ID != currentUser.ID {
|
||||
return utils.FailParam("非法的下级代理参数")
|
||||
}
|
||||
}
|
||||
db.Global.SysUser.UpdateOne(user).SetBlock(req.Block).ExecX(ctx)
|
||||
return utils.SuccessWithMsg("操作成功")
|
||||
}
|
||||
|
||||
func (s *AgentServiceV1) Recharge(ctx context.Context, req *v1.AgentRechargeReq) *utils.Response[any] {
|
||||
// 参数校验
|
||||
currentUser := db.Global.SysUser.Query().Where(sysuser.ID(utils.GetUserInfoFromCtx(ctx).ID)).WithAgent().WithRoles().OnlyX(ctx)
|
||||
user := db.Global.SysUser.Query().Where(sysuser.IDEQ(req.ID)).WithAgent().OnlyX(ctx)
|
||||
// 判断是否是自己的下级代理
|
||||
parent := user.QueryParent().WithAgent().FirstX(ctx)
|
||||
if parent == nil || parent.ID != currentUser.ID {
|
||||
return utils.FailParam("非法的下级代理参数")
|
||||
}
|
||||
tx, err := db.Global.Tx(ctx)
|
||||
utils.OkOrPanic(err, func(err error) error {
|
||||
return oops.
|
||||
WithContext(ctx).
|
||||
With("创建事务失败").
|
||||
Wrap(err)
|
||||
})
|
||||
if !utils.HasRole(currentUser.Edges.Roles, cst.KeyRoleAdmin) {
|
||||
parent.Balance = utils.CalculateBalance(parent.Balance, parent.Edges.Agent.Rate, req.Amount, user.Edges.Agent.Rate)
|
||||
if parent.Balance.Compare(decimal.NewFromInt(0)) < 0 {
|
||||
return utils.FailParam("余额不足")
|
||||
|
||||
if !utils.IsAdminFromCtx(ctx) {
|
||||
currentUser := utils.GetUserInfoFromCtx(ctx)
|
||||
// 参数校验
|
||||
if user.Edges.Agent == nil {
|
||||
return utils.FailParam("用户不是代理")
|
||||
}
|
||||
// 判断是否是自己的下级代理
|
||||
parent := user.QueryParent().WithAgent().FirstX(ctx)
|
||||
if parent == nil || parent.ID != currentUser.ID {
|
||||
return utils.FailParam("非法的下级代理参数")
|
||||
}
|
||||
needBalance := utils.NeedBalance(parent.Edges.Agent.Rate, req.Amount, user.Edges.Agent.Rate)
|
||||
balance.BalanceService.ChangeUserBalance(ctx, parent.ID, needBalance.Neg())
|
||||
|
||||
}
|
||||
tx.SysUser.UpdateOne(parent).SetBalance(parent.Balance).SaveX(ctx)
|
||||
utils.OkOrPanic(err, func(err error) error {
|
||||
return oops.
|
||||
WithContext(ctx).
|
||||
With("更新用户余额失败").
|
||||
Wrap(err)
|
||||
})
|
||||
tx.SysUser.UpdateOne(user).SetBalance(user.Balance.Add(req.Amount)).SaveX(ctx)
|
||||
utils.OkOrPanic(err, func(err error) error {
|
||||
return oops.
|
||||
WithContext(ctx).
|
||||
With("更新用户余额失败").
|
||||
Wrap(err)
|
||||
})
|
||||
err = tx.Commit()
|
||||
balance.BalanceService.ChangeUserBalance(ctx, user.ID, req.Amount)
|
||||
return utils.SuccessWithMsg("操作成功")
|
||||
}
|
||||
|
||||
@@ -170,18 +106,21 @@ func (s *AgentServiceV1) AgentPutInfoReq(ctx context.Context, req *v1.AgentPutIn
|
||||
With("创建事务失败").
|
||||
Wrap(err)
|
||||
})
|
||||
currentUser := tx.SysUser.Query().Where(sysuser.ID(utils.GetUserInfoFromCtx(ctx).ID)).WithAgent().WithRoles().OnlyX(ctx)
|
||||
defer tx.Rollback()
|
||||
user := tx.SysUser.Query().Where(sysuser.ID(req.ID)).WithParent().WithAgent().FirstX(ctx)
|
||||
if user.Edges.Parent == nil || user.Edges.Parent.ID != currentUser.ID {
|
||||
return utils.FailParam("非法的下级代理参数")
|
||||
}
|
||||
// 2. 如果没有代理权限
|
||||
if !utils.HasRole(currentUser.Edges.Roles, cst.KeyRoleAdmin) && !utils.HasRole(currentUser.Edges.Roles, cst.KeyRoleAgent) {
|
||||
return utils.FailParam("代理权限不足")
|
||||
}
|
||||
// 3. 检测代理费率或level是否低于自己
|
||||
if currentUser.Edges.Agent != nil && (req.Level > currentUser.Edges.Agent.Level || req.Rate.LessThan(currentUser.Edges.Agent.Rate)) {
|
||||
return utils.FailParam("代理等级或费率低于自己")
|
||||
if !utils.IsAdminFromCtx(ctx) {
|
||||
currentUser := tx.SysUser.Query().Where(sysuser.ID(utils.GetUserInfoFromCtx(ctx).ID)).WithAgent().WithRoles().OnlyX(ctx)
|
||||
if user.Edges.Parent == nil || user.Edges.Parent.ID != currentUser.ID {
|
||||
return utils.FailParam("非法的下级代理参数")
|
||||
}
|
||||
// 2. 如果没有代理权限
|
||||
if !utils.HasRole(currentUser.Edges.Roles, cst.KeyRoleAdmin) && !utils.HasRole(currentUser.Edges.Roles, cst.KeyRoleAgent) {
|
||||
return utils.FailParam("代理权限不足")
|
||||
}
|
||||
// 3. 检测代理费率或level是否低于自己
|
||||
if currentUser.Edges.Agent != nil && (req.Level > currentUser.Edges.Agent.Level || req.Rate.LessThan(currentUser.Edges.Agent.Rate)) {
|
||||
return utils.FailParam("代理等级或费率低于自己")
|
||||
}
|
||||
}
|
||||
// 5. 检测是否存在代理信息,
|
||||
// 将用户余额先计算为比例为1的用户余额
|
||||
@@ -198,11 +137,13 @@ func (s *AgentServiceV1) AgentPutInfoReq(ctx context.Context, req *v1.AgentPutIn
|
||||
oldBalance = utils.RevertBalance(user.Balance, user.Edges.Agent.Rate)
|
||||
tx.SysAgent.UpdateOne(user.Edges.Agent).SetLevel(req.Level).SetRate(req.Rate).SaveX(ctx)
|
||||
}
|
||||
err = tx.Commit()
|
||||
//按照新费率计算余额
|
||||
newBalance := utils.TransformBalance(oldBalance, req.Rate)
|
||||
// 6. 更新用户余额
|
||||
tx.SysUser.UpdateOne(user).SetBalance(newBalance).SaveX(ctx)
|
||||
err = tx.Commit()
|
||||
// 6. 更新用户余额(如果更新了费率或者第一次改为代理)
|
||||
if user.Edges.Agent == nil || !user.Edges.Agent.Rate.Equal(req.Rate) {
|
||||
balance.BalanceService.ChangeUserBalance(ctx, user.ID, newBalance.Sub(user.Balance))
|
||||
}
|
||||
utils.OkOrPanic(err, func(err error) error {
|
||||
return oops.
|
||||
WithContext(ctx).
|
||||
|
||||
@@ -4,10 +4,10 @@ import (
|
||||
"context"
|
||||
"likedream-goframe/internal/common/errors"
|
||||
"likedream-goframe/internal/db"
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/utils"
|
||||
|
||||
"github.com/samber/oops"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
@@ -16,18 +16,28 @@ var BalanceService = &BalanceServiceV1{}
|
||||
type BalanceServiceV1 struct {
|
||||
}
|
||||
|
||||
func (v *BalanceServiceV1) ChangeUserBalance(ctx context.Context, userId int64, balance decimal.Decimal) {
|
||||
if utils.IsAdminFromCtx(ctx) {
|
||||
return
|
||||
}
|
||||
tx, err := db.Global.Tx(ctx)
|
||||
utils.OkOrPanic(err, oops.WithContext(ctx).Wrap)
|
||||
defer tx.Rollback()
|
||||
user := tx.SysUser.Query().Where(sysuser.ID(userId)).WithRoles().ForUpdate().OnlyX(ctx)
|
||||
newBalance := user.Balance.Add(balance)
|
||||
if newBalance.LessThan(decimal.Zero) {
|
||||
utils.OkOrPanic(errors.NewBusinessError(400, "余额不足"))
|
||||
}
|
||||
tx.SysUser.Update().Where(sysuser.ID(userId)).SetBalance(newBalance).SaveX(ctx)
|
||||
tx.Commit()
|
||||
func (v *BalanceServiceV1) ChangeUserBalance(ctx context.Context, userId int64, balance decimal.Decimal) error {
|
||||
return db.WithTx(ctx, func(c context.Context, tx *ent.Tx) {
|
||||
// 使用 SELECT ... FOR UPDATE 锁定用户记录
|
||||
user, err := tx.SysUser.Query().
|
||||
Where(sysuser.ID(userId)).
|
||||
ForUpdate().
|
||||
Only(ctx)
|
||||
if err != nil {
|
||||
utils.OkOrPanic(err)
|
||||
}
|
||||
|
||||
newBalance := user.Balance.Add(balance)
|
||||
if newBalance.LessThan(decimal.Zero) {
|
||||
utils.OkOrPanic(errors.NewBusinessError(400, "余额不足"))
|
||||
}
|
||||
|
||||
// 更新余额
|
||||
tx.SysUser.Update().
|
||||
Where(sysuser.ID(userId)).
|
||||
SetBalance(newBalance).
|
||||
ExecX(ctx)
|
||||
tx.Commit()
|
||||
}, nil)
|
||||
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ type CardServiceV1 struct{}
|
||||
|
||||
func (v CardServiceV1) List(ctx context.Context, req *v1.ListCardReq) *utils.Response[[]*ent.SysCard] {
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
query := db.Global.SysCard.Query().Where(syscard.HasCreatorWith(sysuser.IDEQ(user.ID))).WithUser().WithCashUser()
|
||||
query := db.Global.SysCard.Query().Where(syscard.HasCreatorWith(sysuser.IDEQ(user.ID))).WithUser().WithCashUser().Order(ent.Desc(syscard.FieldCreateTime))
|
||||
if req.Content != "" {
|
||||
query.Where(syscard.ContentEQ(req.Content))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package cpdaily
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
v1 "likedream-goframe/internal/api/v1"
|
||||
"likedream-goframe/internal/application/filestorage"
|
||||
"likedream-goframe/internal/db"
|
||||
"likedream-goframe/internal/ent/cpimage"
|
||||
"likedream-goframe/internal/utils"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/google/uuid"
|
||||
"github.com/samber/oops"
|
||||
)
|
||||
|
||||
type CpImageServiceV1 struct {
|
||||
}
|
||||
|
||||
func (v CpImageServiceV1) Upload(ctx context.Context, req *v1.UploadImageReq) *utils.Response[any] {
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
file := req.File
|
||||
open, err := file.Open()
|
||||
utils.OkOrPanic(err, oops.WithContext(ctx).Wrap)
|
||||
key := utils.GenerateFileName("cpdaily/")
|
||||
filestorage.GlobalS3.UploadFile(ctx, key, open)
|
||||
img := db.Global.CpImage.Create().
|
||||
SetUserID(user.ID).
|
||||
SetKey(key).
|
||||
SetContentType(file.Header.Get("Content-Type")).
|
||||
SetContentLength(file.Size).
|
||||
SaveX(ctx)
|
||||
return utils.SuccessWithData[any](v1.UploadImageRes{
|
||||
FileKey: img.ImageID.String(),
|
||||
FileSize: &file.Size,
|
||||
})
|
||||
}
|
||||
|
||||
func (v CpImageServiceV1) Preview(ctx context.Context, req *v1.PreviewImageReq) *utils.Response[any] {
|
||||
id, err := uuid.Parse(req.Key)
|
||||
utils.OkOrPanic(err, oops.WithContext(ctx).Wrap)
|
||||
cpImage := db.Global.CpImage.Query().Where(cpimage.ImageID(id)).OnlyX(ctx)
|
||||
file := filestorage.GlobalS3.GetFile(ctx, cpImage.Key)
|
||||
r := g.RequestFromCtx(ctx)
|
||||
r.Response.Header().Set("Content-Type", "image/png")
|
||||
// 将文件写入
|
||||
io.Copy(r.Response.Writer, file)
|
||||
r.Exit()
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewCpImageServiceV1() *CpImageServiceV1 {
|
||||
return &CpImageServiceV1{}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"context"
|
||||
"encoding/gob"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
v1 "likedream-goframe/internal/api/v1"
|
||||
"likedream-goframe/internal/application/cpdaily/login"
|
||||
@@ -21,6 +20,7 @@ import (
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/framework/queue"
|
||||
"likedream-goframe/internal/framework/schedule"
|
||||
"likedream-goframe/internal/service/balance"
|
||||
"likedream-goframe/internal/utils"
|
||||
"time"
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/hibiken/asynq"
|
||||
"github.com/samber/oops"
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
type CpTaskServiceV1 struct {
|
||||
@@ -75,7 +76,7 @@ func (v CpTaskServiceV1) AddTask(ctx context.Context, req *v1.AddTaskReq) *utils
|
||||
|
||||
func (v CpTaskServiceV1) List(ctx context.Context, req *v1.CpTaskListReq) *utils.Response[[]*ent.CpTask] {
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
query := db.Global.CpTask.Query().Where(cptask.HasSysUserWith(sysuser.ID(user.ID))).WithCpUser()
|
||||
query := db.Global.CpTask.Query().Where(cptask.HasSysUserWith(sysuser.ID(user.ID))).WithCpUser().Order(ent.Desc(cptask.FieldCreateTime))
|
||||
if req.TaskType != "" {
|
||||
query.Where(cptask.TaskTypeEQ(req.TaskType))
|
||||
}
|
||||
@@ -123,7 +124,7 @@ func (v CpTaskServiceV1) TaskFormData(ctx context.Context, req *v1.GetCpTaskForm
|
||||
db.Global.CpUser.UpdateOne(cpUser).SetCookie(cpUser.Cookie).ExecX(ctx)
|
||||
client = login.GetClient(ctx, cpUser.Cookie)
|
||||
}
|
||||
taskService := task.GetCpdailyTaskService(ctx, string(cpTask.TaskType), cpUser.Cookie, cpUser.SchoolID)
|
||||
taskService := task.GetCpdailyTaskService(ctx, cpTask.TaskType, cpUser.Cookie, cpUser.SchoolID)
|
||||
formMap := taskService.QueryFormByTitle(ctx, cpTask.Title)
|
||||
formDetail := taskService.ParseFormJson(ctx, formMap)
|
||||
return utils.SuccessWithData[any](formDetail)
|
||||
@@ -172,11 +173,22 @@ func (v CpTaskServiceV1) PostExecute(ctx context.Context, req *v1.PostCpTaskExec
|
||||
if cpTask.Step == cptask.StepForm {
|
||||
utils.OkOrPanic(errors2.NewBusinessError(400, "请先完成前置参数设置"))
|
||||
}
|
||||
pointConsume := req.Frequency - cpTask.Frequency
|
||||
if req.Frequency < 1 || pointConsume < 0 {
|
||||
consume := req.Frequency - cpTask.Frequency
|
||||
if req.Frequency < 1 || consume < 0 {
|
||||
utils.OkOrPanic(errors2.NewBusinessError(400, "执行次数应不低于原有次数"))
|
||||
}
|
||||
//todo 扣积分
|
||||
|
||||
// 记录原始任务状态,用于判断是否需要立即扫描
|
||||
originalStatus := cpTask.TaskStatus
|
||||
|
||||
//扣积分
|
||||
basePoint := decimal.NewFromInt(cst.BasePointCpdaily)
|
||||
if user.Edges.Agent != nil {
|
||||
basePoint = basePoint.Mul(user.Edges.Agent.Rate)
|
||||
}
|
||||
needPoint := basePoint.Mul(decimal.NewFromInt(int64(consume)))
|
||||
balance.BalanceService.ChangeUserBalance(ctx, user.ID, needPoint.Neg())
|
||||
// 更新任务
|
||||
e := db.WithTx(ctx, func(ctx context.Context, tx *ent.Tx) {
|
||||
cpTask := db.Global.CpTask.UpdateOne(cpTask).
|
||||
SetStep(cptask.StepComplete).
|
||||
@@ -187,7 +199,27 @@ func (v CpTaskServiceV1) PostExecute(ctx context.Context, req *v1.PostCpTaskExec
|
||||
SetExecuteMinute(req.ExecuteMinute).
|
||||
SaveX(ctx)
|
||||
|
||||
nextExecuteAt := utils.GetCpdailyNextExecuteTime(cpTask)
|
||||
// 计算下次执行时间
|
||||
var nextExecuteAt int64
|
||||
|
||||
// 只有在原始状态为未开始时,才考虑5分钟窗口立即扫描
|
||||
if originalStatus == cptask.TaskStatusNotStart {
|
||||
currentTime := time.Now().In(cst.TimeZoneShangHai)
|
||||
executeTime := time.Date(currentTime.Year(), currentTime.Month(), currentTime.Day(), req.ExecuteHour, req.ExecuteMinute, 0, 0, cst.TimeZoneShangHai)
|
||||
timeDiff := executeTime.Sub(currentTime)
|
||||
|
||||
if timeDiff >= -5*time.Minute && timeDiff <= 5*time.Minute {
|
||||
// 执行时间在当前时间前后5分钟内,设置为当前时间,让扫描器立即扫描到
|
||||
nextExecuteAt = currentTime.Unix()
|
||||
} else {
|
||||
// 否则使用正常的计算逻辑
|
||||
nextExecuteAt = utils.GetCpdailyNextExecuteTime(cpTask)
|
||||
}
|
||||
} else {
|
||||
// 其他状态(暂停、失败等),使用正常的计算逻辑
|
||||
nextExecuteAt = utils.GetCpdailyNextExecuteTime(cpTask)
|
||||
}
|
||||
|
||||
db.Global.CpTask.UpdateOne(cpTask).SetNextExecuteTime(nextExecuteAt).ExecX(ctx)
|
||||
}, &sql.TxOptions{})
|
||||
utils.OkOrPanic(e)
|
||||
@@ -212,14 +244,21 @@ func (v CpTaskServiceV1) ExecuteNow(ctx context.Context, req *v1.ExecuteNowReq)
|
||||
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
|
||||
taskExist := db.Global.CpTask.Query().
|
||||
// 查询任务并检查状态
|
||||
task := db.Global.CpTask.Query().
|
||||
Where(cptask.ID(req.Id), cptask.UserID(user.ID)).
|
||||
CountX(ctx)
|
||||
Select(cptask.FieldTaskStatus).
|
||||
FirstX(ctx)
|
||||
|
||||
if taskExist == 0 {
|
||||
if task == nil {
|
||||
utils.OkOrPanic(errors2.NewBusinessError(404, "任务不存在"))
|
||||
}
|
||||
|
||||
// 检查任务是否正在执行中
|
||||
if task.TaskStatus == cptask.TaskStatusDoing {
|
||||
utils.OkOrPanic(errors2.NewBusinessError(400, "任务正在执行中,请稍后再试"))
|
||||
}
|
||||
|
||||
payload := &schedule.CpdailyTaskPayload{
|
||||
CpTaskID: req.Id,
|
||||
}
|
||||
@@ -229,22 +268,23 @@ func (v CpTaskServiceV1) ExecuteNow(ctx context.Context, req *v1.ExecuteNowReq)
|
||||
e := gob.NewEncoder(payloadWriter).Encode(payload)
|
||||
utils.OkOrPanic(e, oops.WithContext(ctx).With("payload", payload).In("CpdailyTaskScanner.scanCpdailyTask").Wrap)
|
||||
|
||||
// 使用时间戳生成唯一的 TaskID,避免与自动扫描的任务冲突,也避免 Unique 限制
|
||||
// 由于已经检查了任务状态,不需要使用 Unique 来防重复
|
||||
taskID := fmt.Sprintf("cpdaily:task:manual:%d:%d", req.Id, time.Now().UnixNano())
|
||||
e = utils.Catch(func() {
|
||||
queue.AddTask(ctx, asynq.NewTask(cst.TaskCpdaily, payloadWriter.Bytes()),
|
||||
asynq.TaskID(fmt.Sprintf("cpdaily:task:%d", req.Id)),
|
||||
asynq.TaskID(taskID),
|
||||
asynq.Unique(5*time.Second),
|
||||
asynq.MaxRetry(0),
|
||||
asynq.Unique(10*time.Minute),
|
||||
asynq.Timeout(10*time.Minute),
|
||||
asynq.Queue(cst.TaskQueueCpdaily),
|
||||
)
|
||||
// 更新未开始的任务状态为队列中
|
||||
db.Global.CpTask.Update().Where(cptask.ID(task.ID), cptask.TaskStatusEQ(cptask.TaskStatusNotStart)).SetTaskStatus(cptask.TaskStatusQueue).Exec(ctx)
|
||||
})
|
||||
if e != nil {
|
||||
if errors.Is(e, asynq.ErrDuplicateTask) {
|
||||
utils.OkOrPanic(errors2.NewBusinessError(400, "任务已经在执行中"))
|
||||
} else {
|
||||
g.Log().Errorf(ctx, "立即执行任务入列失败: %+v", e)
|
||||
utils.OkOrPanic(errors2.NewBusinessError(500, "任务执行失败"))
|
||||
}
|
||||
g.Log().Errorf(ctx, "立即执行任务入列失败: %+v", e)
|
||||
utils.OkOrPanic(errors2.NewBusinessError(500, "同一个任务请勿连续执行"))
|
||||
}
|
||||
return utils.SuccessWithMsg("执行成功")
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package cpdaily
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "likedream-goframe/internal/api/v1"
|
||||
"likedream-goframe/internal/db"
|
||||
"likedream-goframe/internal/ent"
|
||||
"likedream-goframe/internal/ent/cptasklog"
|
||||
"likedream-goframe/internal/ent/sysuser"
|
||||
"likedream-goframe/internal/utils"
|
||||
)
|
||||
|
||||
type CpTaskLogServiceV1 struct {
|
||||
}
|
||||
|
||||
func (v CpTaskLogServiceV1) List(ctx context.Context, req *v1.CpTaskLogListReq) *utils.Response[[]*ent.CpTaskLog] {
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
query := db.Global.CpTaskLog.Query().Where(
|
||||
cptasklog.HasSystemUserWith(sysuser.ID(user.ID)),
|
||||
cptasklog.CpTaskID(req.TaskID)).Order(ent.Desc(cptasklog.FieldCreateTime))
|
||||
total := query.CountX(ctx)
|
||||
var data []*ent.CpTaskLog
|
||||
if total > 0 {
|
||||
query.Limit(req.Size).Offset((req.Page - 1) * req.Size)
|
||||
data = query.AllX(ctx)
|
||||
}
|
||||
return utils.SuccessWithTotal(data, total)
|
||||
}
|
||||
|
||||
func NewCpTaskLogServiceV1() *CpTaskLogServiceV1 {
|
||||
return &CpTaskLogServiceV1{}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ func (v CpUserServiceV1) ConfirmAdd(ctx context.Context, req *v1.CpUserConfirmAd
|
||||
|
||||
func (v CpUserServiceV1) List(ctx context.Context, req *v1.CpUserListReq) *utils.Response[[]*ent.CpUser] {
|
||||
user := utils.GetUserInfoFromCtx(ctx)
|
||||
query := db.Global.CpUser.Query().Where(cpuser.HasSysuserWith(sysuser.ID(user.ID))).WithSchool()
|
||||
query := db.Global.CpUser.Query().Where(cpuser.HasSysuserWith(sysuser.ID(user.ID))).WithSchool().Order(ent.Desc(cpuser.FieldCreateTime))
|
||||
if req.Email != "" {
|
||||
query.Where(cpuser.EmailContains(req.Email))
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ func (s *MenuServiceV1) Add(ctx context.Context, req *v1.MenuAddReq) *utils.Resp
|
||||
SetRoute(req.Route).
|
||||
SetComponent(req.Component).
|
||||
SetHidden(req.Hidden).
|
||||
SetKeepAlive(req.KeepAlive).
|
||||
SetIcon(req.Icon).
|
||||
SetOrder(req.Order)
|
||||
if req.ParentId != 0 {
|
||||
@@ -80,6 +81,7 @@ func (s *MenuServiceV1) Update(ctx context.Context, req *v1.MenuUpdateReq) *util
|
||||
SetComponent(req.Component).
|
||||
SetRoute(req.Route).
|
||||
SetHidden(req.Hidden).
|
||||
SetKeepAlive(req.KeepAlive).
|
||||
SetIcon(req.Icon).
|
||||
SetOrder(req.Order)
|
||||
if req.ParentId != 0 {
|
||||
|
||||
@@ -21,6 +21,8 @@ type globalService struct {
|
||||
User *user.UserServiceV1
|
||||
CpUser *cpdaily.CpUserServiceV1
|
||||
CpTask *cpdaily.CpTaskServiceV1
|
||||
CpImage *cpdaily.CpImageServiceV1
|
||||
CpTaskLog *cpdaily.CpTaskLogServiceV1
|
||||
Card *card.CardServiceV1
|
||||
}
|
||||
|
||||
@@ -34,5 +36,7 @@ var Global = globalService{
|
||||
User: user.NewV1(),
|
||||
CpUser: cpdaily.NewCpUserServiceV1(),
|
||||
CpTask: cpdaily.NewCpTaskServiceV1(),
|
||||
CpImage: cpdaily.NewCpImageServiceV1(),
|
||||
CpTaskLog: cpdaily.NewCpTaskLogServiceV1(),
|
||||
Card: card.NewCardServiceV1(),
|
||||
}
|
||||
|
||||
@@ -227,6 +227,7 @@ func buildTreeMenu(list []*ent.SysMenu, parentId int64) []*v1.UserMenuRes {
|
||||
Permission: menu.Permission,
|
||||
Type: string(menu.Type),
|
||||
Hidden: menu.Hidden,
|
||||
KeepAlive: menu.KeepAlive,
|
||||
Children: buildTreeMenu(list, menu.ID),
|
||||
Order: menu.Order,
|
||||
}
|
||||
|
||||
@@ -81,19 +81,18 @@ func (s *UserLoginServiceV1) Register(ctx context.Context, req *v1.UserRegisterR
|
||||
With("提交事务失败").
|
||||
Wrap(err)
|
||||
})
|
||||
|
||||
// 注册成功后发送欢迎邮件(异步发送,不影响注册结果)
|
||||
go func() {
|
||||
ctx2 := context.Background()
|
||||
token := make([]byte, 32)
|
||||
_, _ = rand.Read(token)
|
||||
tokenStr := base64.URLEncoding.EncodeToString(token)
|
||||
set := redis.GetClient().Set(ctx, cst.RedisVerifyCode+tokenStr, req.Email, time.Duration(cst.RedisVerifyCodeExpire)*time.Second)
|
||||
err2 := set.Err()
|
||||
utils.OkOrPanic(err2)
|
||||
err2 := redis.GetClient().SetEx(ctx2, cst.RedisVerifyCode+tokenStr, req.Email, time.Duration(cst.RedisVerifyCodeExpire)*time.Second).Err()
|
||||
utils.OkOrPanic(err2, oops.WithContext(ctx2).Wrap)
|
||||
// 创建新的context避免原context被取消
|
||||
emailCtx := context.Background()
|
||||
emailService := email.NewV1()
|
||||
emailService.SendSignupEmail(emailCtx, req.Email, req.Username, tokenStr)
|
||||
emailService.SendSignupEmail(ctx2, req.Email, req.Username, tokenStr)
|
||||
|
||||
}()
|
||||
|
||||
return utils.SuccessWithMsg("注册成功")
|
||||
|
||||
@@ -50,7 +50,7 @@ func Pass(err *error) {
|
||||
if r := recover(); r != nil {
|
||||
e, ok := errorx.ErrorFromPanic(r)
|
||||
if ok {
|
||||
*err = e
|
||||
*err = oops.Wrap(e)
|
||||
} else {
|
||||
panic(r)
|
||||
}
|
||||
@@ -61,7 +61,7 @@ func HandleError(f func(error)) {
|
||||
if r := recover(); r != nil {
|
||||
e, ok := errorx.ErrorFromPanic(r)
|
||||
if ok {
|
||||
f(e)
|
||||
f(oops.Wrap(e))
|
||||
} else {
|
||||
panic(r)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"github.com/shirou/gopsutil/v3/process"
|
||||
)
|
||||
|
||||
func IsDebug() bool {
|
||||
return isGolandDebug() || isDebugByPath()
|
||||
|
||||
}
|
||||
|
||||
func isDebugByPath() bool {
|
||||
exePath := strings.ToLower(os.Args[0])
|
||||
// 获取绝对路径
|
||||
absPath, err := filepath.Abs(exePath)
|
||||
if err != nil {
|
||||
absPath = exePath
|
||||
}
|
||||
|
||||
// 检查路径中是否包含常见的临时目录或"go-build"字样
|
||||
tmpDir := strings.ToLower(getTempDir())
|
||||
isTemp := strings.Contains(absPath, tmpDir) || strings.Contains(absPath, "go-build") || strings.Contains(absPath, "go_build_")
|
||||
return isTemp
|
||||
}
|
||||
func getTempDir() string {
|
||||
tempDir := os.TempDir()
|
||||
|
||||
// 尝试转换为长路径
|
||||
if longPath, err := filepath.EvalSymlinks(tempDir); err == nil {
|
||||
if absPath, err := filepath.Abs(longPath); err == nil {
|
||||
return absPath
|
||||
}
|
||||
return longPath
|
||||
}
|
||||
|
||||
return filepath.Dir(tempDir)
|
||||
}
|
||||
|
||||
func isGolandDebug() bool {
|
||||
// 获取当前进程ID
|
||||
pid := os.Getpid()
|
||||
|
||||
// 获取当前进程信息
|
||||
currentProcess, err := process.NewProcess(int32(pid))
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 获取父进程
|
||||
parent, err := currentProcess.Parent()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 获取父进程名称
|
||||
name, err := parent.Name()
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查父进程是否是dlv(Go调试器)或GoLand相关进程
|
||||
name = strings.ToLower(name)
|
||||
debugProcessNames := []string{
|
||||
"dlv.exe", "dlv",
|
||||
"goland.exe", "goland64.exe",
|
||||
"goland", "idea.exe",
|
||||
}
|
||||
|
||||
for _, debugName := range debugProcessNames {
|
||||
if strings.Contains(name, debugName) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func GetCpdailyNextExecuteTime(task *ent.CpTask) int64 {
|
||||
|
||||
// 如果当天执行时间已过,返回明天的执行时间
|
||||
executeTime := time.Date(current.Year(), current.Month(), current.Day(), *executeHour, *executeMinute, 0, 0, cst.TimeZoneShangHai)
|
||||
executeTime.AddDate(0, 0, 1)
|
||||
executeTime = executeTime.AddDate(0, 0, 1)
|
||||
|
||||
return executeTime.Unix()
|
||||
}
|
||||
|
||||
@@ -28,6 +28,14 @@ func CalculateBalance(balance decimal.Decimal, rate decimal.Decimal, amount deci
|
||||
return balance.Sub(amount.Div(amountRate).Mul(rate)).Truncate(2)
|
||||
}
|
||||
|
||||
func NeedBalance(rate decimal.Decimal, amount decimal.Decimal, amountRate decimal.Decimal) decimal.Decimal {
|
||||
// 如果当前级别费率为0(超级管理员)
|
||||
if rate.Equal(decimal.NewFromInt(0)) {
|
||||
return decimal.Zero
|
||||
}
|
||||
return amount.Mul(rate).Div(amountRate)
|
||||
}
|
||||
|
||||
// ConsumeBalance 消费余额
|
||||
func ConsumeBalance(balance decimal.Decimal, rate decimal.Decimal) decimal.Decimal {
|
||||
return balance.Mul(rate)
|
||||
|
||||
@@ -1,13 +1,27 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "go.uber.org/automaxprocs"
|
||||
"likedream-goframe/cmd/entc"
|
||||
"likedream-goframe/cmd/server"
|
||||
"likedream-goframe/internal/cst"
|
||||
"log"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
_ "time/tzdata"
|
||||
|
||||
_ "github.com/breml/rootcerts"
|
||||
|
||||
_ "go.uber.org/automaxprocs"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// fix: time: unknown time zone Asia/Shanghai
|
||||
var err error
|
||||
cst.TimeZoneShangHai, err = time.LoadLocation("Asia/Shanghai")
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
args := ""
|
||||
if len(os.Args) > 1 {
|
||||
args = os.Args[1]
|
||||
|
||||
Reference in New Issue
Block a user