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