mirror of https://github.com/elunez/eladmin
1.8 版本
parent
61a9b45a63
commit
a42e1ca732
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>eladmin</artifactId>
|
<artifactId>eladmin</artifactId>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ public class SwaggerConfig {
|
||||||
@Value("${jwt.header}")
|
@Value("${jwt.header}")
|
||||||
private String tokenHeader;
|
private String tokenHeader;
|
||||||
|
|
||||||
|
@Value("${swagger.enabled}")
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket createRestApi() {
|
public Docket createRestApi() {
|
||||||
ParameterBuilder ticketPar = new ParameterBuilder();
|
ParameterBuilder ticketPar = new ParameterBuilder();
|
||||||
|
@ -41,6 +44,7 @@ public class SwaggerConfig {
|
||||||
.build();
|
.build();
|
||||||
pars.add(ticketPar.build());
|
pars.add(ticketPar.build());
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
|
.enable(enabled)
|
||||||
.apiInfo(apiInfo())
|
.apiInfo(apiInfo())
|
||||||
.select()
|
.select()
|
||||||
.paths(Predicates.not(PathSelectors.regex("/error.*")))
|
.paths(Predicates.not(PathSelectors.regex("/error.*")))
|
||||||
|
|
|
@ -93,8 +93,4 @@ public class EncryptUtils {
|
||||||
public static String encryptPassword(String password){
|
public static String encryptPassword(String password){
|
||||||
return DigestUtils.md5DigestAsHex(password.getBytes());
|
return DigestUtils.md5DigestAsHex(password.getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
|
||||||
System.out.println(encryptPassword("123456"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
package me.zhengjie.utils;
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
|
import cn.hutool.json.JSONObject;
|
||||||
import me.zhengjie.exception.BadRequestException;
|
import me.zhengjie.exception.BadRequestException;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
import org.springframework.security.core.userdetails.UserDetails;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前登录的用户名
|
* 获取当前登录的用户
|
||||||
*
|
|
||||||
* @author jie
|
* @author jie
|
||||||
* @date 2019-01-17
|
* @date 2019-01-17
|
||||||
*/
|
*/
|
||||||
public class SecurityContextHolder {
|
public class SecurityUtils {
|
||||||
|
|
||||||
public static UserDetails getUserDetails() {
|
public static UserDetails getUserDetails() {
|
||||||
UserDetails userDetails = null;
|
UserDetails userDetails = null;
|
||||||
|
@ -21,4 +21,24 @@ public class SecurityContextHolder {
|
||||||
}
|
}
|
||||||
return userDetails;
|
return userDetails;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统用户名称
|
||||||
|
* @return 系统用户名称
|
||||||
|
*/
|
||||||
|
public static String getUsername(){
|
||||||
|
Object obj = getUserDetails();
|
||||||
|
JSONObject json = new JSONObject(obj);
|
||||||
|
return json.get("username", String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取系统用户id
|
||||||
|
* @return 系统用户id
|
||||||
|
*/
|
||||||
|
public static Long getUserId(){
|
||||||
|
Object obj = getUserDetails();
|
||||||
|
JSONObject json = new JSONObject(obj);
|
||||||
|
return json.get("id", Long.class);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package me.zhengjie.utils;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import static org.junit.Assert.*;
|
||||||
|
import static me.zhengjie.utils.EncryptUtils.*;
|
||||||
|
|
||||||
|
public class EncryptUtilsTest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对称加密
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDesEncrypt() {
|
||||||
|
try {
|
||||||
|
assertEquals("7772841DC6099402", desEncrypt("123456"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 对称解密
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void testDesDecrypt() {
|
||||||
|
try {
|
||||||
|
assertEquals("123456", desDecrypt("7772841DC6099402"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>eladmin</artifactId>
|
<artifactId>eladmin</artifactId>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin-common</artifactId>
|
<artifactId>eladmin-common</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--模板引擎-->
|
<!--模板引擎-->
|
||||||
|
|
|
@ -2,6 +2,7 @@ package me.zhengjie.service;
|
||||||
|
|
||||||
import me.zhengjie.domain.GenConfig;
|
import me.zhengjie.domain.GenConfig;
|
||||||
import org.springframework.cache.annotation.CacheConfig;
|
import org.springframework.cache.annotation.CacheConfig;
|
||||||
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.CachePut;
|
import org.springframework.cache.annotation.CachePut;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
|
||||||
|
@ -23,6 +24,6 @@ public interface GenConfigService {
|
||||||
* update
|
* update
|
||||||
* @param genConfig
|
* @param genConfig
|
||||||
*/
|
*/
|
||||||
@CachePut(key = "'1'")
|
@CacheEvict(allEntries = true)
|
||||||
GenConfig update(GenConfig genConfig);
|
GenConfig update(GenConfig genConfig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,8 +239,4 @@ public class GenUtil {
|
||||||
writer.close();
|
writer.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args){
|
|
||||||
System.out.println(FileUtil.exist("E:\\1.5.txt"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>eladmin</artifactId>
|
<artifactId>eladmin</artifactId>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin-common</artifactId>
|
<artifactId>eladmin-common</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -2,7 +2,7 @@ package me.zhengjie.rest;
|
||||||
|
|
||||||
import me.zhengjie.domain.Log;
|
import me.zhengjie.domain.Log;
|
||||||
import me.zhengjie.service.query.LogQueryService;
|
import me.zhengjie.service.query.LogQueryService;
|
||||||
import me.zhengjie.utils.SecurityContextHolder;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
@ -33,7 +33,7 @@ public class LogController {
|
||||||
@GetMapping(value = "/logs/user")
|
@GetMapping(value = "/logs/user")
|
||||||
public ResponseEntity getUserLogs(Log log, Pageable pageable){
|
public ResponseEntity getUserLogs(Log log, Pageable pageable){
|
||||||
log.setLogType("INFO");
|
log.setLogType("INFO");
|
||||||
log.setUsername(SecurityContextHolder.getUserDetails().getUsername());
|
log.setUsername(SecurityUtils.getUsername());
|
||||||
return new ResponseEntity(logQueryService.queryAll(log,pageable), HttpStatus.OK);
|
return new ResponseEntity(logQueryService.queryAll(log,pageable), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,12 +5,11 @@ import me.zhengjie.domain.Log;
|
||||||
import me.zhengjie.repository.LogRepository;
|
import me.zhengjie.repository.LogRepository;
|
||||||
import me.zhengjie.service.LogService;
|
import me.zhengjie.service.LogService;
|
||||||
import me.zhengjie.utils.RequestHolder;
|
import me.zhengjie.utils.RequestHolder;
|
||||||
import me.zhengjie.utils.SecurityContextHolder;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import me.zhengjie.utils.StringUtils;
|
import me.zhengjie.utils.StringUtils;
|
||||||
import org.aspectj.lang.ProceedingJoinPoint;
|
import org.aspectj.lang.ProceedingJoinPoint;
|
||||||
import org.aspectj.lang.reflect.MethodSignature;
|
import org.aspectj.lang.reflect.MethodSignature;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Propagation;
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
@ -66,8 +65,7 @@ public class LogServiceImpl implements LogService {
|
||||||
log.setRequestIp(StringUtils.getIP(request));
|
log.setRequestIp(StringUtils.getIP(request));
|
||||||
|
|
||||||
if(!LOGINPATH.equals(signature.getName())){
|
if(!LOGINPATH.equals(signature.getName())){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
username = SecurityUtils.getUsername();
|
||||||
username = userDetails.getUsername();
|
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
JSONObject jsonObject = new JSONObject(argValues[0]);
|
JSONObject jsonObject = new JSONObject(argValues[0]);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>eladmin</artifactId>
|
<artifactId>eladmin</artifactId>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin-generator</artifactId>
|
<artifactId>eladmin-generator</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin-tools</artifactId>
|
<artifactId>eladmin-tools</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--jwt-->
|
<!--jwt-->
|
||||||
|
|
|
@ -6,9 +6,8 @@ import me.zhengjie.modules.system.domain.User;
|
||||||
import me.zhengjie.modules.system.service.DeptService;
|
import me.zhengjie.modules.system.service.DeptService;
|
||||||
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.UserService;
|
||||||
import me.zhengjie.utils.SecurityContextHolder;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
@ -36,7 +35,7 @@ public class DataScope {
|
||||||
|
|
||||||
public Set<Long> getDeptIds() {
|
public Set<Long> getDeptIds() {
|
||||||
|
|
||||||
User user = userService.findByName(SecurityContextHolder.getUserDetails().getUsername());
|
User user = userService.findByName(SecurityUtils.getUsername());
|
||||||
|
|
||||||
// 用于存储部门id
|
// 用于存储部门id
|
||||||
Set<Long> deptIds = new HashSet<>();
|
Set<Long> deptIds = new HashSet<>();
|
||||||
|
|
|
@ -7,13 +7,12 @@ import me.zhengjie.modules.security.security.AuthorizationUser;
|
||||||
import me.zhengjie.modules.security.security.JwtUser;
|
import me.zhengjie.modules.security.security.JwtUser;
|
||||||
import me.zhengjie.utils.EncryptUtils;
|
import me.zhengjie.utils.EncryptUtils;
|
||||||
import me.zhengjie.modules.security.utils.JwtTokenUtil;
|
import me.zhengjie.modules.security.utils.JwtTokenUtil;
|
||||||
import me.zhengjie.utils.SecurityContextHolder;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.authentication.AccountExpiredException;
|
import org.springframework.security.authentication.AccountExpiredException;
|
||||||
import org.springframework.security.core.userdetails.UserDetails;
|
|
||||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
@ -70,8 +69,7 @@ public class AuthenticationController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "${jwt.auth.account}")
|
@GetMapping(value = "${jwt.auth.account}")
|
||||||
public ResponseEntity getUserInfo(){
|
public ResponseEntity getUserInfo(){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(SecurityUtils.getUsername());
|
||||||
JwtUser jwtUser = (JwtUser)userDetailsService.loadUserByUsername(userDetails.getUsername());
|
|
||||||
return ResponseEntity.ok(jwtUser);
|
return ResponseEntity.ok(jwtUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,11 @@ 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.mapper.MenuMapper;
|
import me.zhengjie.modules.system.service.mapper.MenuMapper;
|
||||||
import me.zhengjie.modules.system.service.query.MenuQueryService;
|
import me.zhengjie.modules.system.service.query.MenuQueryService;
|
||||||
import me.zhengjie.utils.SecurityContextHolder;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
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.security.core.userdetails.UserDetails;
|
|
||||||
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 java.util.List;
|
import java.util.List;
|
||||||
|
@ -51,8 +50,7 @@ public class MenuController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/menus/build")
|
@GetMapping(value = "/menus/build")
|
||||||
public ResponseEntity buildMenus(){
|
public ResponseEntity buildMenus(){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
User user = userService.findByName(SecurityUtils.getUsername());
|
||||||
User user = userService.findByName(userDetails.getUsername());
|
|
||||||
List<MenuDTO> menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId()));
|
List<MenuDTO> menuDTOList = menuService.findByRoles(roleService.findByUsers_Id(user.getId()));
|
||||||
List<MenuDTO> menuDTOTree = (List<MenuDTO>)menuService.buildTree(menuDTOList).get("content");
|
List<MenuDTO> menuDTOTree = (List<MenuDTO>)menuService.buildTree(menuDTOList).get("content");
|
||||||
return new ResponseEntity(menuService.buildMenus(menuDTOTree),HttpStatus.OK);
|
return new ResponseEntity(menuService.buildMenus(menuDTOTree),HttpStatus.OK);
|
||||||
|
|
|
@ -122,7 +122,7 @@ public class UserController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/users/validPass/{pass}")
|
@GetMapping(value = "/users/validPass/{pass}")
|
||||||
public ResponseEntity validPass(@PathVariable String pass){
|
public ResponseEntity validPass(@PathVariable String pass){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
UserDetails userDetails = SecurityUtils.getUserDetails();
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("status",200);
|
map.put("status",200);
|
||||||
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(pass))){
|
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(pass))){
|
||||||
|
@ -138,7 +138,7 @@ public class UserController {
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/users/updatePass/{pass}")
|
@GetMapping(value = "/users/updatePass/{pass}")
|
||||||
public ResponseEntity updatePass(@PathVariable String pass){
|
public ResponseEntity updatePass(@PathVariable String pass){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
UserDetails userDetails = SecurityUtils.getUserDetails();
|
||||||
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(pass))){
|
if(userDetails.getPassword().equals(EncryptUtils.encryptPassword(pass))){
|
||||||
throw new BadRequestException("新密码不能与旧密码相同");
|
throw new BadRequestException("新密码不能与旧密码相同");
|
||||||
}
|
}
|
||||||
|
@ -153,9 +153,8 @@ public class UserController {
|
||||||
*/
|
*/
|
||||||
@PostMapping(value = "/users/updateAvatar")
|
@PostMapping(value = "/users/updateAvatar")
|
||||||
public ResponseEntity updateAvatar(@RequestParam MultipartFile file){
|
public ResponseEntity updateAvatar(@RequestParam MultipartFile file){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
Picture picture = pictureService.upload(file, SecurityUtils.getUsername());
|
||||||
Picture picture = pictureService.upload(file,userDetails.getUsername());
|
userService.updateAvatar(SecurityUtils.getUsername(),picture.getUrl());
|
||||||
userService.updateAvatar(userDetails.getUsername(),picture.getUrl());
|
|
||||||
return new ResponseEntity(HttpStatus.OK);
|
return new ResponseEntity(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +167,7 @@ public class UserController {
|
||||||
@Log("修改邮箱")
|
@Log("修改邮箱")
|
||||||
@PostMapping(value = "/users/updateEmail/{code}")
|
@PostMapping(value = "/users/updateEmail/{code}")
|
||||||
public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){
|
public ResponseEntity updateEmail(@PathVariable String code,@RequestBody User user){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
UserDetails userDetails = SecurityUtils.getUserDetails();
|
||||||
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
if(!userDetails.getPassword().equals(EncryptUtils.encryptPassword(user.getPassword()))){
|
||||||
throw new BadRequestException("密码错误");
|
throw new BadRequestException("密码错误");
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,3 +60,7 @@ jwt:
|
||||||
#是否允许生成代码,生产环境设置为false
|
#是否允许生成代码,生产环境设置为false
|
||||||
generator:
|
generator:
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
#是否开启 swagger-ui
|
||||||
|
swagger:
|
||||||
|
enabled: true
|
|
@ -67,3 +67,7 @@ generator:
|
||||||
# swagger:
|
# swagger:
|
||||||
# v2:
|
# v2:
|
||||||
# host: # 接口域名或外网ip
|
# host: # 接口域名或外网ip
|
||||||
|
|
||||||
|
#是否开启 swagger-ui
|
||||||
|
swagger:
|
||||||
|
enabled: false
|
|
@ -5,7 +5,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>eladmin</artifactId>
|
<artifactId>eladmin</artifactId>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin-logging</artifactId>
|
<artifactId>eladmin-logging</artifactId>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!--邮件依赖-->
|
<!--邮件依赖-->
|
||||||
|
|
|
@ -4,13 +4,12 @@ import me.zhengjie.aop.log.Log;
|
||||||
import me.zhengjie.domain.Picture;
|
import me.zhengjie.domain.Picture;
|
||||||
import me.zhengjie.service.PictureService;
|
import me.zhengjie.service.PictureService;
|
||||||
import me.zhengjie.service.query.PictureQueryService;
|
import me.zhengjie.service.query.PictureQueryService;
|
||||||
import me.zhengjie.utils.SecurityContextHolder;
|
import me.zhengjie.utils.SecurityUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
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.security.core.userdetails.UserDetails;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -47,8 +46,7 @@ public class PictureController {
|
||||||
@PreAuthorize("hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_UPLOAD')")
|
@PreAuthorize("hasAnyRole('ADMIN','PICTURE_ALL','PICTURE_UPLOAD')")
|
||||||
@PostMapping(value = "/pictures")
|
@PostMapping(value = "/pictures")
|
||||||
public ResponseEntity upload(@RequestParam MultipartFile file){
|
public ResponseEntity upload(@RequestParam MultipartFile file){
|
||||||
UserDetails userDetails = SecurityContextHolder.getUserDetails();
|
String userName = SecurityUtils.getUsername();
|
||||||
String userName = userDetails.getUsername();
|
|
||||||
Picture picture = pictureService.upload(file,userName);
|
Picture picture = pictureService.upload(file,userName);
|
||||||
Map map = new HashMap();
|
Map map = new HashMap();
|
||||||
map.put("errno",0);
|
map.put("errno",0);
|
||||||
|
|
|
@ -19,7 +19,7 @@ public interface QiNiuService {
|
||||||
* 查配置
|
* 查配置
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Cacheable(key = "'1'")
|
@Cacheable(cacheNames = "qiNiuConfig", key = "'1'")
|
||||||
QiniuConfig find();
|
QiniuConfig find();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,7 +27,7 @@ public interface QiNiuService {
|
||||||
* @param qiniuConfig
|
* @param qiniuConfig
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@CachePut(key = "'1'")
|
@CachePut(cacheNames = "qiNiuConfig", key = "'1'")
|
||||||
QiniuConfig update(QiniuConfig qiniuConfig);
|
QiniuConfig update(QiniuConfig qiniuConfig);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package me.zhengjie.service.impl;
|
package me.zhengjie.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.extra.mail.Mail;
|
||||||
import cn.hutool.extra.mail.MailAccount;
|
import cn.hutool.extra.mail.MailAccount;
|
||||||
import cn.hutool.extra.mail.MailUtil;
|
import cn.hutool.extra.mail.MailUtil;
|
||||||
import me.zhengjie.domain.EmailConfig;
|
import me.zhengjie.domain.EmailConfig;
|
||||||
|
@ -76,12 +77,15 @@ public class EmailServiceImpl implements EmailService {
|
||||||
/**
|
/**
|
||||||
* 发送
|
* 发送
|
||||||
*/
|
*/
|
||||||
|
new MailAccount();
|
||||||
try {
|
try {
|
||||||
MailUtil.send(account,
|
Mail.create(account)
|
||||||
emailVo.getTos(),
|
.setTos(String.valueOf(emailVo.getTos()))
|
||||||
emailVo.getSubject(),
|
.setTitle(emailVo.getSubject())
|
||||||
content,
|
.setContent(content)
|
||||||
true);
|
.setHtml(true)
|
||||||
|
.setUseGlobalSession(false)//关闭session
|
||||||
|
.send();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
throw new BadRequestException(e.getMessage());
|
throw new BadRequestException(e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
2
pom.xml
2
pom.xml
|
@ -7,7 +7,7 @@
|
||||||
<groupId>me.zhengjie</groupId>
|
<groupId>me.zhengjie</groupId>
|
||||||
<artifactId>eladmin</artifactId>
|
<artifactId>eladmin</artifactId>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<version>1.5</version>
|
<version>1.8</version>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>eladmin-common</module>
|
<module>eladmin-common</module>
|
||||||
|
|
Loading…
Reference in New Issue