File tree Expand file tree Collapse file tree
framework/src/main/java/top/cadecode/uniboot/framework Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77import org .springframework .context .annotation .Bean ;
88import org .springframework .context .annotation .Configuration ;
99import top .cadecode .uniboot .framework .security .TokenAuthHolder ;
10- import top .cadecode .uniboot .system .bean .dto .SysUserDto .SysUserDetailsDto ;
1110
1211import java .util .Date ;
13- import java .util .Optional ;
1412
1513/**
1614 * mybatis 配置类
@@ -47,12 +45,7 @@ public void updateFill(MetaObject metaObject) {
4745 }
4846
4947 public void updateUser (MetaObject metaObject ) {
50- SysUserDetailsDto userDetails = TokenAuthHolder .getUserDetails (null );
51- String updateUser = Optional .ofNullable (userDetails )
52- .map (SysUserDetailsDto ::getUsername )
53- .map (String ::valueOf )
54- .orElse (null );
55- this .setFieldValByName ("updateUser" , updateUser , metaObject );
48+ this .setFieldValByName ("updateUser" , TokenAuthHolder .getUsername (), metaObject );
5649 }
5750 };
5851 }
Original file line number Diff line number Diff line change @@ -172,4 +172,15 @@ public static SysUserDetailsDto getUserDetails(Authentication authentication) {
172172 }
173173 return null ;
174174 }
175+
176+ /**
177+ * SpringSecurity相关,取出用户名
178+ */
179+ public static String getUsername () {
180+ SysUserDetailsDto userDetails = getUserDetails (null );
181+ return Optional .ofNullable (userDetails )
182+ .map (SysUserDetailsDto ::getUsername )
183+ .map (String ::valueOf )
184+ .orElse (null );
185+ }
175186}
You can’t perform that action at this time.
0 commit comments