mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-23 05:00:23 +08:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
60a76b6cd5
@ -113,7 +113,8 @@ public class DictController {
|
|||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
|
@PreAuthorize("@pms.hasPermission('sys_dict_del')")
|
||||||
public R removeById(@PathVariable Integer id) {
|
public R removeById(@PathVariable Integer id) {
|
||||||
return sysDictService.removeDict(id);
|
sysDictService.removeDict(id);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -126,7 +127,8 @@ public class DictController {
|
|||||||
@SysLog("修改字典")
|
@SysLog("修改字典")
|
||||||
@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
|
@PreAuthorize("@pms.hasPermission('sys_dict_edit')")
|
||||||
public R updateById(@Valid @RequestBody SysDict sysDict) {
|
public R updateById(@Valid @RequestBody SysDict sysDict) {
|
||||||
return sysDictService.updateDict(sysDict);
|
sysDictService.updateDict(sysDict);
|
||||||
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +122,7 @@ public class MenuController {
|
|||||||
@DeleteMapping("/{id}")
|
@DeleteMapping("/{id}")
|
||||||
@PreAuthorize("@pms.hasPermission('sys_menu_del')")
|
@PreAuthorize("@pms.hasPermission('sys_menu_del')")
|
||||||
public R removeById(@PathVariable Integer id) {
|
public R removeById(@PathVariable Integer id) {
|
||||||
return sysMenuService.removeMenuById(id);
|
return R.ok(sysMenuService.removeMenuById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -163,7 +163,7 @@ public class UserController {
|
|||||||
@SysLog("修改个人信息")
|
@SysLog("修改个人信息")
|
||||||
@PutMapping("/edit")
|
@PutMapping("/edit")
|
||||||
public R updateUserInfo(@Valid @RequestBody UserDTO userDto) {
|
public R updateUserInfo(@Valid @RequestBody UserDTO userDto) {
|
||||||
return userService.updateUserInfo(userDto);
|
return R.ok(userService.updateUserInfo(userDto));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,7 +19,6 @@ package com.pig4cloud.pig.admin.service;
|
|||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.pig4cloud.pig.admin.api.entity.SysDict;
|
import com.pig4cloud.pig.admin.api.entity.SysDict;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典表
|
* 字典表
|
||||||
@ -35,7 +34,7 @@ public interface SysDictService extends IService<SysDict> {
|
|||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
R removeDict(Integer id);
|
void removeDict(Integer id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新字典
|
* 更新字典
|
||||||
@ -43,5 +42,5 @@ public interface SysDictService extends IService<SysDict> {
|
|||||||
* @param sysDict 字典
|
* @param sysDict 字典
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
R updateDict(SysDict sysDict);
|
void updateDict(SysDict sysDict);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||||
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
import com.pig4cloud.pig.admin.api.entity.SysMenu;
|
||||||
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
import com.pig4cloud.pig.admin.api.vo.MenuVO;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -49,9 +48,9 @@ public interface SysMenuService extends IService<SysMenu> {
|
|||||||
* 级联删除菜单
|
* 级联删除菜单
|
||||||
*
|
*
|
||||||
* @param id 菜单ID
|
* @param id 菜单ID
|
||||||
* @return 成功、失败
|
* @return true成功,false失败
|
||||||
*/
|
*/
|
||||||
R removeMenuById(Integer id);
|
Boolean removeMenuById(Integer id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新菜单信息
|
* 更新菜单信息
|
||||||
|
@ -25,7 +25,6 @@ import com.pig4cloud.pig.admin.api.dto.UserDTO;
|
|||||||
import com.pig4cloud.pig.admin.api.dto.UserInfo;
|
import com.pig4cloud.pig.admin.api.dto.UserInfo;
|
||||||
import com.pig4cloud.pig.admin.api.entity.SysUser;
|
import com.pig4cloud.pig.admin.api.entity.SysUser;
|
||||||
import com.pig4cloud.pig.admin.api.vo.UserVO;
|
import com.pig4cloud.pig.admin.api.vo.UserVO;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -65,7 +64,7 @@ public interface SysUserService extends IService<SysUser> {
|
|||||||
* @param userDto 用户信息
|
* @param userDto 用户信息
|
||||||
* @return Boolean
|
* @return Boolean
|
||||||
*/
|
*/
|
||||||
R<Boolean> updateUserInfo(UserDTO userDto);
|
Boolean updateUserInfo(UserDTO userDto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新指定用户信息
|
* 更新指定用户信息
|
||||||
|
@ -29,6 +29,7 @@ import com.pig4cloud.pig.common.core.util.R;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典项
|
* 字典项
|
||||||
@ -54,9 +55,7 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
|
|||||||
SysDictItem dictItem = this.getById(id);
|
SysDictItem dictItem = this.getById(id);
|
||||||
SysDict dict = dictService.getById(dictItem.getDictId());
|
SysDict dict = dictService.getById(dictItem.getDictId());
|
||||||
// 系统内置
|
// 系统内置
|
||||||
if (DictTypeEnum.SYSTEM.getType().equals(dict.getSystem())) {
|
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystem()),"系统内置字典项目不能删除");
|
||||||
return R.failed("系统内置字典项目不能删除");
|
|
||||||
}
|
|
||||||
return R.ok(this.removeById(id));
|
return R.ok(this.removeById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,9 +71,7 @@ public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDi
|
|||||||
//查询字典
|
//查询字典
|
||||||
SysDict dict = dictService.getById(item.getDictId());
|
SysDict dict = dictService.getById(item.getDictId());
|
||||||
// 系统内置
|
// 系统内置
|
||||||
if (DictTypeEnum.SYSTEM.getType().equals(dict.getSystem())) {
|
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystem()),"系统内置字典项目不能修改");
|
||||||
return R.failed("系统内置字典项目不能删除");
|
|
||||||
}
|
|
||||||
return R.ok(this.updateById(item));
|
return R.ok(this.updateById(item));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,11 +26,11 @@ import com.pig4cloud.pig.admin.mapper.SysDictMapper;
|
|||||||
import com.pig4cloud.pig.admin.service.SysDictService;
|
import com.pig4cloud.pig.admin.service.SysDictService;
|
||||||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||||
import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum;
|
import com.pig4cloud.pig.common.core.constant.enums.DictTypeEnum;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 字典表
|
* 字典表
|
||||||
@ -52,17 +52,13 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
@CacheEvict(value = CacheConstants.DICT_DETAILS, allEntries = true)
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public R removeDict(Integer id) {
|
public void removeDict(Integer id) {
|
||||||
SysDict dict = this.getById(id);
|
SysDict dict = this.getById(id);
|
||||||
// 系统内置
|
// 系统内置
|
||||||
if (DictTypeEnum.SYSTEM.getType().equals(dict.getSystem())) {
|
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(dict.getSystem()),"系统内置字典项目不能删除");
|
||||||
return R.failed("系统内置字典不能删除");
|
|
||||||
}
|
|
||||||
|
|
||||||
baseMapper.deleteById(id);
|
baseMapper.deleteById(id);
|
||||||
dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery()
|
dictItemMapper.delete(Wrappers.<SysDictItem>lambdaQuery()
|
||||||
.eq(SysDictItem::getDictId, id));
|
.eq(SysDictItem::getDictId, id));
|
||||||
return R.ok();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,12 +68,10 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public R updateDict(SysDict dict) {
|
public void updateDict(SysDict dict) {
|
||||||
SysDict sysDict = this.getById(dict.getId());
|
SysDict sysDict = this.getById(dict.getId());
|
||||||
// 系统内置
|
// 系统内置
|
||||||
if (DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystem())) {
|
Assert.state(!DictTypeEnum.SYSTEM.getType().equals(sysDict.getSystem()),"系统内置字典项目不能修改");
|
||||||
return R.failed("系统内置字典不能修改");
|
this.updateById(dict);
|
||||||
}
|
|
||||||
return R.ok(this.updateById(dict));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package com.pig4cloud.pig.admin.service.impl;
|
package com.pig4cloud.pig.admin.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
import com.pig4cloud.pig.admin.api.dto.MenuTree;
|
||||||
@ -32,12 +31,12 @@ import com.pig4cloud.pig.admin.service.SysMenuService;
|
|||||||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||||
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
||||||
import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum;
|
import com.pig4cloud.pig.common.core.constant.enums.MenuTypeEnum;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -63,21 +62,25 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
|||||||
return baseMapper.listMenusByRoleId(roleId);
|
return baseMapper.listMenusByRoleId(roleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 级联删除菜单
|
||||||
|
*
|
||||||
|
* @param id 菜单ID
|
||||||
|
* @return true成功,false失败
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true)
|
@CacheEvict(value = CacheConstants.MENU_DETAILS, allEntries = true)
|
||||||
public R removeMenuById(Integer id) {
|
public Boolean removeMenuById(Integer id) {
|
||||||
// 查询父节点为当前节点的节点
|
// 查询父节点为当前节点的节点
|
||||||
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query()
|
List<SysMenu> menuList = this.list(Wrappers.<SysMenu>query()
|
||||||
.lambda().eq(SysMenu::getParentId, id));
|
.lambda().eq(SysMenu::getParentId, id));
|
||||||
if (CollUtil.isNotEmpty(menuList)) {
|
Assert.isNull(menuList,"菜单含有下级不能删除");
|
||||||
return R.failed("菜单含有下级不能删除");
|
|
||||||
}
|
|
||||||
|
|
||||||
sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query()
|
sysRoleMenuMapper.delete(Wrappers.<SysRoleMenu>query()
|
||||||
.lambda().eq(SysRoleMenu::getMenuId, id));
|
.lambda().eq(SysRoleMenu::getMenuId, id));
|
||||||
//删除当前菜单及其子菜单
|
//删除当前菜单及其子菜单
|
||||||
return R.ok(this.removeById(id));
|
return this.removeById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -36,7 +36,6 @@ import com.pig4cloud.pig.admin.mapper.SysUserMapper;
|
|||||||
import com.pig4cloud.pig.admin.service.*;
|
import com.pig4cloud.pig.admin.service.*;
|
||||||
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
import com.pig4cloud.pig.common.core.constant.CacheConstants;
|
||||||
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
import com.pig4cloud.pig.common.core.constant.CommonConstants;
|
||||||
import com.pig4cloud.pig.common.core.util.R;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
@ -46,6 +45,7 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.Assert;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -161,22 +161,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
|
@CacheEvict(value = CacheConstants.USER_DETAILS, key = "#userDto.username")
|
||||||
public R<Boolean> updateUserInfo(UserDTO userDto) {
|
public Boolean updateUserInfo(UserDTO userDto) {
|
||||||
UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
|
UserVO userVO = baseMapper.getUserVoByUsername(userDto.getUsername());
|
||||||
SysUser sysUser = new SysUser();
|
SysUser sysUser = new SysUser();
|
||||||
if (StrUtil.isNotBlank(userDto.getPassword())
|
|
||||||
&& StrUtil.isNotBlank(userDto.getNewpassword1())) {
|
Assert.notNull(userDto.getPassword(),"原密码不存在");
|
||||||
if (ENCODER.matches(userDto.getPassword(), userVO.getPassword())) {
|
Assert.notNull(userDto.getNewpassword1(),"新密码不存在");
|
||||||
sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
|
Assert.state(ENCODER.matches(userDto.getPassword(), userVO.getPassword()),"原密码错误,修改失败");
|
||||||
} else {
|
sysUser.setPassword(ENCODER.encode(userDto.getNewpassword1()));
|
||||||
log.warn("原密码错误,修改密码失败:{}", userDto.getUsername());
|
|
||||||
return R.failed("原密码错误,修改失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sysUser.setPhone(userDto.getPhone());
|
sysUser.setPhone(userDto.getPhone());
|
||||||
sysUser.setUserId(userVO.getUserId());
|
sysUser.setUserId(userVO.getUserId());
|
||||||
sysUser.setAvatar(userDto.getAvatar());
|
sysUser.setAvatar(userDto.getAvatar());
|
||||||
return R.ok(this.updateById(sysUser));
|
return this.updateById(sysUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user