diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/pom.xml b/ludu-module-datacenter/ludu-module-datacenter-biz/pom.xml index 18e366d75..4d2dea9cd 100644 --- a/ludu-module-datacenter/ludu-module-datacenter-biz/pom.xml +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/pom.xml @@ -116,6 +116,12 @@ yudao-spring-boot-starter-monitor + + + org.springframework.cloud + spring-cloud-starter-openfeign + + diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/DatacenterServerApplication.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/DatacenterServerApplication.java index 3aa0aa9cd..87f446c28 100644 --- a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/DatacenterServerApplication.java +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/DatacenterServerApplication.java @@ -2,11 +2,13 @@ package cn.iocoder.yudao.module.datacenter; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * @Description 大屏服务启动类 */ @SpringBootApplication +@EnableFeignClients public class DatacenterServerApplication { public static void main(String[] args) { SpringApplication.run(DatacenterServerApplication.class, args); diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/checkticket/CheckTicketApi.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/checkticket/CheckTicketApi.java index bd7d6865f..5924a2d58 100644 --- a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/checkticket/CheckTicketApi.java +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/checkticket/CheckTicketApi.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.datacenter.controller.app.checkticket; +import cn.iocoder.yudao.module.datacenter.controller.app.clients.LoginClient; +import cn.iocoder.yudao.module.datacenter.controller.app.clients.vo.AuthLoginReqVO; import cn.iocoder.yudao.module.datacenter.service.checkticket.CheckTicketService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; @@ -20,6 +22,10 @@ import java.util.Map; public class CheckTicketApi { @Resource private CheckTicketService checkTicketService; + + @Resource + private LoginClient loginClient; + @GetMapping() @Operation(summary = "获得日期当天的检票人数") public Long checkTicketTotal(String starTime, String endTime) { @@ -35,4 +41,13 @@ public class CheckTicketApi { String replace1 = endTime.replace("-", ""); return checkTicketService.findbytimetemp(replace,replace1); } + + @GetMapping("/getToken") + public Map test(){ + AuthLoginReqVO loginReqVO = new AuthLoginReqVO(); + loginReqVO.setPassword("admin123"); + loginReqVO.setUsername("admin"); + Map token = loginClient.getToken(loginReqVO,"1"); + return token; + } } diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/clients/LoginClient.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/clients/LoginClient.java new file mode 100644 index 000000000..02f78c1b9 --- /dev/null +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/clients/LoginClient.java @@ -0,0 +1,16 @@ +package cn.iocoder.yudao.module.datacenter.controller.app.clients; + +import cn.iocoder.yudao.module.datacenter.controller.app.clients.vo.AuthLoginReqVO; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; + +import java.util.Map; + +@FeignClient("system-server") +public interface LoginClient { + @PostMapping("/admin-api/system/auth/login") + Map getToken(@RequestBody AuthLoginReqVO reqVO, @RequestHeader("Tenant-Id") String tenantId); +} diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/clients/vo/AuthLoginReqVO.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/clients/vo/AuthLoginReqVO.java new file mode 100644 index 000000000..62e8d9f6e --- /dev/null +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/controller/app/clients/vo/AuthLoginReqVO.java @@ -0,0 +1,69 @@ +package cn.iocoder.yudao.module.datacenter.controller.app.clients.vo; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.common.validation.InEnum; +import cn.iocoder.yudao.module.system.enums.social.SocialTypeEnum; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.AssertTrue; +import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.Pattern; + +@Schema(description = "管理后台 - 账号密码登录 Request VO,如果登录并绑定社交用户,需要传递 social 开头的参数") +@Data +@NoArgsConstructor +@AllArgsConstructor +@Builder +public class AuthLoginReqVO { + + @Schema(description = "账号", requiredMode = Schema.RequiredMode.REQUIRED, example = "yudaoyuanma") + @NotEmpty(message = "登录账号不能为空") + @Length(min = 4, max = 16, message = "账号长度为 4-16 位") + @Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母") + private String username; + + @Schema(description = "密码", requiredMode = Schema.RequiredMode.REQUIRED, example = "buzhidao") + @NotEmpty(message = "密码不能为空") + @Length(min = 4, max = 16, message = "密码长度为 4-16 位") + private String password; + + // ========== 图片验证码相关 ========== + + @Schema(description = "验证码,验证码开启时,需要传递", requiredMode = Schema.RequiredMode.REQUIRED, + example = "PfcH6mgr8tpXuMWFjvW6YVaqrswIuwmWI5dsVZSg7sGpWtDCUbHuDEXl3cFB1+VvCC/rAkSwK8Fad52FSuncVg==") + @NotEmpty(message = "验证码不能为空", groups = CodeEnableGroup.class) + private String captchaVerification; + + // ========== 绑定社交登录时,需要传递如下参数 ========== + + @Schema(description = "社交平台的类型,参见 SocialTypeEnum 枚举值", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") + @InEnum(SocialTypeEnum.class) + private Integer socialType; + + @Schema(description = "授权码", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private String socialCode; + + @Schema(description = "state", requiredMode = Schema.RequiredMode.REQUIRED, example = "9b2ffbc1-7425-4155-9894-9d5c08541d62") + private String socialState; + + /** + * 开启验证码的 Group + */ + public interface CodeEnableGroup {} + + @AssertTrue(message = "授权码不能为空") + public boolean isSocialCodeValid() { + return socialType == null || StrUtil.isNotEmpty(socialCode); + } + + @AssertTrue(message = "授权 state 不能为空") + public boolean isSocialState() { + return socialType == null || StrUtil.isNotEmpty(socialState); + } + +} diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/checkticket/CheckTicketServiceImpl.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/checkticket/CheckTicketServiceImpl.java index 641f9bee2..97cc043b3 100644 --- a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/checkticket/CheckTicketServiceImpl.java +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/checkticket/CheckTicketServiceImpl.java @@ -57,14 +57,20 @@ public class CheckTicketServiceImpl implements CheckTicketService { countMap.put("map"+String.format("%02d", Integer.parseInt(i+"")),0); } //查询该时间区域的所有数据 + long s1 = System.currentTimeMillis(); List allByCheckticketdateBetween = checkTicketRepository.findAllByCheckticketdateBetween(starTime, this.publicMethod(endTime)); + long s2 = System.currentTimeMillis(); + System.out.println("1-------------------------"+(s2-s1)); //分析数据 + long s3 = System.currentTimeMillis(); for (CheckTicket checkTicket : allByCheckticketdateBetween) { String checktickettime = checkTicket.getChecktickettime(); String result = checktickettime.substring(0, 2); Integer numberCount = countMap.get("map" + result); countMap.put("map" + result, numberCount+1); } + long s4 = System.currentTimeMillis(); + System.out.println("2--------------------------"+(s4-s3)); //构造数据结构 LocalDateTime startTime = LocalDateTime.now(); diff --git a/yudao-module-infra/yudao-module-infra-biz/pom.xml b/yudao-module-infra/yudao-module-infra-biz/pom.xml index efa130553..88cd15e43 100644 --- a/yudao-module-infra/yudao-module-infra-biz/pom.xml +++ b/yudao-module-infra/yudao-module-infra-biz/pom.xml @@ -164,6 +164,12 @@ tika-core + + + org.springframework.cloud + spring-cloud-starter-openfeign + + diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java index fe3eee495..0aa9663c1 100644 --- a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/InfraServerApplication.java @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.infra; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.openfeign.EnableFeignClients; /** * 项目的启动类 @@ -13,6 +14,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; * @author 芋道源码 */ @SpringBootApplication +@EnableFeignClients public class InfraServerApplication { public static void main(String[] args) { diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/clients/LargeScreenClient.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/clients/LargeScreenClient.java new file mode 100644 index 000000000..8b3b086a0 --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/clients/LargeScreenClient.java @@ -0,0 +1,13 @@ +package cn.iocoder.yudao.module.infra.clients; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; +import java.util.Map; + +@FeignClient("datacenter-server") +public interface LargeScreenClient { + @GetMapping("/api/asset/type") + List assetMethod1(); +} diff --git a/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/job/largeScreenHeartbeat/LargeScreenHeartbeat.java b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/job/largeScreenHeartbeat/LargeScreenHeartbeat.java new file mode 100644 index 000000000..4858e0a8a --- /dev/null +++ b/yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/job/largeScreenHeartbeat/LargeScreenHeartbeat.java @@ -0,0 +1,28 @@ +package cn.iocoder.yudao.module.infra.job.largeScreenHeartbeat; + + +import cn.iocoder.yudao.module.infra.api.websocket.WebSocketSenderApi; +import cn.iocoder.yudao.module.infra.clients.LargeScreenClient; +import com.xxl.job.core.handler.annotation.XxlJob; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; +import java.util.List; +import java.util.Map; + +@Component +public class LargeScreenHeartbeat { + + @Resource + private WebSocketSenderApi webSocketSenderApi; + + @Resource + private LargeScreenClient largeScreenClient; + + @XxlJob("largeScreen") + public void largeScreenToWebSocket(){ + List maps = largeScreenClient.assetMethod1(); + webSocketSenderApi.sendObject(1,"1",maps); + } + +} 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 105183c3d..2c06232d1 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 @@ -67,6 +67,9 @@ public class AuthController { @PermitAll @Operation(summary = "使用账号密码登录") public CommonResult login(@RequestBody @Valid AuthLoginReqVO reqVO) { +// AuthLoginReqVO loginReqVO = new AuthLoginReqVO(); +// loginReqVO.setPassword("admin123"); +// loginReqVO.setUsername("admin"); return success(authService.login(reqVO)); } diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java index 3f0a7ac31..58c266716 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/security/config/SecurityConfiguration.java @@ -30,6 +30,8 @@ public class SecurityConfiguration { .antMatchers("/actuator/**").anonymous(); // RPC 服务的安全配置 registry.antMatchers(ApiConstants.PREFIX + "/**").permitAll(); + //登录接口 + registry.antMatchers("/system/auth/login").permitAll(); } };