Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -16,6 +16,7 @@
|
|||||||
package org.nl.modules.security.rest;
|
package org.nl.modules.security.rest;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.wf.captcha.base.Captcha;
|
import com.wf.captcha.base.Captcha;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@@ -34,6 +35,8 @@ import org.nl.modules.security.security.TokenProvider;
|
|||||||
import org.nl.modules.security.service.OnlineUserService;
|
import org.nl.modules.security.service.OnlineUserService;
|
||||||
import org.nl.modules.security.service.dto.AuthUserDto;
|
import org.nl.modules.security.service.dto.AuthUserDto;
|
||||||
import org.nl.modules.security.service.dto.JwtUserDto;
|
import org.nl.modules.security.service.dto.JwtUserDto;
|
||||||
|
import org.nl.modules.system.service.DeptService;
|
||||||
|
import org.nl.modules.system.service.dto.DeptDto;
|
||||||
import org.nl.utils.RedisUtils;
|
import org.nl.utils.RedisUtils;
|
||||||
import org.nl.utils.RsaUtils;
|
import org.nl.utils.RsaUtils;
|
||||||
import org.nl.utils.SecurityUtils;
|
import org.nl.utils.SecurityUtils;
|
||||||
@@ -71,6 +74,7 @@ public class AuthorizationController {
|
|||||||
private final OnlineUserService onlineUserService;
|
private final OnlineUserService onlineUserService;
|
||||||
private final TokenProvider tokenProvider;
|
private final TokenProvider tokenProvider;
|
||||||
private final AuthenticationManagerBuilder authenticationManagerBuilder;
|
private final AuthenticationManagerBuilder authenticationManagerBuilder;
|
||||||
|
private final DeptService deptService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private LoginProperties loginProperties;
|
private LoginProperties loginProperties;
|
||||||
@@ -98,6 +102,15 @@ public class AuthorizationController {
|
|||||||
// 生成令牌
|
// 生成令牌
|
||||||
String token = tokenProvider.createToken(authentication);
|
String token = tokenProvider.createToken(authentication);
|
||||||
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
|
final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal();
|
||||||
|
// 判断部门是否存在或删除
|
||||||
|
if (ObjectUtil.isEmpty(jwtUserDto.getUser().getDept())) {
|
||||||
|
throw new BadRequestException("部门不存在");
|
||||||
|
}
|
||||||
|
Long id = jwtUserDto.getUser().getDept().getId();
|
||||||
|
DeptDto deptDto = deptService.findById(id);
|
||||||
|
if (!deptDto.getEnabled()) {
|
||||||
|
throw new BadRequestException("部门已禁用");
|
||||||
|
}
|
||||||
// 保存在线信息
|
// 保存在线信息
|
||||||
onlineUserService.save(jwtUserDto, token, request);
|
onlineUserService.save(jwtUserDto, token, request);
|
||||||
// 返回 token 与 用户信息
|
// 返回 token 与 用户信息
|
||||||
|
|||||||
@@ -33,4 +33,11 @@ public interface DictDetailRepository extends JpaRepository<DictDetail, Long>, J
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
List<DictDetail> findByDictName(String name);
|
List<DictDetail> findByDictName(String name);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 根据标签找数据
|
||||||
|
* @param label
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<DictDetail> findByLabelAndDict_Id(String label, Long dict_id);
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,4 +40,11 @@ public interface DictRepository extends JpaRepository<Dict, Long>, JpaSpecificat
|
|||||||
* @return /
|
* @return /
|
||||||
*/
|
*/
|
||||||
List<Dict> findByIdIn(Set<Long> ids);
|
List<Dict> findByIdIn(Set<Long> ids);
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* 根据名字找字典
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Dict findByName(String name);
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.db.Db;
|
import cn.hutool.db.Db;
|
||||||
import cn.hutool.db.Entity;
|
import cn.hutool.db.Entity;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
@@ -43,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
@@ -138,7 +140,17 @@ public class DeptServiceImpl implements DeptService {
|
|||||||
Dept dept = deptRepository.findById(resources.getId()).orElseGet(Dept::new);
|
Dept dept = deptRepository.findById(resources.getId()).orElseGet(Dept::new);
|
||||||
ValidationUtil.isNull(dept.getId(), "Dept", "id", resources.getId());
|
ValidationUtil.isNull(dept.getId(), "Dept", "id", resources.getId());
|
||||||
resources.setId(dept.getId());
|
resources.setId(dept.getId());
|
||||||
deptRepository.save(resources);
|
// 判断如果是修改了启用/禁用,要包括子级一起禁用/启用
|
||||||
|
if (resources.getEnabled() != dept.getEnabled()) {
|
||||||
|
Long id = resources.getId();
|
||||||
|
List<Dept> deptList = this.findByPid(id);
|
||||||
|
for (Dept dep : deptList) {
|
||||||
|
dep.setEnabled(resources.getEnabled());
|
||||||
|
deptRepository.save(dep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deptRepository.save(resources); // 修改
|
||||||
|
|
||||||
// 更新父节点中子节点数目
|
// 更新父节点中子节点数目
|
||||||
updateSubCnt(oldPid);
|
updateSubCnt(oldPid);
|
||||||
updateSubCnt(newPid);
|
updateSubCnt(newPid);
|
||||||
|
|||||||
@@ -15,7 +15,9 @@
|
|||||||
*/
|
*/
|
||||||
package org.nl.modules.system.service.impl;
|
package org.nl.modules.system.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.nl.exception.BadRequestException;
|
||||||
import org.nl.modules.system.domain.Dict;
|
import org.nl.modules.system.domain.Dict;
|
||||||
import org.nl.modules.system.domain.DictDetail;
|
import org.nl.modules.system.domain.DictDetail;
|
||||||
import org.nl.modules.system.repository.DictRepository;
|
import org.nl.modules.system.repository.DictRepository;
|
||||||
@@ -60,6 +62,8 @@ public class DictDetailServiceImpl implements DictDetailService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DictDetail resources) {
|
public void create(DictDetail resources) {
|
||||||
|
List<DictDetail> label = dictDetailRepository.findByLabelAndDict_Id(resources.getLabel(), resources.getDict().getId());
|
||||||
|
if (ObjectUtil.isNotEmpty(label)) throw new BadRequestException("字典[" + resources.getLabel() + "]已存在");
|
||||||
dictDetailRepository.save(resources);
|
dictDetailRepository.save(resources);
|
||||||
// 清理缓存
|
// 清理缓存
|
||||||
delCaches(resources);
|
delCaches(resources);
|
||||||
@@ -95,4 +99,4 @@ public class DictDetailServiceImpl implements DictDetailService {
|
|||||||
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
|
Dict dict = dictRepository.findById(dictDetail.getDict().getId()).orElseGet(Dict::new);
|
||||||
redisUtils.del("dict::name:" + dict.getName());
|
redisUtils.del("dict::name:" + dict.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,10 @@
|
|||||||
package org.nl.modules.system.service.impl;
|
package org.nl.modules.system.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.collection.CollectionUtil;
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.nl.exception.BadRequestException;
|
||||||
import org.nl.modules.system.domain.Dict;
|
import org.nl.modules.system.domain.Dict;
|
||||||
import org.nl.modules.system.repository.DictRepository;
|
import org.nl.modules.system.repository.DictRepository;
|
||||||
import org.nl.modules.system.service.DictService;
|
import org.nl.modules.system.service.DictService;
|
||||||
@@ -25,6 +28,8 @@ import org.nl.modules.system.service.dto.DictDto;
|
|||||||
import org.nl.modules.system.service.dto.DictQueryCriteria;
|
import org.nl.modules.system.service.dto.DictQueryCriteria;
|
||||||
import org.nl.modules.system.service.mapstruct.DictMapper;
|
import org.nl.modules.system.service.mapstruct.DictMapper;
|
||||||
import org.nl.utils.*;
|
import org.nl.utils.*;
|
||||||
|
import org.nl.wql.WQL;
|
||||||
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
@@ -63,6 +68,8 @@ public class DictServiceImpl implements DictService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(Dict resources) {
|
public void create(Dict resources) {
|
||||||
|
Dict dict = dictRepository.findByName(resources.getName());
|
||||||
|
if (ObjectUtil.isNotEmpty(dict)) throw new BadRequestException("字典[" + resources.getName() + "]已存在");
|
||||||
dictRepository.save(resources);
|
dictRepository.save(resources);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,11 +36,16 @@ import org.springframework.cache.annotation.CacheConfig;
|
|||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.jpa.domain.Specification;
|
||||||
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.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.persistence.criteria.CriteriaBuilder;
|
||||||
|
import javax.persistence.criteria.CriteriaQuery;
|
||||||
|
import javax.persistence.criteria.Predicate;
|
||||||
|
import javax.persistence.criteria.Root;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.validation.constraints.NotBlank;
|
import javax.validation.constraints.NotBlank;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|||||||
@@ -107,7 +107,7 @@
|
|||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-switch
|
<el-switch
|
||||||
v-model="scope.row.enabled"
|
v-model="scope.row.enabled"
|
||||||
:disabled="scope.row.id === 1"
|
:disabled="scope.row.id === 1 || scope.row.id === 18"
|
||||||
active-color="#409EFF"
|
active-color="#409EFF"
|
||||||
inactive-color="#F56C6C"
|
inactive-color="#F56C6C"
|
||||||
@change="changeEnabled(scope.row, scope.row.enabled,)"
|
@change="changeEnabled(scope.row, scope.row.enabled,)"
|
||||||
@@ -130,7 +130,8 @@
|
|||||||
<udOperation
|
<udOperation
|
||||||
:data="scope.row"
|
:data="scope.row"
|
||||||
:permission="permission"
|
:permission="permission"
|
||||||
:disabled-dle="scope.row.id === 1"
|
:disabled-dle="scope.row.id === 1 || scope.row.id === 18"
|
||||||
|
:disabled-edit="scope.row.id === 1 || scope.row.id === 18"
|
||||||
msg="确定删除吗,如果存在下级节点则一并删除,此操作不能撤销!"
|
msg="确定删除吗,如果存在下级节点则一并删除,此操作不能撤销!"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
@@ -284,6 +285,7 @@ export default {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
crudDept.edit(data).then(res => {
|
crudDept.edit(data).then(res => {
|
||||||
this.crud.notify(this.dict.label.dept_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
this.crud.notify(this.dict.label.dept_status[val] + '成功', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||||
|
// this.crud.toQuery()
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
data.enabled = !data.enabled
|
data.enabled = !data.enabled
|
||||||
console.log(err.response.data.message)
|
console.log(err.response.data.message)
|
||||||
|
|||||||
@@ -266,7 +266,12 @@ export default {
|
|||||||
name: 'User',
|
name: 'User',
|
||||||
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
|
components: { Treeselect, crudOperation, rrOperation, udOperation, pagination, DateRangePicker },
|
||||||
cruds() {
|
cruds() {
|
||||||
return CRUD({ title: '用户', url: 'api/users', crudMethod: { ...crudUser }})
|
return CRUD({
|
||||||
|
title: '用户',
|
||||||
|
url: 'api/users',
|
||||||
|
sort: ['deptId', 'nickName', 'username'],
|
||||||
|
crudMethod: { ...crudUser }
|
||||||
|
})
|
||||||
},
|
},
|
||||||
mixins: [presenter(), header(), form(defaultForm), crud()],
|
mixins: [presenter(), header(), form(defaultForm), crud()],
|
||||||
// 数据字典
|
// 数据字典
|
||||||
|
|||||||
Reference in New Issue
Block a user