优化获取当前登录人代码
This commit is contained in:
@@ -13,7 +13,8 @@ import java.util.Properties;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
import com.central.common.utils.DateUtils;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.central.common.constant.CommonConstant;
|
||||
import com.central.generator.model.ColumnEntity;
|
||||
import com.central.generator.model.TableEntity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -135,7 +136,7 @@ public class GenUtils {
|
||||
map.put(MODULE_NAME, config.getString(MODULE_NAME));
|
||||
map.put("author", config.getString("author"));
|
||||
map.put("email", config.getString("email"));
|
||||
map.put("datetime", DateUtils.format(new Date(), DateUtils.DATE_TIME_PATTERN));
|
||||
map.put("datetime", DateUtil.format(new Date(), CommonConstant.DATETIME_FORMAT));
|
||||
VelocityContext context = new VelocityContext(map);
|
||||
|
||||
//获取模板列表
|
||||
|
||||
+1
-2
@@ -19,7 +19,6 @@ import org.springframework.cache.annotation.CachePut;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import com.central.common.utils.SysUserUtil;
|
||||
import com.central.user.service.ISysUserService;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -52,7 +51,7 @@ public class SysUserController {
|
||||
@ApiOperation(value = "根据access_token当前登录用户")
|
||||
@GetMapping("/users/current")
|
||||
public LoginAppUser getLoginAppUser(@LoginUser(isFull = true) SysUser user) {
|
||||
return SysUserUtil.getLoginAppUser(user);
|
||||
return appUserService.getLoginAppUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,6 +27,13 @@ public interface ISysUserService extends ISuperService<SysUser> {
|
||||
|
||||
LoginAppUser findByMobile(String username);
|
||||
|
||||
/**
|
||||
* 通过SysUser 转换为 LoginAppUser,把roles和permissions也查询出来
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
LoginAppUser getLoginAppUser(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 根据用户名查询用户
|
||||
* @param username
|
||||
|
||||
+2
-1
@@ -68,7 +68,8 @@ public class SysUserServiceImpl extends SuperServiceImpl<SysUserMapper, SysUser>
|
||||
return getLoginAppUser(sysUser);
|
||||
}
|
||||
|
||||
private LoginAppUser getLoginAppUser(SysUser sysUser) {
|
||||
@Override
|
||||
public LoginAppUser getLoginAppUser(SysUser sysUser) {
|
||||
if (sysUser != null) {
|
||||
LoginAppUser loginAppUser = new LoginAppUser();
|
||||
BeanUtils.copyProperties(sysUser, loginAppUser);
|
||||
|
||||
Reference in New Issue
Block a user