service

package
v0.6.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 30, 2023 License: AGPL-3.0 Imports: 22 Imported by: 0

Documentation

Overview

Copyright (C) 2023 wwhai

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllAiBase

func AllAiBase() []model.MAiBase

获取AiBase列表

func AllApp

func AllApp() []model.MApp

获取App列表

func AllDataSchema

func AllDataSchema() []model.MDataSchema

获取DataSchema列表

func AllDevices

func AllDevices() []model.MDevice

func AllEnabledCronTask

func AllEnabledCronTask() []model.MCronTask

AllEnabledCronTask

func AllGenericGroup

func AllGenericGroup() []model.MGenericGroup

获取GenericGroup列表

func AllGoods

func AllGoods() []model.MGoods

获取Goods列表

func AllHwPort

func AllHwPort() ([]model.MHwPort, error)

* * 所有的接口列表配置 *

func AllInternalNotifies

func AllInternalNotifies() []model.MInternalNotify

* * 所有列表 *

func AllInternalNotifiesHeader

func AllInternalNotifiesHeader() []model.MInternalNotify

* * 右上角 *

func AllMInEnd

func AllMInEnd() []model.MInEnd

func AllMOutEnd

func AllMOutEnd() []model.MOutEnd

func AllMRules

func AllMRules() []model.MRule

-----------------------------------------------------------------------------------

func AllMUser

func AllMUser() []model.MUser

func AllUserLuaTemplate

func AllUserLuaTemplate() []model.MUserLuaTemplate

获取UserLuaTemplate列表

func AllVisual

func AllVisual() []model.MVisual

获取Visual列表

func BindResource

func BindResource(gid, rid string) error

* * 将别的东西加入到分组里面 *

func CheckAlreadyBinding

func CheckAlreadyBinding(gid, rid string) (uint, error)

* * 检查是否重复了 *

func CheckBindResource

func CheckBindResource(gid string) (uint, error)

* * 检查是否绑定 *

func CheckIfAlreadyInitNetWorkConfig

func CheckIfAlreadyInitNetWorkConfig() bool

* * 检查一下是否已经初始化过了,避免覆盖配置 *

func CheckIfAlreadyInitWlanConfig

func CheckIfAlreadyInitWlanConfig() bool

* * 检查是否设置了WIFI网络 *

func CleanGoodsUpload

func CleanGoodsUpload() error

* * 清理垃圾进程包 *

func CleanThumbnailUpload

func CleanThumbnailUpload() error

* * 清理缩略图 *

func ClearInternalNotifies

func ClearInternalNotifies() error

* * 清空表 *

func CountModel

func CountModel(m any) int64

* * 计算 Count *

func CountTable

func CountTable(table string) int64

* * 计算 Count *

func CreateScheduleTask

func CreateScheduleTask(data *dto.CronTaskCreateDTO) (*model.MCronTask, error)

func DeleteAiBase

func DeleteAiBase(uuid string) error

删除AiBase

func DeleteAllModbusPointByDevice

func DeleteAllModbusPointByDevice(deviceUuid string) error

DeleteAllModbusPointByDevice 删除modbus点位与设备

func DeleteAllSiemensPointByDevice

func DeleteAllSiemensPointByDevice(deviceUuid string) error

DeleteAllSiemensPointByDevice 删除Siemens点位与设备

func DeleteApp

func DeleteApp(uuid string) error

删除App

func DeleteDataSchema

func DeleteDataSchema(uuid string) error

删除DataSchema

func DeleteDevice

func DeleteDevice(uuid string) error

删除设备

func DeleteGenericGroup

func DeleteGenericGroup(uuid string) error

删除GenericGroup

func DeleteGoods

func DeleteGoods(uuid string) error

删除Goods

func DeleteMInEnd

func DeleteMInEnd(uuid string) error

func DeleteMOutEnd

func DeleteMOutEnd(uuid string) error

func DeleteMRule

func DeleteMRule(uuid string) error

func DeleteModbusPointByDevice

func DeleteModbusPointByDevice(uuids []string, deviceUuid string) error

DeleteModbusPointByDevice 删除modbus点位与设备

func DeleteScheduleTask

func DeleteScheduleTask(uuid string) error

func DeleteSiemensPointByDevice

func DeleteSiemensPointByDevice(uuids []string, deviceUuid string) error

DeleteSiemensPointByDevice 删除Siemens点位与设备

func DeleteUserLuaTemplate

func DeleteUserLuaTemplate(uuid string) error

删除UserLuaTemplate

func DeleteVisual

func DeleteVisual(uuid string) error

删除Visual

func EtcApply

func EtcApply() error

* * Ubuntu16 ETC 配置应用 * sudo service networking restart

func FindDeviceByGroup

func FindDeviceByGroup(uuid string) []model.MDevice

* * 查询分组下的设备 *

func FindUserTemplateByGroup

func FindUserTemplateByGroup(uuid string) []model.MUserLuaTemplate

*

  • 根据分组类型查询:代码模板

*~

func FindVisualByGroup

func FindVisualByGroup(uuid string) []model.MVisual

* * 查询分组吓得大屏 *

func GetAiBaseWithUUID

func GetAiBaseWithUUID(uuid string) (*model.MAiBase, error)

func GetAllMRule

func GetAllMRule() ([]model.MRule, error)

func GetAllNetConfig

func GetAllNetConfig() ([]model.MNetworkConfig, error)

* * 匹配: /etc/network/interfaces *

func GetDataSchemaWithUUID

func GetDataSchemaWithUUID(uuid string) (*model.MDataSchema, error)

func GetDefaultIpRoute

func GetDefaultIpRoute() (model.MIpRoute, error)

func GetEth0Config

func GetEth0Config() (model.MNetworkConfig, error)

* * 永远只有一个配置,eth0 *

func GetEth1Config

func GetEth1Config() (model.MNetworkConfig, error)

* * 永远只有一个配置,eth1 *

func GetGenericGroupWithUUID

func GetGenericGroupWithUUID(uuid string) (*model.MGenericGroup, error)

func GetGoodsWithUUID

func GetGoodsWithUUID(uuid string) (*model.MGoods, error)

func GetHwPortConfig

func GetHwPortConfig(uuid string) (model.MHwPort, error)

* * 获取HwPort的配置信息 *

func GetMAppWithUUID

func GetMAppWithUUID(uuid string) (*model.MApp, error)

func GetMDeviceWithUUID

func GetMDeviceWithUUID(uuid string) (*model.MDevice, error)

获取设备列表

func GetMInEnd

func GetMInEnd(uuid string) (*model.MInEnd, error)

-----------------------------------------------------------------------------------

func GetMInEndWithUUID

func GetMInEndWithUUID(uuid string) (*model.MInEnd, error)

func GetMOutEnd

func GetMOutEnd(id string) (*model.MOutEnd, error)

-----------------------------------------------------------------------------------

func GetMOutEndWithUUID

func GetMOutEndWithUUID(uuid string) (*model.MOutEnd, error)

func GetMRule

func GetMRule(uuid string) (*model.MRule, error)

-----------------------------------------------------------------------------------

func GetMRuleWithUUID

func GetMRuleWithUUID(uuid string) (*model.MRule, error)

func GetMUser

func GetMUser(username string) (*model.MUser, error)

----------------------------------------------------------------------------------- USER -----------------------------------------------------------------------------------

func GetMemPercent

func GetMemPercent() (float64, error)

func GetOsPort

func GetOsPort() []string

* * 获取系统串口, 这个接口比较特殊,当运行在特殊硬件上的时候,某些系统占用的直接不显示 * 这个接口需要兼容各类特殊硬件

func GetSiteConfig

func GetSiteConfig() (model.MSiteConfig, error)

func GetUserLuaTemplateGroup

func GetUserLuaTemplateGroup(rid string) model.MGenericGroup

* * 获取分组 *

func GetUserLuaTemplateWithUUID

func GetUserLuaTemplateWithUUID(uuid string) (model.MUserLuaTemplate, error)

* * ID获取 *

func GetVisualGroup

func GetVisualGroup(rid string) model.MGenericGroup

func GetVisualWithUUID

func GetVisualWithUUID(uuid string) (model.MVisual, error)

func GetWlan0Config

func GetWlan0Config() (model.MWifiConfig, error)

* * 获取Wlan0的配置信息 *

func InitDefaultIpRoute

func InitDefaultIpRoute() error

每次启动的时候换成最新配置的路由, 默认是ETH1 192.168.64.0 这个初始化的目的是为了配合软路由使用, 和isc-dhcp-server、dnsmasq 两个DHCP服务有关

func InitGenericGroup

func InitGenericGroup(GenericGroup *model.MGenericGroup) error

创建GenericGroup

func InitHwPortConfig

func InitHwPortConfig() error

* * 初始化网卡配置参数 *

func InitMUser

func InitMUser(o *model.MUser) error

func InitNetWorkConfig

func InitNetWorkConfig() error

* * 初始化网卡配置参数 *

func InitSiteConfig

func InitSiteConfig(SiteConfig model.MSiteConfig) error

创建 SiteConfig

func InitWlanConfig

func InitWlanConfig() error

* * 初始化网卡配置参数 *

func InsertAiBase

func InsertAiBase(AiBase *model.MAiBase) error

创建AiBase

func InsertApp

func InsertApp(app *model.MApp) error

创建App

func InsertDataSchema

func InsertDataSchema(DataSchema model.MDataSchema) error

创建DataSchema

func InsertDevice

func InsertDevice(o *model.MDevice) error

创建设备

func InsertGenericGroup

func InsertGenericGroup(GenericGroup *model.MGenericGroup) error

创建GenericGroup

func InsertGoods

func InsertGoods(goods *model.MGoods) error

创建Goods

func InsertInternalNotify

func InsertInternalNotify(m model.MInternalNotify) error

* * InsertInternalNotifies *

func InsertMInEnd

func InsertMInEnd(i *model.MInEnd) error

func InsertMOutEnd

func InsertMOutEnd(o *model.MOutEnd) error

func InsertMRule

func InsertMRule(r *model.MRule) error

func InsertMUser

func InsertMUser(o *model.MUser) error

func InsertModbusPointPosition

func InsertModbusPointPosition(P model.MModbusDataPoint) error

InsertModbusPointPosition 插入modbus点位表

func InsertModbusPointPositions

func InsertModbusPointPositions(list []model.MModbusDataPoint) error

* * Modbus点位表管理 *

InsertModbusPointPosition 插入modbus点位表

func InsertSiemensPointPosition

func InsertSiemensPointPosition(P model.MSiemensDataPoint) error

InsertSiemensPointPosition 插入Siemens点位表

func InsertSiemensPointPositions

func InsertSiemensPointPositions(list []model.MSiemensDataPoint) error

* * Siemens点位表管理 *

InsertSiemensPointPosition 插入Siemens点位表

func InsertUserLuaTemplate

func InsertUserLuaTemplate(UserLuaTemplate model.MUserLuaTemplate) error

创建UserLuaTemplate

func InsertVisual

func InsertVisual(Visual model.MVisual) error

创建Visual

func IpRouteDetail

func IpRouteDetail() (model.MIpRoute, error)

func ListByGroupType

func ListByGroupType(t string) []model.MGenericGroup

func ListScheduleTask

func ListScheduleTask(task model.MCronTask) (any, error)

func Login

func Login(username, pwd string) (*model.MUser, error)

func NetplanApply

func NetplanApply() error

* * 应用最新配置 * sudo netplan apply *

func Paginate

func Paginate(page model.PageRequest) func(db *gorm.DB) *gorm.DB

func ReBindResource

func ReBindResource(action func(tx *gorm.DB) error, Rid, Gid string) error

* * 重新绑定分组需要事务支持 *

func ReadInternalNotifies

func ReadInternalNotifies(uuid string) error

* * 点击已读 *

func ReadPageRequest

func ReadPageRequest(c *gin.Context) (*model.PageRequest, error)

func RestartNetworkManager

func RestartNetworkManager() error

RestartNetworkManager 用于重启 NetworkManager 服务

func SearchUserLuaTemplate

func SearchUserLuaTemplate(label, detail string) []model.MUserLuaTemplate

模糊查询 SELECT * FROM m_user_lua_templates WHERE label like "%%" OR detail like "%%"

func TruncateConfig

func TruncateConfig() error

*

  • 清空表:DELETE FROM table_name; DELETE FROM sqlite_sequence WHERE name='m_network_configs';

*

func TruncateWifiConfig

func TruncateWifiConfig() error

* * 清空WIFI配置表 *

func UnBindResource

func UnBindResource(gid, rid string) error

* * 取消分组绑定 *

func UpdateAiBase

func UpdateAiBase(AiBase *model.MAiBase) error

更新AiBase

func UpdateApp

func UpdateApp(app *model.MApp) error

更新App

func UpdateDataSchema

func UpdateDataSchema(DataSchema model.MDataSchema) error

更新DataSchema

func UpdateDefaultRoute

func UpdateDefaultRoute(newGatewayIP, newIface string) error

* * 删除原来的垃圾路由,换成最新的配置 *

func UpdateDevice

func UpdateDevice(uuid string, o *model.MDevice) error

更新设备信息

func UpdateEth0Config

func UpdateEth0Config(MNetworkConfig model.MNetworkConfig) error

* * 永远只更新id=0的 *

func UpdateEth1Config

func UpdateEth1Config(MNetworkConfig model.MNetworkConfig) error

* * 永远只更新id=1的 *

func UpdateGenericGroup

func UpdateGenericGroup(GenericGroup *model.MGenericGroup) error

更新GenericGroup

func UpdateGoods

func UpdateGoods(goods model.MGoods) error

更新Goods

func UpdateHwPortConfig

func UpdateHwPortConfig(MHwPort model.MHwPort) error

* * 配置WIFI HwPort *

func UpdateIpRoute

func UpdateIpRoute(IpRoute model.MIpRoute) error

更新 IpRoute

func UpdateMInEnd

func UpdateMInEnd(uuid string, i *model.MInEnd) error

func UpdateMOutEnd

func UpdateMOutEnd(uuid string, o *model.MOutEnd) error

func UpdateMRule

func UpdateMRule(uuid string, r *model.MRule) error

func UpdateMUser

func UpdateMUser(o *model.MUser) error

func UpdateModbusPoint

func UpdateModbusPoint(MModbusDataPoint model.MModbusDataPoint) error

更新DataSchema

func UpdateScheduleTask

func UpdateScheduleTask(data *dto.CronTaskUpdateDTO) (*model.MCronTask, error)

func UpdateSiemensPoint

func UpdateSiemensPoint(MSiemensDataPoint model.MSiemensDataPoint) error

更新DataSchema

func UpdateSiteConfig

func UpdateSiteConfig(SiteConfig model.MSiteConfig) error

更新 SiteConfig

func UpdateUserLuaTemplate

func UpdateUserLuaTemplate(UserLuaTemplate model.MUserLuaTemplate) error

更新UserLuaTemplate

func UpdateVisual

func UpdateVisual(Visual model.MVisual) error

更新Visual

func UpdateWlan0Config

func UpdateWlan0Config(MNetworkConfig model.MWifiConfig) error

* * 配置WIFI Wlan0 *

func WrapPageResult

func WrapPageResult(page model.PageRequest, records any, count int64) model.PageResult

Types

type HwPortDto

type HwPortDto struct {
	UUID     string
	Name     string        // 接口名称
	Type     string        // 接口类型, UART(串口),USB(USB),FD(通用文件句柄)
	Alias    string        // 别名
	Busy     bool          // 是否被占
	OccupyBy string        // 被谁占用了
	Config   UartConfigDto // 配置, 串口配置、或者网卡、USB等
}

type UartConfigDto

type UartConfigDto struct {
	Timeout  int
	Uart     string
	BaudRate int
	DataBits int
	Parity   string
	StopBits int
}

func (UartConfigDto) JsonString

func (u UartConfigDto) JsonString() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL