diff --git a/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java b/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java index 3b3c77109..dd8b1370c 100644 --- a/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java +++ b/lms/nladmin-system/src/main/java/org/nl/modules/common/base/BaseDTO.java @@ -1,5 +1,6 @@ package org.nl.modules.common.base; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -19,8 +20,10 @@ public class BaseDTO implements Serializable{ private String updatedBy; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; @Override diff --git a/lms/nladmin-system/src/main/java/org/nl/system/service/dept/impl/SysDeptServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/system/service/dept/impl/SysDeptServiceImpl.java index f49ae20eb..3a771d721 100644 --- a/lms/nladmin-system/src/main/java/org/nl/system/service/dept/impl/SysDeptServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/system/service/dept/impl/SysDeptServiceImpl.java @@ -176,6 +176,7 @@ public class SysDeptServiceImpl extends ServiceImpl impl dept.setCreateId(user.getId()); dept.setCreateName(user.getPresonName()); dept.setCreateTime(new Date()); + dept.setCode(UUID.randomUUID().toString()); this.save(dept); // 清理缓存 if (StringUtils.isNotEmpty(dept.getPid())){ diff --git a/lms/nladmin-system/src/main/java/org/nl/system/service/menu/dao/SysMenu.java b/lms/nladmin-system/src/main/java/org/nl/system/service/menu/dao/SysMenu.java index b5eabc5a9..401fdc22f 100644 --- a/lms/nladmin-system/src/main/java/org/nl/system/service/menu/dao/SysMenu.java +++ b/lms/nladmin-system/src/main/java/org/nl/system/service/menu/dao/SysMenu.java @@ -1,6 +1,7 @@ package org.nl.system.service.menu.dao; import com.baomidou.mybatisplus.annotation.*; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; @@ -117,6 +118,7 @@ public class SysMenu implements Serializable { /** * 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** @@ -132,6 +134,7 @@ public class SysMenu implements Serializable { /** * 修改时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; diff --git a/lms/nladmin-system/src/main/java/org/nl/system/service/menu/impl/SysMenuServiceImpl.java b/lms/nladmin-system/src/main/java/org/nl/system/service/menu/impl/SysMenuServiceImpl.java index 1e31778e8..ad37b1294 100644 --- a/lms/nladmin-system/src/main/java/org/nl/system/service/menu/impl/SysMenuServiceImpl.java +++ b/lms/nladmin-system/src/main/java/org/nl/system/service/menu/impl/SysMenuServiceImpl.java @@ -18,6 +18,7 @@ import org.nl.modules.common.exception.BadRequestException; import org.nl.common.utils.IdUtil; import org.nl.common.utils.SecurityUtils; +import org.nl.system.service.dict.ISysDictService; import org.nl.system.service.dict.dao.Dict; import org.nl.system.service.dict.dao.mapper.SysDictMapper; import org.nl.system.service.menu.ISysMenuService; @@ -48,7 +49,7 @@ import java.util.stream.Collectors; public class SysMenuServiceImpl extends ServiceImpl implements ISysMenuService { private final SysMenuMapper baseMapper; - private final SysDictMapper sysDictMapper; + private final ISysDictService sysDictMapper; @Override public List queryAll(Map param) { @@ -131,7 +132,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl } private void addSystemTypeDict(SysMenu resources) { - Dict dict = sysDictMapper.selectOne(new QueryWrapper().eq("code", DictConstantPool.DICT_SYS_CODE).orderByDesc("value").last("limit 1")); + Dict dict = sysDictMapper.getOne(new QueryWrapper().eq("code", DictConstantPool.DICT_SYS_CODE).orderByDesc("value").last("limit 1")); Integer currentType = dict!=null?Integer.valueOf(dict.getValue())+1:1; Dict currentSysType = new Dict(); currentSysType.setDictId(IdUtil.getStringId()); @@ -140,7 +141,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl currentSysType.setLabel(resources.getTitle()); currentSysType.setValue(String.valueOf(currentType)); currentSysType.setPara1(resources.getMenuId()); - sysDictMapper.insert(currentSysType); + sysDictMapper.save(currentSysType); resources.setSystemType(String.valueOf(currentType)); } private void updateRootSystemType(SysMenu sysMenu) { @@ -171,12 +172,12 @@ public class SysMenuServiceImpl extends ServiceImpl impl baseMapper.deleteById(menu.getMenuId()); String pid = menu.getPid(); if (StringUtils.isEmpty(pid)){ - pids.add(pid); + pids.add(menu.getMenuId()); } updateSubCnt(pid); } if (!CollectionUtils.isEmpty(pids)){ - sysDictMapper.delete(new QueryWrapper().in("para1", pids).eq("code", DictConstantPool.DICT_SYS_CODE)); + sysDictMapper.remove(new QueryWrapper().in("para1", pids).eq("code", DictConstantPool.DICT_SYS_CODE)); } } @@ -185,7 +186,13 @@ public class SysMenuServiceImpl extends ServiceImpl impl public void update(SysMenu resources) { String menuId = resources.getMenuId(); SysMenu menu = baseMapper.selectById(menuId); - List allChildIds = Arrays.asList(baseMapper.findAllChild(menuId).split(",")); + String allChild = baseMapper.findAllChild(menuId); + List allChildIds = new ArrayList<>(); + allChildIds.add(menuId); + if (StringUtils.isNotEmpty(allChild)){ + allChildIds.addAll(Arrays.asList(allChild.split(","))); + } + if (allChildIds.contains(resources.getPid())){ throw new BadRequestException("上级不能为自己或自己的下级"); } @@ -208,7 +215,10 @@ public class SysMenuServiceImpl extends ServiceImpl impl String newPid = resources.getPid(); // 记录的父节点ID if (oldPid == null && newPid != null){ - sysDictMapper.delete(new QueryWrapper().eq("para1",menu.getMenuId())); + sysDictMapper.remove(new QueryWrapper().eq("para1",menu.getMenuId()).eq("code", DictConstantPool.DICT_SYS_CODE)); + } + if (!resources.getTitle().equals(menu.getTitle())){ + sysDictMapper.update(new UpdateWrapper().set("label",resources.getTitle()).eq("para1",menu.getMenuId()).eq("code", DictConstantPool.DICT_SYS_CODE)); } menu.setTitle(resources.getTitle()); menu.setComponent(resources.getComponent()); @@ -379,7 +389,7 @@ public class SysMenuServiceImpl extends ServiceImpl impl @Override public List buildMenus(String systemType) { - Dict dict = sysDictMapper.selectOne(new QueryWrapper().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType)); + Dict dict = sysDictMapper.getOne(new QueryWrapper().eq("code", DictConstantPool.DICT_SYS_CODE).eq("value", systemType)); if (dict == null || StringUtils.isEmpty(dict.getPara1())){ throw new BadRequestException("获取对应的系统菜单不存在"); } diff --git a/lms/nladmin-system/src/main/java/org/nl/system/service/role/dao/SysRole.java b/lms/nladmin-system/src/main/java/org/nl/system/service/role/dao/SysRole.java index d96df40df..5b5d342c0 100644 --- a/lms/nladmin-system/src/main/java/org/nl/system/service/role/dao/SysRole.java +++ b/lms/nladmin-system/src/main/java/org/nl/system/service/role/dao/SysRole.java @@ -3,6 +3,7 @@ package org.nl.system.service.role.dao; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; import lombok.EqualsAndHashCode; @@ -75,6 +76,7 @@ public class SysRole implements Serializable { /** * 创建时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** @@ -90,6 +92,7 @@ public class SysRole implements Serializable { /** * 修改时间 */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date updateTime; /** diff --git a/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/SysUser.java b/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/SysUser.java index 4f712fa26..e72f8a758 100644 --- a/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/SysUser.java +++ b/lms/nladmin-system/src/main/java/org/nl/system/service/user/dao/SysUser.java @@ -106,7 +106,6 @@ public class SysUser implements Serializable { * 创建时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - @JSONField(format = "yyyy-MM-dd HH:mm:ss") private Date createTime; /** diff --git a/lms/nladmin-ui/src/utils/auth.js b/lms/nladmin-ui/src/utils/auth.js index a48cd09fd..e18ebf34d 100644 --- a/lms/nladmin-ui/src/utils/auth.js +++ b/lms/nladmin-ui/src/utils/auth.js @@ -10,7 +10,6 @@ export function getToken() { export function setToken(token, rememberMe) { const domain = window.localStorage.getItem('sso_domain') - debugger if (rememberMe) { return Cookies.set(TokenKey, token, { domain:domain,path:'/',expires: Config.tokenCookieExpires }) } else return Cookies.set(TokenKey, token,{domain:domain,path:'/'})