23 | * 验证码业务场景 24 | *
25 | * @author Zheng Jie 26 | * @date 2020-05-02 27 | */ 28 | @Getter 29 | @AllArgsConstructor 30 | public enum CodeBiEnum { 31 | 32 | /* 旧邮箱修改邮箱 */ 33 | ONE(1, "旧邮箱修改邮箱"), 34 | 35 | /* 通过邮箱修改密码 */ 36 | TWO(2, "通过邮箱修改密码"); 37 | 38 | private final Integer code; 39 | private final String description; 40 | 41 | public static CodeBiEnum find(Integer code) { 42 | for (CodeBiEnum value : CodeBiEnum.values()) { 43 | if (code.equals(value.getCode())) { 44 | return value; 45 | } 46 | } 47 | return null; 48 | } 49 | 50 | } 51 | -------------------------------------------------------------------------------- /eladmin-common/src/main/java/me/zhengjie/annotation/Limit.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.annotation; 17 | 18 | import me.zhengjie.aspect.LimitType; 19 | import java.lang.annotation.ElementType; 20 | import java.lang.annotation.Retention; 21 | import java.lang.annotation.RetentionPolicy; 22 | import java.lang.annotation.Target; 23 | 24 | /** 25 | * @author jacky 26 | */ 27 | @Target(ElementType.METHOD) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | public @interface Limit { 30 | 31 | // 资源名称,用于描述接口功能 32 | String name() default ""; 33 | 34 | // 资源 key 35 | String key() default ""; 36 | 37 | // key prefix 38 | String prefix() default ""; 39 | 40 | // 时间的,单位秒 41 | int period(); 42 | 43 | // 限制访问次数 44 | int count(); 45 | 46 | // 限制类型 47 | LimitType limitType() default LimitType.CUSTOMER; 48 | 49 | } 50 | -------------------------------------------------------------------------------- /eladmin-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 2 |23 | * 验证码业务场景对应的 Redis 中的 key 24 | *
25 | * @author Zheng Jie 26 | * @date 2020-05-02 27 | */ 28 | @Getter 29 | @AllArgsConstructor 30 | public enum CodeEnum { 31 | 32 | /* 通过手机号码重置邮箱 */ 33 | PHONE_RESET_EMAIL_CODE("phone_reset_email_code_", "通过手机号码重置邮箱"), 34 | 35 | /* 通过旧邮箱重置邮箱 */ 36 | EMAIL_RESET_EMAIL_CODE("email_reset_email_code_", "通过旧邮箱重置邮箱"), 37 | 38 | /* 通过手机号码重置密码 */ 39 | PHONE_RESET_PWD_CODE("phone_reset_pwd_code_", "通过手机号码重置密码"), 40 | 41 | /* 通过邮箱重置密码 */ 42 | EMAIL_RESET_PWD_CODE("email_reset_pwd_code_", "通过邮箱重置密码"); 43 | 44 | private final String key; 45 | private final String description; 46 | } 47 | -------------------------------------------------------------------------------- /eladmin-tools/src/main/java/me/zhengjie/service/EmailService.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.service; 17 | 18 | import me.zhengjie.domain.vo.EmailVo; 19 | import me.zhengjie.domain.EmailConfig; 20 | 21 | /** 22 | * @author Zheng Jie 23 | * @date 2018-12-26 24 | */ 25 | public interface EmailService { 26 | 27 | /** 28 | * 更新邮件配置 29 | * @param emailConfig 邮箱配置 30 | * @param old / 31 | * @return / 32 | * @throws Exception / 33 | */ 34 | EmailConfig config(EmailConfig emailConfig, EmailConfig old) throws Exception; 35 | 36 | /** 37 | * 查询配置 38 | * @return EmailConfig 邮件配置 39 | */ 40 | EmailConfig find(); 41 | 42 | /** 43 | * 发送邮件 44 | * @param emailVo 邮件发送的内容 45 | * @param emailConfig 邮件配置 46 | * @throws Exception / 47 | */ 48 | void send(EmailVo emailVo, EmailConfig emailConfig); 49 | } 50 | -------------------------------------------------------------------------------- /eladmin-logging/src/main/java/me/zhengjie/repository/LogRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.repository; 17 | 18 | import me.zhengjie.domain.Log; 19 | import org.springframework.data.jpa.repository.JpaRepository; 20 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; 21 | import org.springframework.data.jpa.repository.Modifying; 22 | import org.springframework.data.jpa.repository.Query; 23 | import org.springframework.stereotype.Repository; 24 | 25 | /** 26 | * @author Zheng Jie 27 | * @date 2018-11-24 28 | */ 29 | @Repository 30 | public interface LogRepository extends JpaRepository23 | * 数据权限枚举 24 | *
25 | * @author Zheng Jie 26 | * @date 2020-05-07 27 | */ 28 | @Getter 29 | @AllArgsConstructor 30 | public enum DataScopeEnum { 31 | 32 | /* 全部的数据权限 */ 33 | ALL("全部", "全部的数据权限"), 34 | 35 | /* 自己部门的数据权限 */ 36 | THIS_LEVEL("本级", "自己部门的数据权限"), 37 | 38 | /* 自定义的数据权限 */ 39 | CUSTOMIZE("自定义", "自定义的数据权限"); 40 | 41 | private final String value; 42 | private final String description; 43 | 44 | public static DataScopeEnum find(String val) { 45 | for (DataScopeEnum dataScopeEnum : DataScopeEnum.values()) { 46 | if (val.equals(dataScopeEnum.getValue())) { 47 | return dataScopeEnum; 48 | } 49 | } 50 | return null; 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/UserQueryCriteria.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.modules.system.service.dto; 17 | 18 | import lombok.Data; 19 | import me.zhengjie.annotation.Query; 20 | import java.io.Serializable; 21 | import java.sql.Timestamp; 22 | import java.util.HashSet; 23 | import java.util.List; 24 | import java.util.Set; 25 | 26 | /** 27 | * @author Zheng Jie 28 | * @date 2018-11-23 29 | */ 30 | @Data 31 | public class UserQueryCriteria implements Serializable { 32 | 33 | @Query 34 | private Long id; 35 | 36 | @Query(propName = "id", type = Query.Type.IN, joinName = "dept") 37 | private Set25 | * 用于判断是否过滤数据权限 26 | * 1、如果没有用到 @OneToOne 这种关联关系,只需要填写 fieldName [参考:DeptQueryCriteria.class] 27 | * 2、如果用到了 @OneToOne ,fieldName 和 joinName 都需要填写,拿UserQueryCriteria.class举例: 28 | * 应该是 @DataPermission(joinName = "dept", fieldName = "id") 29 | *
30 | * @author Zheng Jie 31 | * @website https://el-admin.vip 32 | * @date 2020-05-07 33 | **/ 34 | @Target(ElementType.TYPE) 35 | @Retention(RetentionPolicy.RUNTIME) 36 | public @interface DataPermission { 37 | 38 | /** 39 | * Entity 中的字段名称 40 | */ 41 | String fieldName() default ""; 42 | 43 | /** 44 | * Entity 中与部门关联的字段名称 45 | */ 46 | String joinName() default ""; 47 | } 48 | -------------------------------------------------------------------------------- /eladmin-system/src/main/java/me/zhengjie/modules/mnt/service/dto/AppDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.modules.mnt.service.dto; 17 | 18 | import lombok.Getter; 19 | import lombok.Setter; 20 | import me.zhengjie.base.BaseDTO; 21 | import java.io.Serializable; 22 | 23 | /** 24 | * @author zhanghouying 25 | * @date 2019-08-24 26 | */ 27 | @Getter 28 | @Setter 29 | public class AppDto extends BaseDTO implements Serializable { 30 | 31 | /** 32 | * 应用编号 33 | */ 34 | private Long id; 35 | 36 | /** 37 | * 应用名称 38 | */ 39 | private String name; 40 | 41 | /** 42 | * 端口 43 | */ 44 | private Integer port; 45 | 46 | /** 47 | * 上传目录 48 | */ 49 | private String uploadPath; 50 | 51 | /** 52 | * 部署目录 53 | */ 54 | private String deployPath; 55 | 56 | /** 57 | * 备份目录 58 | */ 59 | private String backupPath; 60 | 61 | /** 62 | * 启动脚本 63 | */ 64 | private String startScript; 65 | 66 | /** 67 | * 部署脚本 68 | */ 69 | private String deployScript; 70 | 71 | } 72 | -------------------------------------------------------------------------------- /eladmin-system/src/main/java/me/zhengjie/modules/security/config/bean/LoginCode.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.modules.security.config.bean; 17 | 18 | import lombok.Data; 19 | 20 | /** 21 | * 登录验证码配置信息 22 | * 23 | * @author: liaojinlong 24 | * @date: 2020/6/10 18:53 25 | */ 26 | @Data 27 | public class LoginCode { 28 | 29 | /** 30 | * 验证码配置 31 | */ 32 | private LoginCodeEnum codeType; 33 | /** 34 | * 验证码有效期 分钟 35 | */ 36 | private Long expiration = 2L; 37 | /** 38 | * 验证码内容长度 39 | */ 40 | private int length = 2; 41 | /** 42 | * 验证码宽度 43 | */ 44 | private int width = 111; 45 | /** 46 | * 验证码高度 47 | */ 48 | private int height = 36; 49 | /** 50 | * 验证码字体 51 | */ 52 | private String fontName; 53 | /** 54 | * 字体大小 55 | */ 56 | private int fontSize = 25; 57 | 58 | public LoginCodeEnum getCodeType() { 59 | return codeType; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /eladmin-system/src/main/java/me/zhengjie/config/thread/ThreadPoolExecutorUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.config.thread; 17 | 18 | import me.zhengjie.utils.SpringContextHolder; 19 | 20 | import java.util.concurrent.ArrayBlockingQueue; 21 | import java.util.concurrent.ThreadPoolExecutor; 22 | import java.util.concurrent.TimeUnit; 23 | 24 | /** 25 | * 用于获取自定义线程池 26 | * @author Zheng Jie 27 | * @date 2019年10月31日18:16:47 28 | */ 29 | public class ThreadPoolExecutorUtil { 30 | 31 | public static ThreadPoolExecutor getPoll(){ 32 | AsyncTaskProperties properties = SpringContextHolder.getBean(AsyncTaskProperties.class); 33 | return new ThreadPoolExecutor( 34 | properties.getCorePoolSize(), 35 | properties.getMaxPoolSize(), 36 | properties.getKeepAliveSeconds(), 37 | TimeUnit.SECONDS, 38 | new ArrayBlockingQueue<>(properties.getQueueCapacity()), 39 | new TheadFactoryName() 40 | ); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /eladmin-common/src/main/java/me/zhengjie/exception/handler/ApiError.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.exception.handler; 17 | 18 | import com.fasterxml.jackson.annotation.JsonFormat; 19 | import lombok.Data; 20 | import java.time.LocalDateTime; 21 | 22 | /** 23 | * @author Zheng Jie 24 | * @date 2018-11-23 25 | */ 26 | @Data 27 | class ApiError { 28 | 29 | private Integer status = 400; 30 | @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") 31 | private LocalDateTime timestamp; 32 | private String message; 33 | 34 | private ApiError() { 35 | timestamp = LocalDateTime.now(); 36 | } 37 | 38 | public static ApiError error(String message){ 39 | ApiError apiError = new ApiError(); 40 | apiError.setMessage(message); 41 | return apiError; 42 | } 43 | 44 | public static ApiError error(Integer status, String message){ 45 | ApiError apiError = new ApiError(); 46 | apiError.setStatus(status); 47 | apiError.setMessage(message); 48 | return apiError; 49 | } 50 | } 51 | 52 | 53 | -------------------------------------------------------------------------------- /eladmin-system/src/main/java/me/zhengjie/modules/security/security/JwtAuthenticationEntryPoint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.modules.security.security; 17 | 18 | import org.springframework.security.core.AuthenticationException; 19 | import org.springframework.security.web.AuthenticationEntryPoint; 20 | import org.springframework.stereotype.Component; 21 | 22 | import javax.servlet.http.HttpServletRequest; 23 | import javax.servlet.http.HttpServletResponse; 24 | import java.io.IOException; 25 | 26 | /** 27 | * @author Zheng Jie 28 | */ 29 | @Component 30 | public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint { 31 | 32 | @Override 33 | public void commence(HttpServletRequest request, 34 | HttpServletResponse response, 35 | AuthenticationException authException) throws IOException { 36 | // 当用户尝试访问安全的REST资源而不提供任何凭据时,将调用此方法发送401 响应 37 | response.sendError(HttpServletResponse.SC_UNAUTHORIZED, authException==null?"Unauthorized":authException.getMessage()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /eladmin-system/src/main/java/me/zhengjie/modules/security/service/dto/OnlineUserDto.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2019-2020 Zheng Jie 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package me.zhengjie.modules.security.service.dto; 17 | 18 | import lombok.AllArgsConstructor; 19 | import lombok.Data; 20 | import lombok.NoArgsConstructor; 21 | import java.util.Date; 22 | 23 | /** 24 | * 在线用户 25 | * @author Zheng Jie 26 | */ 27 | @Data 28 | @AllArgsConstructor 29 | @NoArgsConstructor 30 | public class OnlineUserDto { 31 | 32 | /** 33 | * 用户名 34 | */ 35 | private String userName; 36 | 37 | /** 38 | * 昵称 39 | */ 40 | private String nickName; 41 | 42 | /** 43 | * 岗位 44 | */ 45 | private String dept; 46 | 47 | /** 48 | * 浏览器 49 | */ 50 | private String browser; 51 | 52 | /** 53 | * IP 54 | */ 55 | private String ip; 56 | 57 | /** 58 | * 地址 59 | */ 60 | private String address; 61 | 62 | /** 63 | * token 64 | */ 65 | private String key; 66 | 67 | /** 68 | * 登录时间 69 | */ 70 | private Date loginTime; 71 | 72 | 73 | } 74 | -------------------------------------------------------------------------------- /eladmin-system/src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 |