@@ -73,9 +73,9 @@ CommandLineRunner cleanDataBase(UserRepository userRepository, FileSystemReposit
73
73
74
74
@ Bean
75
75
@ Profile ("prod" )
76
- CommandLineRunner initUserDataBaseProd (UserRepository repository ) {
76
+ CommandLineRunner initDataBaseProd (UserRepository userRepository , FileSystemRepository fileSystemRepository ) {
77
77
return args -> {
78
- LOG .info ("Preloading default admin user: {}." , repository .save (UserEntity
78
+ LOG .info ("Preloading default admin user: {}." , userRepository .save (UserEntity
79
79
.builder ()
80
80
.userId (0L )
81
81
.username ("Admin" )
@@ -84,16 +84,32 @@ CommandLineRunner initUserDataBaseProd(UserRepository repository) {
84
84
.refreshToken ("refreshToken1234" )
85
85
.groupIds (new long []{0 , 1 })
86
86
.build ()));
87
- LOG .info ("Inserting Users {}" , (repository .findAll ().size () == 1 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
87
+
88
+ LOG .info ("Preloading default fsStructure: {}." , fileSystemRepository .save (FileSystemEntity
89
+ .builder ()
90
+ .createdByUserId (0 )
91
+ .id (0 )
92
+ .isFile (false )
93
+ .path ("/" )
94
+ .itemIds (new long [0 ])
95
+ .lastUpdated (Instant .now ().getEpochSecond ())
96
+ .name ("root" )
97
+ .size (0 )
98
+ .typeId (FileSystemType .FOLDER .getId ())
99
+ .visibleForGroupIds (new long []{-1 , 0 , 1 })
100
+ .build ()));
101
+
102
+ LOG .info ("Inserting Users {}" , (userRepository .findAll ().size () == 1 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
103
+ LOG .info ("Inserting fsItems {}" , (fileSystemRepository .findAll ().size () == 1 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
88
104
};
89
105
}
90
106
91
107
@ Bean
92
108
@ Profile ("dev" )
93
- CommandLineRunner initUserDataBaseDev (UserRepository repository ) {
109
+ CommandLineRunner initDataBaseDev (UserRepository userRepository , AccessTokenRepository accessTokenRepository , FileSystemRepository fileSystemRepository ) {
94
110
return args -> {
95
111
LOG .info ("Preloading default users: {} {}." ,
96
- repository .save (UserEntity
112
+ userRepository .save (UserEntity
97
113
.builder ()
98
114
.userId (0 )
99
115
.username ("user" )
@@ -102,7 +118,7 @@ CommandLineRunner initUserDataBaseDev(UserRepository repository) {
102
118
.refreshToken ("rft1234" )
103
119
.groupIds (new long []{1 })
104
120
.build ()),
105
- repository .save (UserEntity
121
+ userRepository .save (UserEntity
106
122
.builder ()
107
123
.userId (1 )
108
124
.username ("user1" )
@@ -111,39 +127,23 @@ CommandLineRunner initUserDataBaseDev(UserRepository repository) {
111
127
.refreshToken ("rft" )
112
128
.groupIds (new long []{-1 })
113
129
.build ()));
114
- LOG .info ("Inserting Users {}" , (repository .findAll ().size () == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
115
- };
116
- }
117
-
118
- @ Bean
119
- @ Profile ("dev" )
120
- CommandLineRunner initAccessTokenDataBaseDev (AccessTokenRepository repository ) {
121
130
122
- return args -> {
123
131
LOG .info ("Preloading default tokens: {} {}" ,
124
- repository .save (AccessTokenEntity
132
+ accessTokenRepository .save (AccessTokenEntity
125
133
.builder ()
126
134
.userId (0 )
127
135
.value ("token" )
128
136
.validUntil (Instant .now ().getEpochSecond () + AccessTokenBusinessService .ACCESS_TOKEN_DURATION_IN_SECONDS )
129
137
.build ()),
130
- repository .save (AccessTokenEntity
138
+ accessTokenRepository .save (AccessTokenEntity
131
139
.builder ()
132
140
.userId (1 )
133
141
.value ("token1234" )
134
142
.validUntil (Instant .now ().getEpochSecond () + AccessTokenBusinessService .ACCESS_TOKEN_DURATION_IN_SECONDS )
135
143
.build ()));
136
- LOG .info ("Inserting token {}" , (repository .findAll ().size () == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
137
- };
138
- }
139
-
140
- @ Bean
141
- @ Profile ("dev" )
142
- CommandLineRunner initFileSystemDataBaseDev (FileSystemRepository repository ) {
143
144
144
- return args -> {
145
145
LOG .info ("Preloading default fsItems: {} {}." ,
146
- repository .save (FileSystemEntity .builder ()
146
+ fileSystemRepository .save (FileSystemEntity .builder ()
147
147
.createdByUserId (0 )
148
148
.id (0 )
149
149
.isFile (false )
@@ -155,7 +155,7 @@ CommandLineRunner initFileSystemDataBaseDev(FileSystemRepository repository) {
155
155
.typeId (FileSystemType .FOLDER .getId ())
156
156
.visibleForGroupIds (new long []{-1 , 0 , 1 })
157
157
.build ()),
158
- repository .save (FileSystemEntity .builder ()
158
+ fileSystemRepository .save (FileSystemEntity .builder ()
159
159
.createdByUserId (0 )
160
160
.id (1 )
161
161
.isFile (true )
@@ -166,7 +166,10 @@ CommandLineRunner initFileSystemDataBaseDev(FileSystemRepository repository) {
166
166
.editableFoGroupIds (new long []{0 })
167
167
.visibleForGroupIds (new long []{0 })
168
168
.build ()));
169
- LOG .info ("Inserting FileSystemItems {}" , (repository .findAll ().size () == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
169
+
170
+ LOG .info ("Inserting FileSystemItems {}" , (fileSystemRepository .findAll ().size () == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
171
+ LOG .info ("Inserting token {}" , (accessTokenRepository .findAll ().size () == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
172
+ LOG .info ("Inserting Users {}" , (userRepository .findAll ().size () == 2 ? MESSAGE_ON_SUCCESS : MESSAGE_ON_FAILURE ));
170
173
};
171
174
}
172
175
}
0 commit comments