mirror of https://github.com/elunez/eladmin
commit
0ec0379efc
|
@ -22,21 +22,10 @@ package me.zhengjie.utils;
|
|||
*/
|
||||
public interface CacheKey {
|
||||
|
||||
/**
|
||||
* 内置 用户、岗位、应用、菜单、角色 相关key
|
||||
*/
|
||||
String USER_MODIFY_TIME_KEY = "user:modify:time:key:";
|
||||
String APP_MODIFY_TIME_KEY = "app:modify:time:key:";
|
||||
String JOB_MODIFY_TIME_KEY = "job:modify:time:key:";
|
||||
String MENU_MODIFY_TIME_KEY = "menu:modify:time:key:";
|
||||
String ROLE_MODIFY_TIME_KEY = "role:modify:time:key:";
|
||||
String DEPT_MODIFY_TIME_KEY = "dept:modify:time:key:";
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
String USER_ID = "user::id:";
|
||||
String USER_NAME = "user::username:";
|
||||
/**
|
||||
* 数据
|
||||
*/
|
||||
|
|
|
@ -44,8 +44,6 @@ public class GenConfigServiceImpl implements GenConfigService {
|
|||
|
||||
@Override
|
||||
public GenConfig update(String tableName, GenConfig genConfig) {
|
||||
// 如果 api 路径为空,则自动生成路径
|
||||
if(StringUtils.isBlank(genConfig.getApiPath())){
|
||||
String separator = File.separator;
|
||||
String[] paths;
|
||||
String symbol = "\\";
|
||||
|
@ -64,7 +62,6 @@ public class GenConfigServiceImpl implements GenConfigService {
|
|||
}
|
||||
}
|
||||
genConfig.setApiPath(api.toString());
|
||||
}
|
||||
return genConfigRepository.save(genConfig);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,8 @@ public class GenUtil {
|
|||
List<String> templates = getAdminTemplateNames();
|
||||
for (String templateName : templates) {
|
||||
Template template = engine.getTemplate("generator/admin/" + templateName + ".ftl");
|
||||
String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), System.getProperty("user.dir"));
|
||||
String rootPath = System.getProperty("user.dir");
|
||||
String filePath = getAdminFilePath(templateName, genConfig, genMap.get("className").toString(), rootPath);
|
||||
|
||||
assert filePath != null;
|
||||
File file = new File(filePath);
|
||||
|
|
|
@ -73,6 +73,7 @@ public class ConfigurerAdapter implements WebMvcConfigurer {
|
|||
|
||||
@Override
|
||||
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
|
||||
// 使用 fastjson 序列化,会导致 @JsonIgnore 失效,可以使用 @JSONField(serialize = false) 替换
|
||||
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
|
||||
List<MediaType> supportMediaTypeList = new ArrayList<>();
|
||||
supportMediaTypeList.add(MediaType.APPLICATION_JSON_UTF8);
|
||||
|
|
|
@ -179,11 +179,12 @@ public class OnlineUserService {
|
|||
* @param username /
|
||||
*/
|
||||
@Async
|
||||
public void kickOutForUsername(String username) {
|
||||
public void kickOutForUsername(String username) throws Exception {
|
||||
List<OnlineUserDto> onlineUsers = getAll(username);
|
||||
for (OnlineUserDto onlineUser : onlineUsers) {
|
||||
if (onlineUser.getUserName().equals(username)) {
|
||||
kickOut(onlineUser.getKey());
|
||||
String token =EncryptUtils.desDecrypt(onlineUser.getKey());
|
||||
kickOut(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package me.zhengjie.modules.security.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import me.zhengjie.modules.system.service.dto.UserDto;
|
||||
|
@ -37,7 +37,7 @@ public class JwtUserDto implements UserDetails {
|
|||
|
||||
private final List<Long> dataScopes;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
private final List<GrantedAuthority> authorities;
|
||||
|
||||
public Set<String> getRoles() {
|
||||
|
@ -45,37 +45,37 @@ public class JwtUserDto implements UserDetails {
|
|||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
public String getPassword() {
|
||||
return user.getPassword();
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
public String getUsername() {
|
||||
return user.getUsername();
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isAccountNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isAccountNonLocked() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
@Override
|
||||
public boolean isCredentialsNonExpired() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
public boolean isEnabled() {
|
||||
return user.getEnabled();
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -44,7 +44,7 @@ public class Dept extends BaseEntity implements Serializable {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
@ManyToMany(mappedBy = "depts")
|
||||
@ApiModelProperty(value = "角色")
|
||||
private Set<Role> roles;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -44,7 +44,7 @@ public class Menu extends BaseEntity implements Serializable {
|
|||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
@ManyToMany(mappedBy = "menus")
|
||||
@ApiModelProperty(value = "菜单角色")
|
||||
private Set<Role> roles;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package me.zhengjie.modules.system.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -47,7 +47,7 @@ public class Role extends BaseEntity implements Serializable {
|
|||
@ApiModelProperty(value = "ID", hidden = true)
|
||||
private Long id;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
@ManyToMany(mappedBy = "roles")
|
||||
@ApiModelProperty(value = "用户", hidden = true)
|
||||
private Set<User> users;
|
||||
|
|
|
@ -17,7 +17,6 @@ package me.zhengjie.modules.system.domain.vo;
|
|||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ public class UserController {
|
|||
@ApiOperation("修改用户")
|
||||
@PutMapping
|
||||
@PreAuthorize("@el.check('user:edit')")
|
||||
public ResponseEntity<Object> update(@Validated(User.Update.class) @RequestBody User resources){
|
||||
public ResponseEntity<Object> update(@Validated(User.Update.class) @RequestBody User resources) throws Exception {
|
||||
checkLevel(resources);
|
||||
userService.update(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
|
|
|
@ -49,7 +49,7 @@ public interface UserService {
|
|||
* 编辑用户
|
||||
* @param resources /
|
||||
*/
|
||||
void update(User resources);
|
||||
void update(User resources) throws Exception;
|
||||
|
||||
/**
|
||||
* 删除用户
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*/
|
||||
package me.zhengjie.modules.system.service.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.zhengjie.base.BaseDTO;
|
||||
|
@ -55,12 +55,12 @@ public class UserDto extends BaseDTO implements Serializable {
|
|||
|
||||
private String avatarPath;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
private String password;
|
||||
|
||||
private Boolean enabled;
|
||||
|
||||
@JsonIgnore
|
||||
@JSONField(serialize = false)
|
||||
private Boolean isAdmin = false;
|
||||
|
||||
private Date pwdResetTime;
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
*/
|
||||
package me.zhengjie.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.zhengjie.modules.system.domain.Menu;
|
||||
import me.zhengjie.modules.system.domain.Role;
|
||||
|
@ -268,13 +268,16 @@ public class MenuServiceImpl implements MenuService {
|
|||
// 如果不是外链
|
||||
if(!menuDTO.getIFrame()){
|
||||
if(menuDTO.getPid() == null){
|
||||
menuVo.setComponent(StrUtil.isEmpty(menuDTO.getComponent())?"Layout":menuDTO.getComponent());
|
||||
}else if(!StrUtil.isEmpty(menuDTO.getComponent())){
|
||||
menuVo.setComponent(StringUtils.isEmpty(menuDTO.getComponent())?"Layout":menuDTO.getComponent());
|
||||
// 如果不是一级菜单,并且菜单类型为目录,则代表是多级菜单
|
||||
}else if(menuDTO.getType() == 0){
|
||||
menuVo.setComponent(StringUtils.isEmpty(menuDTO.getComponent())?"ParentView":menuDTO.getComponent());
|
||||
}else if(StringUtils.isNoneBlank(menuDTO.getComponent())){
|
||||
menuVo.setComponent(menuDTO.getComponent());
|
||||
}
|
||||
}
|
||||
menuVo.setMeta(new MenuMetaVo(menuDTO.getTitle(),menuDTO.getIcon(),!menuDTO.getCache()));
|
||||
if(menuDtoList !=null && menuDtoList.size()!=0){
|
||||
if(CollectionUtil.isNotEmpty(menuDtoList)){
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenus(menuDtoList));
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.File;
|
||||
|
@ -99,7 +98,7 @@ public class UserServiceImpl implements UserService {
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(User resources) {
|
||||
public void update(User resources) throws Exception {
|
||||
User user = userRepository.findById(resources.getId()).orElseGet(User::new);
|
||||
ValidationUtil.isNull(user.getId(), "User", "id", resources.getId());
|
||||
User user1 = userRepository.findByUsername(resources.getUsername());
|
||||
|
@ -120,10 +119,6 @@ public class UserServiceImpl implements UserService {
|
|||
redisUtils.del(CacheKey.MENU_USER + resources.getId());
|
||||
redisUtils.del(CacheKey.ROLE_AUTH + resources.getId());
|
||||
}
|
||||
// 如果用户名称修改
|
||||
if(!resources.getUsername().equals(user.getUsername())){
|
||||
redisUtils.del("user::username:" + user.getUsername());
|
||||
}
|
||||
// 如果用户被禁用,则清除用户登录信息
|
||||
if(!resources.getEnabled()){
|
||||
onlineUserService.kickOutForUsername(resources.getUsername());
|
||||
|
@ -170,7 +165,6 @@ public class UserServiceImpl implements UserService {
|
|||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(key = "'username:' + #p0")
|
||||
public UserDto findByName(String userName) {
|
||||
User user = userRepository.findByUsername(userName);
|
||||
if (user == null) {
|
||||
|
@ -184,7 +178,6 @@ public class UserServiceImpl implements UserService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updatePass(String username, String pass) {
|
||||
userRepository.updatePass(username, pass, new Date());
|
||||
redisUtils.del("user::username:" + username);
|
||||
flushCache(username);
|
||||
}
|
||||
|
||||
|
@ -201,7 +194,6 @@ public class UserServiceImpl implements UserService {
|
|||
FileUtil.del(oldPath);
|
||||
}
|
||||
@NotBlank String username = user.getUsername();
|
||||
redisUtils.del(CacheKey.USER_NAME + username);
|
||||
flushCache(username);
|
||||
return new HashMap<String, String>(1) {{
|
||||
put("avatar", file.getName());
|
||||
|
@ -212,7 +204,6 @@ public class UserServiceImpl implements UserService {
|
|||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateEmail(String username, String email) {
|
||||
userRepository.updateEmail(username, email);
|
||||
redisUtils.del(CacheKey.USER_NAME + username);
|
||||
flushCache(username);
|
||||
}
|
||||
|
||||
|
@ -243,7 +234,6 @@ public class UserServiceImpl implements UserService {
|
|||
*/
|
||||
public void delCaches(Long id, String username) {
|
||||
redisUtils.del(CacheKey.USER_ID + id);
|
||||
redisUtils.del(CacheKey.USER_NAME + username);
|
||||
flushCache(username);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.math.BigDecimal;
|
|||
</#if>
|
||||
import java.io.Serializable;
|
||||
<#if !auto && pkColumnType = 'Long'>
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.alibaba.fastjson.serializer.ToStringSerializer;
|
||||
</#if>
|
||||
|
||||
/**
|
||||
|
@ -45,7 +45,7 @@ public class ${className}Dto implements Serializable {
|
|||
<#if column.columnKey = 'PRI'>
|
||||
<#if !auto && pkColumnType = 'Long'>
|
||||
/** 防止精度丢失 */
|
||||
@JsonSerialize(using= ToStringSerializer.class)
|
||||
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||
</#if>
|
||||
</#if>
|
||||
private ${column.columnType} ${column.changeColumnName};
|
||||
|
|
|
@ -63,7 +63,7 @@ public class ${className} implements Serializable {
|
|||
@NotNull
|
||||
</#if>
|
||||
</#if>
|
||||
<#if (column.dateAnnotation)??>
|
||||
<#if (column.dateAnnotation)?? && column.dateAnnotation != ''>
|
||||
<#if column.dateAnnotation = 'CreationTimestamp'>
|
||||
@CreationTimestamp
|
||||
<#else>
|
||||
|
|
|
@ -369,9 +369,9 @@ INSERT INTO `sys_menu` VALUES (15, 10, 0, 1, '富文本', 'Editor', 'components/
|
|||
INSERT INTO `sys_menu` VALUES (18, 36, 3, 1, '存储管理', 'Storage', 'tools/storage/index', 34, 'qiniu', 'storage', b'0', b'0', b'0', 'storage:list', NULL, NULL, '2018-12-31 11:12:15', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (19, 36, 0, 1, '支付宝工具', 'AliPay', 'tools/aliPay/index', 37, 'alipay', 'aliPay', b'0', b'0', b'0', NULL, NULL, NULL, '2018-12-31 14:52:38', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (21, NULL, 2, 0, '多级菜单', NULL, '', 900, 'menu', 'nested', b'0', b'0', b'0', NULL, NULL, 'admin', '2019-01-04 16:22:03', '2020-06-21 17:27:35');
|
||||
INSERT INTO `sys_menu` VALUES (22, 21, 2, 1, '二级菜单1', NULL, 'nested/menu1/index', 999, 'menu', 'menu1', b'0', b'0', b'0', NULL, NULL, 'admin', '2019-01-04 16:23:29', '2020-06-21 17:27:20');
|
||||
INSERT INTO `sys_menu` VALUES (22, 21, 2, 0, '二级菜单1', NULL, '', 999, 'menu', 'menu1', b'0', b'0', b'0', NULL, NULL, 'admin', '2019-01-04 16:23:29', '2020-06-21 17:27:20');
|
||||
INSERT INTO `sys_menu` VALUES (23, 21, 0, 1, '二级菜单2', NULL, 'nested/menu2/index', 999, 'menu', 'menu2', b'0', b'0', b'0', NULL, NULL, NULL, '2019-01-04 16:23:57', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (24, 22, 0, 1, '三级菜单1', NULL, 'nested/menu1/menu1-1', 999, 'menu', 'menu1-1', b'0', b'0', b'0', NULL, NULL, NULL, '2019-01-04 16:24:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (24, 22, 0, 1, '三级菜单1', 'Test', 'nested/menu1/menu1-1', 999, 'menu', 'menu1-1', b'0', b'0', b'0', NULL, NULL, NULL, '2019-01-04 16:24:48', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (27, 22, 0, 1, '三级菜单2', NULL, 'nested/menu1/menu1-2', 999, 'menu', 'menu1-2', b'0', b'0', b'0', NULL, NULL, NULL, '2019-01-07 17:27:32', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (28, 1, 3, 1, '任务调度', 'Timing', 'system/timing/index', 999, 'timing', 'timing', b'0', b'0', b'0', 'timing:list', NULL, NULL, '2019-01-07 20:34:40', NULL);
|
||||
INSERT INTO `sys_menu` VALUES (30, 36, 0, 1, '代码生成', 'GeneratorIndex', 'generator/index', 32, 'dev', 'generator', b'0', b'1', b'0', NULL, NULL, NULL, '2019-01-11 15:45:55', NULL);
|
||||
|
|
Loading…
Reference in New Issue