Skip to content

Commit 32480b4

Browse files
committed
删除内部代码
1 parent 395945c commit 32480b4

20 files changed

+16
-1688
lines changed

server/common/database.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ func dbAutoMigrate() {
7474
&model.RaspFile{},
7575
&model.RaspErrorLogs{},
7676
&model.HostResource{},
77-
&model.SystemSetting{},
7877
)
7978
if err != nil {
8079
return

server/common/init_data.go

Lines changed: 9 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package common
22

33
import (
44
"errors"
5-
"reflect"
65
"server/config"
76
"server/model"
87
"server/util"
@@ -97,7 +96,6 @@ func InitData() {
9796
menuIcon := "menu"
9897
roleIcon := "role"
9998
userIcon := "user"
100-
settingIcon := "config"
10199

102100
menus := []model.Menu{
103101
{
@@ -252,72 +250,60 @@ func InitData() {
252250
},
253251
{
254252
Model: gorm.Model{ID: systemId + 1},
255-
Name: "Settings",
256-
Title: "系统配置",
257-
Icon: &settingIcon,
258-
Path: "settings",
259-
Component: "/system/settings/index",
260-
Sort: systemId + 1,
261-
ParentId: &systemId,
262-
Roles: roles[:1],
263-
Creator: "系统",
264-
},
265-
{
266-
Model: gorm.Model{ID: systemId + 2},
267253
Name: "User",
268254
Title: "用户管理",
269255
Icon: &userIcon,
270256
Path: "user",
271257
Component: "/system/user/index",
272-
Sort: systemId + 2,
258+
Sort: systemId + 1,
273259
ParentId: &systemId,
274260
Roles: roles[:1],
275261
Creator: "系统",
276262
},
277263
{
278-
Model: gorm.Model{ID: systemId + 3},
264+
Model: gorm.Model{ID: systemId + 2},
279265
Name: "Role",
280266
Title: "角色管理",
281267
Icon: &roleIcon,
282268
Path: "role",
283269
Component: "/system/role/index",
284-
Sort: systemId + 3,
270+
Sort: systemId + 2,
285271
ParentId: &systemId,
286272
Roles: roles[:1],
287273
Creator: "系统",
288274
},
289275
{
290-
Model: gorm.Model{ID: systemId + 4},
276+
Model: gorm.Model{ID: systemId + 3},
291277
Name: "Menu",
292278
Title: "菜单管理",
293279
Icon: &menuIcon,
294280
Path: "menu",
295281
Component: "/system/menu/index",
296-
Sort: systemId + 4,
282+
Sort: systemId + 3,
297283
ParentId: &systemId,
298284
Roles: roles[:1],
299285
Creator: "系统",
300286
},
301287
{
302-
Model: gorm.Model{ID: systemId + 5},
288+
Model: gorm.Model{ID: systemId + 4},
303289
Name: "Api",
304290
Title: "接口管理",
305291
Icon: &apiIcon,
306292
Path: "api",
307293
Component: "/system/api/index",
308-
Sort: systemId + 5,
294+
Sort: systemId + 4,
309295
ParentId: &systemId,
310296
Roles: roles[:1],
311297
Creator: "系统",
312298
},
313299
{
314-
Model: gorm.Model{ID: systemId + 6},
300+
Model: gorm.Model{ID: systemId + 5},
315301
Name: "OperationLog",
316302
Title: "操作日志",
317303
Icon: &apiLogIcon,
318304
Path: "operation-log",
319305
Component: "/system/operation-log/index",
320-
Sort: systemId + 6,
306+
Sort: systemId + 5,
321307
ParentId: &systemId,
322308
Roles: roles[:1],
323309
Creator: "系统",
@@ -361,28 +347,6 @@ func InitData() {
361347
Creator: "系统",
362348
Roles: roles[:1],
363349
},
364-
//{
365-
// Model: gorm.Model{ID: 3},
366-
// Username: "user",
367-
// Password: util.GenPasswd("123456"),
368-
// Mobile: "13899999999",
369-
// Avatar: "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
370-
// Introduction: new(string),
371-
// Status: 1,
372-
// Creator: "系统",
373-
// Roles: roles[1:2],
374-
//},
375-
//{
376-
// Model: gorm.Model{ID: 4},
377-
// Username: "guest",
378-
// Password: util.GenPasswd("123456"),
379-
// Mobile: "13833333333",
380-
// Avatar: "https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif",
381-
// Introduction: new(string),
382-
// Status: 1,
383-
// Creator: "系统",
384-
// Roles: roles[1:2],
385-
//},
386350
}
387351

388352
for _, user := range users {
@@ -947,27 +911,6 @@ func InitData() {
947911
Desc: "批量删除rasp日志",
948912
Creator: "系统",
949913
},
950-
{
951-
Method: "POST",
952-
Path: "/settings/update",
953-
Category: "settings",
954-
Desc: "更新系统配置",
955-
Creator: "系统",
956-
},
957-
{
958-
Method: "GET",
959-
Path: "/settings/list",
960-
Category: "settings",
961-
Desc: "获取系统配置",
962-
Creator: "系统",
963-
},
964-
{
965-
Method: "POST",
966-
Path: "/settings/getProjectInfo",
967-
Category: "settings",
968-
Desc: "获取项目guid",
969-
Creator: "系统",
970-
},
971914
}
972915
newApi := make([]model.Api, 0)
973916
newRoleCasbin := make([]model.RoleCasbin, 0)
@@ -1029,46 +972,4 @@ func InitData() {
1029972
Log.Errorf("写入casbin数据失败:%v", err)
1030973
}
1031974
}
1032-
1033-
// 写入系统默认设置
1034-
settings := []model.SystemSetting{
1035-
{
1036-
Name: "autoUpdate",
1037-
Type: reflect.Bool.String(),
1038-
Value: "false",
1039-
},
1040-
{
1041-
Name: "reportUrl",
1042-
Type: reflect.String.String(),
1043-
Value: "",
1044-
},
1045-
{
1046-
Name: "projectGuid",
1047-
Type: reflect.String.String(),
1048-
Value: "",
1049-
},
1050-
{
1051-
Name: "updateUrl",
1052-
Type: reflect.String.String(),
1053-
Value: "ws://security.epoint.com.cn:8024",
1054-
},
1055-
{
1056-
Name: "projectType",
1057-
Type: reflect.String.String(),
1058-
Value: "live-project",
1059-
},
1060-
}
1061-
newSettings := make([]model.SystemSetting, 0)
1062-
for i, item := range settings {
1063-
item.ID = uint(i + 1)
1064-
err := DB.First(&item, item.ID).Error
1065-
if errors.Is(err, gorm.ErrRecordNotFound) {
1066-
newSettings = append(newSettings, item)
1067-
}
1068-
}
1069-
if len(newSettings) > 0 {
1070-
if err := DB.Create(&newSettings).Error; err != nil {
1071-
Log.Errorf("写入settings数据失败:%v", err)
1072-
}
1073-
}
1074975
}

server/common/install_scripts.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

server/common/logger.go

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -103,55 +103,3 @@ func InitLogger() {
103103
Log = logger.Sugar()
104104
Log.Info("初始化zap日志完成!")
105105
}
106-
107-
func InitReportLog() {
108-
now := time.Now()
109-
attackLogFileName := fmt.Sprintf("%s/report-attack/%04d-%02d-%02d.log", config.Conf.Logs.Path, now.Year(), now.Month(), now.Day())
110-
errorLogFileName := fmt.Sprintf("%s/report-error/%04d-%02d-%02d.log", config.Conf.Logs.Path, now.Year(), now.Month(), now.Day())
111-
var coreArr []zapcore.Core
112-
113-
encoderConfig := zapcore.EncoderConfig{
114-
MessageKey: "msg",
115-
LineEnding: zapcore.DefaultLineEnding,
116-
}
117-
encoder := zapcore.NewConsoleEncoder(encoderConfig)
118-
119-
// 日志级别
120-
highPriority := zap.LevelEnablerFunc(func(level zapcore.Level) bool {
121-
return level == zap.ErrorLevel
122-
})
123-
lowPriority := zap.LevelEnablerFunc(func(level zapcore.Level) bool {
124-
return level == zap.WarnLevel
125-
})
126-
127-
// info文件writeSyncer
128-
infoFileWriteSyncer := zapcore.AddSync(&lumberjack.Logger{
129-
Filename: attackLogFileName, //日志文件存放目录,如果文件夹不存在会自动创建
130-
MaxSize: config.Conf.Logs.MaxSize, //文件大小限制,单位MB
131-
MaxAge: config.Conf.Logs.MaxAge, //日志文件保留天数
132-
MaxBackups: config.Conf.Logs.MaxBackups, //最大保留日志文件数量
133-
LocalTime: false,
134-
Compress: config.Conf.Logs.Compress, //是否压缩处理
135-
})
136-
// 第三个及之后的参数为写入文件的日志级别,ErrorLevel模式只记录error级别的日志
137-
infoFileCore := zapcore.NewCore(encoder, zapcore.NewMultiWriteSyncer(infoFileWriteSyncer), lowPriority)
138-
139-
// error文件writeSyncer
140-
errorFileWriteSyncer := zapcore.AddSync(&lumberjack.Logger{
141-
Filename: errorLogFileName, //日志文件存放目录
142-
MaxSize: config.Conf.Logs.MaxSize, //文件大小限制,单位MB
143-
MaxAge: config.Conf.Logs.MaxAge, //日志文件保留天数
144-
MaxBackups: config.Conf.Logs.MaxBackups, //最大保留日志文件数量
145-
LocalTime: false,
146-
Compress: config.Conf.Logs.Compress, //是否压缩处理
147-
})
148-
// 第三个及之后的参数为写入文件的日志级别,ErrorLevel模式只记录error级别的日志
149-
errorFileCore := zapcore.NewCore(encoder, zapcore.NewMultiWriteSyncer(errorFileWriteSyncer), highPriority)
150-
151-
coreArr = append(coreArr, infoFileCore)
152-
coreArr = append(coreArr, errorFileCore)
153-
154-
logger := zap.New(zapcore.NewTee(coreArr...), zap.AddCaller())
155-
ReportLog = logger.Sugar()
156-
Log.Info("初始化上报日志完成!")
157-
}

server/config/config.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,12 @@ type SystemConfig struct {
110110
}
111111

112112
type LogsConfig struct {
113-
Level zapcore.Level `mapstructure:"level" json:"level"`
114-
Path string `mapstructure:"path" json:"path"`
115-
MaxSize int `mapstructure:"max-size" json:"maxSize"`
116-
MaxBackups int `mapstructure:"max-backups" json:"maxBackups"`
117-
MaxAge int `mapstructure:"max-age" json:"maxAge"`
118-
Compress bool `mapstructure:"compress" json:"compress"`
119-
EnableReportLog bool `mapstructure:"enable-report-log" json:"enableReportLog"`
113+
Level zapcore.Level `mapstructure:"level" json:"level"`
114+
Path string `mapstructure:"path" json:"path"`
115+
MaxSize int `mapstructure:"max-size" json:"maxSize"`
116+
MaxBackups int `mapstructure:"max-backups" json:"maxBackups"`
117+
MaxAge int `mapstructure:"max-age" json:"maxAge"`
118+
Compress bool `mapstructure:"compress" json:"compress"`
120119
}
121120

122121
type CasbinConfig struct {

0 commit comments

Comments
 (0)