29
29
import io .edurt .datacap .service .initializer .InitializerConfigure ;
30
30
import io .edurt .datacap .service .model .AiModel ;
31
31
import io .edurt .datacap .service .record .TreeRecord ;
32
+ import io .edurt .datacap .service .repository .BaseRepository ;
32
33
import io .edurt .datacap .service .repository .RoleRepository ;
33
34
import io .edurt .datacap .service .repository .SourceRepository ;
34
35
import io .edurt .datacap .service .repository .UserRepository ;
@@ -115,7 +116,7 @@ public CommonResponse<UserEntity> saveOrUpdate(UserEntity configure)
115
116
Set <RoleEntity > roles = new HashSet <>();
116
117
if (ObjectUtils .isEmpty (userRoles )) {
117
118
Optional <RoleEntity > userRoleOptional = roleRepository .findByName ("User" );
118
- if (! userRoleOptional .isPresent ()) {
119
+ if (userRoleOptional .isEmpty ()) {
119
120
return CommonResponse .failure (ServiceState .USER_ROLE_NOT_FOUND );
120
121
}
121
122
roles .add (userRoleOptional .get ());
@@ -135,6 +136,15 @@ public CommonResponse<UserEntity> saveOrUpdate(UserEntity configure)
135
136
return CommonResponse .success (userRepository .save (configure ));
136
137
}
137
138
139
+ @ Override
140
+ public CommonResponse <UserEntity > saveOrUpdate (BaseRepository <UserEntity , Long > repository , UserEntity configure )
141
+ {
142
+ if (configure .getId () != null ) {
143
+ configure .setPassword (encoder .encode (configure .getPassword ()));
144
+ }
145
+ return this .saveOrUpdate (configure );
146
+ }
147
+
138
148
@ AuditUserLog
139
149
@ Override
140
150
public CommonResponse <Object > authenticate (UserEntity configure )
0 commit comments