sync: 对齐小程序 v1.0.2 生产代码并脱敏
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
// Package cmd
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package cmd
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package cmd
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package cmd
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/websocket"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/router"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service/allocatedispatch"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/tasks"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
@@ -41,7 +42,10 @@ var Http = &gcmd.Command{
|
||||
s.SetDumpRouterMap(dumpRouterMap)
|
||||
router.InitRouter(ctx, s)
|
||||
websocket.StartWebSocket(ctx)
|
||||
stopAllocateRecovery := allocatedispatch.Start(ctx)
|
||||
defer stopAllocateRecovery()
|
||||
s.Run()
|
||||
stopAllocateRecovery()
|
||||
inithttp.CleanupHttp(ctx)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package cmd
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package cmd
|
||||
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Package cmd
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/cmd/inithttp"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/websocket"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -2,10 +2,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/event"
|
||||
"os"
|
||||
"sync"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/event"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
|
||||
@@ -27,6 +27,7 @@ const (
|
||||
BatchDetailStatusFailed = 3
|
||||
|
||||
BatchSourceTypeBatchSelect = 0
|
||||
BatchSourceTypeFile = 3
|
||||
|
||||
BatchTypePrepare = 4
|
||||
BatchTypeAllocate = 3
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
const (
|
||||
QueueSysOptLog = "queue:sys_opt_log"
|
||||
QueueSysOptLog = "queue:sys_opt_log"
|
||||
QueueWorkOrderAutoClose = "iotlcm.work_order.auto_close"
|
||||
QueueWorkOrderAutoCloseDelay = "iotlcm.work_order.auto_close.delay"
|
||||
)
|
||||
|
||||
// 数据库变动类型
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package consts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package consts
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"strings"
|
||||
v1 "git.5iot.com/iotlcm-public/iotlcm-app/api/app/v1"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/allocaterequest"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service/executionlog"
|
||||
)
|
||||
|
||||
type AllocateResultController struct{}
|
||||
|
||||
func (c *AllocateResultController) Result(ctx context.Context, req *v1.AllocateResultReq) (*v1.AllocateResultRes, error) {
|
||||
batchNo := strings.TrimSpace(req.BatchNo)
|
||||
if batchNo == "" {
|
||||
batch, err := allocaterequest.Find(ctx, contexts.GetTenantId(ctx), contexts.GetUserId(ctx), req.RequestId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if batch == nil {
|
||||
return nil, gerror.New("划拨批次不存在或无权查看")
|
||||
}
|
||||
batchNo = batch.BatchNo
|
||||
}
|
||||
item, err := executionlog.AllocateSummary(ctx, batchNo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AllocateResultRes{AppExecutionLogItem: item}, nil
|
||||
}
|
||||
func (c *AllocateResultController) Details(ctx context.Context, req *v1.AllocateDetailsReq) (*v1.AllocateDetailsRes, error) {
|
||||
items, total, err := executionlog.AllocateDetails(ctx, &req.AppExecutionLogDetailParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.AllocateDetailsRes{Items: items, Total: total}, nil
|
||||
}
|
||||
@@ -57,6 +57,14 @@ func (c *ControllerV1) PhoneLogin(ctx context.Context, req *v1.PhoneLoginReq) (r
|
||||
return &v1.PhoneLoginRes{AppAuthTokenModel: *token}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) PhoneSmsLogin(ctx context.Context, req *v1.PhoneSmsLoginReq) (res *v1.PhoneSmsLoginRes, err error) {
|
||||
token, err := service.AppAuth().PhoneSmsLogin(ctx, &req.AppPhoneSmsLoginParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.PhoneSmsLoginRes{AppAuthTokenModel: *token}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) WechatLogin(ctx context.Context, req *v1.WechatLoginReq) (res *v1.WechatLoginRes, err error) {
|
||||
data, err := service.AppAuth().WechatLogin(ctx, &req.AppWechatLoginParam)
|
||||
if err != nil {
|
||||
|
||||
@@ -8,11 +8,11 @@ import (
|
||||
)
|
||||
|
||||
func (c *ControllerV1) CustomerList(ctx context.Context, req *v1.CustomerListReq) (res *v1.CustomerListRes, err error) {
|
||||
items, total, err := service.AppUser().CustomerList(ctx, &req.AppCustomerListParam)
|
||||
items, total, summary, err := service.AppUser().CustomerList(ctx, &req.AppCustomerListParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.CustomerListRes{Items: items, Total: total}, nil
|
||||
return &v1.CustomerListRes{Items: items, Total: total, Summary: summary}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) CustomerDetail(ctx context.Context, req *v1.CustomerDetailReq) (res *v1.CustomerDetailRes, err error) {
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "git.5iot.com/iotlcm-public/iotlcm-app/api/app/v1"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
)
|
||||
|
||||
func (c *ControllerV1) WarningPreference(ctx context.Context, req *v1.WarningPreferenceReq) (*v1.WarningPreferenceRes, error) {
|
||||
data, err := service.AppUser().WarningPreference(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.WarningPreferenceRes{AppWarningPreferenceModel: *data}, nil
|
||||
}
|
||||
func (c *ControllerV1) SaveWarningPreference(ctx context.Context, req *v1.SaveWarningPreferenceReq) (*v1.SaveWarningPreferenceRes, error) {
|
||||
data, err := service.AppUser().SaveWarningPreference(ctx, &req.AppWarningPreferenceParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.SaveWarningPreferenceRes{AppWarningPreferenceModel: *data}, nil
|
||||
}
|
||||
func (c *ControllerV1) UnbindWechat(ctx context.Context, req *v1.UnbindWechatReq) (*v1.UnbindWechatRes, error) {
|
||||
data, err := service.AppUser().UnbindWechat(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.UnbindWechatRes{AppWechatBindModel: *data}, nil
|
||||
}
|
||||
@@ -38,3 +38,10 @@ func (c *ControllerV1) WorkOrderUpload(ctx context.Context, req *v1.WorkOrderUpl
|
||||
}
|
||||
return &v1.WorkOrderUploadRes{SysOssUploadModel: workOrderFile}, nil
|
||||
}
|
||||
|
||||
func (c *ControllerV1) WorkOrderAction(ctx context.Context, req *v1.WorkOrderActionReq) (*v1.WorkOrderActionRes, error) {
|
||||
if err := service.AppWorkOrder().Action(ctx, &req.AppWorkOrderActionParam); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.WorkOrderActionRes{}, nil
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "git.5iot.com/iotlcm-public/iotlcm-app/api/app/v1"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service/executionlog"
|
||||
)
|
||||
|
||||
type ExecutionLogController struct{}
|
||||
|
||||
func (c *ExecutionLogController) List(ctx context.Context, req *v1.ExecutionLogListReq) (*v1.ExecutionLogListRes, error) {
|
||||
items, total, err := executionlog.List(ctx, &req.AppExecutionLogListParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ExecutionLogListRes{Items: items, Total: total}, nil
|
||||
}
|
||||
func (c *ExecutionLogController) Summary(ctx context.Context, req *v1.ExecutionLogSummaryReq) (*v1.ExecutionLogSummaryRes, error) {
|
||||
item, err := executionlog.Summary(ctx, req.BatchNo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ExecutionLogSummaryRes{AppExecutionLogItem: item}, nil
|
||||
}
|
||||
func (c *ExecutionLogController) Details(ctx context.Context, req *v1.ExecutionLogDetailsReq) (*v1.ExecutionLogDetailsRes, error) {
|
||||
items, total, err := executionlog.Details(ctx, &req.AppExecutionLogDetailParam)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &v1.ExecutionLogDetailsRes{Items: items, Total: total}, nil
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package gen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package gen
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package gen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2026 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package gen
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package gen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// @AutoGenerate Version
|
||||
package system
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
)
|
||||
|
||||
|
||||
func (c *ControllerV1) SysDictTypeList(ctx context.Context, req *v1.SysDictTypeListReq) (res *v1.SysDictTypeListRes, err error) {
|
||||
items, total, err := service.SysDictType().List(ctx, &req.SysDictTypeListParam)
|
||||
if err != nil {
|
||||
|
||||
@@ -26,19 +26,19 @@ type BatchMainColumns struct {
|
||||
OrderSn string // 订单编号
|
||||
BatchType string // 批次类型 枚举
|
||||
BatchStatus string // 批次状态 枚举
|
||||
BatchAsyncStatus string // 异步处理状态 0=已创建 1=待处理 2=处理中 3=成功 4=失败 5=部分成功
|
||||
BatchAsyncStatus string // 异步处理状态
|
||||
SourceType string // 来源方式 枚举
|
||||
SourceBatchNo string // 来源批次编号
|
||||
SourceOssId string // 源文件OSS ID
|
||||
ResultOssId string // 结果文件OSS ID
|
||||
IsCrossDept string // 是否跨级操作机构 0-否 1-是
|
||||
IsCrossDept string // 是否跨级操作机构
|
||||
TargetDeptId string // 目标机构编号
|
||||
DeptId string // 机构编号
|
||||
TotalCount string // 总数量
|
||||
ValidCount string // 有效数量
|
||||
SuccessCount string // 成功数量
|
||||
FailCount string // 失败数量
|
||||
RunResult string // 运行结果:0-待运行 1-运行中 2-成功 3-失败
|
||||
RunResult string // 运行结果
|
||||
FailReason string // 失败原因
|
||||
BatchInfo string // 批次信息:入库/出库展示字段
|
||||
Remark string // 备注扩展字段
|
||||
@@ -50,6 +50,8 @@ type BatchMainColumns struct {
|
||||
CreatedAt string // 创建时间
|
||||
UpdatedBy string // 更新者ID
|
||||
UpdatedAt string // 更新时间
|
||||
SourceChannel string // 发起渠道:console/mini_program/api/system/legacy
|
||||
ExecutionMode string // 操作规模:0未知1单卡2批量
|
||||
}
|
||||
|
||||
// batchMainColumns holds the columns for the table batch_main.
|
||||
@@ -83,6 +85,8 @@ var batchMainColumns = BatchMainColumns{
|
||||
CreatedAt: "created_at",
|
||||
UpdatedBy: "updated_by",
|
||||
UpdatedAt: "updated_at",
|
||||
SourceChannel: "source_channel",
|
||||
ExecutionMode: "execution_mode",
|
||||
}
|
||||
|
||||
// NewBatchMainDao creates and returns a new DAO object for table data access.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package addons
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package addons
|
||||
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package allocaterequest
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"regexp"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
)
|
||||
|
||||
var validID = regexp.MustCompile(`^[A-Za-z0-9_-]{16,96}$`)
|
||||
|
||||
func Key(tenant string, user int64, requestID string) (string, error) {
|
||||
requestID = strings.TrimSpace(requestID)
|
||||
if tenant == "" || user <= 0 || !validID.MatchString(requestID) {
|
||||
return "", gerror.New("划拨请求标识无效")
|
||||
}
|
||||
value, err := json.Marshal([]any{tenant, user, "allocate", requestID})
|
||||
if err != nil {
|
||||
return "", gerror.Wrap(err, "生成划拨请求标识失败")
|
||||
}
|
||||
digest := sha256.Sum256(value)
|
||||
return hex.EncodeToString(digest[:]), nil
|
||||
}
|
||||
|
||||
func Fingerprint(cards []string, source, target int64, mode int, remark string) string {
|
||||
sorted := append([]string(nil), cards...)
|
||||
sort.Strings(sorted)
|
||||
value, _ := json.Marshal([]any{sorted, source, target, mode, strings.TrimSpace(remark)})
|
||||
digest := sha256.Sum256(value)
|
||||
return hex.EncodeToString(digest[:])
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package allocaterequest
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestRequestIdentity(t *testing.T) {
|
||||
requestID := "alloc_0123456789abcdef"
|
||||
first, err := Key("A", 7, requestID)
|
||||
if err != nil || len(first) != 64 {
|
||||
t.Fatal(first, err)
|
||||
}
|
||||
same, _ := Key("A", 7, requestID)
|
||||
if first != same {
|
||||
t.Fatal("unstable identity")
|
||||
}
|
||||
for _, entry := range []struct {
|
||||
tenant string
|
||||
user int64
|
||||
id string
|
||||
}{{"B", 7, requestID}, {"A", 8, requestID}, {"A", 7, requestID + "2"}} {
|
||||
other, err := Key(entry.tenant, entry.user, entry.id)
|
||||
if err != nil || other == first {
|
||||
t.Fatal("identity scope collision", err)
|
||||
}
|
||||
}
|
||||
for _, id := range []string{"", "short", "0123456789abcdef/"} {
|
||||
if _, err := Key("A", 7, id); err == nil {
|
||||
t.Fatal("invalid identity accepted", id)
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestFingerprint(t *testing.T) {
|
||||
first := Fingerprint([]string{"B", "A"}, 1, 2, 2, " remark ")
|
||||
if first != Fingerprint([]string{"A", "B"}, 1, 2, 2, "remark") {
|
||||
t.Fatal("card order changed identity")
|
||||
}
|
||||
for _, other := range []string{Fingerprint([]string{"A"}, 1, 2, 2, "remark"), Fingerprint([]string{"A", "B"}, 2, 2, 2, "remark"), Fingerprint([]string{"A", "B"}, 1, 3, 2, "remark"), Fingerprint([]string{"A", "B"}, 1, 2, 1, "remark"), Fingerprint([]string{"A", "B"}, 1, 2, 2, "other")} {
|
||||
if first == other {
|
||||
t.Fatal("changed parameters accepted")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package allocaterequest
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/entity"
|
||||
)
|
||||
|
||||
func Find(ctx context.Context, tenant string, user int64, requestID string) (*entity.BatchMain, error) {
|
||||
key, err := Key(tenant, user, requestID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var batch *entity.BatchMain
|
||||
columns := dao.BatchMain.Columns()
|
||||
scope := dao.BatchMain.Ctx(ctx).Where(columns.TenantId, tenant).Where(columns.CreatedBy, user)
|
||||
if err = scope.Clone().Where(columns.BatchNo, "ALC"+key[:60]).Scan(&batch); err != nil {
|
||||
return nil, gerror.Wrap(err, "查询历史划拨请求失败")
|
||||
}
|
||||
if batch != nil {
|
||||
return batch, nil
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package allocationunits
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"strings"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
)
|
||||
|
||||
// Fields 是日志展示契约,不增加数据库字段。
|
||||
type Fields struct {
|
||||
SourceDeptId int64 `json:"sourceDeptId" orm:"-"`
|
||||
SourceDeptName string `json:"sourceDeptName" orm:"-"`
|
||||
TargetDeptId int64 `json:"targetDeptId" orm:"-"`
|
||||
TargetDeptName string `json:"targetDeptName" orm:"-"`
|
||||
TargetDeptMode string `json:"targetDeptMode" orm:"-"`
|
||||
}
|
||||
type Unit struct {
|
||||
Id int64 `orm:"dept_id"`
|
||||
Key string `orm:"dept_key"`
|
||||
Name string `orm:"dept_name"`
|
||||
}
|
||||
|
||||
func Load(ctx context.Context, tenant string, ids []int64, tx ...gdb.TX) (map[int64]Unit, error) {
|
||||
unique := map[int64]bool{}
|
||||
for _, id := range ids {
|
||||
if id > 0 {
|
||||
unique[id] = true
|
||||
}
|
||||
}
|
||||
result := map[int64]Unit{}
|
||||
if len(unique) == 0 {
|
||||
return result, nil
|
||||
}
|
||||
ids = nil
|
||||
for id := range unique {
|
||||
ids = append(ids, id)
|
||||
}
|
||||
var rows []Unit
|
||||
if len(tx) > 0 {
|
||||
result, err := tx[0].GetAll("SELECT dept_id,dept_key,dept_name FROM sys_dept WHERE tenant_id=? AND deleted_at IS NULL AND dept_id IN (?)", tenant, ids)
|
||||
if err != nil {
|
||||
return nil, gerror.Wrap(err, "读取划拨单位信息失败")
|
||||
}
|
||||
if err := result.Structs(&rows); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
units := map[int64]Unit{}
|
||||
for _, row := range rows {
|
||||
units[row.Id] = row
|
||||
}
|
||||
return units, nil
|
||||
}
|
||||
mod := dao.SysDept.Ctx(ctx)
|
||||
if err := mod.WhereNull("deleted_at").Where("tenant_id", tenant).WhereIn("dept_id", ids).Fields("dept_id", "dept_key", "dept_name", "deleted_at").Scan(&rows); err != nil {
|
||||
return nil, gerror.Wrap(err, "读取划拨单位信息失败")
|
||||
}
|
||||
for _, row := range rows {
|
||||
result[row.Id] = row
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Snapshot 名称由服务端查询,仅在受理时记录,执行时不覆盖。
|
||||
func Snapshot(ctx context.Context, tenant string, source, target int64, tx ...gdb.TX) (*gjson.Json, error) {
|
||||
units, err := Load(ctx, tenant, []int64{source, target}, tx...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
mode := "single"
|
||||
if target <= 0 {
|
||||
mode = "per_row"
|
||||
}
|
||||
return gjson.New(map[string]any{"sourceDeptId": source, "sourceDeptKey": units[source].Key, "sourceDeptName": units[source].Name, "targetDeptId": target, "targetDeptKey": units[target].Key, "targetDeptName": units[target].Name, "targetDeptMode": mode}), nil
|
||||
}
|
||||
|
||||
func Resolve(info *gjson.Json, source, target int64) Fields {
|
||||
f := Fields{SourceDeptId: source, TargetDeptId: target}
|
||||
if info != nil {
|
||||
if id := info.Get("sourceDeptId").Int64(); id > 0 {
|
||||
f.SourceDeptId = id
|
||||
}
|
||||
if id := info.Get("targetDeptId").Int64(); id > 0 {
|
||||
f.TargetDeptId = id
|
||||
}
|
||||
f.SourceDeptName = strings.TrimSpace(info.Get("sourceDeptName").String())
|
||||
f.TargetDeptName = strings.TrimSpace(info.Get("targetDeptName").String())
|
||||
f.TargetDeptMode = info.Get("targetDeptMode").String()
|
||||
}
|
||||
if f.TargetDeptMode == "" {
|
||||
if f.TargetDeptId > 0 {
|
||||
f.TargetDeptMode = "single"
|
||||
} else {
|
||||
f.TargetDeptMode = "per_row"
|
||||
}
|
||||
}
|
||||
return f
|
||||
}
|
||||
|
||||
// Fill 一页只补查一次旧数据的单位名称,不扫描卡片当前归属,不覆盖历史快照。
|
||||
func Fill(ctx context.Context, tenant string, fields []*Fields) error {
|
||||
ids := []int64{}
|
||||
for _, f := range fields {
|
||||
if f.SourceDeptName == "" {
|
||||
ids = append(ids, f.SourceDeptId)
|
||||
}
|
||||
if f.TargetDeptName == "" {
|
||||
ids = append(ids, f.TargetDeptId)
|
||||
}
|
||||
}
|
||||
units, err := Load(ctx, tenant, ids)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, f := range fields {
|
||||
if f.SourceDeptName == "" {
|
||||
f.SourceDeptName = units[f.SourceDeptId].Name
|
||||
}
|
||||
if f.TargetDeptName == "" {
|
||||
f.TargetDeptName = units[f.TargetDeptId].Name
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func Merge(info, units *gjson.Json) *gjson.Json {
|
||||
data := map[string]any{}
|
||||
if info != nil {
|
||||
for k, v := range info.Map() {
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
if units != nil {
|
||||
for k, v := range units.Map() {
|
||||
data[k] = v
|
||||
}
|
||||
}
|
||||
return gjson.New(data)
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package allocationunits
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
_ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSnapshotAndLegacyFallback(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
if err := gdb.SetConfig(gdb.Config{"default": gdb.ConfigGroup{{Type: "sqlite", Link: "sqlite::@file(:memory:)", MaxOpenConnCount: 1}}}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = g.DB().Close(ctx) })
|
||||
for _, sql := range []string{"CREATE TABLE sys_dept(dept_id INTEGER,tenant_id TEXT,dept_key TEXT,dept_name TEXT,deleted_at TEXT)", "INSERT INTO sys_dept VALUES(1,'A','a','划拨单位',NULL),(2,'A','b','接收单位',NULL),(3,'B','other','其他租户',NULL),(4,'A','gone','已删除单位','2026-01-01')"} {
|
||||
if _, err := g.DB().Exec(ctx, sql); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
snapshot, err := Snapshot(ctx, "A", 1, 2)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if _, err := g.DB().Exec(ctx, "UPDATE sys_dept SET dept_name='新名称' WHERE dept_id=2"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
frozen := Resolve(snapshot, 0, 0)
|
||||
legacy := Resolve(nil, 1, 2)
|
||||
foreign := Resolve(nil, 3, 4)
|
||||
if err := Fill(ctx, "A", []*Fields{&frozen, &legacy, &foreign}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if frozen.TargetDeptName != "接收单位" || legacy.TargetDeptName != "新名称" || foreign.SourceDeptName != "" || foreign.TargetDeptName != "" {
|
||||
t.Fatalf("快照/回退/隔离错误: %+v %+v %+v", frozen, legacy, foreign)
|
||||
}
|
||||
if f := Resolve(gjson.New(map[string]any{"sourceDeptName": "历史名称"}), 1, 0); f.TargetDeptMode != "per_row" {
|
||||
t.Fatal(f)
|
||||
}
|
||||
encoded, err := json.Marshal(frozen)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(string(encoded), "sourceDeptName") {
|
||||
t.Fatal("JSON契约缺少单位字段")
|
||||
}
|
||||
merged := Merge(gjson.New(map[string]any{"jobRole": "allocate_parent"}), snapshot)
|
||||
if merged.Get("jobRole").String() != "allocate_parent" || merged.Get("sourceDeptName").String() != "划拨单位" {
|
||||
t.Fatal(merged)
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package batchimport
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/batchmetadata"
|
||||
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
@@ -21,6 +22,9 @@ type PendingOptions struct {
|
||||
}
|
||||
|
||||
func CreatePendingUpload(ctx context.Context, req SubmitRequest, p Processor, options PendingOptions) (*Result, error) {
|
||||
if err := batchmetadata.ValidateCreation(req.SourceChannel, req.ExecutionMode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg := p.Config()
|
||||
if req.File == nil {
|
||||
return nil, gerror.New("请选择上传文件")
|
||||
@@ -59,6 +63,9 @@ func CreatePendingUpload(ctx context.Context, req SubmitRequest, p Processor, op
|
||||
}
|
||||
|
||||
func CreatePendingRows(ctx context.Context, req SubmitRequest, p Processor, rows []Row, options PendingOptions) (*Result, error) {
|
||||
if err := batchmetadata.ValidateCreation(req.SourceChannel, req.ExecutionMode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
batchNo, err := NextBatchNoContext(ctx, p.Config().BatchNoPrefix)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -103,6 +110,8 @@ func createPending(ctx context.Context, req *SubmitRequest, p Processor, rows []
|
||||
BatchStatus: consts.BatchAsyncStatusPending,
|
||||
BatchAsyncStatus: consts.BatchAsyncStatusPending,
|
||||
SourceType: req.SourceType,
|
||||
SourceChannel: batchmetadata.Channel(req.SourceChannel),
|
||||
ExecutionMode: batchmetadata.NormalizeMode(req.ExecutionMode),
|
||||
SourceBatchNo: sourceBatchNo,
|
||||
IsCrossDept: 0,
|
||||
TargetDeptId: req.TargetDeptId,
|
||||
|
||||
@@ -3,17 +3,18 @@ package batchimport
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/batchmetadata"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/do"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/entity"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility/hash"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility/iot_excelize"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/crypto/gmd5"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
@@ -25,6 +26,9 @@ import (
|
||||
)
|
||||
|
||||
func SubmitAndRun(ctx context.Context, req SubmitRequest, p Processor) (*Result, error) {
|
||||
if err := batchmetadata.ValidateCreation(req.SourceChannel, req.ExecutionMode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg := p.Config()
|
||||
if req.File == nil {
|
||||
return nil, gerror.New("请选择上传文件")
|
||||
@@ -107,6 +111,9 @@ func SubmitAndRun(ctx context.Context, req SubmitRequest, p Processor) (*Result,
|
||||
}
|
||||
|
||||
func RunRows(ctx context.Context, req SubmitRequest, p Processor, rows []Row, sourceName string) (*Result, error) {
|
||||
if err := batchmetadata.ValidateCreation(req.SourceChannel, req.ExecutionMode); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cfg := p.Config()
|
||||
batchNo, err := NextBatchNoContext(ctx, cfg.BatchNoPrefix)
|
||||
if err != nil {
|
||||
@@ -268,6 +275,8 @@ func saveBatchAndExecute(ctx context.Context, req *SubmitRequest, p Processor, r
|
||||
BatchStatus: batchStatusByImportStatus(result.ImportStatus),
|
||||
BatchAsyncStatus: batchStatusByImportStatus(result.ImportStatus),
|
||||
SourceType: req.SourceType,
|
||||
SourceChannel: batchmetadata.Channel(req.SourceChannel),
|
||||
ExecutionMode: batchmetadata.NormalizeMode(req.ExecutionMode),
|
||||
SourceBatchNo: sourceBatchNo,
|
||||
IsCrossDept: 0,
|
||||
TargetDeptId: req.TargetDeptId,
|
||||
|
||||
@@ -10,6 +10,9 @@ import (
|
||||
)
|
||||
|
||||
type SubmitRequest struct {
|
||||
SourceChannel string
|
||||
// ExecutionMode is the semantic size of the operation. Zero means the caller did not specify it.
|
||||
ExecutionMode int
|
||||
File *ghttp.UploadFile
|
||||
BizParams any
|
||||
SourceType int
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package batchmetadata
|
||||
|
||||
import "github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
const (
|
||||
Console = "console"
|
||||
MiniProgram = "mini_program"
|
||||
API = "api"
|
||||
System = "system"
|
||||
Legacy = "legacy"
|
||||
Unknown = 0
|
||||
Single = 1
|
||||
Bulk = 2
|
||||
)
|
||||
|
||||
// NormalizeMode validates the explicit execution size supplied by the business entry point.
|
||||
// Execution size is request metadata and must not be inferred from context or result counts.
|
||||
func NormalizeMode(requested int) int {
|
||||
if requested == Single || requested == Bulk {
|
||||
return requested
|
||||
}
|
||||
return Unknown
|
||||
}
|
||||
|
||||
func ValidChannel(value string) bool {
|
||||
switch value {
|
||||
case Console, MiniProgram, API, System, Legacy:
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Channel(value string) string {
|
||||
if ValidChannel(value) {
|
||||
return value
|
||||
}
|
||||
return Legacy
|
||||
}
|
||||
|
||||
func ValidMode(value int) bool { return value >= Unknown && value <= Bulk }
|
||||
|
||||
// ValidateCreation rejects missing attribution for new work; historical reads
|
||||
// and resumed work continue to use Channel/NormalizeMode for compatibility.
|
||||
func ValidateCreation(channel string, mode int) error {
|
||||
if !ValidChannel(channel) || channel == Legacy {
|
||||
return gerror.New("新建批次发起渠道无效")
|
||||
}
|
||||
if mode != Single && mode != Bulk {
|
||||
return gerror.New("新建批次必须指定单卡或批量操作规模")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package batchmetadata
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestValidateCreation(t *testing.T) {
|
||||
for _, channel := range []string{Console, MiniProgram, API, System} {
|
||||
for _, mode := range []int{Single, Bulk} {
|
||||
if err := ValidateCreation(channel, mode); err != nil {
|
||||
t.Fatal(channel, mode, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, channel := range []string{"", Legacy} {
|
||||
if err := ValidateCreation(channel, Single); err == nil {
|
||||
t.Fatal("missing new batch attribution accepted", channel)
|
||||
}
|
||||
}
|
||||
if ValidateCreation("worker", Single) == nil {
|
||||
t.Fatal("invalid source accepted")
|
||||
}
|
||||
for _, mode := range []int{-1, Unknown, 3} {
|
||||
if ValidateCreation(Console, mode) == nil {
|
||||
t.Fatal("invalid new execution size accepted", mode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestMetadata(t *testing.T) {
|
||||
if NormalizeMode(0) != Unknown {
|
||||
t.Fatal("unspecified entry mode must remain unknown")
|
||||
}
|
||||
if NormalizeMode(Single) != Single {
|
||||
t.Fatal("single entry mode lost")
|
||||
}
|
||||
if NormalizeMode(Bulk) != Bulk {
|
||||
t.Fatal("bulk entry mode lost")
|
||||
}
|
||||
if NormalizeMode(99) != Unknown {
|
||||
t.Fatal("invalid entry mode accepted")
|
||||
}
|
||||
for _, c := range []string{Console, MiniProgram, API, System, Legacy} {
|
||||
if Channel(c) != c {
|
||||
t.Fatal(c)
|
||||
}
|
||||
}
|
||||
if Channel("worker") != Legacy || Channel("") != Legacy {
|
||||
t.Fatal("unknown source was attributed")
|
||||
}
|
||||
if ValidMode(-1) || ValidMode(3) {
|
||||
t.Fatal("invalid mode accepted")
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// Package bcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package bcache
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
// Package bcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package bcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/cache"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Package cache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package cache
|
||||
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// Package file
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package file
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Package contexts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package contexts
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
||||
"slices"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package event
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package event
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package mcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
// 内存缓存管理
|
||||
package mcache
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// Package mcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package mcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/event"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
@@ -28,7 +28,29 @@ func init() {
|
||||
|
||||
}
|
||||
|
||||
type requestAccessKey struct{}
|
||||
|
||||
type requestAccessSnapshot struct {
|
||||
userId int64
|
||||
codes []string
|
||||
scopes []string
|
||||
}
|
||||
|
||||
// WithFreshUserAccess 为小程序请求读取当前权限并保留请求内快照。
|
||||
// 控制台清理本地缓存不会清理小程序进程内的权限缓存。
|
||||
func WithFreshUserAccess(ctx context.Context, userId int64) (context.Context, error) {
|
||||
codes, scopes, err := service.SysAuth().GetUserAccessCodeList(ctx, userId)
|
||||
if err != nil {
|
||||
return ctx, err
|
||||
}
|
||||
snapshot := requestAccessSnapshot{userId: userId, codes: ensureCurrentUserAccessCode(codes), scopes: scopes}
|
||||
return context.WithValue(ctx, requestAccessKey{}, snapshot), nil
|
||||
}
|
||||
|
||||
func GetUserAccessCodeList(ctx context.Context, userId int64) ([]string, []string, error) {
|
||||
if snapshot, ok := ctx.Value(requestAccessKey{}).(requestAccessSnapshot); ok && snapshot.userId == userId {
|
||||
return snapshot.codes, snapshot.scopes, nil
|
||||
}
|
||||
accessCodeList, err := Instance().Get(ctx, fmt.Sprintf(consts.MemCacheUserAccessCodeList, userId))
|
||||
menuRoleDataAccessCodeList, err := Instance().Get(ctx, fmt.Sprintf(consts.MemCacheUserRoleDataAccessCodeList, userId))
|
||||
if err != nil || accessCodeList == nil {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package mcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRequestAccessSnapshotOverridesProcessCache(t *testing.T) {
|
||||
for _, codes := range [][]string{{"cpm:iot:tSimCardAllocate:batch:submit"}, {}} {
|
||||
ctx := context.WithValue(context.Background(), requestAccessKey{}, requestAccessSnapshot{
|
||||
userId: 123, codes: ensureCurrentUserAccessCode(codes), scopes: []string{"scope-current"},
|
||||
})
|
||||
got, scopes, err := GetUserAccessCodeList(ctx, 123)
|
||||
if err != nil || !reflect.DeepEqual(got, ensureCurrentUserAccessCode(codes)) || !reflect.DeepEqual(scopes, []string{"scope-current"}) {
|
||||
t.Fatalf("request snapshot was not respected: codes=%v scopes=%v err=%v", got, scopes, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
// Package mcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package mcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/event"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/request"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
// Package mcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package mcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/event"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"time"
|
||||
)
|
||||
|
||||
func init() {
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// Package mcache
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package mcache
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/event"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"time"
|
||||
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
)
|
||||
|
||||
@@ -3,6 +3,7 @@ package rabbitmq
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -41,6 +42,25 @@ func Publish(ctx context.Context, queue string, data any) error {
|
||||
return PublishBytes(ctx, queue, body)
|
||||
}
|
||||
|
||||
func PublishDelayed(ctx context.Context, delayQueue, targetQueue string, delay time.Duration, data any) error {
|
||||
body, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
return gerror.Wrap(err, "序列化延时工单消息失败")
|
||||
}
|
||||
ch, err := channel(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer ch.Close()
|
||||
if _, err = ch.QueueDeclare(targetQueue, true, false, false, false, nil); err != nil {
|
||||
return gerror.Wrap(err, "声明工单目标队列失败")
|
||||
}
|
||||
if _, err = ch.QueueDeclare(delayQueue, true, false, false, false, amqp.Table{"x-dead-letter-exchange": "", "x-dead-letter-routing-key": targetQueue}); err != nil {
|
||||
return gerror.Wrap(err, "声明工单延时队列失败")
|
||||
}
|
||||
return gerror.Wrap(ch.PublishWithContext(ctx, "", delayQueue, false, false, amqp.Publishing{ContentType: "application/json", DeliveryMode: amqp.Persistent, Expiration: fmt.Sprintf("%d", delay.Milliseconds()), Timestamp: time.Now(), Body: body}), "发送工单延时消息失败")
|
||||
}
|
||||
|
||||
func PublishBytes(ctx context.Context, queue string, body []byte) error {
|
||||
if queue == "" {
|
||||
return gerror.New("RabbitMQ 队列名不能为空")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"context"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
||||
"net/http"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/contexts"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package websocket
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package websocket
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// Package worker
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package worker
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package worker
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package worker
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package worker
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package worker
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genconsts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genconsts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genconsts
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genconsts
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gendao
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gendao
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genmodel
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genmodel
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genmodel
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genmodel
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genmodel
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genmodel
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
gendao "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_dao"
|
||||
genmodel "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_model"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
import (
|
||||
"context"
|
||||
"runtime"
|
||||
"strings"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
genconsts "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_consts"
|
||||
genmodel "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_model"
|
||||
@@ -15,8 +17,6 @@ import (
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility/tree"
|
||||
version "git.5iot.com/iotlcm-public/iotlcm-app/utility/version"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/container/gvar"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/dao"
|
||||
genmodel "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_model"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
genmodel "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility"
|
||||
"strconv"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package genview
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// package genview
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gohtml
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gohtml
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
// package xgen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package xgen
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/library/addons"
|
||||
genconsts "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_consts"
|
||||
gendao "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgen/gen_dao"
|
||||
@@ -16,8 +18,6 @@ import (
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/model/request"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/internal/service"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package xgen
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package xgen
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// package xgorm
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package xgorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility"
|
||||
"slices"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility"
|
||||
|
||||
"reflect"
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// package xgorm
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package xgorm
|
||||
|
||||
import (
|
||||
"context"
|
||||
"slices"
|
||||
gormmodel "git.5iot.com/iotlcm-public/iotlcm-app/internal/library/xgorm/gorm_model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-app/utility/tree"
|
||||
"slices"
|
||||
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package gormmodel
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package gormmodel
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package handler
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package handler
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package handler
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package handler
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package handler
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package handler
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package handler
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package handler
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// package hook
|
||||
// @Link https://github.com/xiujiecn/xiu-admin
|
||||
// @Copyright Copyright (c) 2025 LiXiujie
|
||||
// @Author Lxj <li@xiujie.cn>
|
||||
// @Author Lxj <li@example.com>
|
||||
// @License https://github.com/xiujiecn/xiu-admin/blob/master/LICENSE
|
||||
package hook
|
||||
|
||||
|
||||
@@ -158,6 +158,10 @@ var appFeatureAccessRules = []appFeatureAccessRule{
|
||||
Permissions: []string{consts.SysCheckPermissionCurrentUser, "cpm:system:notice:list"},
|
||||
Routes: []string{"/pages/message/index", "/pages/message/views/cardDetail/index", "/pages/message/views/systemDetail/index"},
|
||||
},
|
||||
{Feature: "workorder:reply", Permissions: []string{"cpm:gen:tWoCommunication:message"}},
|
||||
{Feature: "workorder:resolve", Permissions: []string{"cpm:gen:tWoMain:resolve"}},
|
||||
{Feature: "workorder:transfer", Permissions: []string{"cpm:gen:tWoMain:transfer"}},
|
||||
{Feature: "workorder:close", Permissions: []string{"cpm:gen:tWoMain:close"}},
|
||||
{
|
||||
Feature: "workorder:list",
|
||||
Permissions: []string{"cpm:gen:tWoMain:list"},
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user