Initial commit (code only without large binaries)

This commit is contained in:
robin
2026-02-15 18:58:44 +08:00
commit 35df75498f
9442 changed files with 1495866 additions and 0 deletions

View File

@@ -0,0 +1,91 @@
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package system
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
"github.com/iwind/TeaGo/actions"
"github.com/iwind/TeaGo/maps"
)
type UpdatePopupAction struct {
actionutils.ParentAction
}
func (this *UpdatePopupAction) Init() {
this.Nav("", "", "")
}
func (this *UpdatePopupAction) RunGet(params struct {
DataId string
}) {
systemResp, err := this.RPC().FormalClientSystemRPC().FindFormalClientSystemWithDataId(this.AdminContext(), &pb.FindFormalClientSystemWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
var system = systemResp.FormalClientSystem
if system == nil {
this.NotFound("formalClientSystem", 0)
return
}
if system.Codes == nil {
system.Codes = []string{}
}
this.Data["system"] = maps.Map{
"id": system.Id,
"name": system.Name,
"codes": system.Codes,
"dataId": system.DataId,
}
this.Show()
}
func (this *UpdatePopupAction) RunPost(params struct {
SystemId int64
Name string
Codes []string
DataId string
Must *actions.Must
CSRF *actionutils.CSRF
}) {
defer this.CreateLogInfo(codes.ClientSystem_LogUpdateClientSystem, params.SystemId)
params.Must.
Field("name", params.Name).
Require("请输入操作系统名称").
Field("dataId", params.DataId).
Require("请输入数据ID")
if len(params.Codes) == 0 {
params.Codes = []string{params.Name}
}
// 检查dataId
systemResp, err := this.RPC().FormalClientSystemRPC().FindFormalClientSystemWithDataId(this.AdminContext(), &pb.FindFormalClientSystemWithDataIdRequest{DataId: params.DataId})
if err != nil {
this.ErrorPage(err)
return
}
if systemResp.FormalClientSystem != nil && systemResp.FormalClientSystem.Id != params.SystemId {
this.Fail("该数据ID已经被 '" + systemResp.FormalClientSystem.Name + "'所使用,请换一个")
return
}
_, err = this.RPC().FormalClientSystemRPC().UpdateFormalClientSystem(this.AdminContext(), &pb.UpdateFormalClientSystemRequest{
FormalClientSystemId: params.SystemId,
Name: params.Name,
Codes: params.Codes,
DataId: params.DataId,
})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}