Compare commits
24 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1bc04c74f3 | |||
| dcb5cd8a4e | |||
| 0d7d4c11a0 | |||
| e4d07874eb | |||
| ae9984460f | |||
| e38a1a4480 | |||
| b112f45264 | |||
| 6fad80b5cd | |||
| 1d0e1812c8 | |||
| 40490ffe43 | |||
| 455b6d40de | |||
| 62dcac103f | |||
| 63a83ddd5e | |||
| f8d3d6a0ad | |||
| e2eb27a5ba | |||
| 9fbeddc9f4 | |||
| 289bbe3f0d | |||
| bec6a93b65 | |||
| e2a41fc187 | |||
| c7a04f3857 | |||
| 9c5398071c | |||
| 1f6400ba5d | |||
| afe0c149dd | |||
| 9b9d05a4ac |
+6
-4
@@ -1,14 +1,16 @@
|
||||
FROM golang:alpine AS backend-builder
|
||||
FROM golang:latest AS backend-builder
|
||||
RUN apt update
|
||||
RUN apt install -y build-essential
|
||||
WORKDIR /build
|
||||
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"
|
||||
@@ -28,7 +28,7 @@ require (
|
||||
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
|
||||
@@ -64,7 +64,6 @@ require (
|
||||
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
|
||||
@@ -79,18 +78,12 @@ 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/shoenig/go-m1cpu v0.1.6 // indirect
|
||||
github.com/sourcegraph/conc v0.3.0 // indirect
|
||||
github.com/spf13/afero v1.12.0 // indirect
|
||||
github.com/spf13/cast v1.9.2 // indirect
|
||||
github.com/spf13/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
|
||||
|
||||
@@ -90,8 +90,6 @@ github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1
|
||||
github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU=
|
||||
github.com/go-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=
|
||||
@@ -145,8 +143,6 @@ github.com/oklog/ulid/v2 v2.1.1/go.mod h1:rcEKHmBBKfef9DhnvX7y1HZBYxjXb0cP5ExxNs
|
||||
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
|
||||
github.com/olekukonko/tablewriter v0.0.5/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=
|
||||
@@ -162,8 +158,6 @@ github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||
github.com/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=
|
||||
@@ -178,16 +172,8 @@ github.com/shoenig/test v0.6.4 h1:kVTaSd7WLz5WZ2IaoM0RSzRsUD+m8wRR+5qvntpn4LU=
|
||||
github.com/shoenig/test v0.6.4/go.mod h1:byHiCGXqrVaflBLAMq/srcZIHynQPQgeyvkvXnjqq0k=
|
||||
github.com/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=
|
||||
@@ -198,8 +184,6 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.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=
|
||||
@@ -218,8 +202,8 @@ github.com/wenlng/go-captcha/v2 v2.0.4 h1:5cSUF36ZyA03qeDMjKmeXGpbYJMXEexZIYK3Vg
|
||||
github.com/wenlng/go-captcha/v2 v2.0.4/go.mod h1:5hac1em3uXoyC5ipZ0xFv9umNM/waQvYAQdr0cx/h34=
|
||||
github.com/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=
|
||||
|
||||
@@ -2,6 +2,7 @@ package v1
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
)
|
||||
|
||||
type CpTaskLogListReq struct {
|
||||
@@ -10,3 +11,9 @@ type CpTaskLogListReq struct {
|
||||
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
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -605,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 参数
|
||||
@@ -676,7 +676,6 @@ func (c *CpdailySleepCheckTask) Submit(ctx context.Context, form map[string]*gva
|
||||
sign := taskhelper.GetSubmitSign(submitData)
|
||||
|
||||
submitData["sign"] = gvar.New(sign)
|
||||
utils.OkOrPanic(errors.NewBusinessError(503, "临时拦截"), oops.WithContext(ctx).Wrap)
|
||||
response, e := c.client.R().
|
||||
SetBody(submitData).
|
||||
WithContext(ctx).
|
||||
|
||||
@@ -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
|
||||
}
|
||||
@@ -2,7 +2,9 @@ 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"
|
||||
@@ -11,6 +13,14 @@ import (
|
||||
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
|
||||
|
||||
@@ -9,4 +9,6 @@ import (
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
@@ -186,6 +186,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},
|
||||
@@ -1477,6 +1478,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
@@ -226,6 +226,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 +240,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,
|
||||
},
|
||||
|
||||
@@ -6199,6 +6199,7 @@ type SysMenuMutation struct {
|
||||
permission *string
|
||||
route *string
|
||||
component *string
|
||||
keep_alive *bool
|
||||
hidden *bool
|
||||
icon *string
|
||||
_order *uint
|
||||
@@ -6678,6 +6679,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 +7037,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 +7065,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 +7103,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 +7138,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 +7218,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 +7364,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
|
||||
|
||||
@@ -134,8 +134,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()
|
||||
|
||||
@@ -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"),
|
||||
|
||||
+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)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
"likedream-goframe/internal/application/cpdaily/school"
|
||||
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"
|
||||
@@ -57,6 +58,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 = "未知的错误导致任务执行失败"
|
||||
}
|
||||
@@ -64,11 +67,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))
|
||||
|
||||
@@ -127,7 +130,6 @@ 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)
|
||||
|
||||
@@ -118,7 +118,7 @@ func (ts *TaskScanner) scanCpdailyTask() {
|
||||
queue.AddTask(ts.ctx, asynq.NewTask(cst.TaskCpdaily, payloadWriter.Bytes()),
|
||||
asynq.TaskID(fmt.Sprintf("cpdaily:task:%d", task.ID)),
|
||||
asynq.MaxRetry(3),
|
||||
asynq.Unique(10*time.Minute),
|
||||
asynq.Unique(1*time.Minute),
|
||||
asynq.ProcessAt(execTime),
|
||||
asynq.Deadline(execTime.Add(12*time.Minute)),
|
||||
asynq.Queue(cst.TaskQueueCpdaily),
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user