rev:代码规范:去掉未使用的import与格式化
This commit is contained in:
@@ -39,9 +39,9 @@ import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@Api(tags = "系统:部门管理")
|
||||
@@ -54,61 +54,64 @@ public class DeptController {
|
||||
@GetMapping
|
||||
public ResponseEntity<Object> query(DeptQuery query) throws Exception {
|
||||
List<SysDept> list = deptService.list(query.build());
|
||||
return new ResponseEntity<>(PageUtil.toPage(list, list.size()),HttpStatus.OK);
|
||||
return new ResponseEntity<>(PageUtil.toPage(list, list.size()), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门")
|
||||
@GetMapping("/vo")
|
||||
public ResponseEntity queryvo(DeptQuery query, PageQuery pageQuery) throws Exception {
|
||||
Page deptPage = deptService.queryVo(query, pageQuery);
|
||||
return new ResponseEntity((TableDataInfo.build(deptPage)),HttpStatus.OK);
|
||||
return new ResponseEntity((TableDataInfo.build(deptPage)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation("查询所有部门树")
|
||||
@GetMapping("/allTree")
|
||||
public ResponseEntity<Object> allTree(DeptQuery query) {
|
||||
return new ResponseEntity<>(deptService.buildTree(query),HttpStatus.OK);
|
||||
return new ResponseEntity<>(deptService.buildTree(query), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询部门:根据ID获取同级与上级数据")
|
||||
@PostMapping("/superior")
|
||||
@SaCheckPermission(value = {"user:list", "dept:list"}, mode = SaMode.AND)
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody List<Long> ids) {
|
||||
if (CollectionUtils.isEmpty(ids)){
|
||||
return ResponseEntity.noContent().build();
|
||||
if (CollectionUtils.isEmpty(ids)) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
return new ResponseEntity<>(deptService.getSuperior(ids),HttpStatus.OK);
|
||||
return new ResponseEntity<>(deptService.getSuperior(ids), HttpStatus.OK);
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Log("新增部门")
|
||||
@ApiOperation("新增部门")
|
||||
@PostMapping
|
||||
// @SaCheckPermission("dept:add")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysDept resources){
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysDept resources) {
|
||||
deptService.createDept(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Log("修改部门")
|
||||
@ApiOperation("修改部门")
|
||||
@PutMapping
|
||||
// @SaCheckPermission("dept:edit")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysDept dept){
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysDept dept) {
|
||||
if (dept.getPid() != null && dept.getDeptId().equals(dept.getPid())) {
|
||||
throw new BadRequestException("上级不能为自己");
|
||||
}
|
||||
deptService.updateDept(dept);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
//
|
||||
|
||||
//
|
||||
@Log("删除部门")
|
||||
@ApiOperation("删除部门")
|
||||
@DeleteMapping
|
||||
// @SaCheckPermission("dept:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> deptIds){
|
||||
if (CollectionUtils.isEmpty(deptIds)){
|
||||
return ResponseEntity.noContent().build();
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> deptIds) {
|
||||
if (CollectionUtils.isEmpty(deptIds)) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
deptService.delateDept(deptIds);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
|
||||
@@ -39,15 +39,15 @@ public class SysDictController {
|
||||
@GetMapping
|
||||
@ApiOperation("查询字典")
|
||||
// @SaCheckPermission("dict:list")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery pageable){
|
||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAll(whereJson,pageable)), HttpStatus.OK);
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery pageable) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAll(whereJson, pageable)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("新增字典")
|
||||
@PostMapping
|
||||
@ApiOperation("新增字典")
|
||||
// @SaCheckPermission("dict:add")
|
||||
public ResponseEntity<Object> create(@RequestBody Dict dict){
|
||||
public ResponseEntity<Object> create(@RequestBody Dict dict) {
|
||||
dictService.create(dict);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class SysDictController {
|
||||
@Log("修改字典")
|
||||
@ApiOperation("修改字典")
|
||||
//@SaCheckPermission("@el.check('dict:edit')")
|
||||
public ResponseEntity<Object> updateDict(@Validated @RequestBody Dict dto){
|
||||
public ResponseEntity<Object> updateDict(@Validated @RequestBody Dict dto) {
|
||||
dictService.updateDict(dto);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@@ -65,21 +65,21 @@ public class SysDictController {
|
||||
@ApiOperation("删除字典")
|
||||
@DeleteMapping
|
||||
// @SaCheckPermission("dict:del")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
|
||||
dictService.deleteBatchByIds(ids);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/dictDetail")
|
||||
@ApiOperation("查询字典详情")
|
||||
public ResponseEntity<Object> queryDetails(@RequestParam Map criteria, PageQuery pageable){
|
||||
public ResponseEntity<Object> queryDetails(@RequestParam Map criteria, PageQuery pageable) {
|
||||
DictQuery dictQuery = JSONObject.parseObject(JSONObject.toJSONString(criteria), DictQuery.class);
|
||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAllDetail(dictQuery,pageable)),HttpStatus.OK);
|
||||
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAllDetail(dictQuery, pageable)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("查询多个字典详情")
|
||||
@GetMapping(value = "/dictDetail/map")
|
||||
public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName){
|
||||
public ResponseEntity<Object> getDictDetailMaps(@RequestParam String dictName) {
|
||||
String[] names = dictName.split("[,,]");
|
||||
Map<String, List<Dict>> dictMap = new HashMap<>(16);
|
||||
for (String name : names) {
|
||||
@@ -92,7 +92,7 @@ public class SysDictController {
|
||||
@ApiOperation("新增字典详情")
|
||||
@PostMapping("/dictDetail")
|
||||
// @SaCheckPermission("dict:add")
|
||||
public ResponseEntity<Object> createDetail(@RequestBody Dict resources){
|
||||
public ResponseEntity<Object> createDetail(@RequestBody Dict resources) {
|
||||
dictService.createDetail(resources);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class SysDictController {
|
||||
@ApiOperation("修改字典详情")
|
||||
@PutMapping("/dictDetail")
|
||||
// @SaCheckPermission("dict:edit")
|
||||
public ResponseEntity<Object> updateDetail(@RequestBody Dict resources){
|
||||
public ResponseEntity<Object> updateDetail(@RequestBody Dict resources) {
|
||||
dictService.updateDetail(resources);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class SysDictController {
|
||||
@ApiOperation("删除字典详情")
|
||||
@DeleteMapping(value = "/dictDetail/{id}")
|
||||
// @SaCheckPermission("dict:del")
|
||||
public ResponseEntity<Object> deleteDetail(@PathVariable String id){
|
||||
public ResponseEntity<Object> deleteDetail(@PathVariable String id) {
|
||||
dictService.deleteDetail(id);
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SysMenuController {
|
||||
@ApiOperation("根据用户获取菜单")
|
||||
public ResponseEntity<Object> buildMenus(@Validated String systemType) {
|
||||
//校验系统表是否存在该系统类型
|
||||
return new ResponseEntity(iSysMenuService.buildMenus(systemType),HttpStatus.OK);
|
||||
return new ResponseEntity(iSysMenuService.buildMenus(systemType), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("返回全部的菜单")
|
||||
@@ -49,6 +49,7 @@ public class SysMenuController {
|
||||
public ResponseEntity<Object> query(@RequestParam String pid) {
|
||||
return new ResponseEntity<>(iSysMenuService.getMenus(pid), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("获取菜单列表")
|
||||
@PostMapping(value = "/getMenusByRole")
|
||||
@SaCheckPermission(value = {"menu:list", "roles:list"}, mode = SaMode.AND)
|
||||
@@ -84,7 +85,7 @@ public class SysMenuController {
|
||||
@SaCheckPermission("menu:list")
|
||||
public ResponseEntity<Object> getSuperior(@RequestBody JSONObject param) {
|
||||
Set<MenuDto> menuDtos = new LinkedHashSet<>();
|
||||
String id=param.getString("ids");
|
||||
String id = param.getString("ids");
|
||||
if (StrUtil.isNotEmpty(id)) {
|
||||
menuDtos.addAll(iSysMenuService.getSuperior(iSysMenuService.doToDto(iSysMenuService.findById(id)), new ArrayList<>()));
|
||||
return new ResponseEntity<>(iSysMenuService.buildTree(new ArrayList<>(menuDtos)), HttpStatus.OK);
|
||||
@@ -105,7 +106,7 @@ public class SysMenuController {
|
||||
@ApiOperation("修改菜单")
|
||||
@PutMapping
|
||||
@SaCheckPermission("menu:edit")
|
||||
public ResponseEntity<Object> update( @RequestBody SysMenu form) {
|
||||
public ResponseEntity<Object> update(@RequestBody SysMenu form) {
|
||||
iSysMenuService.update(form);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,11 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@Api(tags = "消息通知管理")
|
||||
@@ -34,15 +35,15 @@ public class SysNoticeController {
|
||||
@Log("查询消息通知")
|
||||
@ApiOperation("查询消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:list')")
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page){
|
||||
return new ResponseEntity<>(TableDataInfo.build(noticeService.queryAll(whereJson,page)),HttpStatus.OK);
|
||||
public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
|
||||
return new ResponseEntity<>(TableDataInfo.build(noticeService.queryAll(whereJson, page)), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
@Log("新增消息通知")
|
||||
@ApiOperation("新增消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:add')")
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysNotice entity){
|
||||
public ResponseEntity<Object> create(@Validated @RequestBody SysNotice entity) {
|
||||
noticeService.create(entity);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@@ -51,7 +52,7 @@ public class SysNoticeController {
|
||||
@Log("修改消息通知")
|
||||
@ApiOperation("修改消息通知")
|
||||
//@SaCheckPermission("@el.check('sysNotice:edit')")
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysNotice entity){
|
||||
public ResponseEntity<Object> update(@Validated @RequestBody SysNotice entity) {
|
||||
noticeService.update(entity);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
@@ -67,32 +68,32 @@ public class SysNoticeController {
|
||||
|
||||
@Log("获取未读的接收消息条数")
|
||||
@GetMapping("/countByReceiveNotRead")
|
||||
public ResponseEntity<Object> countByReceiveNotRead(){
|
||||
public ResponseEntity<Object> countByReceiveNotRead() {
|
||||
return new ResponseEntity<>(noticeService.countByReceiveNotRead(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("接收消息分页")
|
||||
@GetMapping("/pageByReceive")
|
||||
public ResponseEntity<Object> pageByReceive(){
|
||||
public ResponseEntity<Object> pageByReceive() {
|
||||
return new ResponseEntity<>(noticeService.pageByReceive(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("标为已读")
|
||||
@PostMapping("/read")
|
||||
public ResponseEntity<Object> read(@RequestBody String id){
|
||||
public ResponseEntity<Object> read(@RequestBody String id) {
|
||||
noticeService.read(id);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@Log("消息详情")
|
||||
@PostMapping("/findById")
|
||||
public ResponseEntity<Object> findById(@RequestBody String id){
|
||||
public ResponseEntity<Object> findById(@RequestBody String id) {
|
||||
return new ResponseEntity<>(noticeService.getById(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Log("修改已处理")
|
||||
@PostMapping("/deal")
|
||||
public ResponseEntity<Object> deal(@RequestBody String id){
|
||||
public ResponseEntity<Object> deal(@RequestBody String id) {
|
||||
noticeService.deal(id);
|
||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package org.nl.system.controller.param;
|
||||
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import cn.dev33.satoken.annotation.SaMode;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -12,7 +10,6 @@ import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.modules.logging.annotation.Log;
|
||||
import org.nl.system.service.param.ISysParamService;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@@ -74,21 +74,21 @@ public class SysDataPermissionController {
|
||||
@GetMapping("/scopeType")
|
||||
@Log("获取数据权限范围")
|
||||
@ApiOperation("获取数据权限范围")
|
||||
public ResponseEntity<Object> getDataScopeType(){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataScopeType(),HttpStatus.OK);
|
||||
public ResponseEntity<Object> getDataScopeType() {
|
||||
return new ResponseEntity<>(dataPermissionService.getDataScopeType(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@GetMapping("/dataPermissionOption")
|
||||
@Log("获取数据权限下拉框")
|
||||
@ApiOperation("获取数据权限下拉框")
|
||||
public ResponseEntity<Object> getDataPermissionOption(){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataPermissionOption(),HttpStatus.OK);
|
||||
public ResponseEntity<Object> getDataPermissionOption() {
|
||||
return new ResponseEntity<>(dataPermissionService.getDataPermissionOption(), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/saveDataPermission")
|
||||
@Log("保存数据权限")
|
||||
@ApiOperation("保存数据权限")
|
||||
public ResponseEntity<Object> saveDataPermission(@RequestBody JSONObject datas){
|
||||
public ResponseEntity<Object> saveDataPermission(@RequestBody JSONObject datas) {
|
||||
dataPermissionService.savePermission(datas);
|
||||
return new ResponseEntity<>(HttpStatus.CREATED);
|
||||
}
|
||||
@@ -96,15 +96,15 @@ public class SysDataPermissionController {
|
||||
@PostMapping("/dataShow")
|
||||
@Log("查看数据权限")
|
||||
@ApiOperation("查看数据权限")
|
||||
public ResponseEntity<Object> getDataShow(@RequestBody String id){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataShow(id),HttpStatus.OK);
|
||||
public ResponseEntity<Object> getDataShow(@RequestBody String id) {
|
||||
return new ResponseEntity<>(dataPermissionService.getDataShow(id), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/dataDetail")
|
||||
@Log("查看数据明细")
|
||||
@ApiOperation("查看数据明细")
|
||||
public ResponseEntity<Object> getDataDetail(@RequestBody JSONObject data){
|
||||
return new ResponseEntity<>(dataPermissionService.getDataDetail(data),HttpStatus.OK);
|
||||
public ResponseEntity<Object> getDataDetail(@RequestBody JSONObject data) {
|
||||
return new ResponseEntity<>(dataPermissionService.getDataDetail(data), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ public class AuthorizationController {
|
||||
@ApiOperation("登录授权")
|
||||
@PostMapping(value = "/login")
|
||||
public ResponseEntity<Object> login(@RequestBody Map authMap) throws Exception {
|
||||
if (ObjectUtil.isEmpty(authMap)){
|
||||
return ResponseEntity.noContent().build();
|
||||
if (ObjectUtil.isEmpty(authMap)) {
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
return ResponseEntity.ok(onlineUserService.login(authMap));
|
||||
}
|
||||
@@ -82,7 +82,7 @@ public class AuthorizationController {
|
||||
jsonObject.put("user", currentUser.getUser());
|
||||
//TODO:添加部门
|
||||
List<SysDept> depts = deptService.getUserDeptRelation(currentUser.getId());
|
||||
jsonObject.put("depts",depts);
|
||||
jsonObject.put("depts", depts);
|
||||
|
||||
return ResponseEntity.ok(jsonObject);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public class AuthorizationController {
|
||||
@ApiOperation("获取指定用户信息")
|
||||
@GetMapping(value = "/userInfo")
|
||||
public ResponseEntity<Object> getUserInfo(Long loginId) {
|
||||
if (loginId != null){
|
||||
if (loginId != null) {
|
||||
WQLObject userTab = WQLObject.getWQLObject("sys_user");
|
||||
JSONObject user = userTab.query("user_id = '" + loginId + "'").uniqueResult(0);
|
||||
return ResponseEntity.ok(user);
|
||||
|
||||
@@ -42,21 +42,21 @@ public class OnlineController {
|
||||
|
||||
@ApiOperation("查询在线用户")
|
||||
@GetMapping
|
||||
// @SaCheckPermission("@el.check()")
|
||||
public ResponseEntity<Object> query(String filter, Pageable pageable){
|
||||
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable),HttpStatus.OK);
|
||||
// @SaCheckPermission("@el.check()")
|
||||
public ResponseEntity<Object> query(String filter, Pageable pageable) {
|
||||
return new ResponseEntity<>(onlineUserService.getAll(filter, pageable), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("导出数据")
|
||||
@GetMapping(value = "/download")
|
||||
// @SaCheckPermission("@el.check()")
|
||||
// @SaCheckPermission("@el.check()")
|
||||
public void download(HttpServletResponse response, String filter) throws IOException {
|
||||
onlineUserService.download(onlineUserService.getAll(filter), response);
|
||||
}
|
||||
|
||||
@ApiOperation("踢出用户")
|
||||
@DeleteMapping
|
||||
// @SaCheckPermission("@el.check()")
|
||||
// @SaCheckPermission("@el.check()")
|
||||
public ResponseEntity<Object> delete(@RequestBody Set<String> keys) throws Exception {
|
||||
for (String key : keys) {
|
||||
// 解密Key
|
||||
|
||||
@@ -23,8 +23,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.nl.common.TableDataInfo;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.utils.SecurityUtils;
|
||||
import org.nl.modules.common.config.RsaProperties;
|
||||
|
||||
@@ -22,6 +22,7 @@ import java.util.Set;
|
||||
public interface ISysDeptService extends IService<SysDept> {
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param query
|
||||
* @param pageQuery
|
||||
* @return
|
||||
@@ -30,6 +31,7 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
|
||||
/**
|
||||
* 条件查询树结构
|
||||
*
|
||||
* @param query
|
||||
* @return
|
||||
*/
|
||||
@@ -37,6 +39,7 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
|
||||
/**
|
||||
* 查询当前部门id的上级id
|
||||
*
|
||||
* @param deptIds
|
||||
* @return
|
||||
*/
|
||||
@@ -44,6 +47,7 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
|
||||
/**
|
||||
* 保存用户部门关系
|
||||
*
|
||||
* @param UserId
|
||||
* @param deptIds
|
||||
*/
|
||||
@@ -55,12 +59,14 @@ public interface ISysDeptService extends IService<SysDept> {
|
||||
|
||||
/**
|
||||
* 更新部门:同时更新节点
|
||||
*
|
||||
* @param dept
|
||||
*/
|
||||
void updateDept(SysDept dept);
|
||||
|
||||
/**
|
||||
* 删除部门及子部门
|
||||
*
|
||||
* @param deptIds
|
||||
*/
|
||||
void delateDept(Set<String> deptIds);
|
||||
|
||||
@@ -21,10 +21,12 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
* 保存依赖关系
|
||||
*
|
||||
* @param UserId
|
||||
* @param deptId
|
||||
*/
|
||||
void saveDeptRelation(@Param("user") String UserId,@Param("depts") Collection<String> deptId);
|
||||
void saveDeptRelation(@Param("user") String UserId, @Param("depts") Collection<String> deptId);
|
||||
|
||||
void delDeptRelation(@Param("user") String UserId);
|
||||
|
||||
List<Map> getDeptRelation(@Param("deptIds") Collection<String> deptIds);
|
||||
@@ -35,6 +37,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
* 跟新sub_count字段
|
||||
*
|
||||
* @param deptId
|
||||
* @return
|
||||
*/
|
||||
@@ -42,6 +45,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
|
||||
|
||||
/**
|
||||
* 返回字符串列表 split = ,
|
||||
*
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -4,37 +4,35 @@
|
||||
|
||||
<insert id="saveDeptRelation">
|
||||
replace into sys_user_dept values
|
||||
<foreach collection="depts" item="dept" separator=",">
|
||||
(#{user},#{dept})
|
||||
<foreach collection="depts" item="dept" separator=",">
|
||||
(#{user},#{dept})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="delDeptRelation">
|
||||
delete from sys_user_dept where user_id = #{user}
|
||||
delete
|
||||
from sys_user_dept
|
||||
where user_id = #{user}
|
||||
</delete>
|
||||
|
||||
<update id="updateSubCount">
|
||||
update sys_dept set sub_count =
|
||||
(select m.count from (select count(*) count from sys_dept where pid = #{pid}) as m)
|
||||
update sys_dept
|
||||
set sub_count =
|
||||
(select m.count from (select count(*) count from sys_dept where pid = #{pid}) as m)
|
||||
where dept_id = #{pid}
|
||||
</update>
|
||||
<select id="findAllChild" resultType="java.lang.String">
|
||||
SELECT
|
||||
max(t3.childId) as deptIds
|
||||
from
|
||||
(
|
||||
select *,
|
||||
if( find_in_set(t1.pid, @p) > 0,@p := concat(@p,',',id),0 ) as childId
|
||||
from
|
||||
(select dept_id as id, pid from sys_dept t order by id) t1,
|
||||
(select @p := #{pid}) t2
|
||||
) t3
|
||||
SELECT max(t3.childId) as deptIds
|
||||
from (select *,
|
||||
if(find_in_set(t1.pid, @p) > 0, @p := concat(@p,',',id), 0) as childId
|
||||
from (select dept_id as id, pid from sys_dept t order by id) t1,
|
||||
(select @p := #{pid}) t2) t3
|
||||
where childId != '0'
|
||||
</select>
|
||||
<select id="getDeptRelation" resultType="java.util.Map">
|
||||
select * from sys_user_dept where dept_id in (
|
||||
<foreach collection="deptIds" separator="," item="dept">
|
||||
<foreach collection="deptIds" separator="," item="dept">
|
||||
#{dept}
|
||||
</foreach>
|
||||
)
|
||||
)
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -23,9 +23,9 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeptTree implements Serializable {
|
||||
|
||||
@@ -26,9 +26,9 @@ import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
* @author Zheng Jie
|
||||
* @date 2019-03-25
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class DeptVo extends BaseDTO implements Serializable {
|
||||
@@ -59,14 +59,14 @@ public class DeptVo extends BaseDTO implements Serializable {
|
||||
@ApiModelProperty(value = "子节点数目", hidden = true)
|
||||
private Integer subCount = 0;
|
||||
//前端显示
|
||||
private Boolean hasChildren =Boolean.FALSE;
|
||||
private Boolean hasChildren = Boolean.FALSE;
|
||||
|
||||
private List<DeptVo> children;
|
||||
|
||||
public void setSubCount(Integer subCount) {
|
||||
this.subCount = subCount;
|
||||
if (subCount>0){
|
||||
this.hasChildren=Boolean.TRUE;
|
||||
if (subCount > 0) {
|
||||
this.hasChildren = Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
}
|
||||
|
||||
private Map<String, Object> buildTree(List<DeptTree> deptDtos) {
|
||||
List<DeptTree> trees= new ArrayList<>();
|
||||
List<DeptTree> trees = new ArrayList<>();
|
||||
Set<DeptTree> depts = new LinkedHashSet<>();
|
||||
List<String> deptNames = deptDtos.stream().map(DeptTree::getName).collect(Collectors.toList());
|
||||
boolean isChild;
|
||||
@@ -85,18 +85,18 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
|
||||
@Override
|
||||
public Page queryVo(DeptQuery query, PageQuery pageQuery) {
|
||||
if (query.getPidIsNull() == null){
|
||||
if (query.getPid() == null){
|
||||
if (query.getPidIsNull() == null) {
|
||||
if (query.getPid() == null) {
|
||||
query.setPidIsNull(true);
|
||||
}
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed() != null) {
|
||||
query.setPidIsNull(null);
|
||||
}
|
||||
}
|
||||
Page page = this.page(pageQuery.build(SysDept.class), query.build());
|
||||
page.setRecords(CopyUtil.copyList(page.getRecords(), DeptVo.class));
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed()!=null){
|
||||
page.getRecords().forEach(a->((DeptVo)a).setHasChildren(false) );
|
||||
if (StringUtils.isNotEmpty(query.getName()) || query.getIsUsed() != null) {
|
||||
page.getRecords().forEach(a -> ((DeptVo) a).setHasChildren(false));
|
||||
}
|
||||
return page;
|
||||
}
|
||||
@@ -104,15 +104,15 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
|
||||
@Override
|
||||
public void saveUserDeptRelation(String userId, Collection<String> deptIds) {
|
||||
if (StringUtils.isEmpty(userId) || CollectionUtils.isEmpty(deptIds)){
|
||||
if (StringUtils.isEmpty(userId) || CollectionUtils.isEmpty(deptIds)) {
|
||||
return;
|
||||
}
|
||||
sysDeptMapper.saveDeptRelation(userId,deptIds);
|
||||
sysDeptMapper.saveDeptRelation(userId, deptIds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDept> getUserDeptRelation(String user) {
|
||||
return sysDeptMapper.getDeptRelationByUser(user);
|
||||
return sysDeptMapper.getDeptRelationByUser(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -123,13 +123,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDept(SysDept dept) {
|
||||
if (dept == null ||StringUtils.isEmpty(dept.getDeptId())){
|
||||
if (dept == null || StringUtils.isEmpty(dept.getDeptId())) {
|
||||
return;
|
||||
}
|
||||
this.updateById(dept);
|
||||
//删除节点信息
|
||||
this.updateById(dept);
|
||||
//删除节点信息
|
||||
sysDeptMapper.updateSubCount(dept.getDeptId());
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){
|
||||
if (StringUtils.isNotEmpty(dept.getPid())) {
|
||||
sysDeptMapper.updateSubCount(dept.getPid());
|
||||
}
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delateDept(Set<String> deptIds) {
|
||||
if (CollectionUtils.isEmpty(deptIds)){
|
||||
if (CollectionUtils.isEmpty(deptIds)) {
|
||||
return;
|
||||
}
|
||||
verification(deptIds);
|
||||
@@ -147,22 +147,24 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
for (String deptId : deptIds) {
|
||||
depts.add(deptId);
|
||||
String allChild = sysDeptMapper.findAllChild(deptId);
|
||||
if (StringUtils.isNotEmpty(allChild)){
|
||||
if (StringUtils.isNotEmpty(allChild)) {
|
||||
String[] split = allChild.split(",");
|
||||
depts.addAll(Arrays.asList(split));
|
||||
}
|
||||
}
|
||||
this.remove(new QueryWrapper<SysDept>().in("dept_id", depts));
|
||||
deptList.forEach(dept -> {
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){sysDeptMapper.updateSubCount(dept.getPid());}
|
||||
if (StringUtils.isNotEmpty(dept.getPid())) {
|
||||
sysDeptMapper.updateSubCount(dept.getPid());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void verification(Set<String> depeIds) {
|
||||
if (!CollectionUtils.isEmpty(depeIds)){
|
||||
if (!CollectionUtils.isEmpty(depeIds)) {
|
||||
List<Map> deptRelation = sysDeptMapper.getDeptRelation(depeIds);
|
||||
if (!CollectionUtils.isEmpty(deptRelation)){
|
||||
if (!CollectionUtils.isEmpty(deptRelation)) {
|
||||
throw new BadRequestException("部门存在绑定的人员,请先解绑人员对应部门");
|
||||
}
|
||||
}
|
||||
@@ -179,7 +181,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
||||
dept.setCode(UUID.randomUUID().toString());
|
||||
this.save(dept);
|
||||
// 清理缓存
|
||||
if (StringUtils.isNotEmpty(dept.getPid())){
|
||||
if (StringUtils.isNotEmpty(dept.getPid())) {
|
||||
sysDeptMapper.updateSubCount(dept.getPid());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ public interface ISysDictService extends IService<Dict> {
|
||||
|
||||
/**
|
||||
* 分页查找
|
||||
*
|
||||
* @param whereJson
|
||||
* @param pageable
|
||||
* @return
|
||||
@@ -30,24 +31,28 @@ public interface ISysDictService extends IService<Dict> {
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*
|
||||
* @param dict
|
||||
*/
|
||||
void create(Dict dict);
|
||||
|
||||
/**
|
||||
* 修改字典数据
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
void updateDict(Dict dto);
|
||||
|
||||
/**
|
||||
* 通过id批量删除字典
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void deleteBatchByIds(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 分页查询获取字典明细
|
||||
*
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
@@ -56,6 +61,7 @@ public interface ISysDictService extends IService<Dict> {
|
||||
|
||||
/**
|
||||
* 获取字典明细
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
@@ -63,18 +69,21 @@ public interface ISysDictService extends IService<Dict> {
|
||||
|
||||
/**
|
||||
* 添加字典明细
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
void createDetail(Dict resources);
|
||||
|
||||
/**
|
||||
* 更新字典明细
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
void updateDetail(Dict resources);
|
||||
|
||||
/**
|
||||
* 删除字典
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deleteDetail(String id);
|
||||
|
||||
@@ -30,6 +30,7 @@ public interface ISysMenuService extends IService<SysMenu> {
|
||||
|
||||
/**
|
||||
* 条件查询
|
||||
*
|
||||
* @param query
|
||||
* @param page
|
||||
* @return
|
||||
@@ -108,7 +109,8 @@ public interface ISysMenuService extends IService<SysMenu> {
|
||||
* @return /
|
||||
*/
|
||||
List<MenuVo> buildMenus(List<MenuDto> menuDtos);
|
||||
List<MenuVo> buildMenus(List<MenuDto> menuDtos,String pid);
|
||||
|
||||
List<MenuVo> buildMenus(List<MenuDto> menuDtos, String pid);
|
||||
|
||||
List<MenuVo> buildMenus(String systemType);
|
||||
|
||||
|
||||
@@ -34,11 +34,12 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
|
||||
/**
|
||||
* 获取系统菜单
|
||||
*
|
||||
* @param userId
|
||||
* @param systemType
|
||||
* @return
|
||||
*/
|
||||
List<SysMenu> findSystemMenu(@Param("user") String userId,@Param("systemType") String systemType);
|
||||
List<SysMenu> findSystemMenu(@Param("user") String userId, @Param("systemType") String systemType);
|
||||
|
||||
/**
|
||||
* 根据用户标识获取权限列表
|
||||
@@ -56,7 +57,7 @@ public interface SysMenuMapper extends BaseMapper<SysMenu> {
|
||||
@Delete(value = "delete from sys_roles_menus where menu_id = #{menuId}")
|
||||
void untiedMenu(String menuId);
|
||||
|
||||
List<Map> getMenusByRole(@Param("systemType") String systemType, @Param("category")String category);
|
||||
List<Map> getMenusByRole(@Param("systemType") String systemType, @Param("category") String category);
|
||||
|
||||
String findAllChild(String pid);
|
||||
}
|
||||
|
||||
@@ -52,50 +52,43 @@
|
||||
AND permission != ''
|
||||
</select>
|
||||
<select id="findSystemMenu" resultType="org.nl.system.service.menu.dao.SysMenu">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_menu
|
||||
WHERE
|
||||
type != '2'
|
||||
SELECT *
|
||||
FROM sys_menu
|
||||
WHERE type != '2'
|
||||
and system_type = #{systemType}
|
||||
and
|
||||
menu_id IN (
|
||||
SELECT
|
||||
menu_id
|
||||
FROM
|
||||
sys_roles_menus
|
||||
WHERE
|
||||
role_id IN ( SELECT role_id FROM sys_users_roles where user_id = #{user})
|
||||
) order by menu_sort
|
||||
and
|
||||
menu_id IN (
|
||||
SELECT
|
||||
menu_id
|
||||
FROM
|
||||
sys_roles_menus
|
||||
WHERE
|
||||
role_id IN ( SELECT role_id FROM sys_users_roles where user_id = #{user})
|
||||
)
|
||||
order by menu_sort
|
||||
</select>
|
||||
<select id="getMenusByRole" resultType="java.util.Map">
|
||||
SELECT
|
||||
m.* ,
|
||||
(CASE WHEN rm.menu_id IS NULL THEN '0' ELSE '1' END ) AS is_checked ,
|
||||
(CASE WHEN 0 >= sub_count THEN true ELSE false END ) AS leaf
|
||||
(CASE WHEN 0 >= sub_count THEN true ELSE false END ) AS leaf
|
||||
FROM
|
||||
sys_menu m
|
||||
LEFT JOIN sys_roles_menus rm ON m.menu_id = rm.menu_id
|
||||
where (pid is null or pid=0)
|
||||
<if test="systemType != null">
|
||||
and system_type = #{systemType}
|
||||
and system_type = #{systemType}
|
||||
</if>
|
||||
<if test="category != null">
|
||||
and category = #{category}
|
||||
</if>
|
||||
</select>
|
||||
<select id="findAllChild" resultType="java.lang.String">
|
||||
SELECT
|
||||
max(t3.childId) as menus
|
||||
from
|
||||
(
|
||||
select *,
|
||||
if( find_in_set(t1.pid, @p) > 0,@p := concat(@p,',',id),0 ) as childId
|
||||
from
|
||||
(select menu_id as id, pid from sys_menu t order by id) t1,
|
||||
(select @p := #{pid}) t2
|
||||
) t3
|
||||
SELECT max(t3.childId) as menus
|
||||
from (select *,
|
||||
if(find_in_set(t1.pid, @p) > 0, @p := concat(@p,',',id), 0) as childId
|
||||
from (select menu_id as id, pid from sys_menu t order by id) t1,
|
||||
(select @p := #{pid}) t2) t3
|
||||
where childId != '0'
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.nl.system.service.menu.dao.SysMenu;
|
||||
public class MenuQuery extends BaseQuery<SysMenu> {
|
||||
private String pid = "";
|
||||
private String systemType;
|
||||
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
this.doP.put("pid", QParam.builder().k(new String[]{"pid"}).type(QueryTEnum.OREQ).build());
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 构建前端路由时用到
|
||||
*
|
||||
* @author Zheng Jie
|
||||
* @date 2018-12-20
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
@Override
|
||||
public List query(MenuQuery query, PageQuery page) {
|
||||
if (StringUtils.isNotEmpty(query.getBlurry())){
|
||||
if (StringUtils.isNotEmpty(query.getBlurry())) {
|
||||
query.setPid(null);
|
||||
}
|
||||
Page<SysMenu> menuPage = this.page(page.build(SysMenu.class), query.build());
|
||||
@@ -132,7 +132,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
private void addSystemTypeDict(SysMenu resources) {
|
||||
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();
|
||||
currentSysType.setDictId(IdUtil.getStringId());
|
||||
currentSysType.setCode(DictConstantPool.DICT_SYS_CODE);
|
||||
@@ -143,15 +143,17 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
sysDictMapper.save(currentSysType);
|
||||
resources.setSystemType(String.valueOf(currentType));
|
||||
}
|
||||
|
||||
private void updateRootSystemType(SysMenu sysMenu) {
|
||||
String rootMenuId = this.findRootMenuId(sysMenu.getMenuId());
|
||||
if (sysMenu.getMenuId().equals(rootMenuId)){
|
||||
if (sysMenu.getMenuId().equals(rootMenuId)) {
|
||||
return;
|
||||
}
|
||||
SysMenu rootMenu = this.findById(rootMenuId);
|
||||
sysMenu.setSystemType(rootMenu.getSystemType());
|
||||
this.updateById(sysMenu);
|
||||
}
|
||||
|
||||
private String findRootMenuId(String menuId) {
|
||||
SysMenu sysMenu = this.findById(menuId);
|
||||
if (StrUtil.isEmpty(sysMenu.getPid())) {
|
||||
@@ -170,12 +172,12 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
baseMapper.untiedMenu(menu.getMenuId());
|
||||
baseMapper.deleteById(menu.getMenuId());
|
||||
String pid = menu.getPid();
|
||||
if (StringUtils.isEmpty(pid)){
|
||||
if (StringUtils.isEmpty(pid)) {
|
||||
pids.add(menu.getMenuId());
|
||||
}
|
||||
updateSubCnt(pid);
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(pids)){
|
||||
if (!CollectionUtils.isEmpty(pids)) {
|
||||
sysDictMapper.remove(new QueryWrapper<Dict>().in("para1", pids).eq("code", DictConstantPool.DICT_SYS_CODE));
|
||||
}
|
||||
}
|
||||
@@ -188,11 +190,11 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
String allChild = baseMapper.findAllChild(menuId);
|
||||
List<String> allChildIds = new ArrayList<>();
|
||||
allChildIds.add(menuId);
|
||||
if (StringUtils.isNotEmpty(allChild)){
|
||||
if (StringUtils.isNotEmpty(allChild)) {
|
||||
allChildIds.addAll(Arrays.asList(allChild.split(",")));
|
||||
}
|
||||
|
||||
if (allChildIds.contains(resources.getPid())){
|
||||
if (allChildIds.contains(resources.getPid())) {
|
||||
throw new BadRequestException("上级不能为自己或自己的下级");
|
||||
}
|
||||
if (resources.getIframe()) {
|
||||
@@ -204,20 +206,20 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
if (resources.getPid().equals("0")) {
|
||||
resources.setPid(null);
|
||||
if (StringUtils.isNotEmpty(menu.getPid())){
|
||||
if (StringUtils.isNotEmpty(menu.getPid())) {
|
||||
addSystemTypeDict(resources);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
resources.setSystemType(this.findById(resources.getPid()).getSystemType());
|
||||
}
|
||||
String oldPid = menu.getPid();
|
||||
String newPid = resources.getPid();
|
||||
// 记录的父节点ID
|
||||
if (oldPid == null && newPid != null){
|
||||
sysDictMapper.remove(new QueryWrapper<Dict>().eq("para1",menu.getMenuId()).eq("code", DictConstantPool.DICT_SYS_CODE));
|
||||
if (oldPid == null && newPid != null) {
|
||||
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));
|
||||
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.setComponent(resources.getComponent());
|
||||
@@ -236,8 +238,8 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
updateSubCnt(oldPid);
|
||||
updateSubCnt(newPid);
|
||||
//更新SystemType
|
||||
if (!resources.getSystemType().equals(menu.getSystemType())){
|
||||
this.update(new UpdateWrapper<SysMenu>().set(DictConstantPool.DICT_SYS_CODE,resources.getSystemType()).in("menu_id",allChildIds));
|
||||
if (!resources.getSystemType().equals(menu.getSystemType())) {
|
||||
this.update(new UpdateWrapper<SysMenu>().set(DictConstantPool.DICT_SYS_CODE, resources.getSystemType()).in("menu_id", allChildIds));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -356,7 +358,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
public MenuDto doToDto(SysMenu entity) {
|
||||
|
||||
MenuDto menuDto = new MenuDto();
|
||||
if (ObjectUtil.isEmpty(entity)){
|
||||
if (ObjectUtil.isEmpty(entity)) {
|
||||
return menuDto;
|
||||
}
|
||||
menuDto.setMenuId(entity.getMenuId());
|
||||
@@ -391,15 +393,15 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
@Override
|
||||
public List<MenuVo> buildMenus(String 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("获取对应的系统菜单不存在");
|
||||
}
|
||||
String pid = dict.getPara1();
|
||||
List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(),systemType);
|
||||
List<SysMenu> menuDtoList = baseMapper.findSystemMenu(SecurityUtils.getCurrentUserId(), systemType);
|
||||
//移除系统级菜单
|
||||
menuDtoList.removeIf(a->a.getMenuId().equals(pid));
|
||||
menuDtoList.removeIf(a -> a.getMenuId().equals(pid));
|
||||
List<MenuDto> menuDtos = this.buildTree(CopyUtil.copyList(menuDtoList, MenuDto.class));
|
||||
return this.buildMenus(menuDtos,pid);
|
||||
return this.buildMenus(menuDtos, pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -412,7 +414,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
MenuVo menuVo = new MenuVo();
|
||||
menuVo.setName(ObjectUtil.isNotEmpty(menuDTO.getComponentName()) ? menuDTO.getComponentName() : menuDTO.getTitle());
|
||||
// 一级目录需要加斜杠,不然会报警告
|
||||
menuVo.setPath(pid.equals(menuDTO.getPid())? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setPath(pid.equals(menuDTO.getPid()) ? "/" + menuDTO.getPath() : menuDTO.getPath());
|
||||
menuVo.setHidden(menuDTO.getHidden());
|
||||
// 如果不是外链
|
||||
if (!menuDTO.getIframe()) {
|
||||
@@ -429,7 +431,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
if (menuDtoList != null && menuDtoList.size() != 0) {
|
||||
menuVo.setAlwaysShow(true);
|
||||
menuVo.setRedirect("noredirect");
|
||||
menuVo.setChildren(buildMenus(menuDtoList,pid));
|
||||
menuVo.setChildren(buildMenus(menuDtoList, pid));
|
||||
// 处理是一级菜单并且没有子菜单的情况
|
||||
} else if (StrUtil.isEmpty(menuDTO.getPid())) {
|
||||
MenuVo menuVo1 = new MenuVo();
|
||||
@@ -458,7 +460,7 @@ public class SysMenuServiceImpl extends ServiceImpl<SysMenuMapper, SysMenu> impl
|
||||
|
||||
@Override
|
||||
public List<Map> getMenusByRole(String roleId, String systemType, String category) {
|
||||
baseMapper.getMenusByRole(systemType,category);
|
||||
baseMapper.getMenusByRole(systemType, category);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,73 +12,83 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @description 服务接口
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
* @author lyd
|
||||
* @description 服务接口
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
public interface ISysNoticeService extends IService<SysNotice> {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param whereJson 条件
|
||||
* @param pageable 分页参数
|
||||
* @return IPage<SysNotice>
|
||||
*/
|
||||
* 查询数据分页
|
||||
*
|
||||
* @param whereJson 条件
|
||||
* @param pageable 分页参数
|
||||
* @return IPage<SysNotice>
|
||||
*/
|
||||
IPage<SysNotice> queryAll(Map whereJson, PageQuery pageable);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param entity /
|
||||
*/
|
||||
* 创建
|
||||
*
|
||||
* @param entity /
|
||||
*/
|
||||
void create(SysNotice entity);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param entity /
|
||||
*/
|
||||
* 编辑
|
||||
*
|
||||
* @param entity /
|
||||
*/
|
||||
void update(SysNotice entity);
|
||||
|
||||
/**
|
||||
* 多选删除
|
||||
* @param ids /
|
||||
*/
|
||||
* 多选删除
|
||||
*
|
||||
* @param ids /
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 获取未读的接收消息条数
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Integer countByReceiveNotRead();
|
||||
|
||||
/**
|
||||
* 获取不同类型的前三条信息
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
LinkedList<List<SysNotice>> pageByReceive();
|
||||
|
||||
/**
|
||||
* 标记已读
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void read(String id);
|
||||
|
||||
/**
|
||||
* 处理信息
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void deal(String id);
|
||||
|
||||
/**
|
||||
* 批量已读
|
||||
*
|
||||
* @param jsonObject
|
||||
*/
|
||||
void changeRead(JSONObject jsonObject);
|
||||
|
||||
/**
|
||||
* 写入信息
|
||||
* @param msg: 数据信息
|
||||
*
|
||||
* @param msg: 数据信息
|
||||
* @param title: 唯一
|
||||
* @param type: 类型
|
||||
* @param type: 类型
|
||||
*/
|
||||
void createNotice(String msg, String title, String type);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public enum NoticeEnum {
|
||||
/**
|
||||
* 未读
|
||||
*/
|
||||
HAVE_READ_OFF("1","未读"),
|
||||
HAVE_READ_OFF("1", "未读"),
|
||||
/**
|
||||
* 已读
|
||||
*/
|
||||
|
||||
@@ -12,10 +12,10 @@ import lombok.EqualsAndHashCode;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
* @author lyd
|
||||
* @description /
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
|
||||
@@ -4,9 +4,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
public interface SysNoticeMapper extends BaseMapper<SysNotice> {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,37 +1,54 @@
|
||||
package org.nl.system.service.notice.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @description /
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
* @author lyd
|
||||
* @description /
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
@Data
|
||||
public class SysNoticeDto implements Serializable {
|
||||
|
||||
/** 信息标识 */
|
||||
/**
|
||||
* 信息标识
|
||||
*/
|
||||
private String notice_id;
|
||||
|
||||
/** 信息标题 */
|
||||
/**
|
||||
* 信息标题
|
||||
*/
|
||||
private String notice_title;
|
||||
|
||||
/** 信息内容 */
|
||||
/**
|
||||
* 信息内容
|
||||
*/
|
||||
private String notice_content;
|
||||
|
||||
/** 信息类型 */
|
||||
/**
|
||||
* 信息类型
|
||||
*/
|
||||
private String notice_type;
|
||||
|
||||
/** 读取状态 */
|
||||
/**
|
||||
* 读取状态
|
||||
*/
|
||||
private String have_read;
|
||||
|
||||
/** 读取时间 */
|
||||
/**
|
||||
* 读取时间
|
||||
*/
|
||||
private String read_time;
|
||||
|
||||
/** 处理状态 */
|
||||
/**
|
||||
* 处理状态
|
||||
*/
|
||||
private String deal_status;
|
||||
|
||||
/** 创建时间 */
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String create_time;
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import org.nl.common.domain.query.BaseQuery;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
|
||||
/**
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
* @author lyd
|
||||
* @date 2023-05-09
|
||||
**/
|
||||
public class SysNoticeQuery extends BaseQuery<SysNotice> {
|
||||
|
||||
}
|
||||
|
||||
@@ -16,14 +16,15 @@ import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.mnt.websocket.MsgType;
|
||||
import org.nl.modules.mnt.websocket.SocketMsg;
|
||||
import org.nl.modules.mnt.websocket.WebSocketServer;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
||||
import org.nl.system.service.notice.ISysNoticeService;
|
||||
import org.nl.system.service.notice.NoticeEnum;
|
||||
import org.nl.system.service.notice.dao.SysNotice;
|
||||
import org.nl.system.service.notice.dao.mapper.SysNoticeMapper;
|
||||
import org.nl.system.service.dict.dao.Dict;
|
||||
import org.nl.system.service.dict.dao.mapper.SysDictMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.IOException;
|
||||
import java.util.LinkedList;
|
||||
|
||||
@@ -25,6 +25,7 @@ public interface ISysDataPermissionService extends IService<SysDataPermission> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param dataPermissionQuery
|
||||
* @param page
|
||||
* @return
|
||||
@@ -33,30 +34,33 @@ public interface ISysDataPermissionService extends IService<SysDataPermission> {
|
||||
|
||||
/**
|
||||
* 新增数据权限
|
||||
*
|
||||
* @param permission
|
||||
*/
|
||||
void create(SysDataPermission permission);
|
||||
|
||||
/**
|
||||
* 修改
|
||||
*
|
||||
* @param permission
|
||||
*/
|
||||
void update(SysDataPermission permission);
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void deleteAll(Set<String> ids);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<Dict> getDataScopeType();
|
||||
|
||||
/**
|
||||
* 获取数据权限下拉框
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SysDataPermission> getDataPermissionOption();
|
||||
@@ -65,12 +69,14 @@ public interface ISysDataPermissionService extends IService<SysDataPermission> {
|
||||
|
||||
/**
|
||||
* 保存数据权限
|
||||
*
|
||||
* @param datas
|
||||
*/
|
||||
void savePermission(JSONObject datas);
|
||||
|
||||
/**
|
||||
* 数据展示
|
||||
*
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -10,7 +10,9 @@
|
||||
VALUES (#{dataScope.selfUserId}, #{dataScope.permissionScopeType}, #{dataScope.userId}, #{dataScope.deptId})
|
||||
</insert>
|
||||
<delete id="deleteScopeBySelfUserId">
|
||||
DELETE FROM sys_data_scope WHERE self_user_id = #{userId}
|
||||
DELETE
|
||||
FROM sys_data_scope
|
||||
WHERE self_user_id = #{userId}
|
||||
</delete>
|
||||
|
||||
<select id="findDataScopeUserIdBySelfUserIdAndScopeType" resultType="java.lang.String">
|
||||
@@ -37,17 +39,18 @@
|
||||
</select>
|
||||
<select id="getDataDetail" resultType="org.nl.system.service.permission.dao.SysDataScope">
|
||||
SELECT
|
||||
scop.*,
|
||||
dept.`name` as deptName,
|
||||
user.person_name,
|
||||
dp.`name` as permissionName,
|
||||
permission.permission_id
|
||||
scop.*,
|
||||
dept.`name` as deptName,
|
||||
user.person_name,
|
||||
dp.`name` as permissionName,
|
||||
permission.permission_id
|
||||
FROM
|
||||
`sys_data_scope` scop
|
||||
LEFT JOIN sys_user_data_permission permission ON scop.permission_scope_type = permission.permission_scope_type AND permission.user_id = scop.self_user_id
|
||||
LEFT JOIN sys_data_permission dp ON permission.permission_id = dp.permission_id
|
||||
LEFT JOIN sys_dept dept ON scop.dept_id = dept.dept_id
|
||||
LEFT JOIN sys_user user ON scop.user_id = user.user_id
|
||||
`sys_data_scope` scop
|
||||
LEFT JOIN sys_user_data_permission permission ON scop.permission_scope_type = permission.permission_scope_type
|
||||
AND permission.user_id = scop.self_user_id
|
||||
LEFT JOIN sys_data_permission dp ON permission.permission_id = dp.permission_id
|
||||
LEFT JOIN sys_dept dept ON scop.dept_id = dept.dept_id
|
||||
LEFT JOIN sys_user user ON scop.user_id = user.user_id
|
||||
<where>
|
||||
<if test="selfUserId != null and selfUserId != ''">
|
||||
scop.self_user_id = #{selfUserId}
|
||||
|
||||
@@ -22,6 +22,7 @@ public interface ISysQuartzJobService extends IService<SysQuartzJob> {
|
||||
|
||||
/**
|
||||
* 分页查询任务
|
||||
*
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
@@ -30,6 +31,7 @@ public interface ISysQuartzJobService extends IService<SysQuartzJob> {
|
||||
|
||||
/**
|
||||
* 分页查询日志
|
||||
*
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
@@ -38,30 +40,35 @@ public interface ISysQuartzJobService extends IService<SysQuartzJob> {
|
||||
|
||||
/**
|
||||
* 创建任务
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
void createJob(SysQuartzJob resources);
|
||||
|
||||
/**
|
||||
* 修改任务
|
||||
*
|
||||
* @param resources
|
||||
*/
|
||||
void updateJob(SysQuartzJob resources);
|
||||
|
||||
/**
|
||||
* 更改定时任务状态
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void updateIsPause(SysQuartzJob id);
|
||||
|
||||
/**
|
||||
* 执行定时任务
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
void execution(SysQuartzJob id);
|
||||
|
||||
/**
|
||||
* 批量删除定时任务
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void deleteJob(Set<String> ids);
|
||||
@@ -70,6 +77,7 @@ public interface ISysQuartzJobService extends IService<SysQuartzJob> {
|
||||
|
||||
/**
|
||||
* 查找已启动的任务
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<SysQuartzJob> findByIsPauseIsFalse();
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
package org.nl.system.service.quartz.config;
|
||||
|
||||
import org.quartz.Scheduler;
|
||||
import org.quartz.spi.TriggerFiredBundle;
|
||||
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.quartz.AdaptableJobFactory;
|
||||
import org.springframework.scheduling.quartz.SchedulerFactoryBean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 定时任务配置
|
||||
*
|
||||
* @author /
|
||||
* @date 2019-01-07
|
||||
*/
|
||||
|
||||
@@ -19,6 +19,7 @@ public class JobQuery extends BaseQuery<SysQuartzJob> {
|
||||
private String jobName;
|
||||
private Boolean isSuccess;
|
||||
private List<Timestamp> createTime;
|
||||
|
||||
@Override
|
||||
public void paramMapping() {
|
||||
this.doP.put("jobName", QParam.builder().k(new String[]{"job_name"}).type(QueryTEnum.LK).build());
|
||||
|
||||
@@ -59,7 +59,7 @@ public class SysQuartzJobServiceImpl extends ServiceImpl<SysQuartzJobMapper, Sys
|
||||
.eq(ObjectUtil.isNotEmpty(criteria.getIsSuccess()), SysQuartzLog::getIsSuccess, criteria.getIsSuccess())
|
||||
.nested(ObjectUtil.isNotEmpty(criteria.getCreateTime()), i -> {
|
||||
i.ge(SysQuartzLog::getCreateTime, criteria.getCreateTime().get(0))
|
||||
.le(SysQuartzLog::getCreateTime, criteria.getCreateTime().get(1));
|
||||
.le(SysQuartzLog::getCreateTime, criteria.getCreateTime().get(1));
|
||||
});
|
||||
IPage<SysQuartzLog> pages = new Page<>(page.getPage() + 1, page.getSize());
|
||||
quartzLogMapper.selectPage(pages, lam);
|
||||
@@ -75,7 +75,7 @@ public class SysQuartzJobServiceImpl extends ServiceImpl<SysQuartzJobMapper, Sys
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
resources.setJobId(IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
resources.setJobId(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
resources.setCreateId(currentUserId);
|
||||
resources.setCreateName(nickName);
|
||||
resources.setCreateTime(now);
|
||||
|
||||
@@ -12,15 +12,15 @@ import org.springframework.stereotype.Component;
|
||||
@Component
|
||||
public class TestTask {
|
||||
|
||||
public void run(){
|
||||
public void run() {
|
||||
log.info("run 执行成功");
|
||||
}
|
||||
|
||||
public void run1(String str){
|
||||
public void run1(String str) {
|
||||
log.info("run1 执行成功,参数为: {}" + str);
|
||||
}
|
||||
|
||||
public void run2(){
|
||||
public void run2() {
|
||||
log.info("run2 执行成功");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ public class ExecutionJob extends QuartzJobBean {
|
||||
* 该处仅供参考
|
||||
*/
|
||||
private final static ThreadPoolExecutor EXECUTOR = ThreadPoolExecutorUtil.getPoll();
|
||||
|
||||
@Override
|
||||
protected void executeInternal(JobExecutionContext context) throws JobExecutionException {
|
||||
SysQuartzJob quartzJob = (SysQuartzJob) context.getMergedJobDataMap().get(SysQuartzJob.JOB_KEY);
|
||||
@@ -47,7 +48,7 @@ public class ExecutionJob extends QuartzJobBean {
|
||||
String uuid = quartzJob.getUuid();
|
||||
|
||||
SysQuartzLog logDto = new SysQuartzLog();
|
||||
logDto.setLogId(IdUtil.getSnowflake(1,1).nextIdStr());
|
||||
logDto.setLogId(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
logDto.setJobName(quartzJob.getJobName());
|
||||
logDto.setBeanName(quartzJob.getBeanName());
|
||||
logDto.setMethodName(quartzJob.getMethodName());
|
||||
|
||||
@@ -40,16 +40,16 @@ public class QuartzManage {
|
||||
cronTrigger.getJobDataMap().put(SysQuartzJob.JOB_KEY, quartzJob);
|
||||
|
||||
//重置启动时间
|
||||
((CronTriggerImpl)cronTrigger).setStartTime(new Date());
|
||||
((CronTriggerImpl) cronTrigger).setStartTime(new Date());
|
||||
|
||||
//执行定时任务
|
||||
scheduler.scheduleJob(jobDetail,cronTrigger);
|
||||
scheduler.scheduleJob(jobDetail, cronTrigger);
|
||||
|
||||
// 暂停任务
|
||||
if (quartzJob.getIsPause()) {
|
||||
pauseJob(quartzJob);
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("创建定时任务失败", e);
|
||||
throw new BadRequestException("创建定时任务失败");
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class QuartzManage {
|
||||
|
||||
/**
|
||||
* 更新job cron表达式
|
||||
*
|
||||
* @param quartzJob /
|
||||
*/
|
||||
public void updateJobCron(SysQuartzJob quartzJob) {
|
||||
@@ -64,22 +65,22 @@ public class QuartzManage {
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getJobId());
|
||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||
// 如果不存在则创建一个定时任务
|
||||
if(trigger == null){
|
||||
if (trigger == null) {
|
||||
addJob(quartzJob);
|
||||
trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||
}
|
||||
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(quartzJob.getCronExpression());
|
||||
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
|
||||
//重置启动时间
|
||||
((CronTriggerImpl)trigger).setStartTime(new Date());
|
||||
trigger.getJobDataMap().put(SysQuartzJob.JOB_KEY,quartzJob);
|
||||
((CronTriggerImpl) trigger).setStartTime(new Date());
|
||||
trigger.getJobDataMap().put(SysQuartzJob.JOB_KEY, quartzJob);
|
||||
|
||||
scheduler.rescheduleJob(triggerKey, trigger);
|
||||
// 暂停任务
|
||||
if (quartzJob.getIsPause()) {
|
||||
pauseJob(quartzJob);
|
||||
}
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("更新定时任务失败", e);
|
||||
throw new BadRequestException("更新定时任务失败");
|
||||
}
|
||||
@@ -87,6 +88,7 @@ public class QuartzManage {
|
||||
|
||||
/**
|
||||
* 恢复一个job
|
||||
*
|
||||
* @param quartzJob /
|
||||
*/
|
||||
public void resumeJob(SysQuartzJob quartzJob) {
|
||||
@@ -94,12 +96,12 @@ public class QuartzManage {
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getJobId());
|
||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||
// 如果不存在则创建一个定时任务
|
||||
if(trigger == null) {
|
||||
if (trigger == null) {
|
||||
addJob(quartzJob);
|
||||
}
|
||||
JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getJobId());
|
||||
scheduler.resumeJob(jobKey);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("恢复定时任务失败", e);
|
||||
throw new BadRequestException("恢复定时任务失败");
|
||||
}
|
||||
@@ -107,13 +109,14 @@ public class QuartzManage {
|
||||
|
||||
/**
|
||||
* 暂停一个job
|
||||
*
|
||||
* @param quartzJob /
|
||||
*/
|
||||
public void pauseJob(SysQuartzJob quartzJob) {
|
||||
try {
|
||||
JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getJobId());
|
||||
scheduler.pauseJob(jobKey);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("定时任务暂停失败", e);
|
||||
throw new BadRequestException("定时任务暂停失败");
|
||||
}
|
||||
@@ -121,6 +124,7 @@ public class QuartzManage {
|
||||
|
||||
/**
|
||||
* 立即执行job
|
||||
*
|
||||
* @param quartzJob /
|
||||
*/
|
||||
public void runJobNow(SysQuartzJob quartzJob) {
|
||||
@@ -128,14 +132,14 @@ public class QuartzManage {
|
||||
TriggerKey triggerKey = TriggerKey.triggerKey(JOB_NAME + quartzJob.getJobId());
|
||||
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
|
||||
// 如果不存在则创建一个定时任务
|
||||
if(trigger == null) {
|
||||
if (trigger == null) {
|
||||
addJob(quartzJob);
|
||||
}
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put(SysQuartzJob.JOB_KEY, quartzJob);
|
||||
JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getJobId());
|
||||
scheduler.triggerJob(jobKey,dataMap);
|
||||
} catch (Exception e){
|
||||
scheduler.triggerJob(jobKey, dataMap);
|
||||
} catch (Exception e) {
|
||||
log.error("定时任务执行失败", e);
|
||||
throw new BadRequestException("定时任务执行失败");
|
||||
}
|
||||
@@ -143,6 +147,7 @@ public class QuartzManage {
|
||||
|
||||
/**
|
||||
* 删除job
|
||||
*
|
||||
* @param quartzJob
|
||||
*/
|
||||
public void deleteJob(SysQuartzJob quartzJob) {
|
||||
@@ -150,7 +155,7 @@ public class QuartzManage {
|
||||
JobKey jobKey = JobKey.jobKey(JOB_NAME + quartzJob.getJobId());
|
||||
scheduler.pauseJob(jobKey);
|
||||
scheduler.deleteJob(jobKey);
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
log.error("删除定时任务失败", e);
|
||||
throw new BadRequestException("删除定时任务失败");
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* 执行定时任务
|
||||
*
|
||||
* @author /
|
||||
*/
|
||||
@Slf4j
|
||||
|
||||
@@ -24,30 +24,35 @@ public interface ISysRoleService extends IService<SysRole> {
|
||||
|
||||
/**
|
||||
* 创建角色
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void create(JSONObject param);
|
||||
|
||||
/**
|
||||
* 更新角色
|
||||
*
|
||||
* @param param
|
||||
*/
|
||||
void update(JSONObject param);
|
||||
|
||||
/**
|
||||
* 删除角色
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
void deleteBatchByIds(Set<String> ids);
|
||||
|
||||
/**
|
||||
* 更新角色菜单
|
||||
*
|
||||
* @param form
|
||||
*/
|
||||
void updateMenu(JSONObject form);
|
||||
|
||||
/**
|
||||
* 通过id获取用户的权限
|
||||
*
|
||||
* @param userDto
|
||||
* @return
|
||||
*/
|
||||
@@ -56,9 +61,11 @@ public interface ISysRoleService extends IService<SysRole> {
|
||||
|
||||
/**
|
||||
* 保存用户角色关系
|
||||
*
|
||||
* @param UserId
|
||||
* @param deptIds
|
||||
*/
|
||||
void saveUserRoleRelation(String UserId, List<String> deptIds);
|
||||
|
||||
void delUserRoleRelation(String UserId);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import java.util.List;
|
||||
public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
void saveRoleRelation(@Param("user") String UserId, @Param("roles") Collection<String> roles);
|
||||
|
||||
void delRoleRelation(@Param("user") String UserId);
|
||||
|
||||
void deleteRoleMenuBatchRoleIds(Collection<String> ids);
|
||||
@@ -26,6 +27,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
|
||||
|
||||
/**
|
||||
* 插入角色/菜单表
|
||||
*
|
||||
* @param roleId
|
||||
* @param menuIds
|
||||
*/
|
||||
|
||||
@@ -4,19 +4,20 @@
|
||||
|
||||
<insert id="saveRoleRelation">
|
||||
replace into sys_users_roles values
|
||||
<foreach collection="roles" item="role" separator=",">
|
||||
(#{user},#{role})
|
||||
<foreach collection="roles" item="role" separator=",">
|
||||
(#{user},#{role})
|
||||
</foreach>
|
||||
</insert>
|
||||
<delete id="delRoleRelation">
|
||||
delete from sys_users_roles where user_id = #{user}
|
||||
delete
|
||||
from sys_users_roles
|
||||
where user_id = #{user}
|
||||
</delete>
|
||||
|
||||
|
||||
|
||||
<insert id="insertRoleMenu">
|
||||
insert into sys_roles_menus values
|
||||
<foreach collection="menuIds" item="menuId" separator=",">
|
||||
<foreach collection="menuIds" item="menuId" separator=",">
|
||||
(#{menuId},#{roleId})
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -27,6 +28,8 @@
|
||||
</foreach>
|
||||
</delete>
|
||||
<select id="selectMenuIdsByRoles" resultType="java.lang.String">
|
||||
SELECT DISTINCT menu_id FROM sys_roles_menus WHERE role_id = #{roleId}
|
||||
SELECT DISTINCT menu_id
|
||||
FROM sys_roles_menus
|
||||
WHERE role_id = #{roleId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -145,7 +145,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
// 查看是否为管理员
|
||||
String currentUserId = SecurityUtils.getCurrentUserId();
|
||||
SysUser sysUser = userMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserId, currentUserId));
|
||||
if ( ObjectUtil.isNotEmpty(sysUser.getIsAdmin()) && sysUser.getIsAdmin()) {
|
||||
if (ObjectUtil.isNotEmpty(sysUser.getIsAdmin()) && sysUser.getIsAdmin()) {
|
||||
permission.add("admin");
|
||||
}
|
||||
permission.addAll(sysMenuMapper.getPermissionByUserId(userDto.getString("userId")));
|
||||
@@ -154,10 +154,10 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
||||
|
||||
@Override
|
||||
public void saveUserRoleRelation(String user, List<String> roles) {
|
||||
if (StringUtils.isEmpty(user) || CollectionUtils.isEmpty(roles)){
|
||||
if (StringUtils.isEmpty(user) || CollectionUtils.isEmpty(roles)) {
|
||||
return;
|
||||
}
|
||||
roleMapper.saveRoleRelation(user,roles);
|
||||
roleMapper.saveRoleRelation(user, roles);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 在线用户
|
||||
*
|
||||
* @author Zheng Jie
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -67,11 +67,12 @@ public class OnlineUserService {
|
||||
|
||||
/**
|
||||
* 保存在线用户信息
|
||||
*
|
||||
* @param userDto /
|
||||
* @param token /
|
||||
* @param token /
|
||||
* @param request /
|
||||
*/
|
||||
public void save(UserDto userDto, String token, HttpServletRequest request){
|
||||
public void save(UserDto userDto, String token, HttpServletRequest request) {
|
||||
// String dept = userDto.getDept().getName();
|
||||
String dept = "";
|
||||
String ip = StringUtils.getIp(request);
|
||||
@@ -82,39 +83,41 @@ public class OnlineUserService {
|
||||
try {
|
||||
// onlineUserDto = new OnlineUserDto(userDto.getUsername(), userDto.getNickName(), dept, browser , ip, address, EncryptUtils.desEncrypt(token), new Date());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
redisUtils.set(token, onlineUserDto, StpUtil.getTokenTimeout());
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据
|
||||
* @param filter /
|
||||
*
|
||||
* @param filter /
|
||||
* @param pageable /
|
||||
* @return /
|
||||
*/
|
||||
public Map<String,Object> getAll(String filter, Pageable pageable){
|
||||
public Map<String, Object> getAll(String filter, Pageable pageable) {
|
||||
List<OnlineUserDto> onlineUserDtos = getAll(filter);
|
||||
return PageUtil.toPage(
|
||||
PageUtil.toPage(pageable.getPageNumber(),pageable.getPageSize(), onlineUserDtos),
|
||||
PageUtil.toPage(pageable.getPageNumber(), pageable.getPageSize(), onlineUserDtos),
|
||||
onlineUserDtos.size()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部数据,不分页
|
||||
*
|
||||
* @param filter /
|
||||
* @return /
|
||||
*/
|
||||
public List<OnlineUserDto> getAll(String filter){
|
||||
public List<OnlineUserDto> getAll(String filter) {
|
||||
List<String> keys = redisUtils.scan("*");
|
||||
Collections.reverse(keys);
|
||||
List<OnlineUserDto> onlineUserDtos = new ArrayList<>();
|
||||
for (String key : keys) {
|
||||
if (key.length() == 1511) {
|
||||
OnlineUserDto onlineUserDto = (OnlineUserDto) redisUtils.get(key);
|
||||
if(StrUtil.isNotEmpty(filter)){
|
||||
if(onlineUserDto.toString().contains(filter)){
|
||||
if (StrUtil.isNotEmpty(filter)) {
|
||||
if (onlineUserDto.toString().contains(filter)) {
|
||||
onlineUserDtos.add(onlineUserDto);
|
||||
}
|
||||
} else {
|
||||
@@ -129,14 +132,16 @@ public class OnlineUserService {
|
||||
|
||||
/**
|
||||
* 踢出用户
|
||||
*
|
||||
* @param key /
|
||||
*/
|
||||
public void kickOut(String key){
|
||||
public void kickOut(String key) {
|
||||
redisUtils.del(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
*
|
||||
* @param token /
|
||||
*/
|
||||
public void logout(String token) {
|
||||
@@ -145,14 +150,15 @@ public class OnlineUserService {
|
||||
|
||||
/**
|
||||
* 导出
|
||||
* @param all /
|
||||
*
|
||||
* @param all /
|
||||
* @param response /
|
||||
* @throws IOException /
|
||||
*/
|
||||
public void download(List<OnlineUserDto> all, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (OnlineUserDto user : all) {
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("用户名", user.getUserName());
|
||||
map.put("部门", user.getDept());
|
||||
map.put("登录IP", user.getIp());
|
||||
@@ -166,33 +172,35 @@ public class OnlineUserService {
|
||||
|
||||
/**
|
||||
* 查询用户
|
||||
*
|
||||
* @param key /
|
||||
* @return /
|
||||
*/
|
||||
public OnlineUserDto getOne(String key) {
|
||||
return (OnlineUserDto)redisUtils.get(key);
|
||||
return (OnlineUserDto) redisUtils.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测用户是否在之前已经登录,已经登录踢下线
|
||||
*
|
||||
* @param userName 用户名
|
||||
*/
|
||||
public void checkLoginOnUser(String userName, String igoreToken){
|
||||
public void checkLoginOnUser(String userName, String igoreToken) {
|
||||
List<OnlineUserDto> onlineUserDtos = getAll(userName);
|
||||
if(onlineUserDtos ==null || onlineUserDtos.isEmpty()){
|
||||
if (onlineUserDtos == null || onlineUserDtos.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for(OnlineUserDto onlineUserDto : onlineUserDtos){
|
||||
if(onlineUserDto.getUserName().equals(userName)){
|
||||
for (OnlineUserDto onlineUserDto : onlineUserDtos) {
|
||||
if (onlineUserDto.getUserName().equals(userName)) {
|
||||
try {
|
||||
String token =EncryptUtils.desDecrypt(onlineUserDto.getKey());
|
||||
if(StrUtil.isNotEmpty(igoreToken)&&!igoreToken.equals(token)){
|
||||
String token = EncryptUtils.desDecrypt(onlineUserDto.getKey());
|
||||
if (StrUtil.isNotEmpty(igoreToken) && !igoreToken.equals(token)) {
|
||||
this.kickOut(token);
|
||||
}else if(StrUtil.isEmpty(igoreToken)){
|
||||
} else if (StrUtil.isEmpty(igoreToken)) {
|
||||
this.kickOut(token);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("checkUser is error",e);
|
||||
log.error("checkUser is error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -200,6 +208,7 @@ public class OnlineUserService {
|
||||
|
||||
/**
|
||||
* 根据用户名强退用户
|
||||
*
|
||||
* @param username /
|
||||
*/
|
||||
@Async
|
||||
@@ -207,13 +216,14 @@ public class OnlineUserService {
|
||||
List<OnlineUserDto> onlineUsers = getAll(username);
|
||||
for (OnlineUserDto onlineUser : onlineUsers) {
|
||||
if (onlineUser.getUserName().equals(username)) {
|
||||
String token =EncryptUtils.desDecrypt(onlineUser.getKey());
|
||||
String token = EncryptUtils.desDecrypt(onlineUser.getKey());
|
||||
kickOut(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
public Map<String, Object> login(Map paramMap){
|
||||
public Map<String, Object> login(Map paramMap) {
|
||||
// 密码解密 - 前端的加密规则: encrypt
|
||||
AuthUserDto authUser = JSON.toJavaObject((JSON) JSON.toJSON(paramMap), AuthUserDto.class);
|
||||
String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword());
|
||||
@@ -229,8 +239,8 @@ public class OnlineUserService {
|
||||
// }
|
||||
// 校验数据库
|
||||
// 根据用户名查询,在比对密码
|
||||
SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username",authUser.getUsername()));
|
||||
if (userInfo == null||!userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
||||
SysUser userInfo = sysUserService.getOne(new QueryWrapper<SysUser>().eq("username", authUser.getUsername()));
|
||||
if (userInfo == null || !userInfo.getPassword().equals(SaSecureUtil.md5BySalt(password, "salt"))) { // 这里需要密码加密
|
||||
throw new BadRequestException("账号或密码错误");
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
/**
|
||||
* 修改密码
|
||||
*
|
||||
* @param passVo:oldPass/newPass
|
||||
*/
|
||||
void updatePass(JSONObject passVo);
|
||||
void updatePass(JSONObject passVo);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ import java.util.Map;
|
||||
*/
|
||||
public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
|
||||
List<SysUserDetail> getUserDetail(@Param("query") UserQuery query, @Param("page")PageQuery page);
|
||||
List<SysUserDetail> getUserDetail(@Param("query") UserQuery query, @Param("page") PageQuery page);
|
||||
|
||||
List<Map<String,Object>> getDetailForMap(@Param("query") UserQuery query, @Param("page")PageQuery page);
|
||||
List<Map<String, Object>> getDetailForMap(@Param("query") UserQuery query, @Param("page") PageQuery page);
|
||||
|
||||
List<UserDataPermissionDto> getUserDataPermissionByPermissionId(String permissionId);
|
||||
|
||||
|
||||
@@ -2,7 +2,10 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.nl.system.service.user.dao.mapper.SysUserMapper">
|
||||
<sql id="Base_Column_List">
|
||||
sys_user.user_id as userId,
|
||||
sys_user
|
||||
.
|
||||
user_id
|
||||
as userId,
|
||||
sys_user.username as username,
|
||||
sys_user.person_name as personName,
|
||||
sys_user.gender,
|
||||
@@ -25,35 +28,40 @@
|
||||
sys_user.extuser_id as extuserId
|
||||
</sql>
|
||||
<insert id="insertDataPermission">
|
||||
INSERT INTO sys_user_data_permission(user_id, permission_scope_type, permission_id) VALUES (#{dataPermission.userId}, #{dataPermission.permissionScopeType}, #{dataPermission.permissionId})
|
||||
INSERT INTO sys_user_data_permission(user_id, permission_scope_type, permission_id)
|
||||
VALUES (#{dataPermission.userId}, #{dataPermission.permissionScopeType}, #{dataPermission.permissionId})
|
||||
</insert>
|
||||
<delete id="deleteDataPermissionById">
|
||||
DELETE FROM sys_user_data_permission WHERE user_id = #{userId}
|
||||
DELETE
|
||||
FROM sys_user_data_permission
|
||||
WHERE user_id = #{userId}
|
||||
</delete>
|
||||
<resultMap id="UserDetail" type="org.nl.system.service.user.dto.SysUserDetail" >
|
||||
<id column="userId" property="userId" />
|
||||
<result column="username" property="username" />
|
||||
<result column="personName" property="personName" />
|
||||
<result column="gender" property="gender" />
|
||||
<result column="phone" property="phone" />
|
||||
<result column="email" property="email" />
|
||||
<result column="avatarName" property="avatarName" />
|
||||
<result column="avatarPath" property="avatarPath" />
|
||||
<result column="password" property="password" />
|
||||
<result column="isAdmin" property="isAdmin" />
|
||||
<result column="isUsed" property="isUsed" />
|
||||
<result column="pwdResetUserId" property="pwdResetUserId" />
|
||||
<result column="pwdResetTime" property="pwdResetTime" />
|
||||
<result column="create_id" property="createId" />
|
||||
<result column="createName" property="createName" />
|
||||
<result column="createTime" property="createTime" />
|
||||
<result column="updateId" property="updateId" />
|
||||
<result column="updateName" property="updateName" />
|
||||
<result column="updateTime" property="updateTime" />
|
||||
<result column="extpersonId" property="extpersonId" />
|
||||
<result column="extuserId" property="extuserId" />
|
||||
<collection property="depts" ofType="org.nl.system.service.dept.dao.SysDept" column="userId" select="selectDept"></collection>
|
||||
<collection property="roles" ofType="org.nl.system.service.role.dao.SysRole" column="userId" select="selectRole"></collection>
|
||||
<resultMap id="UserDetail" type="org.nl.system.service.user.dto.SysUserDetail">
|
||||
<id column="userId" property="userId"/>
|
||||
<result column="username" property="username"/>
|
||||
<result column="personName" property="personName"/>
|
||||
<result column="gender" property="gender"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="email" property="email"/>
|
||||
<result column="avatarName" property="avatarName"/>
|
||||
<result column="avatarPath" property="avatarPath"/>
|
||||
<result column="password" property="password"/>
|
||||
<result column="isAdmin" property="isAdmin"/>
|
||||
<result column="isUsed" property="isUsed"/>
|
||||
<result column="pwdResetUserId" property="pwdResetUserId"/>
|
||||
<result column="pwdResetTime" property="pwdResetTime"/>
|
||||
<result column="create_id" property="createId"/>
|
||||
<result column="createName" property="createName"/>
|
||||
<result column="createTime" property="createTime"/>
|
||||
<result column="updateId" property="updateId"/>
|
||||
<result column="updateName" property="updateName"/>
|
||||
<result column="updateTime" property="updateTime"/>
|
||||
<result column="extpersonId" property="extpersonId"/>
|
||||
<result column="extuserId" property="extuserId"/>
|
||||
<collection property="depts" ofType="org.nl.system.service.dept.dao.SysDept" column="userId"
|
||||
select="selectDept"></collection>
|
||||
<collection property="roles" ofType="org.nl.system.service.role.dao.SysRole" column="userId"
|
||||
select="selectRole"></collection>
|
||||
</resultMap>
|
||||
<select id="getUserDetail" resultMap="UserDetail">
|
||||
SELECT
|
||||
@@ -75,17 +83,17 @@
|
||||
and #{query.endTime} >= sys_user.create_time
|
||||
</if>
|
||||
<if test="query.blurry != null">
|
||||
and (email like "%"#{query.blurry}"%" or username like "%"#{query.blurry}"%" or person_name like "%"#{query.blurry}"%")
|
||||
and (email like "%"#{query.blurry}"%" or username like "%"#{query.blurry}"%" or person_name like
|
||||
"%"#{query.blurry}"%")
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="selectDept" resultType="org.nl.system.service.dept.dao.SysDept">
|
||||
select
|
||||
sys_dept.dept_id as deptId,
|
||||
sys_dept.name as name
|
||||
from sys_dept
|
||||
left join sys_user_dept
|
||||
on sys_user_dept.dept_id = sys_dept.dept_id
|
||||
select sys_dept.dept_id as deptId,
|
||||
sys_dept.name as name
|
||||
from sys_dept
|
||||
left join sys_user_dept
|
||||
on sys_user_dept.dept_id = sys_dept.dept_id
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
<select id="selectRole" resultType="org.nl.system.service.role.dao.SysRole">
|
||||
@@ -126,11 +134,15 @@
|
||||
</select>
|
||||
<select id="getUserDataPermissionByPermissionId"
|
||||
resultType="org.nl.system.service.user.dto.UserDataPermissionDto">
|
||||
SELECT * FROM sys_user_data_permission WHERE permission_id = #{permissionId}
|
||||
SELECT *
|
||||
FROM sys_user_data_permission
|
||||
WHERE permission_id = #{permissionId}
|
||||
</select>
|
||||
<select id="getUserDataPermissionByUserId"
|
||||
resultType="org.nl.system.service.user.dto.UserDataPermissionDto">
|
||||
SELECT * FROM sys_user_data_permission WHERE user_id = #{userId}
|
||||
SELECT *
|
||||
FROM sys_user_data_permission
|
||||
WHERE user_id = #{userId}
|
||||
</select>
|
||||
<select id="getUserIdByDeptId" resultType="java.lang.String">
|
||||
SELECT
|
||||
|
||||
@@ -23,6 +23,7 @@ import java.util.Date;
|
||||
|
||||
/**
|
||||
* 在线用户
|
||||
*
|
||||
* @author Zheng Jie
|
||||
*/
|
||||
@Data
|
||||
|
||||
@@ -79,7 +79,7 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
|
||||
@Override
|
||||
public TableDataInfo<SysUserDetail> getUserDetail(UserQuery query, PageQuery pageQuery) {
|
||||
Page<Object> page = PageHelper.startPage(pageQuery.getPage()+1, pageQuery.getSize());
|
||||
Page<Object> page = PageHelper.startPage(pageQuery.getPage() + 1, pageQuery.getSize());
|
||||
List<SysUserDetail> userDetail = sysUserMapper.getUserDetail(query, pageQuery);
|
||||
TableDataInfo<SysUserDetail> build = TableDataInfo.build(userDetail);
|
||||
build.setTotalElements(page.getTotal());
|
||||
@@ -94,13 +94,15 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
//userDetail 中 createTime是string类型BeanUtils.populate不支持解析或者使用MapStruct
|
||||
ConvertUtils.register((m, o) -> {
|
||||
try {
|
||||
if (o == null){ return null; }
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(o.toString());
|
||||
}catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
return new Date();
|
||||
}
|
||||
}, Date.class);
|
||||
BeanUtils.populate(sysUser,userDetail);
|
||||
BeanUtils.populate(sysUser, userDetail);
|
||||
// 默认密码 123456
|
||||
if (ObjectUtil.isEmpty(sysUser.getPassword())) {
|
||||
sysUser.setPassword(SaSecureUtil.md5BySalt("123456", "salt"));
|
||||
@@ -110,53 +112,58 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
String userId = IdUtil.getStringId();
|
||||
sysUser.setUserId(userId);
|
||||
this.save(sysUser);
|
||||
if (userDetail.get("depts") !=null){
|
||||
deptService.saveUserDeptRelation(userId,(List)userDetail.get("depts"));
|
||||
};
|
||||
if (userDetail.get("roles") !=null){
|
||||
roleService.saveUserRoleRelation(userId,(List)userDetail.get("roles"));
|
||||
};
|
||||
if (userDetail.get("depts") != null) {
|
||||
deptService.saveUserDeptRelation(userId, (List) userDetail.get("depts"));
|
||||
}
|
||||
;
|
||||
if (userDetail.get("roles") != null) {
|
||||
roleService.saveUserRoleRelation(userId, (List) userDetail.get("roles"));
|
||||
}
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void update(Map userDetail) {
|
||||
if(CollectionUtils.isEmpty(userDetail)|| userDetail.get("userId")==null){
|
||||
if (CollectionUtils.isEmpty(userDetail) || userDetail.get("userId") == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
SysUser sysUser = new SysUser();
|
||||
org.springframework.beans.BeanUtils.copyProperties(userDetail,sysUser);
|
||||
org.springframework.beans.BeanUtils.copyProperties(userDetail, sysUser);
|
||||
//转换器
|
||||
ConvertUtils.register(new Converter() {
|
||||
@Override
|
||||
public Object convert(Class aClass, Object o) {
|
||||
try {
|
||||
if (o == null){ return null; }
|
||||
if (o == null) {
|
||||
return null;
|
||||
}
|
||||
return new SimpleDateFormat("yyyy-MM-dd").parse(o.toString());
|
||||
}catch (Exception ex){
|
||||
} catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}, Date.class);
|
||||
try {
|
||||
BeanUtils.populate(sysUser,userDetail);
|
||||
}catch (Exception ex){
|
||||
BeanUtils.populate(sysUser, userDetail);
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
if ("123456".equals(sysUser.getPassword())){
|
||||
if ("123456".equals(sysUser.getPassword())) {
|
||||
sysUser.setPassword(SaSecureUtil.md5BySalt("123456", "salt"));
|
||||
}
|
||||
sysUser.setUpdateTime(new Date());
|
||||
sysUser.setUpdateId(SecurityUtils.getCurrentUserId());
|
||||
this.updateById(sysUser);
|
||||
if (userDetail.get("deptIds")!=null){
|
||||
if (userDetail.get("deptIds") != null) {
|
||||
deptService.delUserDeptRelation(sysUser.getUserId());
|
||||
deptService.saveUserDeptRelation(sysUser.getUserId(), (List) userDetail.get("deptIds"));
|
||||
};
|
||||
if (userDetail.get("rolesIds") !=null){
|
||||
}
|
||||
;
|
||||
if (userDetail.get("rolesIds") != null) {
|
||||
roleService.delUserRoleRelation(sysUser.getUserId());
|
||||
roleService.saveUserRoleRelation(sysUser.getUserId(),(List) userDetail.get("rolesIds"));
|
||||
roleService.saveUserRoleRelation(sysUser.getUserId(), (List) userDetail.get("rolesIds"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,13 +195,13 @@ public class ISysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> imp
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public void updatePass(JSONObject passVo) {
|
||||
if (passVo==null){
|
||||
if (passVo == null) {
|
||||
throw new BadRequestException("请求参数不能为空");
|
||||
}
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("oldPass"));
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey,passVo.getString("newPass"));
|
||||
String oldPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getString("oldPass"));
|
||||
String newPass = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, passVo.getString("newPass"));
|
||||
// 解密,得到字符密码
|
||||
if (StringUtils.isEmpty(oldPass)||StringUtils.isEmpty(newPass)){
|
||||
if (StringUtils.isEmpty(oldPass) || StringUtils.isEmpty(newPass)) {
|
||||
throw new BadRequestException("密码不能为空");
|
||||
}
|
||||
SysUser user = this.getOne(new QueryWrapper<SysUser>().eq("username", SecurityUtils.getCurrentUsername()));
|
||||
|
||||
Reference in New Issue
Block a user