Compare commits

..

10 Commits

Author SHA1 Message Date
sugarBecomer 1bc04c74f3 🐛 菜单 keep alive 2025-11-07 14:30:12 +08:00
sugarBecomer dcb5cd8a4e 🐛 菜单修复 2025-11-07 14:00:45 +08:00
sugarBecomer 0d7d4c11a0 🐛 Login need kick 2025-11-07 12:11:50 +08:00
sugarBecomer e4d07874eb 🐛 任务执行bug和日志 2025-11-07 01:14:10 +08:00
sugarBecomer ae9984460f 🐛 取消临时err 2025-11-07 00:25:31 +08:00
sugarBecomer e38a1a4480 🐛 取消临时err 2025-11-07 00:14:41 +08:00
sugarBecomer b112f45264 🐛 onnx运行路径问题 2025-11-06 23:50:10 +08:00
sugarBecomer 6fad80b5cd 🐛 onnx运行路径问题 2025-11-06 22:39:02 +08:00
sugarBecomer 1d0e1812c8 🐛 onnx运行路径问题 2025-11-06 22:25:58 +08:00
RecordingTheSmile 40490ffe43 fix: update Dockerfile to install packages non-interactively 2025-11-06 21:31:02 +08:00
23 changed files with 281 additions and 17 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
FROM golang:latest AS backend-builder
RUN apt update
RUN apt install build-essential
RUN apt install -y build-essential
WORKDIR /build
COPY . .
ENV CGO_ENABLED=1
RUN go build -ldflags="-s -w" -o bin/server
RUN apt install upx-ucl
RUN apt install -y upx-ucl
RUN upx --best --lzma bin/server
+6 -1
View File
@@ -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"
+1
View File
@@ -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"`
+1
View File
@@ -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"`
+24 -1
View File
@@ -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)
}
@@ -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).
+27
View File
@@ -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
}
+6
View File
@@ -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
+2 -1
View File
@@ -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,
},
+55 -1
View File
@@ -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
+5 -1
View File
@@ -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()
+3 -1
View File
@@ -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
View File
@@ -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(", ")
+10
View File
@@ -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()
+15
View File
@@ -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))
+65
View File
@@ -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) {
+34
View File
@@ -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)
utils.OkOrPanic(errors.NewBusinessError(400, "临时错误"))
taskExecutor.Submit(ctx, submitForm, targetTask.Edges.CpUser.Username, deviceID)
db.Global.CpTask.UpdateOneID(taskPayload.CpTaskID).SetTaskStatus(cptask.TaskStatusDone).AddSuccessCount(1).ExecX(ctx)
+1 -1
View File
@@ -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),
+2
View File
@@ -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,
}