dev (#239)
* 优化图标和LOGO * 修改登录页面动画的速度为3 * 增加对websocket的异常处理 * 修复了用户组和用户名唯一判断错误的问题 * 提示版本号 * 修复readme错别字 * 修复单词拼写错误的问题 * 修复代码格式 * 修改Windows资产属性名称 * Docker 打包流程增加 upx 压缩 * 升级依赖文件,修改sqlite驱动为 github.com/glebarez/sqlite * 修复第一次查询「授权令牌」的错误 * 移除无关代码 * 修改docker打包脚本 * 增加打包脚本 * 增加微信群 * 修复单词拼写错误的问题 * 修复代码格式 * 修改Windows资产属性名称 * Docker 打包流程增加 upx 压缩 * 修改docker打包脚本 * - 替换 sqlite 驱动为 github.com/glebarez/sqlite - 修复数据库锁定的问题 - 修复部分代码不完善的问题 - 修复策略显示不完整的问题 - 修复编辑文件换行符的问题 - 优化guacd连接
This commit is contained in:
@ -119,7 +119,7 @@ func (s assetService) FindByIdAndDecrypt(c context.Context, id string) (model.As
|
||||
func (s assetService) CheckStatus(accessGatewayId string, ip string, port int) (active bool, err error) {
|
||||
if accessGatewayId != "" && accessGatewayId != "-" {
|
||||
g, e1 := GatewayService.GetGatewayAndReconnectById(accessGatewayId)
|
||||
if err != nil {
|
||||
if e1 != nil {
|
||||
return false, e1
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ func (s assetService) CheckStatus(accessGatewayId string, ip string, port int) (
|
||||
return active, err
|
||||
}
|
||||
|
||||
func (s assetService) Create(m echo.Map) (model.Asset, error) {
|
||||
func (s assetService) Create(ctx context.Context, m echo.Map) (model.Asset, error) {
|
||||
|
||||
data, err := json.Marshal(m)
|
||||
if err != nil {
|
||||
@ -156,29 +156,36 @@ func (s assetService) Create(m echo.Map) (model.Asset, error) {
|
||||
item.Created = utils.NowJsonTime()
|
||||
item.Active = true
|
||||
|
||||
return item, env.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
c := s.Context(tx)
|
||||
if s.InTransaction(ctx) {
|
||||
return item, s.create(ctx, item, m)
|
||||
} else {
|
||||
return item, env.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||
c := s.Context(tx)
|
||||
return s.create(c, item, m)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if err := s.Encrypt(&item, config.GlobalCfg.EncryptionPassword); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := repository.AssetRepository.Create(c, &item); err != nil {
|
||||
return err
|
||||
}
|
||||
func (s assetService) create(c context.Context, item model.Asset, m echo.Map) error {
|
||||
if err := s.Encrypt(&item, config.GlobalCfg.EncryptionPassword); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := repository.AssetRepository.Create(c, &item); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := repository.AssetRepository.UpdateAttributes(c, item.ID, item.Protocol, m); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := repository.AssetRepository.UpdateAttributes(c, item.ID, item.Protocol, m); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
go func() {
|
||||
active, _ := s.CheckStatus(item.AccessGatewayId, item.IP, item.Port)
|
||||
|
||||
if item.Active != active {
|
||||
_ = repository.AssetRepository.UpdateActiveById(context.TODO(), active, item.ID)
|
||||
}
|
||||
}()
|
||||
return nil
|
||||
})
|
||||
//go func() {
|
||||
// active, _ := s.CheckStatus(item.AccessGatewayId, item.IP, item.Port)
|
||||
//
|
||||
// if item.Active != active {
|
||||
// _ = repository.AssetRepository.UpdateActiveById(context.TODO(), active, item.ID)
|
||||
// }
|
||||
//}()
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s assetService) DeleteById(id string) error {
|
||||
|
Reference in New Issue
Block a user