Commit 7c35a79c authored by ZhengJie's avatar ZhengJie
Browse files

[新增功能](el-admin v2.5): v2.5 beta

详情 https://www.ydyno.com/archives/1225.html
parent d35ffc9d
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
...@@ -15,11 +30,11 @@ import java.util.Set; ...@@ -15,11 +30,11 @@ import java.util.Set;
public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificationExecutor<Menu> { public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificationExecutor<Menu> {
/** /**
* 根据菜单名称查询 * 根据菜单标题查询
* @param name 菜单名称 * @param title 菜单标题
* @return / * @return /
*/ */
Menu findByName(String name); Menu findByTitle(String title);
/** /**
* 根据组件名称查询 * 根据组件名称查询
...@@ -41,5 +56,5 @@ public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificat ...@@ -41,5 +56,5 @@ public interface MenuRepository extends JpaRepository<Menu, Long>, JpaSpecificat
* @param type 类型 * @param type 类型
* @return / * @return /
*/ */
LinkedHashSet<Menu> findByRoles_IdInAndTypeNotOrderBySortAsc(Set<Long> roleIds, int type); LinkedHashSet<Menu> findByRoles_IdInAndTypeNotOrderByMenuSortAsc(Set<Long> roleIds, int type);
} }
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
...@@ -35,11 +50,4 @@ public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificat ...@@ -35,11 +50,4 @@ public interface RoleRepository extends JpaRepository<Role, Long>, JpaSpecificat
@Modifying @Modifying
@Query(value = "delete from roles_menus where menu_id = ?1",nativeQuery = true) @Query(value = "delete from roles_menus where menu_id = ?1",nativeQuery = true)
void untiedMenu(Long id); void untiedMenu(Long id);
/**
* 根据角色权限查询
* @param permission /
* @return /
*/
Role findByPermission(String permission);
} }
package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.UserAvatar;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
/**
* @author Zheng Jie
* @date 2018-11-22
*/
public interface UserAvatarRepository extends JpaRepository<UserAvatar, Long>, JpaSpecificationExecutor<UserAvatar> {
}
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.repository; package me.zhengjie.modules.system.repository;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
...@@ -34,7 +49,7 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat ...@@ -34,7 +49,7 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
* @param lastPasswordResetTime / * @param lastPasswordResetTime /
*/ */
@Modifying @Modifying
@Query(value = "update user set password = ?2 , last_password_reset_time = ?3 where username = ?1",nativeQuery = true) @Query(value = "update sys_user set password = ?2 , pwd_reset_time = ?3 where username = ?1",nativeQuery = true)
void updatePass(String username, String pass, Date lastPasswordResetTime); void updatePass(String username, String pass, Date lastPasswordResetTime);
/** /**
...@@ -43,6 +58,6 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat ...@@ -43,6 +58,6 @@ public interface UserRepository extends JpaRepository<User, Long>, JpaSpecificat
* @param email 邮箱 * @param email 邮箱
*/ */
@Modifying @Modifying
@Query(value = "update user set email = ?2 where username = ?1",nativeQuery = true) @Query(value = "update sys_user set email = ?2 where username = ?1",nativeQuery = true)
void updateEmail(String username, String email); void updateEmail(String username, String email);
} }
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.config.DataScope; import me.zhengjie.config.DataScope;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
...@@ -27,21 +43,15 @@ import java.util.Set; ...@@ -27,21 +43,15 @@ import java.util.Set;
* @date 2019-03-25 * @date 2019-03-25
*/ */
@RestController @RestController
@RequiredArgsConstructor
@Api(tags = "系统:部门管理") @Api(tags = "系统:部门管理")
@RequestMapping("/api/dept") @RequestMapping("/api/dept")
public class DeptController { public class DeptController {
private final DeptService deptService; private final DeptService deptService;
private final DataScope dataScope; private final DataScope dataScope;
private static final String ENTITY_NAME = "dept"; private static final String ENTITY_NAME = "dept";
public DeptController(DeptService deptService, DataScope dataScope) {
this.deptService = deptService;
this.dataScope = dataScope;
}
@Log("导出部门数据") @Log("导出部门数据")
@ApiOperation("导出部门数据") @ApiOperation("导出部门数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.domain.Dict;
...@@ -13,7 +29,6 @@ import org.springframework.http.ResponseEntity; ...@@ -13,7 +29,6 @@ import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.util.Set;
...@@ -22,19 +37,15 @@ import java.util.Set; ...@@ -22,19 +37,15 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2019-04-10 * @date 2019-04-10
*/ */
@Api(tags = "系统:字典管理")
@RestController @RestController
@RequiredArgsConstructor
@Api(tags = "系统:字典管理")
@RequestMapping("/api/dict") @RequestMapping("/api/dict")
public class DictController { public class DictController {
private final DictService dictService; private final DictService dictService;
private static final String ENTITY_NAME = "dict"; private static final String ENTITY_NAME = "dict";
public DictController(DictService dictService) {
this.dictService = dictService;
}
@Log("导出字典数据") @Log("导出字典数据")
@ApiOperation("导出字典数据") @ApiOperation("导出字典数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
...@@ -55,7 +66,7 @@ public class DictController { ...@@ -55,7 +66,7 @@ public class DictController {
@ApiOperation("查询字典") @ApiOperation("查询字典")
@GetMapping @GetMapping
@PreAuthorize("@el.check('dict:list')") @PreAuthorize("@el.check('dict:list')")
public ResponseEntity<Object> getDicts(DictQueryCriteria resources, Pageable pageable){ public ResponseEntity<Object> getByQuery(DictQueryCriteria resources, Pageable pageable){
return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK); return new ResponseEntity<>(dictService.queryAll(resources,pageable),HttpStatus.OK);
} }
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
...@@ -23,23 +39,19 @@ import java.util.Map; ...@@ -23,23 +39,19 @@ import java.util.Map;
* @date 2019-04-10 * @date 2019-04-10
*/ */
@RestController @RestController
@RequiredArgsConstructor
@Api(tags = "系统:字典详情管理") @Api(tags = "系统:字典详情管理")
@RequestMapping("/api/dictDetail") @RequestMapping("/api/dictDetail")
public class DictDetailController { public class DictDetailController {
private final DictDetailService dictDetailService; private final DictDetailService dictDetailService;
private static final String ENTITY_NAME = "dictDetail"; private static final String ENTITY_NAME = "dictDetail";
public DictDetailController(DictDetailService dictDetailService) {
this.dictDetailService = dictDetailService;
}
@Log("查询字典详情") @Log("查询字典详情")
@ApiOperation("查询字典详情") @ApiOperation("查询字典详情")
@GetMapping @GetMapping
public ResponseEntity<Object> getDictDetails(DictDetailQueryCriteria criteria, public ResponseEntity<Object> getDictDetails(DictDetailQueryCriteria criteria,
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){
return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK); return new ResponseEntity<>(dictDetailService.queryAll(criteria,pageable),HttpStatus.OK);
} }
...@@ -47,7 +59,7 @@ public class DictDetailController { ...@@ -47,7 +59,7 @@ public class DictDetailController {
@ApiOperation("查询多个字典详情") @ApiOperation("查询多个字典详情")
@GetMapping(value = "/map") @GetMapping(value = "/map")
public ResponseEntity<Object> getDictDetailMaps(DictDetailQueryCriteria criteria, public ResponseEntity<Object> getDictDetailMaps(DictDetailQueryCriteria criteria,
@PageableDefault(sort = {"sort"}, direction = Sort.Direction.ASC) Pageable pageable){ @PageableDefault(sort = {"dictSort"}, direction = Sort.Direction.ASC) Pageable pageable){
String[] names = criteria.getDictName().split(","); String[] names = criteria.getDictName().split(",");
Map<String,Object> map = new HashMap<>(names.length); Map<String,Object> map = new HashMap<>(names.length);
for (String name : names) { for (String name : names) {
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.config.DataScope;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
import me.zhengjie.modules.system.service.JobService; import me.zhengjie.modules.system.service.JobService;
...@@ -23,22 +38,15 @@ import java.util.Set; ...@@ -23,22 +38,15 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2019-03-29 * @date 2019-03-29
*/ */
@Api(tags = "系统:岗位管理")
@RestController @RestController
@RequiredArgsConstructor
@Api(tags = "系统:岗位管理")
@RequestMapping("/api/job") @RequestMapping("/api/job")
public class JobController { public class JobController {
private final JobService jobService; private final JobService jobService;
private final DataScope dataScope;
private static final String ENTITY_NAME = "job"; private static final String ENTITY_NAME = "job";
public JobController(JobService jobService, DataScope dataScope) {
this.jobService = jobService;
this.dataScope = dataScope;
}
@Log("导出岗位数据") @Log("导出岗位数据")
@ApiOperation("导出岗位数据") @ApiOperation("导出岗位数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
...@@ -52,8 +60,6 @@ public class JobController { ...@@ -52,8 +60,6 @@ public class JobController {
@GetMapping @GetMapping
@PreAuthorize("@el.check('job:list','user:list')") @PreAuthorize("@el.check('job:list','user:list')")
public ResponseEntity<Object> getJobs(JobQueryCriteria criteria, Pageable pageable){ public ResponseEntity<Object> getJobs(JobQueryCriteria criteria, Pageable pageable){
// 数据权限
criteria.setDeptIds(dataScope.getDeptIds());
return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK); return new ResponseEntity<>(jobService.queryAll(criteria, pageable),HttpStatus.OK);
} }
......
package me.zhengjie.modules.monitor.rest; /*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.service.MenuService; import me.zhengjie.modules.system.service.MenuService;
import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.MenuDto; import me.zhengjie.modules.system.service.dto.MenuDto;
import me.zhengjie.modules.system.service.dto.MenuQueryCriteria; import me.zhengjie.modules.system.service.dto.MenuQueryCriteria;
import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException; import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
...@@ -28,26 +41,18 @@ import java.util.Set; ...@@ -28,26 +41,18 @@ import java.util.Set;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-03 * @date 2018-12-03
*/ */
@Api(tags = "系统:菜单管理")
@RestController @RestController
@RequiredArgsConstructor
@Api(tags = "系统:菜单管理")
@RequestMapping("/api/menus") @RequestMapping("/api/menus")
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class MenuController { public class MenuController {
private final MenuService menuService; private final MenuService menuService;
private final UserService userService;
private final RoleService roleService; private final RoleService roleService;
private static final String ENTITY_NAME = "menu"; private static final String ENTITY_NAME = "menu";
public MenuController(MenuService menuService, UserService userService, RoleService roleService) {
this.menuService = menuService;
this.userService = userService;
this.roleService = roleService;
}
@Log("导出菜单数据") @Log("导出菜单数据")
@ApiOperation("导出菜单数据") @ApiOperation("导出菜单数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.service.MonitorService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
/**
* @author Zheng Jie
* @date 2020-05-02
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "系统-服务监控管理")
@RequestMapping("/api/monitor")
public class MonitorController {
private final MonitorService serverService;
@GetMapping
@ApiOperation("查询服务监控")
@PreAuthorize("@el.check('monitor:list')")
public ResponseEntity<Object> getServers(){
return new ResponseEntity<>(serverService.getServers(),HttpStatus.OK);
}
}
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import cn.hutool.core.lang.Dict; import cn.hutool.core.lang.Dict;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.modules.system.domain.Role; import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.service.RoleService; import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.RoleDto; import me.zhengjie.modules.system.service.dto.RoleDto;
import me.zhengjie.modules.system.service.dto.RoleQueryCriteria; import me.zhengjie.modules.system.service.dto.RoleQueryCriteria;
import me.zhengjie.modules.system.service.dto.RoleSmallDto; import me.zhengjie.modules.system.service.dto.RoleSmallDto;
import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.utils.SecurityUtils; import me.zhengjie.utils.SecurityUtils;
import me.zhengjie.utils.ThrowableUtil; import me.zhengjie.utils.ThrowableUtil;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
...@@ -33,21 +47,16 @@ import java.util.stream.Collectors; ...@@ -33,21 +47,16 @@ import java.util.stream.Collectors;
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-03 * @date 2018-12-03
*/ */
@Api(tags = "系统:角色管理")
@RestController @RestController
@RequiredArgsConstructor
@Api(tags = "系统:角色管理")
@RequestMapping("/api/roles") @RequestMapping("/api/roles")
public class RoleController { public class RoleController {
private final RoleService roleService; private final RoleService roleService;
private final UserService userService;
private static final String ENTITY_NAME = "role"; private static final String ENTITY_NAME = "role";
public RoleController(RoleService roleService, UserService userService) {
this.roleService = roleService;
this.userService = userService;
}
@ApiOperation("获取单个role") @ApiOperation("获取单个role")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
@PreAuthorize("@el.check('roles:list')") @PreAuthorize("@el.check('roles:list')")
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest; package me.zhengjie.modules.system.rest;
import cn.hutool.crypto.asymmetric.KeyType; import cn.hutool.crypto.asymmetric.KeyType;
import cn.hutool.crypto.asymmetric.RSA; import cn.hutool.crypto.asymmetric.RSA;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.aop.log.Log; import me.zhengjie.aop.log.Log;
import me.zhengjie.config.DataScope; import me.zhengjie.config.DataScope;
import me.zhengjie.domain.VerificationCode;
import me.zhengjie.modules.system.domain.User; import me.zhengjie.modules.system.domain.User;
import me.zhengjie.exception.BadRequestException; import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.system.domain.vo.UserPassVo; import me.zhengjie.modules.system.domain.vo.UserPassVo;
...@@ -15,9 +30,10 @@ import me.zhengjie.modules.system.service.RoleService; ...@@ -15,9 +30,10 @@ import me.zhengjie.modules.system.service.RoleService;
import me.zhengjie.modules.system.service.dto.RoleSmallDto; import me.zhengjie.modules.system.service.dto.RoleSmallDto;
import me.zhengjie.modules.system.service.dto.UserDto; import me.zhengjie.modules.system.service.dto.UserDto;
import me.zhengjie.modules.system.service.dto.UserQueryCriteria; import me.zhengjie.modules.system.service.dto.UserQueryCriteria;
import me.zhengjie.service.VerificationCodeService; import me.zhengjie.modules.system.service.VerifyService;
import me.zhengjie.utils.*; import me.zhengjie.utils.*;
import me.zhengjie.modules.system.service.UserService; import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.utils.enums.CodeEnum;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -41,6 +57,7 @@ import java.util.stream.Collectors; ...@@ -41,6 +57,7 @@ import java.util.stream.Collectors;
@Api(tags = "系统:用户管理") @Api(tags = "系统:用户管理")
@RestController @RestController
@RequestMapping("/api/users") @RequestMapping("/api/users")
@RequiredArgsConstructor
public class UserController { public class UserController {
@Value("${rsa.private_key}") @Value("${rsa.private_key}")
...@@ -50,16 +67,7 @@ public class UserController { ...@@ -50,16 +67,7 @@ public class UserController {
private final DataScope dataScope; private final DataScope dataScope;
private final DeptService deptService; private final DeptService deptService;
private final RoleService roleService; private final RoleService roleService;
private final VerificationCodeService verificationCodeService; private final VerifyService verificationCodeService;
public UserController(PasswordEncoder passwordEncoder, UserService userService, DataScope dataScope, DeptService deptService, RoleService roleService, VerificationCodeService verificationCodeService) {
this.passwordEncoder = passwordEncoder;
this.userService = userService;
this.dataScope = dataScope;
this.deptService = deptService;
this.roleService = roleService;
this.verificationCodeService = verificationCodeService;
}
@Log("导出用户数据") @Log("导出用户数据")
@ApiOperation("导出用户数据") @ApiOperation("导出用户数据")
...@@ -187,8 +195,7 @@ public class UserController { ...@@ -187,8 +195,7 @@ public class UserController {
if(!passwordEncoder.matches(password, userDto.getPassword())){ if(!passwordEncoder.matches(password, userDto.getPassword())){
throw new BadRequestException("密码错误"); throw new BadRequestException("密码错误");
} }
VerificationCode verificationCode = new VerificationCode(code, ElAdminConstant.RESET_MAIL,"email",user.getEmail()); verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + user.getEmail(), code);
verificationCodeService.validated(verificationCode);
userService.updateEmail(userDto.getUsername(),user.getEmail()); userService.updateEmail(userDto.getUsername(),user.getEmail());
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
......
package me.zhengjie.rest; /*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.rest;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import me.zhengjie.domain.VerificationCode; import lombok.RequiredArgsConstructor;
import me.zhengjie.domain.vo.EmailVo; import me.zhengjie.domain.vo.EmailVo;
import me.zhengjie.service.EmailService; import me.zhengjie.service.EmailService;
import me.zhengjie.service.VerificationCodeService; import me.zhengjie.modules.system.service.VerifyService;
import me.zhengjie.utils.ElAdminConstant; import me.zhengjie.utils.enums.CodeBiEnum;
import me.zhengjie.utils.enums.CodeEnum;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Objects;
/** /**
* @author Zheng Jie * @author Zheng Jie
* @date 2018-12-26 * @date 2018-12-26
*/ */
@RestController @RestController
@RequiredArgsConstructor
@RequestMapping("/api/code") @RequestMapping("/api/code")
@Api(tags = "工具:验证码管理") @Api(tags = "系统:验证码管理")
public class VerificationCodeController { public class VerifyController {
private final VerificationCodeService verificationCodeService;
private final VerifyService verificationCodeService;
private final EmailService emailService; private final EmailService emailService;
public VerificationCodeController(VerificationCodeService verificationCodeService, EmailService emailService) {
this.verificationCodeService = verificationCodeService;
this.emailService = emailService;
}
@PostMapping(value = "/resetEmail") @PostMapping(value = "/resetEmail")
@ApiOperation("重置邮箱,发送验证码") @ApiOperation("重置邮箱,发送验证码")
public ResponseEntity<Object> resetEmail(@RequestBody VerificationCode code) throws Exception { public ResponseEntity<Object> resetEmail(@RequestParam String email){
code.setScenes(ElAdminConstant.RESET_MAIL); EmailVo emailVo = verificationCodeService.sendEmail(email, CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey());
EmailVo emailVo = verificationCodeService.sendEmail(code);
emailService.send(emailVo,emailService.find()); emailService.send(emailVo,emailService.find());
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@PostMapping(value = "/email/resetPass") @PostMapping(value = "/email/resetPass")
@ApiOperation("重置密码,发送验证码") @ApiOperation("重置密码,发送验证码")
public ResponseEntity<Object> resetPass(@RequestParam String email) throws Exception { public ResponseEntity<Object> resetPass(@RequestParam String email){
VerificationCode code = new VerificationCode(); EmailVo emailVo = verificationCodeService.sendEmail(email, CodeEnum.EMAIL_RESET_PWD_CODE.getKey());
code.setType("email");
code.setValue(email);
code.setScenes(ElAdminConstant.RESET_MAIL);
EmailVo emailVo = verificationCodeService.sendEmail(code);
emailService.send(emailVo,emailService.find()); emailService.send(emailVo,emailService.find());
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@GetMapping(value = "/validated") @GetMapping(value = "/validated")
@ApiOperation("验证码验证") @ApiOperation("验证码验证")
public ResponseEntity<Object> validated(VerificationCode code){ public ResponseEntity<Object> validated(@RequestParam String email, @RequestParam String code, @RequestParam Integer codeBi){
verificationCodeService.validated(code); CodeBiEnum biEnum = CodeBiEnum.find(codeBi);
switch (Objects.requireNonNull(biEnum)){
case ONE:
verificationCodeService.validated(CodeEnum.EMAIL_RESET_EMAIL_CODE.getKey() + email ,code);
break;
case TWO:
verificationCodeService.validated(CodeEnum.EMAIL_RESET_PWD_CODE.getKey() + email ,code);
break;
}
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
} }
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Dept; import me.zhengjie.modules.system.domain.Dept;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.DictDetail; import me.zhengjie.modules.system.domain.DictDetail;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Dict; import me.zhengjie.modules.system.domain.Dict;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Job; import me.zhengjie.modules.system.domain.Job;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service; package me.zhengjie.modules.system.service;
import me.zhengjie.modules.system.domain.Menu; import me.zhengjie.modules.system.domain.Menu;
......
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package me.zhengjie.modules.system.service;
import java.util.Map;
/**
* @author Zheng Jie
* @date 2020-05-02
*/
public interface MonitorService {
/**
* 查询数据分页
* @return Map<String,Object>
*/
Map<String,Object> getServers();
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment