diff --git a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java index c538c694d..414ee341c 100644 --- a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java +++ b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/JobLogApi.java @@ -7,13 +7,13 @@ import com.xxl.job.admin.api.log.dto.JobLogPageReqDTO; import com.xxl.job.admin.api.log.dto.JobLogRespDTO; import com.xxl.job.admin.enums.ApiConstants; import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; import javax.validation.Valid; +import java.util.Date; /** * @Description 调度任务日志Api接口 @@ -24,5 +24,15 @@ public interface JobLogApi { String PREFIX = ApiConstants.PREFIX + "/log"; @GetMapping(PREFIX + "/page") @Operation(summary = "获得所有任务列表") - public CommonResult> getPage(@Valid JobLogPageReqDTO jobLogPageReqDTO); + public CommonResult> getPage(@RequestParam(value = "pageNo") Integer pageNo, + @RequestParam(value = "pageSize") Integer pageSize, + @RequestParam(value = "jobId") Integer jobId, + @RequestParam(required = false, value = "handlerName") String handlerName, + @RequestParam(required = false, value = "beginTime") String beginTime, + @RequestParam(required = false, value = "endTime") String endTime, + @RequestParam(required = false, value = "status") Integer status); + + @GetMapping(PREFIX + "/get") + @Operation(summary = "获得任务日志详情") + CommonResult get(@RequestParam("id") Integer id); } diff --git a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogPageReqDTO.java b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogPageReqDTO.java index 09eaf54b3..041202059 100644 --- a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogPageReqDTO.java +++ b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogPageReqDTO.java @@ -19,11 +19,9 @@ public class JobLogPageReqDTO extends PageParam { @Schema(description = "处理器的名字") private String handlerName; @Schema(description = "开始执行时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date beginTime; + private String beginTime; @Schema(description = "结束执行时间") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - private Date endTime; + private String endTime; @Schema(description = "任务状态") private Integer status; } diff --git a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogRespDTO.java b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogRespDTO.java index fa0b6f931..b9cdb03d2 100644 --- a/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogRespDTO.java +++ b/ludu-job-admin/ludu-job-admin-api/src/main/java/com/xxl/job/admin/api/log/dto/JobLogRespDTO.java @@ -28,15 +28,16 @@ public class JobLogRespDTO { private Integer executeIndex; @Schema(description = "开始执行时间") @ExcelProperty("开始执行时间") - private Date beginTime; + private String beginTime; @Schema(description = "结束执行时间") @ExcelProperty("结束执行时间") - private Date endTime; + private String endTime; @Schema(description = "执行时长") @ExcelProperty("执行时长") private Integer duration; @Schema(description = "任务状态") @ExcelProperty("任务状态") private Integer status; - + @Schema(description = "任务详细结果") + private String result; } diff --git a/ludu-job-admin/ludu-job-admin-biz/pom.xml b/ludu-job-admin/ludu-job-admin-biz/pom.xml index 5d73635c8..faedb7e1c 100644 --- a/ludu-job-admin/ludu-job-admin-biz/pom.xml +++ b/ludu-job-admin/ludu-job-admin-biz/pom.xml @@ -5,7 +5,7 @@ xxl-job-admin cn.iocoder.cloud - 2.1.0-jdk8-snapshot + ${revision} 4.0.0 @@ -23,8 +23,28 @@ ludu-job-core ${revision} + + cn.iocoder.cloud + yudao-module-system + ${revision} + + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-security + + + + cn.hutool + hutool-all + 5.8.22 + cn.iocoder.cloud ludu-job-admin-api @@ -62,10 +82,6 @@ - - cn.iocoder.cloud - yudao-spring-boot-starter-security - org.springframework.boot diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java index 75627a42a..95418d7fb 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/api/log/JobLogApiImpl.java @@ -9,14 +9,23 @@ import com.xxl.job.admin.api.log.dto.JobLogRespDTO; import com.xxl.job.admin.controller.JobInfoController; import com.xxl.job.admin.controller.JobLogController; import com.xxl.job.admin.core.model.XxlJobLog; +import com.xxl.job.admin.core.scheduler.XxlJobScheduler; +import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.admin.dao.XxlJobGroupDao; import com.xxl.job.admin.dao.XxlJobInfoDao; import com.xxl.job.admin.dao.XxlJobLogDao; +import com.xxl.job.core.biz.ExecutorBiz; +import com.xxl.job.core.biz.model.LogParam; +import com.xxl.job.core.biz.model.LogResult; +import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.util.DateUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.util.StringUtils; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.util.HtmlUtils; import javax.annotation.Resource; import java.util.Date; @@ -40,17 +49,71 @@ public class JobLogApiImpl implements JobLogApi { public XxlJobLogDao xxlJobLogDao; @Override - public CommonResult> getPage(JobLogPageReqDTO jobLogPageReqDTO) { + public CommonResult> getPage(Integer pageNo, + Integer pageSize, + Integer jobId, + String handlerName, + String beginTime, + String endTime, + Integer status) { // 设置默认组为3 int jobGroup = 3; - int status = jobLogPageReqDTO.getStatus() == null ? -1 : jobLogPageReqDTO.getStatus(); + // 计算起始页数 + pageNo = (pageNo - 1) * pageSize; // page query - List list = xxlJobLogDao.apiPageList(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobGroup, jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), status); - int list_count = xxlJobLogDao.pageListCount(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobGroup, jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), status); + List list = xxlJobLogDao.apiPageList(pageNo, pageSize, jobGroup, jobId, beginTime, endTime, status, handlerName); + int list_count = xxlJobLogDao.apiPageListCount(pageNo, pageSize, jobGroup, jobId, beginTime, endTime, status, handlerName); // package result PageResult pageResult = new PageResult<>(); pageResult.setTotal((long) list_count); pageResult.setList(list); return CommonResult.success(pageResult); } + + @Override + public CommonResult get(Integer id) { + XxlJobLog load = xxlJobLogDao.load(id); + JobLogRespDTO jobLogRespDTO = new JobLogRespDTO(); + jobLogRespDTO.setId(id); + jobLogRespDTO.setJobId(load.getJobId()); + if (load.getTriggerCode() == 200) { + jobLogRespDTO.setDuration((int) (load.getHandleTime().getTime() - load.getTriggerTime().getTime())); + } + jobLogRespDTO.setBeginTime(load.getTriggerTime() == null ? null : DateUtil.formatDateTime(load.getTriggerTime())); + jobLogRespDTO.setEndTime(load.getHandleTime() == null ? null : DateUtil.formatDateTime(load.getHandleTime())); + jobLogRespDTO.setHandlerName(load.getExecutorHandler()); + jobLogRespDTO.setHandlerParam(load.getExecutorParam()); + jobLogRespDTO.setStatus(load.getHandleCode() == 200 ? 1 : 2); + // 使用原系统的方法实现日志结果显示 + try { + // valid + XxlJobLog jobLog = xxlJobLogDao.load(id); + if (jobLog == null) { + jobLogRespDTO.setResult("joblog_logid_unvalid"); + } + + // log cat + ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(jobLog.getExecutorAddress()); + ReturnT logResult = executorBiz.log(new LogParam(jobLog.getTriggerTime().getTime(), id, 1)); + + // is end + if (logResult.getContent() != null && logResult.getContent().getFromLineNum() > logResult.getContent().getToLineNum()) { + if (jobLog.getHandleCode() > 0) { + logResult.getContent().setEnd(true); + } + } + + // fix xss + if (logResult.getContent() != null && StringUtils.hasText(logResult.getContent().getLogContent())) { + String newLogContent = logResult.getContent().getLogContent(); + newLogContent = HtmlUtils.htmlEscape(newLogContent, "UTF-8"); + logResult.getContent().setLogContent(newLogContent); + } + jobLogRespDTO.setResult(logResult.getContent().getLogContent()); + } catch (Exception e) { + logger.error(e.getMessage(), e); + jobLogRespDTO.setResult("joblog_logid_failed"); + } + return CommonResult.success(jobLogRespDTO); + } } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/OAuth2Client.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/OAuth2Client.java new file mode 100644 index 000000000..80fc9563b --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/OAuth2Client.java @@ -0,0 +1,157 @@ +package com.xxl.job.admin.client; + +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.client.dto.oauth2.OAuth2AccessTokenRespDTO; +import com.xxl.job.admin.client.dto.oauth2.OAuth2CheckTokenRespDTO; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.*; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; +import org.springframework.util.Base64Utils; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +import java.nio.charset.StandardCharsets; + +/** + * OAuth 2.0 客户端 + * + * 对应调用 OAuth2OpenController 接口 + */ +@Component +public class OAuth2Client { + + private static final String BASE_URL = "http://127.0.0.1:48080/admin-api/system/oauth2"; + + /** + * 租户编号 + * + * 默认使用 1;如果使用别的租户,可以调整 + */ + public static final Long TENANT_ID = 1L; + + private static final String CLIENT_ID = "ludu-job-admin"; + private static final String CLIENT_SECRET = "test"; + + +// @Resource // 可优化,注册一个 RestTemplate Bean,然后注入 + private final RestTemplate restTemplate = new RestTemplate(); + + /** + * 使用 code 授权码,获得访问令牌 + * + * @param code 授权码 + * @param redirectUri 重定向 URI + * @return 访问令牌 + */ + public CommonResult postAccessToken(String code, String redirectUri) { + // 1.1 构建请求头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.set("tenant-id", TENANT_ID.toString()); + addClientHeader(headers); + // 1.2 构建请求参数 + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("grant_type", "authorization_code"); + body.add("code", code); + body.add("redirect_uri", redirectUri); +// body.add("state", ""); // 选填;填了会校验 + + // 2. 执行请求 + ResponseEntity> exchange = restTemplate.exchange( + BASE_URL + "/token", + HttpMethod.POST, + new HttpEntity<>(body, headers), + new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 + Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); + return exchange.getBody(); + } + + /** + * 校验访问令牌,并返回它的基本信息 + * + * @param token 访问令牌 + * @return 访问令牌的基本信息 + */ + public CommonResult checkToken(String token) { + // 1.1 构建请求头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.set("tenant-id", TENANT_ID.toString()); + addClientHeader(headers); + // 1.2 构建请求参数 + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("token", token); + + // 2. 执行请求 + ResponseEntity> exchange = restTemplate.exchange( + BASE_URL + "/check-token", + HttpMethod.POST, + new HttpEntity<>(body, headers), + new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 + Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); + return exchange.getBody(); + } + + /** + * 使用刷新令牌,获得(刷新)访问令牌 + * + * @param refreshToken 刷新令牌 + * @return 访问令牌 + */ + public CommonResult refreshToken(String refreshToken) { + // 1.1 构建请求头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.set("tenant-id", TENANT_ID.toString()); + addClientHeader(headers); + // 1.2 构建请求参数 + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("grant_type", "refresh_token"); + body.add("refresh_token", refreshToken); + + // 2. 执行请求 + ResponseEntity> exchange = restTemplate.exchange( + BASE_URL + "/token", + HttpMethod.POST, + new HttpEntity<>(body, headers), + new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 + Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); + return exchange.getBody(); + } + + /** + * 删除访问令牌 + * + * @param token 访问令牌 + * @return 成功 + */ + public CommonResult revokeToken(String token) { + // 1.1 构建请求头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.set("tenant-id", TENANT_ID.toString()); + addClientHeader(headers); + // 1.2 构建请求参数 + MultiValueMap body = new LinkedMultiValueMap<>(); + body.add("token", token); + + // 2. 执行请求 + ResponseEntity> exchange = restTemplate.exchange( + BASE_URL + "/token", + HttpMethod.DELETE, + new HttpEntity<>(body, headers), + new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 + Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); + return exchange.getBody(); + } + + private static void addClientHeader(HttpHeaders headers) { + // client 拼接,需要 BASE64 编码 + String client = CLIENT_ID + ":" + CLIENT_SECRET; + client = Base64Utils.encodeToString(client.getBytes(StandardCharsets.UTF_8)); + headers.add("Authorization", "Basic " + client); + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/UserClient.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/UserClient.java new file mode 100644 index 000000000..d794b549d --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/UserClient.java @@ -0,0 +1,73 @@ +package com.xxl.job.admin.client; + +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.client.dto.user.UserInfoRespDTO; +import com.xxl.job.admin.client.dto.user.UserUpdateReqDTO; +import com.xxl.job.admin.framework.security.core.LoginUser; +import com.xxl.job.admin.framework.security.core.util.SecurityUtils; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.*; +import org.springframework.stereotype.Component; +import org.springframework.util.Assert; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; + +/** + * 用户 User 信息的客户端 + * + * 对应调用 OAuth2UserController 接口 + */ +@Component +public class UserClient { + + private static final String BASE_URL = "http://127.0.0.1:48080/admin-api/system/oauth2/user"; + + // @Resource // 可优化,注册一个 RestTemplate Bean,然后注入 + private final RestTemplate restTemplate = new RestTemplate(); + + public CommonResult getUser() { + // 1.1 构建请求头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); + headers.set("tenant-id", OAuth2Client.TENANT_ID.toString()); + addTokenHeader(headers); + // 1.2 构建请求参数 + MultiValueMap body = new LinkedMultiValueMap<>(); + + // 2. 执行请求 + ResponseEntity> exchange = restTemplate.exchange( + BASE_URL + "/get", + HttpMethod.GET, + new HttpEntity<>(body, headers), + new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 + Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); + return exchange.getBody(); + } + + public CommonResult updateUser(UserUpdateReqDTO updateReqDTO) { + // 1.1 构建请求头 + HttpHeaders headers = new HttpHeaders(); + headers.setContentType(MediaType.APPLICATION_JSON); + headers.set("tenant-id", OAuth2Client.TENANT_ID.toString()); + addTokenHeader(headers); + // 1.2 构建请求参数 + // 使用 updateReqDTO 即可 + + // 2. 执行请求 + ResponseEntity> exchange = restTemplate.exchange( + BASE_URL + "/update", + HttpMethod.PUT, + new HttpEntity<>(updateReqDTO, headers), + new ParameterizedTypeReference>() {}); // 解决 CommonResult 的泛型丢失 + Assert.isTrue(exchange.getStatusCode().is2xxSuccessful(), "响应必须是 200 成功"); + return exchange.getBody(); + } + + + private static void addTokenHeader(HttpHeaders headers) { + LoginUser loginUser = SecurityUtils.getLoginUser(); + Assert.notNull(loginUser, "登录用户不能为空"); + headers.add("Authorization", "Bearer " + loginUser.getAccessToken()); + } +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/CommonResult.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/CommonResult.java new file mode 100644 index 000000000..ef23cdab4 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/CommonResult.java @@ -0,0 +1,28 @@ +package com.xxl.job.admin.client.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 通用返回 + * + * @param 数据泛型 + */ +@Data +public class CommonResult implements Serializable { + + /** + * 错误码 + */ + private Integer code; + /** + * 返回数据 + */ + private T data; + /** + * 错误提示,用户可阅读 + */ + private String msg; + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/oauth2/OAuth2AccessTokenRespDTO.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/oauth2/OAuth2AccessTokenRespDTO.java new file mode 100644 index 000000000..67b9ea7d3 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/oauth2/OAuth2AccessTokenRespDTO.java @@ -0,0 +1,45 @@ +package com.xxl.job.admin.client.dto.oauth2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 访问令牌 Response DTO + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OAuth2AccessTokenRespDTO { + + /** + * 访问令牌 + */ + @JsonProperty("access_token") + private String accessToken; + + /** + * 刷新令牌 + */ + @JsonProperty("refresh_token") + private String refreshToken; + + /** + * 令牌类型 + */ + @JsonProperty("token_type") + private String tokenType; + + /** + * 过期时间;单位:秒 + */ + @JsonProperty("expires_in") + private Long expiresIn; + + /** + * 授权范围;如果多个授权范围,使用空格分隔 + */ + private String scope; + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/oauth2/OAuth2CheckTokenRespDTO.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/oauth2/OAuth2CheckTokenRespDTO.java new file mode 100644 index 000000000..97c3c58d9 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/oauth2/OAuth2CheckTokenRespDTO.java @@ -0,0 +1,59 @@ +package com.xxl.job.admin.client.dto.oauth2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 校验令牌 Response DTO + * + * @author 芋道源码 + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class OAuth2CheckTokenRespDTO { + + /** + * 用户编号 + */ + @JsonProperty("user_id") + private Long userId; + /** + * 用户类型 + */ + @JsonProperty("user_type") + private Integer userType; + /** + * 租户编号 + */ + @JsonProperty("tenant_id") + private Long tenantId; + + /** + * 客户端编号 + */ + @JsonProperty("client_id") + private String clientId; + /** + * 授权范围 + */ + private List scopes; + + /** + * 访问令牌 + */ + @JsonProperty("access_token") + private String accessToken; + + /** + * 过期时间 + * + * 时间戳 / 1000,即单位:秒 + */ + private Long exp; + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/user/UserInfoRespDTO.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/user/UserInfoRespDTO.java new file mode 100644 index 000000000..0b3a44dca --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/user/UserInfoRespDTO.java @@ -0,0 +1,97 @@ +package com.xxl.job.admin.client.dto.user; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.List; + +/** + * 获得用户基本信息 Response dto + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserInfoRespDTO { + + /** + * 用户编号 + */ + private Long id; + + /** + * 用户账号 + */ + private String username; + + /** + * 用户昵称 + */ + private String nickname; + + /** + * 用户邮箱 + */ + private String email; + /** + * 手机号码 + */ + private String mobile; + + /** + * 用户性别 + */ + private Integer sex; + + /** + * 用户头像 + */ + private String avatar; + + /** + * 所在部门 + */ + private Dept dept; + + /** + * 所属岗位数组 + */ + private List posts; + + /** + * 部门 + */ + @Data + public static class Dept { + + /** + * 部门编号 + */ + private Long id; + + /** + * 部门名称 + */ + private String name; + + } + + /** + * 岗位 + */ + @Data + public static class Post { + + /** + * 岗位编号 + */ + private Long id; + + /** + * 岗位名称 + */ + private String name; + + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/user/UserUpdateReqDTO.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/user/UserUpdateReqDTO.java new file mode 100644 index 000000000..9ceed44e8 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/client/dto/user/UserUpdateReqDTO.java @@ -0,0 +1,35 @@ +package com.xxl.job.admin.client.dto.user; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * 更新用户基本信息 Request DTO + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserUpdateReqDTO { + + /** + * 用户昵称 + */ + private String nickname; + + /** + * 用户邮箱 + */ + private String email; + + /** + * 手机号码 + */ + private String mobile; + + /** + * 用户性别 + */ + private Integer sex; + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/AuthController.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/AuthController.java new file mode 100644 index 000000000..4f573bfce --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/AuthController.java @@ -0,0 +1,73 @@ +package com.xxl.job.admin.controller; + +import cn.hutool.core.util.StrUtil; +import com.xxl.job.admin.client.OAuth2Client; +import com.xxl.job.admin.client.UserClient; +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.client.dto.oauth2.OAuth2AccessTokenRespDTO; +import com.xxl.job.admin.client.dto.user.UserInfoRespDTO; +import com.xxl.job.admin.framework.security.core.util.SecurityUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +@RestController +@RequestMapping("/auth") +public class AuthController { + @Resource + private UserClient userClient; + @Resource + private OAuth2Client oauth2Client; + + /** + * 使用 code 访问令牌,获得访问令牌 + * + * @param code 授权码 + * @param redirectUri 重定向 URI + * @return 访问令牌;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 + */ + @PostMapping("/login-by-code") + public CommonResult loginByCode(@RequestParam("code") String code, + @RequestParam("redirectUri") String redirectUri) { + return oauth2Client.postAccessToken(code, redirectUri); + } + + /** + * 使用刷新令牌,获得(刷新)访问令牌 + * + * @param refreshToken 刷新令牌 + * @return 访问令牌;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 + */ + @PostMapping("/refresh-token") + public CommonResult refreshToken(@RequestParam("refreshToken") String refreshToken) { + return oauth2Client.refreshToken(refreshToken); + } + + /** + * 退出登录 + * + * @param request 请求 + * @return 成功 + */ + @PostMapping("/logout") + public CommonResult logout(HttpServletRequest request) { + String token = SecurityUtils.obtainAuthorization(request, "Authorization"); + if (StrUtil.isNotBlank(token)) { + return oauth2Client.revokeToken(token); + } + // 返回成功 + return new CommonResult<>(); + } + + + /** + * 获得当前登录用户的基本信息 + * + * @return 用户信息;注意,实际项目中,最好创建对应的 ResponseVO 类,只返回必要的字段 + */ + @GetMapping("/get") + public CommonResult getUser() { + return userClient.getUser(); + } +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/IndexController.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/IndexController.java index eb63f0bd4..4e4ef4c62 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/IndexController.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/IndexController.java @@ -54,10 +54,10 @@ public class IndexController { @RequestMapping("/toLogin") @PermissionLimit(limit=false) public ModelAndView toLogin(HttpServletRequest request, HttpServletResponse response,ModelAndView modelAndView) { - if (loginService.ifLogin(request, response) != null) { + /*if (loginService.ifLogin(request, response) != null) { modelAndView.setView(new RedirectView("/",true,false)); return modelAndView; - } + }*/ return new ModelAndView("login"); } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java index e80202ac1..94331b8c8 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/PermissionInterceptor.java @@ -42,7 +42,8 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor { if (needLogin) { XxlJobUser loginUser = loginService.ifLogin(request, response); - if (loginUser == null) { + Boolean authorState = loginService.ifAuthorizedLogin(request, response); + if (loginUser == null || !authorState) { response.setStatus(302); response.setHeader("location", request.getContextPath()+"/toLogin"); return false; @@ -53,7 +54,6 @@ public class PermissionInterceptor implements AsyncHandlerInterceptor { request.setAttribute(LoginService.LOGIN_IDENTITY_KEY, loginUser); } - // TODO 未解决单点登录问题 暂时直接放行 前面有网关的系统登录拦截 return true; // proceed with the next interceptor } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/WebMvcConfig.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/WebMvcConfig.java index 0be6ba663..2030c729f 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/WebMvcConfig.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/controller/interceptor/WebMvcConfig.java @@ -1,5 +1,6 @@ package com.xxl.job.admin.controller.interceptor; +import com.xxl.job.admin.enums.ApiConstants; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -21,8 +22,8 @@ public class WebMvcConfig implements WebMvcConfigurer { @Override public void addInterceptors(InterceptorRegistry registry) { - registry.addInterceptor(permissionInterceptor).addPathPatterns("/**"); - registry.addInterceptor(cookieInterceptor).addPathPatterns("/**"); + registry.addInterceptor(permissionInterceptor).addPathPatterns("/**").excludePathPatterns("/auth/login-by-code", "/auth/refresh-token", "/auth/logout", ApiConstants.PREFIX + "/**"); + registry.addInterceptor(cookieInterceptor).addPathPatterns("/**").excludePathPatterns("/auth/login-by-code", "/auth/refresh-token", "/auth/logout", ApiConstants.PREFIX + "/**"); } } \ No newline at end of file diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java index a1523aa47..503680342 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/core/util/CookieUtil.java @@ -37,7 +37,7 @@ public class CookieUtil { * @param value * @param maxAge */ - private static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) { + public static void set(HttpServletResponse response, String key, String value, String domain, String path, int maxAge, boolean isHttpOnly) { Cookie cookie = new Cookie(key, value); if (domain != null) { cookie.setDomain(domain); @@ -89,10 +89,20 @@ public class CookieUtil { * @param key */ public static void remove(HttpServletRequest request, HttpServletResponse response, String key) { - Cookie cookie = get(request, key); - if (cookie != null) { - set(response, key, "", null, COOKIE_PATH, 0, true); - } + remove(request, response, key, COOKIE_PATH); } + /** + * 删除Cookie(自定义作用范围路径) + * + * @param request + * @param response + * @param key + */ + public static void remove(HttpServletRequest request, HttpServletResponse response, String key, String path) { + Cookie cookie = get(request, key); + if (cookie != null) { + set(response, key, "", null, path, 0, true); + } + } } \ No newline at end of file diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java index fe73542f8..1f5479805 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/dao/XxlJobLogDao.java @@ -28,9 +28,10 @@ public interface XxlJobLogDao { @Param("pagesize") int pagesize, @Param("jobGroup") int jobGroup, @Param("jobId") int jobId, - @Param("triggerTimeStart") Date triggerTimeStart, - @Param("triggerTimeEnd") Date triggerTimeEnd, - @Param("logStatus") Integer logStatus); + @Param("triggerTimeStart") String triggerTimeStart, + @Param("triggerTimeEnd") String triggerTimeEnd, + @Param("logStatus") Integer logStatus, + @Param("handlerName") String handlerName); public int pageListCount(@Param("offset") int offset, @Param("pagesize") int pagesize, @Param("jobGroup") int jobGroup, @@ -67,4 +68,12 @@ public interface XxlJobLogDao { public List findLostJobIds(@Param("losedTime") Date losedTime); + int apiPageListCount(@Param("offset") int offset, + @Param("pagesize") int pagesize, + @Param("jobGroup") int jobGroup, + @Param("jobId") int jobId, + @Param("triggerTimeStart") String triggerTimeStart, + @Param("triggerTimeEnd") String triggerTimeEnd, + @Param("logStatus") Integer logStatus, + @Param("handlerName") String handlerName); } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/config/SecurityConfiguration.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/config/SecurityConfiguration.java index a66983351..ea61bb8ff 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/config/SecurityConfiguration.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/config/SecurityConfiguration.java @@ -1,39 +1,58 @@ package com.xxl.job.admin.framework.security.config; -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; import com.xxl.job.admin.enums.ApiConstants; +import com.xxl.job.admin.framework.security.core.filter.TokenAuthenticationFilter; +import com.xxl.job.admin.framework.security.core.handler.AccessDeniedHandlerImpl; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.SecurityFilterChain; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +import javax.annotation.Resource; /** * Demo 模块的 Security 配置 */ @Configuration(proxyBeanMethods = false) +@EnableWebSecurity public class SecurityConfiguration { + @Resource + private TokenAuthenticationFilter tokenAuthenticationFilter; + + @Resource + private AccessDeniedHandlerImpl accessDeniedHandler; + @Resource + private AuthenticationEntryPoint authenticationEntryPoint; @Bean - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { + protected SecurityFilterChain filterChain(HttpSecurity httpSecurity) throws Exception { + // 设置 URL 安全权限 + httpSecurity.csrf().disable() // 禁用 CSRF 保护 + .authorizeRequests() + // 1. 静态资源,可匿名访问 + .antMatchers("/**").permitAll() + .antMatchers(HttpMethod.GET, "/*.html", "/**/*.html", "/**/*.css", "/**/*.js").permitAll() + // 2. 登录相关的接口,可匿名访问 + .antMatchers("/toLogin").permitAll() + .antMatchers("/auth/login-by-code").permitAll() + .antMatchers("/auth/refresh-token").permitAll() + .antMatchers("/auth/logout").permitAll() + // last. 兜底规则,必须认证 + .and().authorizeRequests() + .anyRequest().authenticated(); - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - // 放行所有后台原本请求和rpc接口 - registry.antMatchers("/**").permitAll(); - } + // 设置处理器 + httpSecurity.exceptionHandling().accessDeniedHandler(accessDeniedHandler) + .authenticationEntryPoint(authenticationEntryPoint); - }; + // 添加 Token Filter + httpSecurity.addFilterBefore(tokenAuthenticationFilter, UsernamePasswordAuthenticationFilter.class); + return httpSecurity.build(); } } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/LoginUser.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/LoginUser.java new file mode 100644 index 000000000..17ed79931 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/LoginUser.java @@ -0,0 +1,37 @@ +package com.xxl.job.admin.framework.security.core; + +import lombok.Data; + +import java.util.List; + +/** + * 登录用户信息 + * + * @author 芋道源码 + */ +@Data +public class LoginUser { + + /** + * 用户编号 + */ + private Long id; + /** + * 用户类型 + */ + private Integer userType; + /** + * 租户编号 + */ + private Long tenantId; + /** + * 授权范围 + */ + private List scopes; + + /** + * 访问令牌 + */ + private String accessToken; + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/filter/TokenAuthenticationFilter.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/filter/TokenAuthenticationFilter.java new file mode 100644 index 000000000..3fcb5d88b --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/filter/TokenAuthenticationFilter.java @@ -0,0 +1,67 @@ +package com.xxl.job.admin.framework.security.core.filter; + + +import com.xxl.job.admin.client.OAuth2Client; +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.client.dto.oauth2.OAuth2CheckTokenRespDTO; +import com.xxl.job.admin.framework.security.core.LoginUser; +import com.xxl.job.admin.framework.security.core.util.SecurityUtils; +import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; +import org.springframework.web.filter.OncePerRequestFilter; + +import javax.annotation.Resource; +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * Token 过滤器,验证 token 的有效性 + * 验证通过后,获得 {@link LoginUser} 信息,并加入到 Spring Security 上下文 + * + * @author 芋道源码 + */ +@Component +public class TokenAuthenticationFilter extends OncePerRequestFilter { + + @Resource + private OAuth2Client oauth2Client; + + @Override + protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, + FilterChain filterChain) throws ServletException, IOException { + // 1. 获得访问令牌 + String token = SecurityUtils.obtainAuthorization(request, "Authorization"); + if (StringUtils.hasText(token)) { + // 2. 基于 token 构建登录用户 + LoginUser loginUser = buildLoginUserByToken(token); + // 3. 设置当前用户 + if (loginUser != null) { + SecurityUtils.setLoginUser(loginUser, request); + } + } + + // 继续过滤链 + filterChain.doFilter(request, response); + } + + private LoginUser buildLoginUserByToken(String token) { + try { + CommonResult accessTokenResult = oauth2Client.checkToken(token); + OAuth2CheckTokenRespDTO accessToken = accessTokenResult.getData(); + if (accessToken == null) { + return null; + } + // 构建登录用户 + return new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) + .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()) + .setAccessToken(accessToken.getAccessToken()); + } catch (Exception exception) { + // 校验 Token 不通过时,考虑到一些接口是无需登录的,所以直接返回 null 即可 + return null; + } + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/handler/AccessDeniedHandlerImpl.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/handler/AccessDeniedHandlerImpl.java new file mode 100644 index 000000000..1d5576791 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/handler/AccessDeniedHandlerImpl.java @@ -0,0 +1,45 @@ +package com.xxl.job.admin.framework.security.core.handler; + +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.framework.security.core.util.SecurityUtils; +import com.xxl.job.admin.framework.security.core.util.ServletUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.access.AccessDeniedException; +import org.springframework.security.web.access.AccessDeniedHandler; +import org.springframework.security.web.access.ExceptionTranslationFilter; +import org.springframework.stereotype.Component; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +/** + * 访问一个需要认证的 URL 资源,已经认证(登录)但是没有权限的情况下,返回 {@link GlobalErrorCodeConstants#FORBIDDEN} 错误码。 + * + * 补充:Spring Security 通过 {@link ExceptionTranslationFilter#handleAccessDeniedException(HttpServletRequest, HttpServletResponse, FilterChain, AccessDeniedException)} 方法,调用当前类 + * + * @author 芋道源码 + */ +@Component +@SuppressWarnings("JavadocReference") +@Slf4j +public class AccessDeniedHandlerImpl implements AccessDeniedHandler { + + @Override + public void handle(HttpServletRequest request, HttpServletResponse response, AccessDeniedException e) + throws IOException, ServletException { + // 打印 warn 的原因是,不定期合并 warn,看看有没恶意破坏 + log.warn("[commence][访问 URL({}) 时,用户({}) 权限不够]", request.getRequestURI(), + SecurityUtils.getLoginUserId(), e); + // 返回 403 + CommonResult result = new CommonResult<>(); + result.setCode(HttpStatus.FORBIDDEN.value()); + result.setMsg("没有该操作权限"); + ServletUtils.writeJSON(response, result); + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/handler/AuthenticationEntryPointImpl.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/handler/AuthenticationEntryPointImpl.java new file mode 100644 index 000000000..1b8fbf8cb --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/handler/AuthenticationEntryPointImpl.java @@ -0,0 +1,37 @@ +package com.xxl.job.admin.framework.security.core.handler; + +import cn.iocoder.yudao.framework.common.exception.enums.GlobalErrorCodeConstants; +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.framework.security.core.util.ServletUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.AuthenticationEntryPoint; +import org.springframework.security.web.access.ExceptionTranslationFilter; +import org.springframework.stereotype.Component; + +import javax.servlet.FilterChain; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 访问一个需要认证的 URL 资源,但是此时自己尚未认证(登录)的情况下,返回 {@link GlobalErrorCodeConstants#UNAUTHORIZED} 错误码,从而使前端重定向到登录页 + * + * 补充:Spring Security 通过 {@link ExceptionTranslationFilter#sendStartAuthentication(HttpServletRequest, HttpServletResponse, FilterChain, AuthenticationException)} 方法,调用当前类 + */ +@Component +@Slf4j +@SuppressWarnings("JavadocReference") // 忽略文档引用报错 +public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint { + + @Override + public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) { + log.debug("[commence][访问 URL({}) 时,没有登录]", request.getRequestURI(), e); + // 返回 401 + CommonResult result = new CommonResult<>(); + result.setCode(HttpStatus.UNAUTHORIZED.value()); + result.setMsg("账号未登录"); + ServletUtils.writeJSON(response, result); + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/util/SecurityUtils.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/util/SecurityUtils.java new file mode 100644 index 000000000..0bc7401e6 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/util/SecurityUtils.java @@ -0,0 +1,103 @@ +package com.xxl.job.admin.framework.security.core.util; + +import com.xxl.job.admin.framework.security.core.LoginUser; +import org.springframework.lang.Nullable; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContext; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; +import org.springframework.util.StringUtils; + +import javax.servlet.http.HttpServletRequest; +import java.util.Collections; + +/** + * 安全服务工具类 + * + * @author 芋道源码 + */ +public class SecurityUtils { + + public static final String AUTHORIZATION_BEARER = "Bearer"; + + private SecurityUtils() {} + + /** + * 从请求中,获得认证 Token + * + * @param request 请求 + * @param header 认证 Token 对应的 Header 名字 + * @return 认证 Token + */ + public static String obtainAuthorization(HttpServletRequest request, String header) { + String authorization = request.getHeader(header); + if (!StringUtils.hasText(authorization)) { + return null; + } + int index = authorization.indexOf(AUTHORIZATION_BEARER + " "); + if (index == -1) { // 未找到 + return null; + } + return authorization.substring(index + 7).trim(); + } + + /** + * 获得当前认证信息 + * + * @return 认证信息 + */ + public static Authentication getAuthentication() { + SecurityContext context = SecurityContextHolder.getContext(); + if (context == null) { + return null; + } + return context.getAuthentication(); + } + + /** + * 获取当前用户 + * + * @return 当前用户 + */ + @Nullable + public static LoginUser getLoginUser() { + Authentication authentication = getAuthentication(); + if (authentication == null) { + return null; + } + return authentication.getPrincipal() instanceof LoginUser ? (LoginUser) authentication.getPrincipal() : null; + } + + /** + * 获得当前用户的编号,从上下文中 + * + * @return 用户编号 + */ + @Nullable + public static Long getLoginUserId() { + LoginUser loginUser = getLoginUser(); + return loginUser != null ? loginUser.getId() : null; + } + + /** + * 设置当前用户 + * + * @param loginUser 登录用户 + * @param request 请求 + */ + public static void setLoginUser(LoginUser loginUser, HttpServletRequest request) { + // 创建 Authentication,并设置到上下文 + Authentication authentication = buildAuthentication(loginUser, request); + SecurityContextHolder.getContext().setAuthentication(authentication); + } + + private static Authentication buildAuthentication(LoginUser loginUser, HttpServletRequest request) { + // 创建 UsernamePasswordAuthenticationToken 对象 + UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken( + loginUser, null, Collections.emptyList()); + authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request)); + return authenticationToken; + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/util/ServletUtils.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/util/ServletUtils.java new file mode 100644 index 000000000..b0884e577 --- /dev/null +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/framework/security/core/util/ServletUtils.java @@ -0,0 +1,32 @@ +package com.xxl.job.admin.framework.security.core.util; + +import cn.hutool.extra.servlet.ServletUtil; +import cn.hutool.json.JSONUtil; +import org.springframework.http.MediaType; + +import javax.servlet.http.HttpServletResponse; + +/** + * 客户端工具类 + * + * @author 芋道源码 + */ +public class ServletUtils { + + /** + * 返回 JSON 字符串 + * + * @param response 响应 + * @param object 对象,会序列化成 JSON 字符串 + */ + @SuppressWarnings("deprecation") // 必须使用 APPLICATION_JSON_UTF8_VALUE,否则会乱码 + public static void writeJSON(HttpServletResponse response, Object object) { + String content = JSONUtil.toJsonStr(object); + ServletUtil.write(response, content, MediaType.APPLICATION_JSON_UTF8_VALUE); + } + + public static void write(HttpServletResponse response, String text, String contentType) { + ServletUtil.write(response, text, contentType); + } + +} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/LoginService.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/LoginService.java index 319f85e8b..508451822 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/LoginService.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/LoginService.java @@ -1,13 +1,23 @@ package com.xxl.job.admin.service; +import com.xxl.job.admin.client.OAuth2Client; +import com.xxl.job.admin.client.dto.CommonResult; +import com.xxl.job.admin.client.dto.oauth2.OAuth2AccessTokenRespDTO; +import com.xxl.job.admin.client.dto.oauth2.OAuth2CheckTokenRespDTO; import com.xxl.job.admin.core.model.XxlJobUser; import com.xxl.job.admin.core.util.CookieUtil; import com.xxl.job.admin.core.util.I18nUtil; import com.xxl.job.admin.core.util.JacksonUtil; import com.xxl.job.admin.dao.XxlJobUserDao; +import com.xxl.job.admin.framework.security.core.LoginUser; +import com.xxl.job.admin.framework.security.core.filter.TokenAuthenticationFilter; +import com.xxl.job.admin.framework.security.core.handler.AccessDeniedHandlerImpl; +import com.xxl.job.admin.framework.security.core.util.SecurityUtils; import com.xxl.job.core.biz.model.ReturnT; import org.springframework.context.annotation.Configuration; +import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.util.DigestUtils; +import org.springframework.util.StringUtils; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -21,17 +31,23 @@ import java.math.BigInteger; public class LoginService { public static final String LOGIN_IDENTITY_KEY = "XXL_JOB_LOGIN_IDENTITY"; - + public static final String ACCESS_TOKEN = "ACCESS_TOKEN"; + public static final String REFRESH_TOKEN = "REFRESH_TOKEN"; + public static final String LUNDU_LOGIN = "LUNDU_LOGIN"; + public static final String COOKIE_PATH = "/xxl-job-admin"; + @Resource + private OAuth2Client oauth2Client; @Resource private XxlJobUserDao xxlJobUserDao; - private String makeToken(XxlJobUser xxlJobUser){ + private String makeToken(XxlJobUser xxlJobUser) { String tokenJson = JacksonUtil.writeValueAsString(xxlJobUser); String tokenHex = new BigInteger(tokenJson.getBytes()).toString(16); return tokenHex; } - private XxlJobUser parseToken(String tokenHex){ + + private XxlJobUser parseToken(String tokenHex) { XxlJobUser xxlJobUser = null; if (tokenHex != null) { String tokenJson = new String(new BigInteger(tokenHex, 16).toByteArray()); // username_password(md5) @@ -41,10 +57,10 @@ public class LoginService { } - public ReturnT login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember){ + public ReturnT login(HttpServletRequest request, HttpServletResponse response, String username, String password, boolean ifRemember) { // param - if (username==null || username.trim().length()==0 || password==null || password.trim().length()==0){ + if (username == null || username.trim().length() == 0 || password == null || password.trim().length() == 0) { return new ReturnT(500, I18nUtil.getString("login_param_empty")); } @@ -71,7 +87,7 @@ public class LoginService { * @param request * @param response */ - public ReturnT logout(HttpServletRequest request, HttpServletResponse response){ + public ReturnT logout(HttpServletRequest request, HttpServletResponse response) { CookieUtil.remove(request, response, LOGIN_IDENTITY_KEY); return ReturnT.SUCCESS; } @@ -82,7 +98,7 @@ public class LoginService { * @param request * @return */ - public XxlJobUser ifLogin(HttpServletRequest request, HttpServletResponse response){ + public XxlJobUser ifLogin(HttpServletRequest request, HttpServletResponse response) { // String cookieToken = CookieUtil.getValue(request, LOGIN_IDENTITY_KEY); // if (cookieToken != null) { @@ -112,4 +128,54 @@ public class LoginService { return test; } + /** + * 判断是否登录授权 + * + * @param request + * @param response + * @return java.lang.Boolean + */ + public Boolean ifAuthorizedLogin(HttpServletRequest request, HttpServletResponse response) { + String accessToken = CookieUtil.getValue(request, ACCESS_TOKEN); + String refreshToken = CookieUtil.getValue(request, REFRESH_TOKEN); + String loginState = CookieUtil.getValue(request, LUNDU_LOGIN); + if (loginState == null) { + CookieUtil.remove(request, response, ACCESS_TOKEN, COOKIE_PATH); + CookieUtil.remove(request, response, REFRESH_TOKEN, COOKIE_PATH); + return false; + } else if (accessToken == null && refreshToken == null) { + // 如果未登录授权过 需要跳转登录授权页面 + return false; + } else if (accessToken == null) { + // 刷新令牌 不需要跳转登录授权页面 + OAuth2AccessTokenRespDTO refreshData = oauth2Client.refreshToken(refreshToken).getData(); + CookieUtil.set(response, ACCESS_TOKEN, refreshData.getAccessToken(), null, "/xxl-job-admin", refreshData.getExpiresIn().intValue(), true); + return true; + } + // 基于 token 构建登录用户 + LoginUser loginUser = buildLoginUserByToken(accessToken); + // 设置当前用户 + if (loginUser != null) { + SecurityUtils.setLoginUser(loginUser, request); + } + // 令牌未过期不需要重新登录 + return true; + } + + private LoginUser buildLoginUserByToken(String token) { + try { + CommonResult accessTokenResult = oauth2Client.checkToken(token); + OAuth2CheckTokenRespDTO accessToken = accessTokenResult.getData(); + if (accessToken == null) { + return null; + } + // 构建登录用户 + return new LoginUser().setId(accessToken.getUserId()).setUserType(accessToken.getUserType()) + .setTenantId(accessToken.getTenantId()).setScopes(accessToken.getScopes()) + .setAccessToken(accessToken.getAccessToken()); + } catch (Exception exception) { + // 校验 Token 不通过时,考虑到一些接口是无需登录的,所以直接返回 null 即可 + return null; + } + } } diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java index 778c035bc..250eea773 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/java/com/xxl/job/admin/service/impl/XxlJobServiceImpl.java @@ -482,6 +482,8 @@ public class XxlJobServiceImpl implements XxlJobService { public PageResult apiPage(Integer pageNo, Integer pageSize, String name, Integer status, String handlerName) { PageResult pageResult = new PageResult<>(); if (status != null && status == 2) status = 0; + // 计算起始页数 + pageNo = (pageNo - 1) * pageSize; pageResult.setList(xxlJobInfoDao.apiPage(pageNo, pageSize, name, status, handlerName)); pageResult.setTotal(xxlJobInfoDao.apiPageCount(name, status, handlerName)); return pageResult; diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml index e872a9d68..748933037 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobInfoMapper.xml @@ -39,10 +39,7 @@ - t - . - id - , + t.id, t.job_group, t.job_desc, t.add_time, @@ -276,7 +273,7 @@ - LIMIT #{pageSize} OFFSET ${(pageNo - 1) * pageSize} + LIMIT #{pageNo}, #{pageSize} diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml index 8fdbbbe6a..98a85f0e8 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/mybatis-mapper/XxlJobLogMapper.xml @@ -1,30 +1,30 @@ - + - - - - - + + - - - - - - - - - - - - - + + - - + + + + + + + + + + + + + + + + t.id, @@ -42,172 +42,214 @@ t.handle_code, t.handle_msg, t.alarm_status - - - + - - - - - - - - - - - - - - - - + - - - INSERT INTO xxl_job_log ( - `job_group`, - `job_id`, - `trigger_time`, - `trigger_code`, - `handle_code` - ) VALUES ( - #{jobGroup}, - #{jobId}, - #{triggerTime}, - #{triggerCode}, - #{handleCode} - ); - - + + + + + + + + + + + + - - UPDATE xxl_job_log - SET - `trigger_time`= #{triggerTime}, - `trigger_code`= #{triggerCode}, - `trigger_msg`= #{triggerMsg}, - `executor_address`= #{executorAddress}, - `executor_handler`=#{executorHandler}, - `executor_param`= #{executorParam}, - `executor_sharding_param`= #{executorShardingParam}, - `executor_fail_retry_count`= #{executorFailRetryCount} - WHERE `id`= #{id} - + + - - UPDATE xxl_job_log - SET - `handle_time`= #{handleTime}, - `handle_code`= #{handleCode}, - `handle_msg`= #{handleMsg} - WHERE `id`= #{id} - - - - delete from xxl_job_log - WHERE job_id = #{jobId} - + + + + + INSERT INTO xxl_job_log ( + `job_group`, + `job_id`, + `trigger_time`, + `trigger_code`, + `handle_code` + ) VALUES ( + #{jobGroup}, + #{jobId}, + #{triggerTime}, + #{triggerCode}, + #{handleCode} + ); + + + + + UPDATE xxl_job_log + SET `trigger_time`= #{triggerTime}, + `trigger_code`= #{triggerCode}, + `trigger_msg`= #{triggerMsg}, + `executor_address`= #{executorAddress}, + `executor_handler`=#{executorHandler}, + `executor_param`= #{executorParam}, + `executor_sharding_param`= #{executorShardingParam}, + `executor_fail_retry_count`= #{executorFailRetryCount} + WHERE `id` = #{id} + + + + UPDATE xxl_job_log + SET `handle_time`= #{handleTime}, + `handle_code`= #{handleCode}, + `handle_msg`= #{handleMsg} + WHERE `id` = #{id} + + + + delete + from xxl_job_log + WHERE job_id = #{jobId} + - + SELECT COUNT(handle_code) triggerDayCount, + SUM(CASE WHEN (trigger_code in (0, 200) and handle_code = 0) then 1 else 0 end) as triggerDayCountRunning, + SUM(CASE WHEN handle_code = 200 then 1 else 0 end) as triggerDayCountSuc + FROM xxl_job_log + WHERE trigger_time BETWEEN #{from} and #{to} - + - - delete from xxl_job_log - WHERE id in - - #{item} - - + + delete from xxl_job_log + WHERE id in + + #{item} + + - + - - UPDATE xxl_job_log - SET - `alarm_status` = #{newAlarmStatus} - WHERE `id`= #{logId} AND `alarm_status` = #{oldAlarmStatus} - + + UPDATE xxl_job_log + SET `alarm_status` = #{newAlarmStatus} + WHERE `id` = #{logId} + AND `alarm_status` = #{oldAlarmStatus} + - - + + \ No newline at end of file diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/common.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/common.1.js index 1a3fd24ce..09c840da4 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/common.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/common.1.js @@ -1,5 +1,12 @@ $(function(){ - + // 获取当前登录用户信息 + $.get(base_url + "/auth/get", function(data, status) { + if (data.code !== 0) { + alert('获得个人信息失败,原因:' + result.msg) + return; + } + $('#authUsername').text(data.data.nickname); + }); // logout $("#logoutBtn").click(function(){ layer.confirm( I18n.logout_confirm , { @@ -8,8 +15,15 @@ $(function(){ btn: [ I18n.system_ok, I18n.system_cancel ] }, function(index){ layer.close(index); - - $.post(base_url + "/logout", function(data, status) { + // 直接清理cookie,直接设置过期 + document.cookie = "ACCESS_TOKEN=; max-age=0; path=/xxl-job-admin"; + document.cookie = "REFRESH_TOKEN=; max-age=0; path=/xxl-job-admin"; + layer.open({ + icon: '2', + title: I18n.system_tips, + content: ('已退出登录请关闭当前会话框!' || I18n.logout_success) + }); + /*$.post(base_url + "/logout", function(data, status) { if (data.code == "200") { layer.msg( I18n.logout_success ); setTimeout(function(){ @@ -23,7 +37,7 @@ $(function(){ icon: '2' }); } - }); + });*/ }); }); diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobcode.index.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobcode.index.1.js index 668d63470..12a0c95d7 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobcode.index.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobcode.index.1.js @@ -63,6 +63,9 @@ $(function() { 'glueSource' : glueSource, 'glueRemark' : glueRemark }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobgroup.index.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobgroup.index.1.js index 0e5b23565..f4d12c9c0 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobgroup.index.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobgroup.index.1.js @@ -8,6 +8,9 @@ $(function() { "ajax": { url: base_url + "/jobgroup/pageList", type:"post", + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, data : function ( d ) { var obj = {}; obj.appname = $('#appname').val(); @@ -166,6 +169,9 @@ $(function() { type : 'POST', url : base_url + '/jobgroup/remove', data : {"id":id}, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobinfo.index.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobinfo.index.1.js index b479e9724..4bb80fb21 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobinfo.index.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/jobinfo.index.1.js @@ -8,6 +8,9 @@ $(function() { "ajax": { url: base_url + "/jobinfo/pageList", type:"post", + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, data : function ( d ) { var obj = {}; obj.jobGroup = $('#jobGroup').val(); @@ -243,6 +246,9 @@ $(function() { data : { "id" : id }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { @@ -278,6 +284,9 @@ $(function() { "executorParam" : $("#jobTriggerModal .textarea[name='executorParam']").val(), "addressList" : $("#jobTriggerModal .textarea[name='addressList']").val() }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { @@ -308,6 +317,9 @@ $(function() { data : { "id" : jobGroup }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ @@ -342,6 +354,9 @@ $(function() { "scheduleType" : row.scheduleType, "scheduleConf" : row.scheduleConf }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.detail.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.detail.1.js index 0638eee27..c0d7dc6f0 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.detail.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.detail.1.js @@ -28,6 +28,9 @@ $(function() { "logId":logId, "fromLineNum":fromLineNum }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.index.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.index.1.js index e0fc3f20b..7fe5f66c8 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.index.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/joblog.index.1.js @@ -8,6 +8,9 @@ $(function() { async: false, // async, avoid js invoke pagelist before jobId data init url : base_url + '/joblog/getJobsByGroup', data : {"jobGroup":jobGroup}, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { @@ -77,6 +80,9 @@ $(function() { "ajax": { url: base_url + "/joblog/pageList" , type:"post", + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, data : function ( d ) { var obj = {}; obj.jobGroup = $('#jobGroup').val(); @@ -279,6 +285,9 @@ $(function() { type : 'POST', url : base_url + '/joblog/logKill', data : {"id":_id}, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/user.index.1.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/user.index.1.js index 48d3f3020..86f3dce07 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/user.index.1.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/js/user.index.1.js @@ -8,6 +8,9 @@ $(function() { "ajax": { url: base_url + "/user/pageList", type:"post", + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, data : function ( d ) { var obj = {}; obj.username = $('#username').val(); @@ -124,6 +127,9 @@ $(function() { data : { "id" : id }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code == 200) { diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen.js index 223937224..9cc0c3fb8 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen.js @@ -644,6 +644,9 @@ "scheduleType" : 'CRON', "scheduleConf" : inputElement.val() }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code === 200) { diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen_en.js b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen_en.js index cbf84ee3f..ebdedc73e 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen_en.js +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/static/plugins/cronGen/cronGen_en.js @@ -644,6 +644,9 @@ "scheduleType" : 'CRON', "scheduleConf" : inputElement.val() }, + headers: { + 'Authorization': 'Bearer ' + localStorage.getItem('ACCESS-TOKEN') + }, dataType : "json", success : function(data){ if (data.code === 200) { diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/common/common.macro.ftl b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/common/common.macro.ftl index aace849f9..c02fe2e79 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/common/common.macro.ftl +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/common/common.macro.ftl @@ -84,11 +84,12 @@ <#-- login user --> diff --git a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/login.ftl b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/login.ftl index c3f696385..3c01abf72 100644 --- a/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/login.ftl +++ b/ludu-job-admin/ludu-job-admin-biz/src/main/resources/templates/login.ftl @@ -1,45 +1,104 @@ - <#import "./common/common.macro.ftl" as netCommon> - <@netCommon.commonStyle /> + <#import "./common/common.macro.ftl" as netCommon> + <@netCommon.commonStyle /> - ${I18n.admin_name} + ${I18n.admin_name} - +<#-- --> <@netCommon.commonScript /> - - +<#----> +<#----> + + diff --git a/ludu-module-sampling/ludu-module-sampling-api/pom.xml b/ludu-module-sampling/ludu-module-sampling-api/pom.xml deleted file mode 100644 index 3dcc127fd..000000000 --- a/ludu-module-sampling/ludu-module-sampling-api/pom.xml +++ /dev/null @@ -1,47 +0,0 @@ - - - - ludu-module-sampling - cn.iocoder.cloud - ${revision} - - 4.0.0 - - ludu-module-sampling-api - - ${project.artifactId} - - ticket 模块 API,暴露给其它模块调用 - - - - - cn.iocoder.cloud - yudao-common - - - - - org.springdoc - springdoc-openapi-ui - provided - - - - - org.springframework.boot - spring-boot-starter-validation - true - - - - - org.springframework.cloud - spring-cloud-starter-openfeign - true - - - - \ No newline at end of file diff --git a/ludu-module-sampling/ludu-module-sampling-biz/pom.xml b/ludu-module-sampling/ludu-module-sampling-biz/pom.xml deleted file mode 100644 index b020ba28f..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/pom.xml +++ /dev/null @@ -1,160 +0,0 @@ - - - - ludu-module-sampling - cn.iocoder.cloud - ${revision} - - 4.0.0 - - ludu-module-sampling-biz - - ${project.artifactId} - - sampling 模块,我们抽数模块。 - 例如说:检票和售票的数据抽数等等 - - - - - - cn.iocoder.cloud - ludu-job-core - ${revision} - - - - cn.iocoder.cloud - ludu-module-ticket-manager-api - ${revision} - - - - cn.iocoder.cloud - ludu-module-sampling-api - ${revision} - - - - org.springframework.cloud - spring-cloud-starter-bootstrap - - - - cn.iocoder.cloud - yudao-spring-boot-starter-env - - - - - cn.iocoder.cloud - yudao-module-system-api - ${revision} - - - cn.iocoder.cloud - yudao-module-infra-api - ${revision} - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-tenant - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-security - - - - org.springframework.boot - spring-boot-starter-validation - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mybatis - - - - cn.iocoder.cloud - yudao-spring-boot-starter-redis - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-rpc - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-discovery - - - - - com.alibaba.cloud - spring-cloud-starter-alibaba-nacos-config - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-mq - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-test - test - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-excel - - - - cn.iocoder.cloud - yudao-spring-boot-starter-biz-ip - - - - - cn.iocoder.cloud - yudao-spring-boot-starter-monitor - - - - - - - ${project.artifactId} - - - - org.springframework.boot - spring-boot-maven-plugin - ${spring.boot.version} - - - - repackage - - - - - - - - \ No newline at end of file diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/SamplingServerApplication.java b/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/SamplingServerApplication.java deleted file mode 100644 index c7c21ba2d..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/SamplingServerApplication.java +++ /dev/null @@ -1,17 +0,0 @@ -package cn.iocoder.yudao.module.sampling; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -import javax.annotation.Resource; - -/** - * @Description TODO - */ -@SpringBootApplication -public class SamplingServerApplication { - - public static void main(String[] args) { - SpringApplication.run(SamplingServerApplication.class, args); - } -} diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/controller/admin/test/TestController.java b/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/controller/admin/test/TestController.java deleted file mode 100644 index 947670d31..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/controller/admin/test/TestController.java +++ /dev/null @@ -1,24 +0,0 @@ -package cn.iocoder.yudao.module.sampling.controller.admin.test; - -import cn.iocoder.yudao.module.ticket.api.asset.TicketAssetApi; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; - -/** - * @Description TODO - */ -@RestController -@RequestMapping("/sampling") -@Valid -public class TestController { - @Autowired - private TicketAssetApi ticketAssetApi; - @RequestMapping("/test") - public void test(){ - System.out.println(ticketAssetApi.countAsset()); - } -} diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/framework/rpc/config/RpcConfiguration.java b/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/framework/rpc/config/RpcConfiguration.java deleted file mode 100644 index ea646b821..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/framework/rpc/config/RpcConfiguration.java +++ /dev/null @@ -1,15 +0,0 @@ -package cn.iocoder.yudao.module.sampling.framework.rpc.config; - -import cn.iocoder.yudao.module.ticket.api.asset.TicketAssetApi; -import cn.iocoder.yudao.module.ticket.api.checkticket.TicketCheckTicketApi; -import cn.iocoder.yudao.module.ticket.api.saledata.TicketSaleDataApi; -import org.springframework.cloud.openfeign.EnableFeignClients; -import org.springframework.context.annotation.Configuration; - -/** - * @Description TODO - */ -@Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {TicketAssetApi.class, TicketSaleDataApi.class, TicketCheckTicketApi.class}) -public class RpcConfiguration { -} diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/framework/security/config/SecurityConfiguration.java b/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/framework/security/config/SecurityConfiguration.java deleted file mode 100644 index c9e63afcd..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/framework/security/config/SecurityConfiguration.java +++ /dev/null @@ -1,37 +0,0 @@ -package cn.iocoder.yudao.module.sampling.framework.security.config; - -import cn.iocoder.yudao.framework.security.config.AuthorizeRequestsCustomizer; -import cn.iocoder.yudao.module.system.enums.ApiConstants; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.security.config.annotation.web.builders.HttpSecurity; -import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer; - -/** - * Demo 模块的 Security 配置 - */ -@Configuration(proxyBeanMethods = false) -public class SecurityConfiguration { - - @Bean - public AuthorizeRequestsCustomizer authorizeRequestsCustomizer() { - return new AuthorizeRequestsCustomizer() { - - @Override - public void customize(ExpressionUrlAuthorizationConfigurer.ExpressionInterceptUrlRegistry registry) { - // Swagger 接口文档 - registry.antMatchers("/v3/api-docs/**").permitAll() // 元数据 - .antMatchers("/swagger-ui.html").permitAll(); // Swagger UI - // Druid 监控 - registry.antMatchers("/druid/**").anonymous(); - // Spring Boot Actuator 的安全配置 - registry.antMatchers("/actuator").anonymous() - .antMatchers("/actuator/**").anonymous(); - // RPC 服务的安全配置 - registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); - } - - }; - } - -} diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application.yaml b/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application.yaml deleted file mode 100644 index a4f8a4202..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application.yaml +++ /dev/null @@ -1,115 +0,0 @@ -spring: - main: - allow-circular-references: true # 允许循环依赖,因为项目是三层架构,无法避免这个情况。 - allow-bean-definition-overriding: true # 允许 Bean 覆盖,例如说 Feign 等会存在重复定义的服务 - - # Servlet 配置 - servlet: - # 文件上传相关配置项 - multipart: - max-file-size: 16MB # 单个文件大小 - max-request-size: 32MB # 设置总上传的文件大小 - mvc: - pathmatch: - matching-strategy: ANT_PATH_MATCHER # 解决 SpringFox 与 SpringBoot 2.6.x 不兼容的问题,参见 SpringFoxHandlerProviderBeanPostProcessor 类 - - # Jackson 配置项 - jackson: - serialization: - write-dates-as-timestamps: true # 设置 LocalDateTime 的格式,使用时间戳 - write-date-timestamps-as-nanoseconds: false # 设置不使用 nanoseconds 的格式。例如说 1611460870.401,而是直接 1611460870401 - write-durations-as-timestamps: true # 设置 Duration 的格式,使用时间戳 - fail-on-empty-beans: false # 允许序列化无属性的 Bean - - # Cache 配置项 - cache: - type: REDIS - redis: - time-to-live: 1h # 设置过期时间为 1 小时 - ---- #################### 接口文档配置 #################### - -springdoc: - api-docs: - enabled: true # 1. 是否开启 Swagger 接文档的元数据 - path: /v3/api-docs - swagger-ui: - enabled: true # 2.1 是否开启 Swagger 文档的官方 UI 界面 - path: /swagger-ui.html - default-flat-param-object: true # 参见 https://doc.xiaominfo.com/docs/faq/v4/knife4j-parameterobject-flat-param 文档 - -knife4j: - enable: true # 2.2 是否开启 Swagger 文档的 Knife4j UI 界面 - setting: - language: zh_cn - -# MyBatis Plus 的配置项 -mybatis-plus: - configuration: - map-underscore-to-camel-case: true # 虽然默认为 true ,但是还是显示去指定下。 - global-config: - db-config: - id-type: NONE # “智能”模式,基于 IdTypeEnvironmentPostProcessor + 数据源的类型,自动适配成 AUTO、INPUT 模式。 - # id-type: AUTO # 自增 ID,适合 MySQL 等直接自增的数据库 - # id-type: INPUT # 用户输入 ID,适合 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库 - # id-type: ASSIGN_ID # 分配 ID,默认使用雪花算法。注意,Oracle、PostgreSQL、Kingbase、DB2、H2 数据库时,需要去除实体类上的 @KeySequence 注解 - logic-delete-value: 1 # 逻辑已删除值(默认为 1) - logic-not-delete-value: 0 # 逻辑未删除值(默认为 0) - banner: false # 关闭控制台的 Banner 打印 - type-aliases-package: ${yudao.info.base-package}.dal.dataobject - encryptor: - password: XDV71a+xqStEA3WH # 加解密的秘钥,可使用 https://www.imaegoo.com/2020/aes-key-generator/ 网站生成 - -mybatis-plus-join: - banner: false # 关闭控制台的 Banner 打印 - -# Spring Data Redis 配置 -spring: - data: - redis: - repositories: - enabled: false # 项目未使用到 Spring Data Redis 的 Repository,所以直接禁用,保证启动速度 - -# VO 转换(数据翻译)相关 -easy-trans: - is-enable-global: true # 启用全局翻译(拦截所有 SpringMVC ResponseBody 进行自动翻译 )。如果对于性能要求很高可关闭此配置,或通过 @IgnoreTrans 忽略某个接口 - is-enable-cloud: false # 禁用 TransType.RPC 微服务模式 - ---- #################### RPC 远程调用相关配置 #################### - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin - executor: - appname: ${spring.application.name} # 执行器 AppName - address: - ip: # 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; - port: 0 # ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口; - logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - logretentiondays: 30 # 执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; - accessToken: # 执行器通讯TOKEN - ---- #################### 芋道相关配置 #################### - -yudao: - info: - version: 1.0.0 - base-package: cn.iocoder.yudao.module.sampling - swagger: - title: 管理后台 - description: 提供管理员管理的所有功能 - version: ${yudao.info.version} - base-package: ${yudao.info.base-package} - captcha: - enable: true # 验证码的开关,默认为 true; - tenant: # 多租户相关配置项 - enable: false - ignore-urls: - ignore-tables: - -debug: false diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/bootstrap.yaml b/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/bootstrap.yaml deleted file mode 100644 index 1cb6528e0..000000000 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/bootstrap.yaml +++ /dev/null @@ -1,14 +0,0 @@ -spring: - application: - name: sampling-server - - profiles: - active: local - -server: - port: 48089 - -# 日志文件配置。注意,如果 logging.file.name 不放在 bootstrap.yaml 配置文件,而是放在 application.yaml 中,会导致出现 LOG_FILE_IS_UNDEFINED 文件 -logging: - file: - name: ${user.home}/logs/${spring.application.name}.log # 日志文件名,全路径 diff --git a/ludu-module-sampling/pom.xml b/ludu-module-sampling/pom.xml deleted file mode 100644 index 3d4a69439..000000000 --- a/ludu-module-sampling/pom.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - yudao - cn.iocoder.cloud - ${revision} - - 4.0.0 - - ludu-module-sampling-api - ludu-module-sampling-biz - - - ludu-module-sampling - - pom - - ${project.artifactId} - - sampling 模块,我们放抽数服务。 - - - \ No newline at end of file diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application-dev.yaml b/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application-dev.yaml deleted file mode 100644 index b4696be2d..000000000 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application-dev.yaml +++ /dev/null @@ -1,103 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 5 # 初始连接数 - min-idle: 10 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - slave: # 模拟从库,可根据自己需要修改 # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 400-infra.server.iocoder.cn # 地址 - port: 6379 # 端口 - database: 1 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### -xxl: - job: - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - # Spring Boot Admin Server 服务端的相关配置 - context-path: /admin # 配置 Spring - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - xss: - enable: false - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - demo: true # 开启演示模式 diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application-local.yaml b/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application-local.yaml deleted file mode 100644 index 74021e60a..000000000 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application-local.yaml +++ /dev/null @@ -1,127 +0,0 @@ ---- #################### 数据库相关配置 #################### -spring: - # 数据源配置项 - autoconfigure: - exclude: - - com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure # 排除 Druid 的自动配置,使用 dynamic-datasource-spring-boot-starter 配置多数据源 - - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - datasource: - druid: # Druid 【监控】相关的全局配置 - web-stat-filter: - enabled: true - stat-view-servlet: - enabled: true - allow: # 设置白名单,不填则允许所有访问 - url-pattern: /druid/* - login-username: # 控制台管理用户名和密码 - login-password: - filter: - stat: - enabled: true - log-slow-sql: true # 慢 SQL 记录 - slow-sql-millis: 100 - merge-sql: true - wall: - config: - multi-statement-allow: true - dynamic: # 多数据源配置 - druid: # Druid 【连接池】相关的全局配置 - initial-size: 1 # 初始连接数 - min-idle: 1 # 最小连接池数量 - max-active: 20 # 最大连接池数量 - max-wait: 600000 # 配置获取连接等待超时的时间,单位:毫秒 - time-between-eviction-runs-millis: 60000 # 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位:毫秒 - min-evictable-idle-time-millis: 300000 # 配置一个连接在池中最小生存的时间,单位:毫秒 - max-evictable-idle-time-millis: 900000 # 配置一个连接在池中最大生存的时间,单位:毫秒 - validation-query: SELECT 1 FROM DUAL # 配置检测连接是否有效 - test-while-idle: true - test-on-borrow: false - test-on-return: false - primary: master - datasource: - master: - url: jdbc:mysql://120.46.37.243:3306/ludu_ticket?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 - # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 - # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 - # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 - # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=ruoyi-vue-pro # SQLServer 连接的示例 - # url: jdbc:dm://10.211.55.4:5236?schema=RUOYI_VUE_PRO # DM 连接的示例 - username: root - password: xpower1234 - # username: sa # SQL Server 连接的示例 - # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W # SQL Server 连接的示例 - # username: SYSDBA # DM 连接的示例 - # password: SYSDBA # DM 连接的示例 - slave: # 模拟从库,可根据自己需要修改 - lazy: true # 开启懒加载,保证启动速度 - url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true - username: root - password: 123456 - - # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 - redis: - host: 127.0.0.1 # 地址 - port: 6379 # 端口 - database: 0 # 数据库索引 -# password: 123456 # 密码,建议生产环境开启 - ---- #################### MQ 消息队列相关配置 #################### - ---- #################### 定时任务相关配置 #################### - -xxl: - job: - enabled: false # 是否开启调度中心,默认为 true 开启 - admin: - addresses: http://127.0.0.1:9090/xxl-job-admin # 调度中心部署跟地址 - ---- #################### 服务保障相关配置 #################### - -# Lock4j 配置项 -lock4j: - acquire-timeout: 3000 # 获取分布式锁超时时间,默认为 3000 毫秒 - expire: 30000 # 分布式锁的超时时间,默认为 30 毫秒 - ---- #################### 监控相关配置 #################### - -# Actuator 监控端点的配置项 -management: - endpoints: - web: - base-path: /actuator # Actuator 提供的 API 接口的根目录。默认为 /actuator - exposure: - include: '*' # 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。 - -# Spring Boot Admin 配置项 -spring: - boot: - admin: - # Spring Boot Admin Client 客户端的相关配置 - client: - instance: - service-host-type: IP # 注册实例时,优先使用 IP [IP, HOST_NAME, CANONICAL_HOST_NAME] - -# 日志文件配置 -logging: - level: - # 配置自己写的 MyBatis Mapper 打印日志 - cn.iocoder.yudao.module.system.dal.mysql: debug - cn.iocoder.yudao.module.system.dal.mysql.sensitiveword.SensitiveWordMapper: INFO # 配置 SensitiveWordMapper 的日志级别为 info - cn.iocoder.yudao.module.system.dal.mysql.sms.SmsChannelMapper: INFO # 配置 SmsChannelMapper 的日志级别为 info - ---- #################### 芋道相关配置 #################### - -# 芋道配置项,设置当前项目所有自定义的配置 -yudao: - env: # 多环境的配置项 - tag: ${HOSTNAME} - web: - admin-ui: - url: http://dashboard.yudao.iocoder.cn # Admin 管理后台 UI 的地址 - security: - mock-enable: true - xss: - enable: false - access-log: # 访问日志的配置项 - enable: false - demo: false # 关闭演示模式 diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/bootstrap-local.yaml b/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/bootstrap-local.yaml deleted file mode 100644 index 2de0efbf7..000000000 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/bootstrap-local.yaml +++ /dev/null @@ -1,23 +0,0 @@ ---- #################### 注册中心相关配置 #################### - -spring: - cloud: - nacos: - server-addr: 127.0.0.1:8848 - discovery: - namespace: dev # 命名空间。这里使用 dev 开发环境 - metadata: - version: 1.0.0 # 服务实例的版本号,可用于灰度发布 - ---- #################### 配置中心相关配置 #################### - -spring: - cloud: - nacos: - # Nacos Config 配置项,对应 NacosConfigProperties 配置属性类 - config: - server-addr: 127.0.0.1:8848 # Nacos 服务器地址 - namespace: dev # 命名空间 dev 的ID,不能直接使用 dev 名称。创建命名空间的时候需要指定ID为 dev,这里使用 dev 开发环境 - group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP - name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name - file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/logback-spring.xml b/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/logback-spring.xml deleted file mode 100644 index b1b9f3faf..000000000 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/logback-spring.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - -       - - - ${PATTERN_DEFAULT} - - - - - - - - - - ${PATTERN_DEFAULT} - - - - ${LOG_FILE} - - - ${LOGBACK_ROLLINGPOLICY_FILE_NAME_PATTERN:-${LOG_FILE}.%d{yyyy-MM-dd}.%i.gz} - - ${LOGBACK_ROLLINGPOLICY_CLEAN_HISTORY_ON_START:-false} - - ${LOGBACK_ROLLINGPOLICY_MAX_FILE_SIZE:-10MB} - - ${LOGBACK_ROLLINGPOLICY_TOTAL_SIZE_CAP:-0} - - ${LOGBACK_ROLLINGPOLICY_MAX_HISTORY:-30} - - - - - - 0 - - 256 - - - - - - - - ${PATTERN_DEFAULT} - - - - - - - - - - - - - - - - - - - - - - diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/pom.xml b/ludu-module-ticketing/ludu-module-ticketing-api/pom.xml similarity index 93% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/pom.xml rename to ludu-module-ticketing/ludu-module-ticketing-api/pom.xml index bad4d4944..38e19896e 100644 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/pom.xml +++ b/ludu-module-ticketing/ludu-module-ticketing-api/pom.xml @@ -3,12 +3,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - ludu-module-ticket-manager + ludu-module-ticketing cn.iocoder.cloud ${revision} 4.0.0 - ludu-module-ticket-manager-api + ludu-module-ticketing-api jar ${project.artifactId} diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApi.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApi.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApi.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApi.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/dto/TicketAssetRespDTO.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/dto/TicketAssetRespDTO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/dto/TicketAssetRespDTO.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/dto/TicketAssetRespDTO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApi.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApi.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApi.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApi.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/dto/CheckTicketSaveReqDTO.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/dto/CheckTicketSaveReqDTO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/dto/CheckTicketSaveReqDTO.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/dto/CheckTicketSaveReqDTO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApi.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApi.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApi.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApi.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/dto/SaleDataSaveReqDTO.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/dto/SaleDataSaveReqDTO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/dto/SaleDataSaveReqDTO.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/dto/SaleDataSaveReqDTO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ApiConstants.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ApiConstants.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ApiConstants.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ApiConstants.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ErrorCodeConstants.java b/ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ErrorCodeConstants.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ErrorCodeConstants.java rename to ludu-module-ticketing/ludu-module-ticketing-api/src/main/java/cn/iocoder/yudao/module/ticket/enums/ErrorCodeConstants.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/pom.xml b/ludu-module-ticketing/ludu-module-ticketing-biz/pom.xml similarity index 96% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/pom.xml rename to ludu-module-ticketing/ludu-module-ticketing-biz/pom.xml index 84a2e8c57..6f5dfae96 100644 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/pom.xml +++ b/ludu-module-ticketing/ludu-module-ticketing-biz/pom.xml @@ -3,13 +3,13 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - ludu-module-ticket-manager + ludu-module-ticketing cn.iocoder.cloud ${revision} 4.0.0 - ludu-module-ticket-manager-biz + ludu-module-ticketing-biz jar @@ -23,7 +23,7 @@ cn.iocoder.cloud - ludu-module-ticket-manager-api + ludu-module-ticketing-api ${revision} diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/TicketManagerServerApplication.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/TicketingServerApplication.java similarity index 68% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/TicketManagerServerApplication.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/TicketingServerApplication.java index 9d7e0d2c0..477d2ded0 100644 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/TicketManagerServerApplication.java +++ b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/TicketingServerApplication.java @@ -8,8 +8,8 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; */ @SpringBootApplication -public class TicketManagerServerApplication { +public class TicketingServerApplication { public static void main(String[] args) { - SpringApplication.run(TicketManagerServerApplication.class, args); + SpringApplication.run(TicketingServerApplication.class, args); } } diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApiImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApiImpl.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApiImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/asset/TicketAssetApiImpl.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApiImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApiImpl.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApiImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/checkticket/TicketCheckTicketApiImpl.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApiImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApiImpl.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApiImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/api/saledata/TicketSaleDataApiImpl.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/AssetController.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/AssetController.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/AssetController.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/AssetController.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetPageReqVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetPageReqVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetPageReqVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetPageReqVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetRespVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetRespVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetRespVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetRespVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetSaveReqVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetSaveReqVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetSaveReqVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/asset/vo/AssetSaveReqVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/CheckTicketController.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/CheckTicketController.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/CheckTicketController.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/CheckTicketController.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketPageReqVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketPageReqVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketPageReqVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketPageReqVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketRespVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketRespVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketRespVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketRespVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketSaveReqVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketSaveReqVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketSaveReqVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/checkticket/vo/vo/CheckTicketSaveReqVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/SaleDataController.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/SaleDataController.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/SaleDataController.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/SaleDataController.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataPageReqVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataPageReqVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataPageReqVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataPageReqVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataRespVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataRespVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataRespVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataRespVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataSaveReqVO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataSaveReqVO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataSaveReqVO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/controller/admin/saledata/vo/SaleDataSaveReqVO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvert.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvert.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvert.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvert.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvertImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvertImpl.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvertImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/convert/asset/AssetConvertImpl.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/asset/AssetDO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/asset/AssetDO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/asset/AssetDO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/asset/AssetDO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/checkticket/CheckTicketDO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/checkticket/CheckTicketDO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/checkticket/CheckTicketDO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/checkticket/CheckTicketDO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/saledata/SaleDataDO.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/saledata/SaleDataDO.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/saledata/SaleDataDO.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/dataobject/saledata/SaleDataDO.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/asset/AssetMapper.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/asset/AssetMapper.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/asset/AssetMapper.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/asset/AssetMapper.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/checkticket/CheckTicketMapper.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/checkticket/CheckTicketMapper.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/checkticket/CheckTicketMapper.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/checkticket/CheckTicketMapper.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/saledata/SaleDataMapper.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/saledata/SaleDataMapper.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/saledata/SaleDataMapper.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/dal/mysql/saledata/SaleDataMapper.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/framework/security/config/SecurityConfiguration.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/framework/security/config/SecurityConfiguration.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/framework/security/config/SecurityConfiguration.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/framework/security/config/SecurityConfiguration.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetService.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetService.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetService.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetService.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImpl.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImpl.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketService.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketService.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketService.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketService.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImpl.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImpl.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataService.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataService.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataService.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataService.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImpl.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImpl.java similarity index 99% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImpl.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImpl.java index 1bf55c521..8efe1190a 100644 --- a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImpl.java +++ b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImpl.java @@ -95,8 +95,7 @@ public class SaleDataServiceImpl implements SaleDataService { try { date1 = inputFormat.parse(startTime); } catch (ParseException e) { -// throw new RuntimeException(e); - System.out.println("抛出日期转换异常"); + throw new RuntimeException(e); } calendar.setTime(date1); calendar.add(Calendar.DAY_OF_YEAR, -9); diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application-dev.yaml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application-dev.yaml similarity index 100% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application-dev.yaml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application-dev.yaml diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application-local.yaml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application-local.yaml similarity index 96% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application-local.yaml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application-local.yaml index 74021e60a..05aa78028 100644 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/application-local.yaml +++ b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application-local.yaml @@ -40,7 +40,7 @@ spring: primary: master datasource: master: - url: jdbc:mysql://120.46.37.243:3306/ludu_ticket?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 + url: jdbc:mysql://120.46.37.243:3306/ludu_ticketing?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 # url: jdbc:mysql://127.0.0.1:3306/ruoyi-vue-pro?useSSL=true&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai # MySQL Connector/J 5.X 连接的示例 # url: jdbc:postgresql://127.0.0.1:5432/ruoyi-vue-pro # PostgreSQL 连接的示例 # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application.yaml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application.yaml similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/application.yaml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/application.yaml diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/bootstrap-local.yaml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/bootstrap-local.yaml similarity index 100% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/bootstrap-local.yaml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/bootstrap-local.yaml diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/bootstrap.yaml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/bootstrap.yaml similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/bootstrap.yaml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/bootstrap.yaml diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/logback-spring.xml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/logback-spring.xml similarity index 100% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/resources/logback-spring.xml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/logback-spring.xml diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/mapper/asset/AssetMapper.xml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/mapper/asset/AssetMapper.xml similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/mapper/asset/AssetMapper.xml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/mapper/asset/AssetMapper.xml diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/mapper/checkticket/CheckticketMapper.xml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/mapper/checkticket/CheckticketMapper.xml similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/mapper/checkticket/CheckticketMapper.xml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/mapper/checkticket/CheckticketMapper.xml diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/mapper/saledata/SaleDataMapper.xml b/ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/mapper/saledata/SaleDataMapper.xml similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/main/resources/mapper/saledata/SaleDataMapper.xml rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/main/resources/mapper/saledata/SaleDataMapper.xml diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImplTest.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImplTest.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImplTest.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/asset/AssetServiceImplTest.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImplTest.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImplTest.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImplTest.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/checkticket/CheckTicketServiceImplTest.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImplTest.java b/ludu-module-ticketing/ludu-module-ticketing-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImplTest.java similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImplTest.java rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/test/java/cn/iocoder/yudao/module/ticket/service/saledata/SaleDataServiceImplTest.java diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/resources/sql/clean.sql b/ludu-module-ticketing/ludu-module-ticketing-biz/src/test/resources/sql/clean.sql similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/resources/sql/clean.sql rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/test/resources/sql/clean.sql diff --git a/ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/resources/sql/create_tables.sql b/ludu-module-ticketing/ludu-module-ticketing-biz/src/test/resources/sql/create_tables.sql similarity index 100% rename from ludu-module-ticket-manager/ludu-module-ticket-manager-biz/src/test/resources/sql/create_tables.sql rename to ludu-module-ticketing/ludu-module-ticketing-biz/src/test/resources/sql/create_tables.sql diff --git a/ludu-module-ticket-manager/pom.xml b/ludu-module-ticketing/pom.xml similarity index 81% rename from ludu-module-ticket-manager/pom.xml rename to ludu-module-ticketing/pom.xml index d38fb442a..c50afa459 100644 --- a/ludu-module-ticket-manager/pom.xml +++ b/ludu-module-ticketing/pom.xml @@ -9,10 +9,10 @@ 4.0.0 - ludu-module-ticket-manager-api - ludu-module-ticket-manager-biz + ludu-module-ticketing-api + ludu-module-ticketing-biz - ludu-module-ticket-manager + ludu-module-ticketing pom ${project.artifactId} diff --git a/pom.xml b/pom.xml index adfe58568..ac2908240 100644 --- a/pom.xml +++ b/pom.xml @@ -15,12 +15,8 @@ yudao-module-system yudao-module-infra yudao-module-member - ludu-module-ticket-manager - ludu-module-sampling - ludu-module-sampling/ludu-module-sampling-api - ludu-module-sampling/ludu-module-sampling-biz + ludu-module-ticketing ludu-job-admin - ludu-job-admin/ludu-job-admin-biz diff --git a/yudao-framework/yudao-spring-boot-starter-security/pom.xml b/yudao-framework/yudao-spring-boot-starter-security/pom.xml index 18d4c73b9..3720d81f6 100644 --- a/yudao-framework/yudao-spring-boot-starter-security/pom.xml +++ b/yudao-framework/yudao-spring-boot-starter-security/pom.xml @@ -73,7 +73,19 @@ io.github.mouzt bizlog-sdk - + + + org.springframework.boot + spring-boot-starter-oauth2-client + + + org.springframework.boot + spring-boot-starter-oauth2-resource-server + + + org.springframework.security + spring-security-oauth2-jose + diff --git a/yudao-module-infra/yudao-module-infra-biz/pom.xml b/yudao-module-infra/yudao-module-infra-biz/pom.xml index e3920ab4b..33a542340 100644 --- a/yudao-module-infra/yudao-module-infra-biz/pom.xml +++ b/yudao-module-infra/yudao-module-infra-biz/pom.xml @@ -19,11 +19,18 @@ + cn.iocoder.cloud ludu-job-core ${revision} + + + cn.iocoder.cloud + ludu-module-ticketing-api + ${revision} + cn.iocoder.cloud ludu-job-admin-api diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/config/XxlJobConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/config/XxlJobConfiguration.java similarity index 94% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/config/XxlJobConfiguration.java rename to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/config/XxlJobConfiguration.java index c0c3cc9a9..ba7573d1d 100644 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/config/XxlJobConfiguration.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/config/XxlJobConfiguration.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.sampling.config; +package cn.iocoder.yudao.module.infra.config; import com.xxl.job.core.executor.impl.XxlJobSpringExecutor; import org.springframework.beans.factory.annotation.Value; @@ -6,7 +6,7 @@ import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** - * @Description TODO + * @Description xxl-job配置文件 */ @Configuration public class XxlJobConfiguration { diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/joblog/JobLogController.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/joblog/JobLogController.java index 0a1255ffb..e1047d03c 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/joblog/JobLogController.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/controller/admin/joblog/JobLogController.java @@ -1,8 +1,12 @@ package cn.iocoder.yudao.module.infra.controller.admin.joblog; +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import com.xxl.job.admin.api.info.dto.JobInfoPageReqDTO; import com.xxl.job.admin.api.info.dto.JobInfoRespDTO; import com.xxl.job.admin.api.log.JobLogApi; import com.xxl.job.admin.api.log.dto.JobLogPageReqDTO; @@ -11,12 +15,15 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; @Tag(name = "管理后台 - 定时任务日志") @RestController @@ -25,9 +32,29 @@ import javax.validation.Valid; public class JobLogController { @Resource private JobLogApi jobLogApi; - @RequestMapping("/page") + @GetMapping("/page") @Operation(summary = "获得任务日志列表") + @PreAuthorize("@ss.hasPermission('infra:job-log:query')") public CommonResult> getPage(@Valid JobLogPageReqDTO jobLogPageReqDTO){ - return jobLogApi.getPage(jobLogPageReqDTO); + return jobLogApi.getPage(jobLogPageReqDTO.getPageNo(), jobLogPageReqDTO.getPageSize(), jobLogPageReqDTO.getJobId(), jobLogPageReqDTO.getHandlerName(), jobLogPageReqDTO.getBeginTime(), jobLogPageReqDTO.getEndTime(), jobLogPageReqDTO.getStatus()); + } + + @GetMapping("/get") + @Operation(summary = "获取任务详情") + @PreAuthorize("@ss.hasPermission('infra:job-log:query')") + public CommonResult get(@RequestParam("id") Integer id){ + return jobLogApi.get(id); + } + @GetMapping("/export-excel") + @Operation(summary = "导出任务 Excel") + @PreAuthorize("@ss.hasPermission('infra:job-log:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportJobInfoExcel(@Valid JobLogPageReqDTO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = jobLogApi.getPage(pageReqVO.getPageNo(), pageReqVO.getPageSize(), pageReqVO.getJobId(), pageReqVO.getHandlerName(), pageReqVO.getBeginTime(), pageReqVO.getEndTime(), pageReqVO.getStatus()).getData().getList(); + //导出 Excel + ExcelUtils.write(response, "任务调度日志.xls", "数据", JobLogRespDTO.class, + list); } } diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java index 2b16b44cb..00558c33e 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/framework/rpc/config/RpcConfiguration.java @@ -1,12 +1,15 @@ package cn.iocoder.yudao.module.infra.framework.rpc.config; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.ticket.api.asset.TicketAssetApi; +import cn.iocoder.yudao.module.ticket.api.checkticket.TicketCheckTicketApi; +import cn.iocoder.yudao.module.ticket.api.saledata.TicketSaleDataApi; import com.xxl.job.admin.api.info.JobInfoApi; import com.xxl.job.admin.api.log.JobLogApi; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) -@EnableFeignClients(clients = {AdminUserApi.class, JobInfoApi.class, JobLogApi.class}) +@EnableFeignClients(clients = {AdminUserApi.class, JobInfoApi.class, JobLogApi.class, TicketSaleDataApi.class, TicketCheckTicketApi.class}) public class RpcConfiguration { } diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/TicketingSamplingJob.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/TicketDataMigration.java similarity index 96% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/TicketingSamplingJob.java rename to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/TicketDataMigration.java index b571c75f0..e27096f03 100644 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/TicketingSamplingJob.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/TicketDataMigration.java @@ -1,10 +1,10 @@ -package cn.iocoder.yudao.module.sampling.service.ticketing; +package cn.iocoder.yudao.module.infra.service.ticketing; import cn.hutool.http.HttpUtil; import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.util.date.TickingDateUtils; -import cn.iocoder.yudao.module.sampling.service.ticketing.vo.TicketingSamplingReqVO; -import cn.iocoder.yudao.module.sampling.service.ticketing.vo.TicketingSamplingRespVO; +import cn.iocoder.yudao.module.infra.service.ticketing.vo.TicketingSamplingReqVO; +import cn.iocoder.yudao.module.infra.service.ticketing.vo.TicketingSamplingRespVO; import cn.iocoder.yudao.module.ticket.api.checkticket.TicketCheckTicketApi; import cn.iocoder.yudao.module.ticket.api.checkticket.dto.CheckTicketSaveReqDTO; import cn.iocoder.yudao.module.ticket.api.saledata.TicketSaleDataApi; @@ -18,16 +18,15 @@ import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.math.BigDecimal; -import java.util.HashMap; import java.util.List; import java.util.Map; /** - * @Description 抽数服务 + * @Description 票务抽数服务 */ @Component -public class TicketingSamplingJob { - private static Logger logger = LoggerFactory.getLogger(TicketingSamplingJob.class); +public class TicketDataMigration { + private static Logger logger = LoggerFactory.getLogger(TicketDataMigration.class); private static final int PAGE_SIZE = 500; @Resource @@ -186,7 +185,6 @@ public class TicketingSamplingJob { saleData.setItemname((String) currentMap.get("itemname")); saleData.setSalepropetyvaluename((String) currentMap.get("salepropetyvaluename")); saleData.setTenant_id(1L); - if (ticketSaleDataApi.createSaleData(saleData).getCode() != 0) { failedCount++; XxlJobHelper.log("第{}条数据插入失败,数据值为:{}", ((pageNumber - 1) * PAGE_SIZE + i + 1), currentMap); @@ -216,8 +214,6 @@ public class TicketingSamplingJob { checkTicket.setSdshipping((String) currentMap.get("sdshipping")); checkTicket.setSalepropetyvaluename((String) currentMap.get("salepropetyvaluename")); checkTicket.setTenant_id(1L); - ticketCheckTicketApi.createCheckTicket(checkTicket); - if (ticketCheckTicketApi.createCheckTicket(checkTicket).getCode() != 0) { failedCount++; XxlJobHelper.log("第{}条数据插入失败,数据值为:{}", ((pageNumber - 1) * PAGE_SIZE + i + 1), currentMap); diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/vo/TicketingSamplingReqVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/vo/TicketingSamplingReqVO.java similarity index 92% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/vo/TicketingSamplingReqVO.java rename to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/vo/TicketingSamplingReqVO.java index 01544d376..52a483363 100644 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/vo/TicketingSamplingReqVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/vo/TicketingSamplingReqVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.sampling.service.ticketing.vo; +package cn.iocoder.yudao.module.infra.service.ticketing.vo; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; diff --git a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/vo/TicketingSamplingRespVO.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/vo/TicketingSamplingRespVO.java similarity index 93% rename from ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/vo/TicketingSamplingRespVO.java rename to yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/vo/TicketingSamplingRespVO.java index af0de9169..877cf0ad7 100644 --- a/ludu-module-sampling/ludu-module-sampling-biz/src/main/java/cn/iocoder/yudao/module/sampling/service/ticketing/vo/TicketingSamplingRespVO.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/ticketing/vo/TicketingSamplingRespVO.java @@ -1,4 +1,4 @@ -package cn.iocoder.yudao.module.sampling.service.ticketing.vo; +package cn.iocoder.yudao.module.infra.service.ticketing.vo; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.swagger.v3.oas.annotations.media.Schema; diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml index 0b387b909..635d7399c 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/resources/application.yaml @@ -107,10 +107,16 @@ spring: xxl: job: + admin: + addresses: http://127.0.0.1:9090/xxl-job-admin executor: appname: ${spring.application.name} # 执行器 AppName + address: + ip: # 执行器IP [选填]:默认为空表示自动获取IP,多网卡时可手动设置指定IP,该IP不会绑定Host仅作为通讯实用;地址信息用于 "执行器注册" 和 "调度中心请求并触发任务"; + port: 0 # ### 执行器端口号 [选填]:小于等于0则自动获取;默认端口为9999,单机部署多个执行器时,注意要配置不同执行器端口; logpath: ${user.home}/logs/xxl-job/${spring.application.name} # 执行器运行日志文件存储磁盘路径 - accessToken: default_token # 执行器通讯TOKEN + logretentiondays: 30 # 执行器日志文件保存天数 [选填] : 过期日志自动清理, 限制值大于等于3时生效; 否则, 如-1, 关闭自动清理功能; + accessToken: # 执行器通讯TOKEN --- #################### 芋道相关配置 #################### @@ -156,7 +162,6 @@ yudao: - infra_file_content - infra_job - infra_job_log - - infra_job_log - infra_data_source_config debug: false diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java index 521e4e7cf..105183c3d 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/controller/admin/auth/AuthController.java @@ -7,6 +7,7 @@ import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.security.config.SecurityProperties; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; import cn.iocoder.yudao.module.system.convert.auth.AuthConvert; import cn.iocoder.yudao.module.system.dal.dataobject.permission.MenuDO; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java index 52796ec2f..6de1c90ef 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.system.service.auth; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.controller.admin.auth.vo.*; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java index 53a6b2075..eeea14dec 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/auth/AdminAuthServiceImpl.java @@ -3,10 +3,12 @@ package cn.iocoder.yudao.module.system.service.auth; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.monitor.TracerUtils; import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils; import cn.iocoder.yudao.framework.common.util.validation.ValidationUtils; import cn.iocoder.yudao.module.system.api.logger.dto.LoginLogCreateReqDTO; +import cn.iocoder.yudao.module.system.api.oauth2.dto.OAuth2AccessTokenRespDTO; import cn.iocoder.yudao.module.system.api.sms.SmsCodeApi; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserBindReqDTO; import cn.iocoder.yudao.module.system.api.social.dto.SocialUserRespDTO; @@ -29,10 +31,18 @@ import com.xingyuv.captcha.model.vo.CaptchaVO; import com.xingyuv.captcha.service.CaptchaService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.*; import org.springframework.stereotype.Service; +import org.springframework.util.Assert; +import org.springframework.util.Base64Utils; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import org.springframework.web.client.RestTemplate; import javax.annotation.Resource; import javax.validation.Validator; +import java.nio.charset.StandardCharsets; import java.util.Objects; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; @@ -70,6 +80,7 @@ public class AdminAuthServiceImpl implements AdminAuthService { */ @Value("${yudao.captcha.enable:true}") private Boolean captchaEnable; + private final RestTemplate restTemplate = new RestTemplate(); @Override public AdminUserDO authenticate(String username, String password) {