diff --git a/pom.xml b/pom.xml index 255d28d7..bb447386 100644 --- a/pom.xml +++ b/pom.xml @@ -3,12 +3,6 @@ xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - top.continew continew-starter @@ -19,14 +13,16 @@ zayac-admin ${revision} pom - ContiNew Admin(Continue New Admin)持续迭代优化的前后端分离中后台管理系统框架,开箱即用,持续提供舒适的开发体验。 + Zayac Admin(Zayac + Admin)持续迭代优化的前后端分离中后台管理系统框架,开箱即用,持续提供舒适的开发体验。 + zayac-admin-webapi zayac-admin-system zayac-admin-generator zayac-admin-common - zayac-admin-account + zayac-admin-backend @@ -37,6 +33,15 @@ + + + + + com.zayac + zayac-admin-backend + ${revision} + + com.zayac @@ -64,6 +69,7 @@ zayac-admin-common ${revision} + diff --git a/zayac-admin-account/pom.xml b/zayac-admin-backend/pom.xml similarity index 90% rename from zayac-admin-account/pom.xml rename to zayac-admin-backend/pom.xml index 290b3ed5..2fd4606c 100644 --- a/zayac-admin-account/pom.xml +++ b/zayac-admin-backend/pom.xml @@ -9,8 +9,8 @@ ${revision} - zayac-admin-account - 后台账号相关组件 + zayac-admin-backend + 后台定时任务相关组件 diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/config/WebClientConfig.java b/zayac-admin-backend/src/main/java/com/zayac/admin/config/WebClientConfig.java new file mode 100644 index 00000000..2eaa2f34 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/config/WebClientConfig.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.web.reactive.function.client.WebClient; + +@Configuration +public class WebClientConfig { + @Bean + public WebClient webClient() { + return WebClient.builder().defaultHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON_VALUE).build(); + } +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/constant/ApiPathConstants.java b/zayac-admin-backend/src/main/java/com/zayac/admin/constant/ApiPathConstants.java new file mode 100644 index 00000000..ddd11f5e --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/constant/ApiPathConstants.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.constant; + +/** + * 三方接口请求URL路径常量 + * + * @author zayac + * @since 2024/05/19 12:29 + */ +public class ApiPathConstants { + + /** + * BANNER_URL 对应页面上的banner + */ + public static final String BANNER_URL = "/agent/api/v1/front/banner"; + + /** + * VISUAL_LIST_URL 对应页上的图表信息 + */ + public static final String VISUAL_LIST_URL = "/agent/api/v1/front/getAgentDataVisualList"; + + /** + * MEMBER_LIST_URL 会员管理页面 + */ + public static final String MEMBER_LIST_URL = "/agent/api/v1/member/list"; + + /** + * MEMBER_LIST_URL 点击会员详情页面 + */ + public static final String MEMBER_DETAIL_URL = "/agent/api/v1/member/detail"; + /** + * PAY_RECORD_URL 下级管理 存款记录页面 + */ + public static final String PAY_RECORDS_LIST_URL = "/agent/api/v1/payRecords/list"; + + /** + * PAY_RECORD_LIST_URL 查询单个会员的存款记录 查询注册但存款失败用户 + * res:{'data': {'page': 1, 'pageNum': 0, 'pageSize': 15, 'total': 0, 'list': [], 'orderAmountTotal': '0', + * 'rebateAmountTotal': '0', 'scoreAmountTotal': '0'}, 'message': '未找到数据', 'status_code': 6000} + */ + public static final String PAY_RECORD_LIST_URL = "/agent/api/v1/member/payRecordList"; + + /** + * FINANCE_STATEMENT_URL 财务报表 + */ + public static final String FINANCE_STATEMENT_URL = "/agent/api/v1/finance/excel/total"; + + /** + * MEMBER_TEAM_LIST_URL 团队会员 + */ + public static final String MEMBER_TEAM_LIST_URL = "/agent/api/v1/member/teamList"; + + /** + * 团队信息 + */ + public static final String TEAM_LIST_URL = "/agent/api/v1/team/list"; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java new file mode 100644 index 00000000..c44b4a7f --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/AgentDataVisualListReq.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class AgentDataVisualListReq { + @JsonFormat(pattern = "yyyy-MM") + @Builder.Default + private LocalDate monthDate = LocalDate.now(); +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/FinancialStatementReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/FinancialStatementReq.java new file mode 100644 index 00000000..27794390 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/FinancialStatementReq.java @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; + +import java.time.LocalDate; +import java.time.temporal.TemporalAdjusters; + +@Data +@AllArgsConstructor +@Builder +public class FinancialStatementReq { + //起始日期 + @JsonFormat(pattern = "yyyy-MM-dd") + @Builder.Default + private LocalDate startDate = LocalDate.now().with(TemporalAdjusters.firstDayOfMonth()); + //结束日期 + @JsonFormat(pattern = "yyyy-MM-dd") + @Builder.Default + private LocalDate endDate = LocalDate.now(); + //未知参数,默认为0 + @Builder.Default + private Integer topId = 0; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberDetailsReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberDetailsReq.java new file mode 100644 index 00000000..39b0a957 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberDetailsReq.java @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class MemberDetailsReq { + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate startDate; + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate endDate; + + private Long id; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberListReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberListReq.java new file mode 100644 index 00000000..e5fed31a --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/MemberListReq.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +/** + * 会员管理界面 请求参数 + */ + +/** + * { + * "pageNum": 1, + * "pageSize": 10, + * "registerSort": -1, + * "drawSort": -1, + * "depositSort": -1, + * "lastLoginTimeSort": -1, + * "name": "", + * "minPay": null, + * "maxPay": null, + * "startDate": "2024-04-01", + * "registerStartDate": "2024-04-25", + * "endDate": "2024-04-25", + * "registerEndDate": "2024-04-25", + * "firstPayStartTime": "", + * "firstPayEndTime": "", + * "isBet": "", + * "status": -1, + * "isRest": false, + * "tagsIds": [ + * "20000005181", + * "20000005479", + * "20000008037" + * ], + * "tagsFlag": "1" + * } + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +public class MemberListReq { + @Builder.Default + private int pageNum = 1; + @Builder.Default + private int pageSize = 10; + + //注册时间排序 + @Builder.Default + private int registerSort = -1; + + //提款排序 + @Builder.Default + private int drawSort = -1; + + //存款排序 + @Builder.Default + private int depositSort = -1; + + //最后登录时间排序 + @Builder.Default + private int lastLoginTimeSort = -1; + + //会员账号 + private String name; + + //存款金额 最小金额 + private Double minPay; + + //存款金额 最大金额 + private Double maxPay; + + //统计时间 开始日期 + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate startDate; + + //统计时间 结束日期 + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate endDate; + + //注册起始日期 + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate registerStartDate; + + //注册结束日期 + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate registerEndDate; + + //首次存款起始时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime firstPayStartTime; + + //首次存款结束时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime firstPayEndTime; + + //是否投注 默认空 1投注 0未投注 + private String isBet; + + //状态 -1 全部 1 正常 0禁用 + @Builder.Default + private int status = -1; + + // 重置 + @Builder.Default + private boolean isRest = false; + + // 标签id 不传或为空查询所有 + @Builder.Default + private List tagsIds = new ArrayList<>(); + + // 未知 + @Builder.Default + private String tagsFlag = "1"; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/PayRecordsListReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/PayRecordsListReq.java new file mode 100644 index 00000000..36647819 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/PayRecordsListReq.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDate; + +/** + * 下级信息:存款记录 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class PayRecordsListReq { + /** + * 用户名 + */ + private String memberName; + + /** + * 支付状态 1 待确认 2成功 4 已取消 + */ + private int payState; + /** + * 重置 + */ + private boolean isRest; + + /** + * 页码 + */ + @Builder.Default + private int pageNum = 1; + + /** + * 每页显示数量 + */ + private int pageSize; + + /** + * 起始日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate startDate; + + /** + * 结束日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate endDate; + + /** + * 代理线 + */ + private String agentName; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java new file mode 100644 index 00000000..dccc90ca --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamInfoReq.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req.team; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.time.LocalDateTime; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@Builder +public class TeamInfoReq { + /** + * 代理线 + */ + private String agentName; + /** + * 结束日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime endDate; + + /** + * 页码 + */ + private int pageNum; + + /** + * 每页显示数量 + */ + private int pageSize; + + /** + * 起始日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime startDate; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java new file mode 100644 index 00000000..26ff5cc6 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberListReq.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req.team; + +import com.zayac.admin.req.MemberListReq; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +public class TeamMemberListReq extends MemberListReq { + private String topAgentName; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java b/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java new file mode 100644 index 00000000..511383bf --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/req/team/TeamMemberReq.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.req.team; + +import com.zayac.admin.req.MemberListReq; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.SuperBuilder; + +/** + * {"pageNum":1,"pageSize":10,"registerSort":-1,"drawSort":-1,"depositSort":-1,"lastLoginTimeSort":-1,"name":"","minPay":null,"maxPay":null,"startDate":"2024-05-01","registerStartDate":"","endDate":"2024-05-23","registerEndDate":"","firstPayStartTime":"","firstPayEndTime":"","topAgentName":"","isBet":"","status":-1,"isRest":false,"tagsIds":[],"tagsFlag":"1"} + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +@SuperBuilder +public class TeamMemberReq extends MemberListReq { + + private String topAgentName; + +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java new file mode 100644 index 00000000..75efd772 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/AgentDataVisualList.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.util.List; + +/** + * 后台图表中的数据 对应请求地址/agent/api/v1/front/getAgentDataVisualList + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class AgentDataVisualList implements Serializable { + private List curData; + private List lastData; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/ApiResponse.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/ApiResponse.java new file mode 100644 index 00000000..0c2125b2 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/ApiResponse.java @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import com.fasterxml.jackson.annotation.JsonProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class ApiResponse implements Serializable { + T data; + String message; + @JsonProperty("status_code") + Integer statusCode; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Banner.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Banner.java new file mode 100644 index 00000000..f230ec7c --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Banner.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +/** + * 后台中的banner信息;对应 /agent/api/v1/front/banner + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Banner implements Serializable { + // 总会员数 + private Integer totalMembers; + + // 注册会员数 + private Integer registerMembers; + + // 活跃会员数 + private Integer activeMembers; + + // 净输赢金额负数表示亏损 + private BigDecimal netWinLose; + + // 净输赢金额 + private BigDecimal unlimitedNetWinLose; + + // 佣金等级 + private Integer commissionLevel; + + // 无限制的佣金等级 + private Integer unlimitedCommissionLevel; + + // 首次存款的会员数 + private Integer firstDepositNum; + + // 利润金额负数表示亏损 + private BigDecimal profit; + + // 有效新会员数 + private Integer effectiveNew; + + // 存款增长百分比 + private BigDecimal depositIncrease; + + // 注册增长百分比 + private BigDecimal registerIncrease; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java new file mode 100644 index 00000000..d2753913 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/DeptUserAccounts.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import com.zayac.admin.system.model.entity.DeptDO; +import com.zayac.admin.system.model.entity.UserDO; + +import java.util.List; + +public class DeptUserAccounts { + private DeptDO dept; + + private List users; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/FinancialStatement.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/FinancialStatement.java new file mode 100644 index 00000000..2de7c95b --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/FinancialStatement.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class FinancialStatement implements Serializable { + // 总输赢 + private BigDecimal profit; + // 红利 + private BigDecimal promo; + // 场馆费 + private BigDecimal thirdPartySpend; + // 净输赢 + private BigDecimal netProfit; + // 存款 + private BigDecimal deposit; + // 提款 + private BigDecimal draw; + // 返水 + private BigDecimal rebate; + // 账号调整 + private BigDecimal adjust; + // 有效投注 + private BigDecimal netAmount; + // 投注总金额金额 + private BigDecimal betAmount; + // 存提手续费 + private BigDecimal handlingFee; + // 合作利润 + private BigDecimal partnershipProfit; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Member.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Member.java new file mode 100644 index 00000000..3935234f --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Member.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.List; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Member implements Serializable { + private Long id; + //用户名 + private String name; + // 用户真实姓名 + private String realName; + // 注册时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime registerDate; + + /** + * 存款金额 + */ + private BigDecimal deposit; + // 提款金额 + private BigDecimal draw; + /** + * 利润 + */ + private BigDecimal profit; + /** + * 最后登录时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String lastLoginTime; + /** + * 用户是否活跃,0表示不活跃,1表示活跃 + */ + + private int active; + // 返水 + private BigDecimal promo; + // 返水比例 + private Double rebate; + // 风险调整金额 + private String riskAdjust; + // 有效投注 + private BigDecimal netAmount; + /** + * 投注金额 + */ + private BigDecimal betAmount; + // 变动日志 + private String changeLog; + + /** + * 是否有变更,0无变更,1有变更 + */ + private int isChange; + //vip等级 + private int vipGrade; + //vip等级字符 + private String vipGradeStr; + /** + * 存款金额 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime firstPayAt; + + private List tagsIds; + + /** + * 标签信息 + */ + private String tagsInfo; + + /** + * 备注 + */ + String remark; + + /** + * 用户状态 1正常 0禁用 + */ + private int status; + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime lastBetTime; + + private List venueNetAmountList; + + private List venueProfitList; +} \ No newline at end of file diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/MemberPagination.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/MemberPagination.java new file mode 100644 index 00000000..ebc67e75 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/MemberPagination.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class MemberPagination extends Pagination { + private int eyesStatus; + private int unassigned; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Pagination.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Pagination.java new file mode 100644 index 00000000..41457dec --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Pagination.java @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * 三方接口返回对象分页 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Pagination implements Serializable { + private int page; + private int pageNum; + private int pageSize; + private int total; + private T list; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/PayRecord.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/PayRecord.java new file mode 100644 index 00000000..f6bf6582 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/PayRecord.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PayRecord implements Serializable { + /** + * 订单号 + */ + private String billNo; + + /** + * 会员账号 + */ + private String name; + /** + * 代理线 + */ + private String agentName; + /** + * 订单金额 + */ + private BigDecimal orderAmount; + /** + * 赠送金额 + */ + private BigDecimal rebateAmount; + + /** + * 未知参数说明 + */ + private int flowRatio; + + /** + * 支付方式 + */ + private int payType; + + /** + * 支付方式名称 + */ + private String payName; + + /** + * 收款人账户? + */ + private String recipientAccount; + + /** + * 存款时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createdAt; + + /** + * 支付状态 + */ + private int payStatus; + /** + * 支付状态名称 + */ + private String payStatusName; + /** + * 是否获取卡 + */ + private String whetherGetCard; + /** + * ??? + */ + private Long topId; + /** + * 存款成功金额 + */ + private BigDecimal scoreAmount; + +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Statics.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Statics.java new file mode 100644 index 00000000..982383a7 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Statics.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Statics implements Serializable { + /** + * 日期 + */ + LocalDate staticsDate; + /** + * 代理id + */ + Long agentId; + /** + * 代理类型 + */ + Integer agentType; + /** + * 代理推荐码 + */ + String agentCode; + /** + * 代理名称 + */ + String agentName; + /** + * 新增人数 + */ + Integer isNew; + /** + * 首存人数 + */ + Double firstDeposit; + /** + * 投注额 + */ + Double deposit; + /** + * 投注红利 + */ + Double depositPromo; + /** + * 取款 + */ + Double draw; + /** + * 返水 + */ + Double promo; + /** + * 返水比例 + */ + Double promoDividend; + Double rebate; + /** + * 账号调整 + */ + Double adjust; + /** + * 风险等级 + */ + Double riskAdjust; + /** + * 有效投注额 + */ + Double bets; + /** + * 输赢 + */ + Double profit; + /** + * 总投注额 + */ + Double allBets; + /** + * 首存人数 + */ + Integer firstCount; + /** + * 存款人数 + */ + Integer countDeposit; + /** + * 取款人数 + */ + Integer countDraw; + /** + * 投注人数 + */ + Integer countBets; + /** + * 创建日期 + */ + LocalDateTime createdAt; + /** + * 更新日期 + */ + LocalDateTime updatedAt; + /** + * 老用户存款人数 + */ + Double oldDeposit; + /** + * 老用户存款金额 + */ + Integer oldDepositCount; + /** + * 新用户存款金额 + */ + Double newDeposit; +} \ No newline at end of file diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Venue.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Venue.java new file mode 100644 index 00000000..1aaaece7 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/Venue.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class Venue implements Serializable { + //场馆id + private Integer venueId; + //场馆名称 + private String venueName; + //游戏类型 + private Integer gameType; + //盈利 + private BigDecimal profit; + //场馆费用 + private BigDecimal thirdPartySpend; + //返水 + private BigDecimal promo; + //调整 + private BigDecimal riskAdjust; + //净输赢 + private BigDecimal netProfit; + //有效投注 + private BigDecimal netAmount; + //返水百分比 + private Double commissionRate; + private BigDecimal amount; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/Team.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/Team.java new file mode 100644 index 00000000..ddb183eb --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/Team.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp.team; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Team implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + private int agentCount; + private String teamName; + private int total; + private int subMemberCount; + private int firstDepositNum; + private int pageNum; + private int pageSize; + private List list; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccount.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccount.java new file mode 100644 index 00000000..2ff81598 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccount.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp.team; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serial; +import java.io.Serializable; + +/** + * + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TeamAccount implements Serializable { + @Serial + private static final long serialVersionUID = 1L; + private long id; + private long teamId; + private String agentName; + private long memberId; + private int captainId; + private String inviteCode; + private int isCaptain; + private String tStatus; + private String createdAt; + private String updatedAt; + private int subMemberNum; + private int firstDepositNum; + +} \ No newline at end of file diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java new file mode 100644 index 00000000..d5375bb4 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamAccountWithChange.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp.team; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class TeamAccountWithChange extends TeamAccount { + private int newRegisterNum; + private int newDepositNum; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamMember.java b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamMember.java new file mode 100644 index 00000000..fb5519e5 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/resp/team/TeamMember.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.resp.team; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +@Data +@AllArgsConstructor +@NoArgsConstructor +public class TeamMember { + private Long id; + //用户名 + private String name; + // 用户真实姓名 + private String realName; + // 注册时间 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime registerDate; + + /** + * 存款金额 + */ + private BigDecimal deposit; + // 提款金额 + private BigDecimal draw; + /** + * 利润 + */ + private BigDecimal profit; + /** + * 最后登录时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private String lastLoginTime; + /** + * 用户是否活跃,0表示不活跃,1表示活跃 + */ + + private int active; + + /** + * 是否有变更,0无变更,1有变更 + */ + private int isChange; + //vip等级 + private int vipGrade; + //vip等级字符 + private String vipGradeStr; + + /** + * 用户状态 1正常 0禁用 + */ + private int status; + + /** + * 上级代理线 + */ + private String topAgentName; +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/MessageSchedule.java b/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/MessageSchedule.java new file mode 100644 index 00000000..069107e7 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/MessageSchedule.java @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.schedule; + +import com.zayac.admin.common.enums.DisEnableStatusEnum; +import com.zayac.admin.constant.ApiPathConstants; +import com.zayac.admin.req.MemberDetailsReq; +import com.zayac.admin.req.MemberListReq; +import com.zayac.admin.req.PayRecordsListReq; +import com.zayac.admin.resp.*; +import com.zayac.admin.service.BannerService; +import com.zayac.admin.service.CompletableFutureWebClientService; +import com.zayac.admin.service.TelegramMessageService; +import com.zayac.admin.system.model.entity.UserDO; +import com.zayac.admin.system.model.resp.AccountResp; +import com.zayac.admin.system.service.AccountService; +import com.zayac.admin.system.service.UserService; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.CompletableFuture; +import java.util.stream.Collectors; + +/** + * 定时任务 查询注册 新增用 暂定一分钟执行一次 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class MessageSchedule { + + private final UserService userService; + private final AccountService accountService; + private final CompletableFutureWebClientService completableFutureWebClientService; + private final TelegramMessageService telegramMessageService; + private final BannerService bannerService; + + //@Scheduled(fixedDelay = 60000) + public void newCheckRegistrationAndNewDeposit() { + // Get the current date and time + LocalDate nowDate = LocalDate.now(); + LocalDateTime nowDateTime = LocalDateTime.now(); + // Fetch all enabled users + List allEnableUser = userService.getAllEnabledUsers(); + + allEnableUser.forEach(user -> processUser(user, nowDate, nowDateTime).join()); + } + + private CompletableFuture processUser(UserDO user, LocalDate nowDate, LocalDateTime nowDateTime) { + List accounts = accountService.getAccountsByUserId(user.getId(), DisEnableStatusEnum.ENABLE); + List> futures = accounts.stream() + .map(account -> processAccount(account, user, nowDate, nowDateTime)) + .toList(); + + return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); + } + + private CompletableFuture processAccount(AccountResp account, + UserDO user, + LocalDate nowDate, + LocalDateTime nowDateTime) { + CompletableFuture bannerFuture = bannerService.getLatestBannerInfoAsync(account); + Banner prevBanner = bannerService.getPreviousBanner(account); + + return CompletableFuture.allOf(bannerFuture).thenCompose(v -> { + Banner currentBanner = bannerFuture.join(); + + CompletableFuture registrationProcess = processRegistration(account, user, currentBanner, prevBanner, nowDate); + CompletableFuture depositProcess = processDeposits(account, user, currentBanner, prevBanner, nowDate, nowDateTime); + + return CompletableFuture.allOf(registrationProcess, depositProcess) + .thenRun(() -> bannerService.updateBanner(account, currentBanner)); + }); + } + + private CompletableFuture processRegistration(AccountResp account, + UserDO currUser, + Banner banner, + Banner prevBanner, + LocalDate nowDate) { + if (prevBanner != null && banner.getRegisterMembers() > prevBanner.getRegisterMembers()) { + int registerCount = banner.getRegisterMembers() - prevBanner.getRegisterMembers(); + + MemberListReq memberListReq = MemberListReq.builder() + .registerStartDate(nowDate) + .registerEndDate(nowDate) + .startDate(nowDate) + .endDate(nowDate) + .registerSort(1) + .pageSize(registerCount) + .build(); + CompletableFuture>> memberPaginationCompletableFuture = completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.MEMBER_LIST_URL, memberListReq, new ParameterizedTypeReference<>() { + }); + return memberPaginationCompletableFuture.thenApply(MemberPagination::getList).thenAccept(members -> { + if (!members.isEmpty()) { + String memberNames = members.stream().map(Member::getName).collect(Collectors.joining(", ")); + + String notification = String.format("👏 %s 注册: %d 用户: `%s` 总数:*%d*", account + .getNickname(), registerCount, memberNames, banner.getRegisterMembers()); + if (DisEnableStatusEnum.ENABLE.equals(currUser.getNeedNotify())) { + telegramMessageService.sendMessage(currUser.getBotToken(), currUser.getGroupId(), notification); + } + } + }); + } + return CompletableFuture.completedFuture(null); + } + + private CompletableFuture processDeposits(AccountResp account, + UserDO user, + Banner current, + Banner previous, + LocalDate nowDate, + LocalDateTime nowDateTime) { + return CompletableFuture.runAsync(() -> { + if (previous != null && current.getFirstDepositNum() > previous.getFirstDepositNum()) { + int newDeposits = current.getFirstDepositNum() - previous.getFirstDepositNum(); + + PayRecordsListReq req = PayRecordsListReq.builder() + .startDate(nowDate) + .endDate(nowDate) + .pageSize(100) + .payState(2) + .build(); + CompletableFuture>> paginationCompletableFuture = completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.PAY_RECORDS_LIST_URL, req, new ParameterizedTypeReference<>() { + }); + paginationCompletableFuture.thenApply(Pagination::getList).thenAccept(payRecords -> { + List names = payRecords.stream() + .filter(record -> record.getCreatedAt().isAfter(nowDateTime.minusHours(1))) + .map(PayRecord::getName) + .distinct() + .toList(); + + names.forEach(name -> fetchMemberDetails(account, name, nowDate).thenAccept(member -> { + Optional matchingRecord = payRecords.stream() + .filter(record -> record.getCreatedAt().equals(member.getFirstPayAt())) + .findFirst(); + matchingRecord.ifPresent(record -> { + String depositResults = String.format("用户: `%s`, 首存金额: *%s*", member.getName(), record + .getScoreAmount()); + String depResults = "🎉 " + account + .getNickname() + " 首存: " + newDeposits + depositResults + " 总数:*" + current + .getFirstDepositNum() + "*"; + if (DisEnableStatusEnum.ENABLE.equals(user.getNeedNotify())) { + telegramMessageService.sendMessage(user.getBotToken(), user.getGroupId(), depResults); + } + }); + }).exceptionally(ex -> { + log.error("Error fetching details for member {}: {}", name, ex.getMessage()); + return null; + }).join()); + }).exceptionally(ex -> { + log.error("Error processing deposits for account {}: {}", account.getId(), ex.getMessage()); + return null; + }).join(); + } + }); + } + + private CompletableFuture fetchMemberDetails(AccountResp account, String name, LocalDate nowDate) { + MemberListReq memberListReq = MemberListReq.builder() + .name(name) + .startDate(nowDate) + .endDate(nowDate) + .status(1) + .build(); + + CompletableFuture>> memberFuture = completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.MEMBER_LIST_URL, memberListReq, new ParameterizedTypeReference<>() { + }); + + return memberFuture.thenApply(MemberPagination::getList) + .thenApply(list -> list.stream().findFirst()) + .thenCompose(optionalMember -> optionalMember.map(member -> fetchDetailedMemberInfo(account, member + .getId(), nowDate)).orElseThrow(() -> new RuntimeException("没有找到匹配的成员信息"))); + } + + private CompletableFuture fetchDetailedMemberInfo(AccountResp account, Long memberId, LocalDate nowDate) { + MemberDetailsReq detailsReq = MemberDetailsReq.builder() + .id(memberId) + .startDate(nowDate) + .endDate(nowDate) + .build(); + + return completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.MEMBER_DETAIL_URL, detailsReq, new ParameterizedTypeReference<>() { + }); + } +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java b/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java new file mode 100644 index 00000000..d8f32f49 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/schedule/TelegramTeamMessageSchedule.java @@ -0,0 +1,308 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.schedule; + +import cn.hutool.core.collection.CollUtil; +import com.zayac.admin.common.enums.DisEnableStatusEnum; +import com.zayac.admin.constant.ApiPathConstants; +import com.zayac.admin.req.MemberDetailsReq; +import com.zayac.admin.req.PayRecordsListReq; +import com.zayac.admin.req.team.TeamMemberListReq; +import com.zayac.admin.req.team.TeamMemberReq; +import com.zayac.admin.resp.*; +import com.zayac.admin.resp.team.Team; +import com.zayac.admin.resp.team.TeamAccount; +import com.zayac.admin.resp.team.TeamAccountWithChange; +import com.zayac.admin.resp.team.TeamMember; +import com.zayac.admin.service.CompletableFutureWebClientService; +import com.zayac.admin.service.TeamService; +import com.zayac.admin.service.TelegramMessageService; +import com.zayac.admin.system.model.entity.RoleDO; +import com.zayac.admin.system.model.entity.UserDO; +import com.zayac.admin.system.model.resp.AccountResp; +import com.zayac.admin.system.service.*; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.BeanUtils; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.function.Function; +import java.util.stream.Collectors; + +/** + * 定时任务 查询注册 新增用 暂定一分钟执行一次 + */ +@Slf4j +@Component +@RequiredArgsConstructor +public class TelegramTeamMessageSchedule { + + private final UserService userService; + private final AccountService accountService; + private final CompletableFutureWebClientService completableFutureWebClientService; + private final TelegramMessageService telegramMessageService; + private final TeamService teamService; + private final RoleService roleService; + private final UserRoleService userRoleService; + + @Scheduled(fixedDelay = 60000) + public void newCheckRegistrationAndNewDeposit() { + // Get the current date and time + LocalDate nowDate = LocalDate.now(); + LocalDateTime nowDateTime = LocalDateTime.now(); + //获取部长角色 + RoleDO minister = roleService.getByCode("minister"); + List users = userRoleService.listUserIdByRoleId(minister.getId()); + //获取所有部长角色对应部门的用户 + users.forEach(userId -> { + //传入对应部长用户 + processUser(userService.getById(userId), nowDate, nowDateTime).join(); + }); + } + + private CompletableFuture processUser(UserDO user, LocalDate nowDate, LocalDateTime nowDateTime) { + //获取当前用户名下的所有团队账号 + List accounts = accountService.getAccountsByUserId(user.getId(), DisEnableStatusEnum.ENABLE) + .stream() + .filter(AccountResp::getIsTeam) + .toList(); + + List> futures = accounts.stream() + .map(account -> processTeamAccount(account, nowDate, nowDateTime)) + .toList(); + + return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); + } + + private CompletableFuture processTeamAccount(AccountResp account, + LocalDate nowDate, + LocalDateTime nowDateTime) { + CompletableFuture teamFuture = teamService.getLatestTeamInfoAsync(account, nowDate, nowDateTime); + Team prevTeamInfo = teamService.getPreviousTeamInfo(account); + + return CompletableFuture.allOf(teamFuture).thenCompose(v -> { + Team currentTeamInfo = teamFuture.join(); + log.info("prev:{}", prevTeamInfo); + log.info("curr:{}", currentTeamInfo); + //获取代理线 代理对象映射 + Map teamAccountMap = currentTeamInfo.getList() + .stream() + .collect(Collectors.toMap(TeamAccount::getAgentName, Function.identity())); + + CompletableFuture registrationProcess = processRegistration(account, currentTeamInfo, prevTeamInfo, nowDate, teamAccountMap); + CompletableFuture depositProcess = processDeposits(account, currentTeamInfo, prevTeamInfo, nowDate, nowDateTime, teamAccountMap); + + return CompletableFuture.allOf(registrationProcess, depositProcess) + .thenRun(() -> teamService.updateTeamInfo(account, currentTeamInfo)); + }); + } + + private CompletableFuture processRegistration(AccountResp account, + Team currentTeamInfo, + Team prevTeamInfo, + LocalDate nowDate, + Map teamAccountMap) { + if (prevTeamInfo != null && currentTeamInfo.getSubMemberCount() > prevTeamInfo.getSubMemberCount()) { + //代理线总共的新增注册数量 + int registerCount = currentTeamInfo.getSubMemberCount() - prevTeamInfo.getSubMemberCount(); + //构建查询参数 + TeamMemberReq memberListReq = TeamMemberReq.builder() + .registerStartDate(nowDate) + .registerEndDate(nowDate) + .startDate(nowDate) + .endDate(nowDate) + .registerSort(1) + .pageSize(registerCount) + .build(); + //查询所有新注册的会员 + CompletableFuture>> memberPaginationCompletableFuture = completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() { + }); + return memberPaginationCompletableFuture.thenApply(MemberPagination::getList).thenAccept(members -> { + log.info("Successfully get {} new registered members", members.size()); + //获取所有的新注册的会员对象 + if (!members.isEmpty()) { + //根据上级代理名分组 + Map> groupByTopAgentName = members.stream() + .collect(Collectors.groupingBy(TeamMember::getTopAgentName)); + groupByTopAgentName.forEach((accountName, accountMembers) -> { + String memberNames = accountMembers.stream() + .map(TeamMember::getName) + .collect(Collectors.joining(", ")); + log.info("Successfully get new registrations {}", memberNames); + String notification = String.format("👏 %s 注册: %d 用户: `%s` 总数:*%d*", accountName, accountMembers + .size(), memberNames, teamAccountMap.get(accountName).getSubMemberNum()); + UserDO currUser = accountService.getUserByAccountUsername(accountName); + // if (currUser != null && DisEnableStatusEnum.ENABLE.equals(currUser.getNeedNotify())) { + // telegramMessageService.sendMessage(currUser.getBotToken(), currUser.getGroupId(), notification); + // } + + telegramMessageService + .sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, notification); + } + + ); + } + }); + } + return CompletableFuture.completedFuture(null); + } + + private CompletableFuture processDeposits(AccountResp account, + Team currentTeam, + Team previousTeam, + LocalDate nowDate, + LocalDateTime nowDateTime, + Map teamAccountMap) { + return CompletableFuture.runAsync(() -> { + if (previousTeam != null && currentTeam.getFirstDepositNum() > previousTeam.getFirstDepositNum()) { + PayRecordsListReq req = PayRecordsListReq.builder() + .startDate(nowDate) + .endDate(nowDate) + .pageSize(100) + .payState(2) + .build(); + CompletableFuture>> paginationCompletableFuture = completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.PAY_RECORDS_LIST_URL, req, new ParameterizedTypeReference<>() { + }); + + paginationCompletableFuture.thenApply(Pagination::getList).thenAccept(payRecords -> { + Map> agentNameWithNames = payRecords.stream() + .filter(record -> record.getCreatedAt().isAfter(nowDateTime.minusHours(1))) + .collect(Collectors.groupingBy(PayRecord::getAgentName, Collectors + .mapping(PayRecord::getName, Collectors.collectingAndThen(Collectors + .toSet(), ArrayList::new)))); + agentNameWithNames.forEach((agentName, names) -> { + StringBuilder depositResults = new StringBuilder(); + + List> fetchFutures = names.stream() + .map(name -> fetchMemberDetails(account, name, nowDate).thenAccept(member -> { + payRecords.stream() + .filter(record -> record.getCreatedAt().equals(member.getFirstPayAt())) + .findFirst() + .ifPresent(record -> { + depositResults.append(String.format("用户: `%s`, 首存金额: *%s*\n", member + .getName(), record.getScoreAmount())); + }); + }).exceptionally(ex -> { + log.error("Error fetching details for member {}: {}", name, ex.getMessage()); + return null; + })) + .toList(); + + CompletableFuture allFetches = CompletableFuture.allOf(fetchFutures + .toArray(new CompletableFuture[0])); + + allFetches.thenRun(() -> { + if (!depositResults.isEmpty()) { + String notification = String.format("🎉 %s 首存: *%d* %s 总数: *%d*", agentName, fetchFutures + .size(), depositResults, teamAccountMap.get(agentName).getFirstDepositNum()); + + UserDO currUser = accountService.getUserByAccountUsername(agentName); +// if (currUser != null && DisEnableStatusEnum.ENABLE.equals(currUser.getNeedNotify())) { +// telegramMessageService.sendMessage(currUser.getBotToken(), currUser +// .getGroupId(), depResults); +// } + telegramMessageService + .sendMessage("6013830443:AAHUOS4v6Ln19ziZkH-L28-HZQLJrGcvhto", 6054562838L, notification); + } + }).exceptionally(ex -> { + log.error("Error sending notification for account {}: {}", account.getId(), ex + .getMessage()); + return null; + }); + }); + }).exceptionally(ex -> { + log.error("Error processing deposits for account {}: {}", account.getId(), ex.getMessage()); + return null; + }).join(); + } + }); + } + + //根据用户名查询对应会员详情 + private CompletableFuture fetchMemberDetails(AccountResp account, String name, LocalDate nowDate) { + TeamMemberListReq memberListReq = TeamMemberListReq.builder() + .name(name) + .startDate(nowDate) + .endDate(nowDate) + .status(1) + .build(); + + CompletableFuture>> memberFuture = completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.MEMBER_TEAM_LIST_URL, memberListReq, new ParameterizedTypeReference<>() { + }); + + return memberFuture.thenApply(MemberPagination::getList) + .thenApply(list -> list.stream().findFirst()) + .thenCompose(optionalMember -> optionalMember.map(member -> fetchDetailedMemberInfo(account, member + .getId(), nowDate)).orElseThrow(() -> new RuntimeException("没有找到匹配的成员信息"))); + } + + private CompletableFuture fetchDetailedMemberInfo(AccountResp account, Long memberId, LocalDate nowDate) { + MemberDetailsReq detailsReq = MemberDetailsReq.builder() + .id(memberId) + .startDate(nowDate) + .endDate(nowDate) + .build(); + + return completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.MEMBER_DETAIL_URL, detailsReq, new ParameterizedTypeReference<>() { + }); + } + + /** + * 对比两个Team中发生变化的具体TeamAccount + * + * @param prevTeam 缓存中的Team + * @param currTeam 新查询到的Team + * @return TeamAccountWithChange + */ + public List findChangedTeamAccount(Team prevTeam, Team currTeam) { + if (prevTeam == null || currTeam == null || CollUtil.isEmpty(prevTeam.getList()) || CollUtil.isEmpty(currTeam + .getList())) { + return CollUtil.newArrayList(); + } + + Map team2AccountMap = currTeam.getList() + .stream() + .collect(Collectors.toMap(TeamAccount::getId, account -> account)); + + return prevTeam.getList() + .stream() + .filter(account1 -> team2AccountMap.containsKey(account1.getId())) + .map(account1 -> { + TeamAccount account2 = team2AccountMap.get(account1.getId()); + TeamAccountWithChange changedAccount = new TeamAccountWithChange(); + BeanUtils.copyProperties(account1, changedAccount); + if (account1.getFirstDepositNum() != account2.getFirstDepositNum()) { + changedAccount.setNewDepositNum(account1.getFirstDepositNum() - account2.getFirstDepositNum()); + } + if (account1.getSubMemberNum() != account2.getSubMemberNum()) { + changedAccount.setNewRegisterNum(account1.getSubMemberNum() - account2.getSubMemberNum()); + } + return changedAccount; + }) + .collect(Collectors.toList()); + } +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/BannerService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/BannerService.java new file mode 100644 index 00000000..5adff219 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/service/BannerService.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.service; + +import com.alicp.jetcache.anno.CacheType; +import com.alicp.jetcache.anno.CacheUpdate; +import com.alicp.jetcache.anno.Cached; +import com.zayac.admin.constant.ApiPathConstants; +import com.zayac.admin.resp.Banner; +import com.zayac.admin.system.model.resp.AccountResp; +import lombok.RequiredArgsConstructor; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.stereotype.Service; + +import java.util.concurrent.CompletableFuture; + +@Service +@RequiredArgsConstructor +public class BannerService { + private final CompletableFutureWebClientService completableFutureWebClientService; + + public CompletableFuture getLatestBannerInfoAsync(AccountResp account) { + // Fetch banner data using a WebClient service + return completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.BANNER_URL, null, new ParameterizedTypeReference<>() { + }); + } + + @Cached(name = "bannerCache", key = "#account.id", expire = 90, cacheType = CacheType.BOTH, syncLocal = true) + public Banner getPreviousBanner(AccountResp account) { + // 这个方法不需要实际的加载逻辑,因为它只是返回缓存中的数据 + return null; + } + + @CacheUpdate(name = "bannerCache", key = "#account.id", value = "#banner") + public void updateBanner(AccountResp account, Banner banner) { + // Method intentionally left empty, used only for cache update + } +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java new file mode 100644 index 00000000..563d1c57 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/service/CompletableFutureWebClientService.java @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.service; + +import cn.hutool.core.lang.TypeReference; +import cn.hutool.json.JSONUtil; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.zayac.admin.resp.ApiResponse; +import com.zayac.admin.system.model.resp.AccountResp; +import io.netty.handler.timeout.TimeoutException; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.http.HttpStatusCode; +import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; +import org.springframework.web.reactive.function.client.WebClientResponseException; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; +import reactor.util.retry.Retry; +import top.continew.starter.core.exception.BusinessException; + +import java.time.Duration; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.Semaphore; +import java.util.concurrent.TimeUnit; + +@Service +@Slf4j +public class CompletableFutureWebClientService { + private final WebClient webClient; + private final Semaphore semaphore; + private final ObjectMapper objectMapper; + + public CompletableFutureWebClientService(WebClient.Builder webClientBuilder, + @Value("${webclient.max-concurrent-requests}") int maxConcurrentRequests, + ObjectMapper objectMapper) { + this.webClient = webClientBuilder.build(); + this.semaphore = new Semaphore(maxConcurrentRequests); + this.objectMapper = objectMapper; + } + + public CompletableFuture fetchDataForAccount(AccountResp account, + String apiPath, + Object params, + ParameterizedTypeReference> typeRef) { + // 创建一个CompletableFuture列表,每个元素对应一个API请求 + return this.fetchData(account.getPlatformUrl() + apiPath, account.getHeaders(), params, typeRef); + } + + // public CompletableFuture fetchData(String url, String headers, Object params, ParameterizedTypeReference> typeRef) { + // webClient.mutate() + // .filters(filters -> filters.add(0, new ApiResponseHandler<>(typeRef))) // 添加到过滤器链的开始 + // .build(); + // System.out.println(webClient); + // return webClient.post() + // .uri(url) + // + // .headers(httpHeaders -> { + // Map headerMap = JSONUtil.toBean(headers, new TypeReference<>() { + // }, true); + // headerMap.forEach(httpHeaders::add); + // }) + // .body(params != null ? BodyInserters.fromValue(params) : BodyInserters.empty()) + // .retrieve() + // .bodyToMono(typeRef) + // .map(ApiResponse::data) + // .doFinally(signal -> semaphore.release()) + // .toFuture(); + // } + + public CompletableFuture fetchData(String url, + String headers, + Object params, + ParameterizedTypeReference> typeRef) { + return Mono.fromCallable(() -> { + if (!semaphore.tryAcquire(10, TimeUnit.SECONDS)) { // 使用非阻塞方式获取许可 + throw new RuntimeException("Unable to acquire a permit"); + } + return true; + }).subscribeOn(Schedulers.boundedElastic()).then(this.webClient.post().uri(url).headers(httpHeaders -> { + Map headerMap = JSONUtil.toBean(headers, new TypeReference<>() { + }, true); + headerMap.forEach(httpHeaders::add); + }) + .body(params != null ? BodyInserters.fromValue(params) : BodyInserters.empty()) + .retrieve() + .onStatus(HttpStatusCode::isError, response -> Mono.error(new BusinessException("API call failed"))) + .bodyToMono(String.class) + .doOnNext(resStr -> { + log.info("request url:{}", url); + log.info("request headers :{}", headers); + log.info("request params:{}", params); + log.info("response {}", resStr); + }) + .flatMap(body -> { + try { + ApiResponse apiResponse = objectMapper.readValue(body, objectMapper.getTypeFactory() + .constructType(typeRef.getType())); + return Mono.justOrEmpty(apiResponse); + } catch (Exception e) { + log.warn("JSON parsing exception: " + e.getMessage()); + return Mono.just(new ApiResponse(null, "Decoding error", 6008)); + } + }) + .flatMap(this::respHandler) + .retryWhen(Retry.backoff(3, Duration.ofSeconds(3)).filter(this::isRetryableException))) + .doFinally(signal -> semaphore.release()) + .toFuture(); + } + + private boolean isRetryableException(Throwable throwable) { + // 判断错误类型,只对特定的错误进行重试 + return throwable instanceof TimeoutException || throwable instanceof WebClientResponseException.ServiceUnavailable; + } + + private Mono respHandler(ApiResponse response) { + if (response.getStatusCode().equals(6000)) { + return Mono.just(response.getData()); + } else if (response.getStatusCode().equals(6001)) { + // 重新登录逻辑或其他处理 + return Mono.error(new BusinessException("API token expired")); + } else { + return Mono.error(new BusinessException("Error status code: " + response.getStatusCode())); + } + } +} \ No newline at end of file diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/TeamService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/TeamService.java new file mode 100644 index 00000000..9dd53a36 --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/service/TeamService.java @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.service; + +import com.alicp.jetcache.anno.CacheType; +import com.alicp.jetcache.anno.CacheUpdate; +import com.alicp.jetcache.anno.Cached; +import com.zayac.admin.constant.ApiPathConstants; +import com.zayac.admin.req.team.TeamInfoReq; +import com.zayac.admin.resp.team.Team; +import com.zayac.admin.system.model.resp.AccountResp; +import lombok.RequiredArgsConstructor; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.stereotype.Service; + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.temporal.TemporalAdjusters; +import java.util.concurrent.CompletableFuture; + +@Service +@RequiredArgsConstructor +public class TeamService { + private final CompletableFutureWebClientService completableFutureWebClientService; + + public CompletableFuture getLatestTeamInfoAsync(AccountResp account, + LocalDate nowDate, + LocalDateTime nowDateTime) { + TeamInfoReq.TeamInfoReqBuilder teamInfoReqBuilder = TeamInfoReq.builder() + .pageNum(1) + .pageSize(100) + .startDate(nowDateTime.with(TemporalAdjusters.firstDayOfMonth())) + .endDate(nowDateTime); + return completableFutureWebClientService + .fetchDataForAccount(account, ApiPathConstants.TEAM_LIST_URL, teamInfoReqBuilder, new ParameterizedTypeReference<>() { + }); + } + + @Cached(name = "TEAM_CACHE", key = "#account.id", expire = 90, cacheType = CacheType.BOTH, syncLocal = true) + public Team getPreviousTeamInfo(AccountResp account) { + // 这个方法不需要实际的加载逻辑,因为它只是返回缓存中的数据 + return null; + } + + @CacheUpdate(name = "TEAM_CACHE", key = "#account.id", value = "#team") + public void updateTeamInfo(AccountResp account, Team team) { + // Method intentionally left empty, used only for cache update + } +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/TelegramMessageService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/TelegramMessageService.java new file mode 100644 index 00000000..2b156aab --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/service/TelegramMessageService.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.service; + +import lombok.RequiredArgsConstructor; +import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.stereotype.Service; + +import java.util.Arrays; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class TelegramMessageService { + private final RabbitTemplate rabbitTemplate; + + public void sendMessage(String botToken, Long targetId, String message) { + String fullMessage = String.format("%s|%s|%s", botToken, targetId, escapeMarkdown(message)); + this.rabbitTemplate.convertAndSend("message_queue", fullMessage); + } + + private static String escapeMarkdown(String text) { + + List escapeChars = Arrays + .asList('_', '[', ']', '(', ')', '~', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'); + for (Character charItem : escapeChars) { + text = text.replace(charItem.toString(), "\\" + charItem); + } + return text; + } +} diff --git a/zayac-admin-backend/src/main/java/com/zayac/admin/service/WebClientService.java b/zayac-admin-backend/src/main/java/com/zayac/admin/service/WebClientService.java new file mode 100644 index 00000000..f4f770da --- /dev/null +++ b/zayac-admin-backend/src/main/java/com/zayac/admin/service/WebClientService.java @@ -0,0 +1,128 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.service; + +import cn.hutool.core.lang.TypeReference; +import cn.hutool.json.JSONUtil; +import com.zayac.admin.resp.ApiResponse; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.ParameterizedTypeReference; +import org.springframework.stereotype.Service; +import org.springframework.web.reactive.function.BodyInserters; +import org.springframework.web.reactive.function.client.WebClient; +import reactor.core.publisher.Mono; +import reactor.core.scheduler.Schedulers; +import reactor.util.retry.Retry; +import top.continew.starter.core.exception.BusinessException; + +import java.time.Duration; +import java.util.Map; +import java.util.concurrent.Semaphore; + +/** + * 封装了一个简单可用的调用后端api的服务类 + */ +@Service +public class WebClientService { + private final WebClient webClient; + + private final Semaphore semaphore; + + public WebClientService(@Value("${webclient.max-concurrent-requests}") int maxConcurrentRequests) { + this.webClient = WebClient.create(); + this.semaphore = new Semaphore(maxConcurrentRequests); + } + + public T fetchData(String url, + String headers, + Object params, + ParameterizedTypeReference> typeRef) { + try { + semaphore.acquire(); // 尝试获取许可 + return this.webClient.post().uri(url).headers(httpHeaders -> { + Map headerMap = JSONUtil.toBean(headers, new TypeReference<>() { + }, true); + headerMap.forEach(httpHeaders::add); + }) + .body(params != null ? BodyInserters.fromValue(params) : BodyInserters.empty()) + .retrieve() + .onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), response -> response + .bodyToMono(String.class) + .map(body -> new BusinessException("Error response: " + body))) + .bodyToMono(typeRef) + .flatMap(this::respHandler) + .retryWhen(Retry.backoff(3, Duration.ofSeconds(3))) + .block(); // 遇到网络问题,每三秒重试一次 + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new BusinessException("Failed to acquire semaphore", e); + } finally { + semaphore.release(); // 释放许可 + } + } + + public Mono MonoFetchData(String url, + String headers, + Object params, + ParameterizedTypeReference> typeRef) { + System.out.println(Thread.currentThread().getName()); + System.out.println(Thread.currentThread().getId()); + return Mono.fromCallable(() -> { + semaphore.acquire(); // 尝试获取许可 + return true; + }) + .subscribeOn(Schedulers.boundedElastic()) + .flatMap(acquired -> this.webClient.post().uri(url).headers(httpHeaders -> { + Map headerMap = JSONUtil.toBean(headers, new TypeReference<>() { + }, true); + headerMap.forEach(httpHeaders::add); + }) + .body(params != null ? BodyInserters.fromValue(params) : BodyInserters.empty()) + .retrieve() + .onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), response -> response + .bodyToMono(String.class) + .map(body -> new BusinessException("Error response: " + body))) + .bodyToMono(typeRef) + .flatMap(this::monoRespHandler) + .retryWhen(Retry.backoff(3, Duration.ofSeconds(3))) + .doFinally(signal -> semaphore.release())); + } + + private Mono monoRespHandler(ApiResponse apiResponse) { + // 根据响应状态码处理逻辑 + if (apiResponse.getStatusCode() == 6000) { + return Mono.just(apiResponse.getData()); // 正常情况下返回数据 + } else if (apiResponse.getStatusCode() == 6001) { + return Mono.error(new BusinessException("API token expired")); // API令牌过期 + } else { + return Mono.error(new BusinessException("Error status code: " + apiResponse.getStatusCode())); // 其他错误 + } + } + + private Mono respHandler(ApiResponse apiResponse) { + System.out.println(apiResponse); + //api接口只有在statusCode为6000的时候返回的数据才是正常数据 + if (apiResponse.getStatusCode().equals(6000)) { + return Mono.just(apiResponse.getData()); + } else if (apiResponse.getStatusCode().equals(6001)) { + // TODO 调用登录接口,刷新header信息重试 + return Mono.error(new BusinessException("xApiToken失效")); // 状态码6001,登录失效 + } else { + return Mono.error(new BusinessException("错误状态码: " + apiResponse.getStatusCode())); // 其他状态码,抛出异常 + } + } +} \ No newline at end of file diff --git a/zayac-admin-common/src/main/java/com/zayac/admin/common/config/mybatis/DataPermissionFilterImpl.java b/zayac-admin-common/src/main/java/com/zayac/admin/common/config/mybatis/DataPermissionFilterImpl.java index 029f1153..26a2f162 100644 --- a/zayac-admin-common/src/main/java/com/zayac/admin/common/config/mybatis/DataPermissionFilterImpl.java +++ b/zayac-admin-common/src/main/java/com/zayac/admin/common/config/mybatis/DataPermissionFilterImpl.java @@ -16,6 +16,7 @@ package com.zayac.admin.common.config.mybatis; +import cn.dev33.satoken.exception.NotWebContextException; import cn.hutool.core.convert.Convert; import com.zayac.admin.common.model.dto.LoginUser; import com.zayac.admin.common.util.helper.LoginHelper; @@ -23,25 +24,33 @@ import top.continew.starter.data.mybatis.plus.datapermission.DataPermissionCurre import top.continew.starter.data.mybatis.plus.datapermission.DataPermissionFilter; import top.continew.starter.data.mybatis.plus.datapermission.DataScope; +import java.util.Set; import java.util.stream.Collectors; -/** - * 数据权限过滤器实现类 - * - * @author Charles7c - * @since 2023/12/21 21:19 - */ public class DataPermissionFilterImpl implements DataPermissionFilter { @Override public boolean isFilter() { - LoginUser loginUser = LoginHelper.getLoginUser(); - return !loginUser.isAdmin(); + try { + LoginUser loginUser = LoginHelper.getLoginUser(); + return !loginUser.isAdmin(); + } catch (NotWebContextException e) { + return false; // 根据具体情况调整此返回值 + } } @Override public DataPermissionCurrentUser getCurrentUser() { - LoginUser loginUser = LoginHelper.getLoginUser(); + try { + LoginUser loginUser = LoginHelper.getLoginUser(); + return convertToDataPermissionCurrentUser(loginUser); + } catch (NotWebContextException e) { + // 提供定时任务的默认用户数据权限配置 + return getDefaultUserDataPermission(); + } + } + + private DataPermissionCurrentUser convertToDataPermissionCurrentUser(LoginUser loginUser) { DataPermissionCurrentUser currentUser = new DataPermissionCurrentUser(); currentUser.setUserId(Convert.toStr(loginUser.getId())); currentUser.setDeptId(Convert.toStr(loginUser.getDeptId())); @@ -53,4 +62,13 @@ public class DataPermissionFilterImpl implements DataPermissionFilter { .collect(Collectors.toSet())); return currentUser; } -} + + private DataPermissionCurrentUser getDefaultUserDataPermission() { + // 创建一个具有特定角色和数据权限的默认用户 + DataPermissionCurrentUser currentUser = new DataPermissionCurrentUser(); + currentUser.setUserId("1"); // 代表系统用户 + currentUser.setDeptId("1"); // 可以设定一个默认部门 + currentUser.setRoles(Set.of(new DataPermissionCurrentUser.CurrentUserRole("1", DataScope.CUSTOM))); + return currentUser; + } +} \ No newline at end of file diff --git a/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/CacheConstants.java b/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/CacheConstants.java index a75cb8be..869f7135 100644 --- a/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/CacheConstants.java +++ b/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/CacheConstants.java @@ -66,6 +66,11 @@ public class CacheConstants { */ public static final String DASHBOARD_KEY_PREFIX = "DASHBOARD" + DELIMITER; + /** + * 用户对应的Accounts缓存键前缀 + */ + public static final String ENABLED_ACCOUNTS_KEY_PREFIX = "ENABLED_ACCOUNTS" + DELIMITER; + private CacheConstants() { } } diff --git a/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/ContainerConstants.java b/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/ContainerConstants.java index 01b15bdd..6f253a99 100644 --- a/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/ContainerConstants.java +++ b/zayac-admin-common/src/main/java/com/zayac/admin/common/constant/ContainerConstants.java @@ -36,6 +36,11 @@ public class ContainerConstants extends ContainerPool { */ public static final String USER_ROLE_ID_LIST = "UserRoleIdList"; + /** + * 角色用户 ID 列表 + */ + public static final String ROLE_USER_ID_LIST = "RoleUserIdList"; + /** * 角色部门列表 */ diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AccountMapper.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AccountMapper.java index 0a27e293..2fea8855 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AccountMapper.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/AccountMapper.java @@ -1,13 +1,28 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.mapper; import com.zayac.admin.system.model.entity.AccountDO; import top.continew.starter.data.mybatis.plus.base.BaseMapper; - /** -* 账号 Mapper -* -* @author zayac -* @since 2024/05/10 20:44 -*/ + * 账号 Mapper + * + * @author zayac + * @since 2024/05/10 20:44 + */ public interface AccountMapper extends BaseMapper {} \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/PlatformMapper.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/PlatformMapper.java index cfe44fc2..bc668377 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/PlatformMapper.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/PlatformMapper.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.mapper; import org.apache.ibatis.annotations.Select; @@ -5,11 +21,11 @@ import top.continew.starter.data.mybatis.plus.base.BaseMapper; import com.zayac.admin.system.model.entity.PlatformDO; /** -* 平台 Mapper -* -* @author zayac -* @since 2024/05/14 12:28 -*/ + * 平台 Mapper + * + * @author zayac + * @since 2024/05/14 12:28 + */ public interface PlatformMapper extends BaseMapper { @Select("SELECT * FROM sys_platform WHERE name = #{name}") PlatformDO selectByName(String name); diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/UserRoleMapper.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/UserRoleMapper.java index 9db2bcbd..b56c4da5 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/UserRoleMapper.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/mapper/UserRoleMapper.java @@ -39,4 +39,13 @@ public interface UserRoleMapper extends BaseMapper { */ @Select("SELECT role_id FROM sys_user_role WHERE user_id = #{userId}") List selectRoleIdByUserId(@Param("userId") Long userId); + + /** + * 根据角色 ID 查询 + * + * @param roleId 用户 ID + * @return 用户 ID 列表 + */ + @Select("SELECT user_id FROM sys_user_role WHERE role_id = #{roleId}") + List selectUserIdByRoleId(@Param("roleId") Long roleId); } diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AccountDO.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AccountDO.java index 9ed1cc60..70b912c3 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AccountDO.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/AccountDO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.entity; import java.io.Serial; @@ -57,4 +73,14 @@ public class AccountDO extends BaseDO { */ private Long platformId; + + /** + * 是否为团队账号 + */ + private Boolean isTeam; + + // /** + // * 消息通知对象IDs + // */ + // private String receiverIds; } \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/PlatformDO.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/PlatformDO.java index 32c02bec..cb886157 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/PlatformDO.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/entity/PlatformDO.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.entity; import java.io.Serial; @@ -22,7 +38,6 @@ public class PlatformDO extends BaseDO { @Serial private static final long serialVersionUID = 1L; - /** * 平台代码 */ diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AccountQuery.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AccountQuery.java index 12867cc9..ba0fb974 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AccountQuery.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/AccountQuery.java @@ -1,8 +1,23 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.query; import java.io.Serial; import java.io.Serializable; -import java.time.LocalDateTime; import lombok.Data; diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/PlatformQuery.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/PlatformQuery.java index 7028fda5..2220bab8 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/PlatformQuery.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/query/PlatformQuery.java @@ -1,10 +1,24 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.query; import java.io.Serial; import java.io.Serializable; -import java.time.LocalDateTime; -import com.zayac.admin.common.enums.DisEnableStatusEnum; import lombok.Data; import io.swagger.v3.oas.annotations.media.Schema; @@ -53,7 +67,6 @@ public class PlatformQuery implements Serializable { @Query(type = QueryType.EQ) private String url; - /** * 状态(1启用,2禁用) */ diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AccountReq.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AccountReq.java index 4ad80272..7b79795d 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AccountReq.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/AccountReq.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.req; import java.io.Serial; @@ -68,4 +84,10 @@ public class AccountReq extends BaseReq { @Schema(description = "所属平台ID", example = "123456789") private Long platformId; + /** + * 是否团团队账号 + */ + @Schema(description = "是否团团队账号", example = "false") + private Boolean isTeam; + } \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/PlatformReq.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/PlatformReq.java index ac425b32..a4a59fb6 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/PlatformReq.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/PlatformReq.java @@ -1,7 +1,22 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.req; import java.io.Serial; -import java.time.LocalDateTime; import com.zayac.admin.common.enums.DisEnableStatusEnum; import jakarta.validation.constraints.*; diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/UserReq.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/UserReq.java index 5a57802b..e1d7be02 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/UserReq.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/req/UserReq.java @@ -84,7 +84,6 @@ public class UserReq extends BaseReq { @Length(max = 64, message = "botToken不能超过 {max} 个字符") private String botToken; - /** * 注册新增通知群组ID */ diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountDetailResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountDetailResp.java index f6105e73..1a9515a8 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountDetailResp.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountDetailResp.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.resp; import java.io.Serial; @@ -61,7 +77,6 @@ public class AccountDetailResp extends BaseDetailResp { @ExcelProperty(value = "状态(1:启用;2:禁用)") private DisEnableStatusEnum status; - /** * 用户ID */ @@ -76,18 +91,24 @@ public class AccountDetailResp extends BaseDetailResp { @ExcelProperty(value = "所属用户") private String ownerName; - - /** * 平台ID */ @Schema(description = "平台ID") @ExcelProperty(value = "平台ID") private Long platformId; + /** * 平台名称 */ @Schema(description = "平台名称") @ExcelProperty(value = "平台名称") private String platformName; + + /** + * 平台名称 + */ + @Schema(description = "是否团队账号") + @ExcelProperty(value = "是否团队账号") + private Boolean isTeam; } \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java index 3736445a..602c6356 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountResp.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.resp; import java.io.Serial; @@ -54,14 +70,20 @@ public class AccountResp extends BaseResp { @Schema(description = "平台名称", example = "开云") private String platformName; + /** + * 平台名称 + */ + @Schema(description = "平台地址", example = "https://www.nvdf9.com:8003") + private String platformUrl; + /** * 平台ID */ @Schema(description = "平台ID") - @AssembleMethod(targetType = PlatformService.class, method = @ContainerMethod(bindMethod = "get", resultType = PlatformResp.class), prop = "name:platformName") + @AssembleMethod(targetType = PlatformService.class, method = @ContainerMethod(bindMethod = "get", resultType = PlatformResp.class), props = { + @Mapping(src = "url", ref = "platformUrl"), @Mapping(src = "name", ref = "platformName")}) private Long platformId; - /** * headers */ @@ -74,7 +96,6 @@ public class AccountResp extends BaseResp { @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") private DisEnableStatusEnum status; - /** * 用户ID */ @@ -87,4 +108,11 @@ public class AccountResp extends BaseResp { */ @Schema(description = "所属用户", example = "张三") private String ownerName; + + /** + * 是否为团队账号 + */ + @Schema(description = "是否为团队账号", example = "false") + private Boolean isTeam; + } \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountUserResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountUserResp.java new file mode 100644 index 00000000..4355f31a --- /dev/null +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/AccountUserResp.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.zayac.admin.system.model.resp; + +import cn.crane4j.annotation.AssembleMethod; +import cn.crane4j.annotation.ContainerMethod; +import cn.crane4j.annotation.Mapping; +import com.zayac.admin.common.enums.DisEnableStatusEnum; +import com.zayac.admin.system.service.PlatformService; +import com.zayac.admin.system.service.UserService; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import top.continew.starter.extension.crud.model.resp.BaseResp; +import top.continew.starter.security.mask.annotation.JsonMask; +import top.continew.starter.security.mask.enums.MaskType; + +import java.io.Serial; + +@Data +@Schema(description = "用户账号关联对象") +public class AccountUserResp extends BaseResp { + @Serial + private static final long serialVersionUID = 1L; + + /** + * 账号昵称 + */ + @Schema(description = "账号昵称", example = "ky1线") + private String nickname; + + /** + * 账号 + */ + @Schema(description = "账号", example = "ky3tg107001") + private String username; + + /** + * 密码 + */ + @Schema(description = "密码", example = "tg666888") + @JsonMask(MaskType.PASSWORD) + private String password; + + /** + * 平台名称 + */ + @Schema(description = "平台名称", example = "开云") + private String platformName; + + /** + * 平台名称 + */ + @Schema(description = "平台地址", example = "https://www.nvdf9.com:8003") + private String platformUrl; + + /** + * 平台ID + */ + @Schema(description = "平台ID") + @AssembleMethod(targetType = PlatformService.class, method = @ContainerMethod(bindMethod = "get", resultType = PlatformResp.class), props = { + @Mapping(src = "url", ref = "platformUrl"), @Mapping(src = "name", ref = "platformName")}) + private Long platformId; + + /** + * headers + */ + @Schema(description = "headers", type = "JSON") + private String headers; + + /** + * 状态(1:启用;2:禁用) + */ + @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") + private DisEnableStatusEnum status; + + /** + * 用户ID + */ + @Schema(description = "用户ID") + @AssembleMethod(targetType = UserService.class, method = @ContainerMethod(bindMethod = "get", resultType = UserResp.class), props = @Mapping(src = "username", ref = "user")) + private Long userId; + + /** + * 所属用户 + */ + @Schema(description = "所属用户", example = "张三") + private UserResp user; + + /** + * 是否为团队账号 + */ + @Schema(description = "是否为团队账号", example = "false") + private Boolean isTeam; + +} diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformDetailResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformDetailResp.java index f20574a8..019816e1 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformDetailResp.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformDetailResp.java @@ -1,7 +1,22 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.resp; import java.io.Serial; -import java.time.LocalDateTime; import com.zayac.admin.common.enums.DisEnableStatusEnum; import lombok.Data; diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformResp.java index fb49ae1c..6619c756 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformResp.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/PlatformResp.java @@ -1,7 +1,22 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.model.resp; import java.io.Serial; -import java.time.LocalDateTime; import com.zayac.admin.common.enums.DisEnableStatusEnum; import lombok.Data; diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserDetailResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserDetailResp.java index ed50ee34..6ebfd138 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserDetailResp.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserDetailResp.java @@ -184,7 +184,6 @@ public class UserDetailResp extends BaseDetailResp { @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") private DisEnableStatusEnum needNotify; - @Override public Boolean getDisabled() { return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId()); diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserResp.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserResp.java index 0ba37530..bd56d7a0 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserResp.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/model/resp/UserResp.java @@ -125,19 +125,19 @@ public class UserResp extends BaseDetailResp { * 注册新增消息通知群组 */ @Schema(description = "注册消息通知群组", example = "bot:xxxx") - private String groupId; + private Long groupId; /** * 报数消息通知群组id */ @Schema(description = "报数消息通知群组", example = "bot:xxxx") - private String countGroupId; + private Long countGroupId; /** * 聊天消息id */ @Schema(description = "聊天消息", example = "bot:xxxx") - private String chatId; + private Long chatId; /** * 用户telegram @@ -151,7 +151,6 @@ public class UserResp extends BaseDetailResp { @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") private DisEnableStatusEnum needNotify; - @Override public Boolean getDisabled() { return this.getIsSystem() || Objects.equals(this.getId(), LoginHelper.getUserId()); diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java index ed063a23..acae3141 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/AccountService.java @@ -1,11 +1,30 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.service; +import com.zayac.admin.common.enums.DisEnableStatusEnum; +import com.zayac.admin.system.model.entity.UserDO; import com.zayac.admin.system.model.query.AccountQuery; import com.zayac.admin.system.model.req.AccountReq; import com.zayac.admin.system.model.resp.AccountDetailResp; import com.zayac.admin.system.model.resp.AccountResp; import top.continew.starter.extension.crud.service.BaseService; +import java.util.List; /** * 账号业务接口 @@ -13,4 +32,8 @@ import top.continew.starter.extension.crud.service.BaseService; * @author zayac * @since 2024/05/10 20:44 */ -public interface AccountService extends BaseService {} \ No newline at end of file +public interface AccountService extends BaseService { + List getAccountsByUserId(Long id, DisEnableStatusEnum status); + + UserDO getUserByAccountUsername(String username); +} \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/DeptService.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/DeptService.java index a27eaa17..611bb72f 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/DeptService.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/DeptService.java @@ -40,4 +40,6 @@ public interface DeptService extends BaseService listChildren(Long id); + + List getByName(String name); } diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/PlatformService.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/PlatformService.java index aed94848..cb4ecafe 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/PlatformService.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/PlatformService.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.service; import com.zayac.admin.common.model.resp.LabelValueResp; diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserRoleService.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserRoleService.java index 65d5e283..093c1733 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserRoleService.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserRoleService.java @@ -57,4 +57,6 @@ public interface UserRoleService { * @return true:已关联;false:未关联 */ boolean isRoleIdExists(List roleIds); + + List listUserIdByRoleId(Long roleId); } \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserService.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserService.java index 19153350..0ae25657 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserService.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/UserService.java @@ -16,8 +16,8 @@ package com.zayac.admin.system.service; +import com.zayac.admin.common.enums.DisEnableStatusEnum; import com.zayac.admin.common.model.resp.LabelValueResp; -import com.zayac.admin.system.model.resp.RoleResp; import org.springframework.web.multipart.MultipartFile; import com.zayac.admin.system.model.entity.UserDO; import com.zayac.admin.system.model.query.UserQuery; @@ -147,4 +147,17 @@ public interface UserService extends BaseService> buildDict(List list); + + /** + * 查询所有的可用用户 + * + * @return 用户列表 + */ + List getAllEnabledUsers(); + + /** + * 查询所有部门用户 + */ + List getByDeptId(DisEnableStatusEnum status, Long deptId); + } diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java index f478a4a0..466b55c5 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/AccountServiceImpl.java @@ -1,18 +1,41 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.service.impl; +import com.alicp.jetcache.anno.CacheType; +import com.alicp.jetcache.anno.Cached; +import com.zayac.admin.common.constant.CacheConstants; +import com.zayac.admin.common.enums.DisEnableStatusEnum; import com.zayac.admin.system.mapper.AccountMapper; import com.zayac.admin.system.model.entity.AccountDO; +import com.zayac.admin.system.model.entity.UserDO; import com.zayac.admin.system.model.query.AccountQuery; import com.zayac.admin.system.model.req.AccountReq; import com.zayac.admin.system.model.resp.AccountDetailResp; import com.zayac.admin.system.model.resp.AccountResp; import com.zayac.admin.system.service.AccountService; +import com.zayac.admin.system.service.UserService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; +import java.util.List; /** * 账号业务实现 @@ -22,4 +45,26 @@ import top.continew.starter.extension.crud.service.impl.BaseServiceImpl; */ @Service @RequiredArgsConstructor -public class AccountServiceImpl extends BaseServiceImpl implements AccountService {} \ No newline at end of file +public class AccountServiceImpl extends BaseServiceImpl implements AccountService { + private final UserService userService; + + @Override + @Cached(cacheType = CacheType.LOCAL, key = "#userId", name = CacheConstants.ENABLED_ACCOUNTS_KEY_PREFIX, localExpire = 300, expire = 300) + public List getAccountsByUserId(Long id, DisEnableStatusEnum status) { + AccountQuery accountQuery = new AccountQuery(); + accountQuery.setStatus(status.getValue()); + accountQuery.setUserId(id); + return list(accountQuery, null); + } + + @Override + @Cached(cacheType = CacheType.LOCAL, key = "#username", name = CacheConstants.ENABLED_ACCOUNTS_KEY_PREFIX, localExpire = 300, expire = 300) + public UserDO getUserByAccountUsername(String username) { + return baseMapper.lambdaQuery() + .eq(AccountDO::getUsername, username) + .eq(AccountDO::getStatus, DisEnableStatusEnum.ENABLE) + .oneOpt() + .map(account -> userService.getById(account.getId())) + .orElse(null); + } +} \ No newline at end of file diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/DeptServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/DeptServiceImpl.java index 41fcc541..6f1204d2 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/DeptServiceImpl.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/DeptServiceImpl.java @@ -62,6 +62,11 @@ public class DeptServiceImpl extends BaseServiceImpl getByName(String name) { + return baseMapper.lambdaQuery().eq(DeptDO::getName, name).list(); + } + @Override protected void beforeAdd(DeptReq req) { String name = req.getName(); diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/PlatformServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/PlatformServiceImpl.java index cc0de33c..95c66242 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/PlatformServiceImpl.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/PlatformServiceImpl.java @@ -1,8 +1,23 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.system.service.impl; import cn.hutool.core.collection.CollUtil; import com.zayac.admin.common.model.resp.LabelValueResp; -import com.zayac.admin.system.model.resp.RoleResp; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserRoleServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserRoleServiceImpl.java index 349be223..429b26af 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserRoleServiceImpl.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserRoleServiceImpl.java @@ -74,6 +74,12 @@ public class UserRoleServiceImpl implements UserRoleService { return baseMapper.selectRoleIdByUserId(userId); } + @Override + @ContainerMethod(namespace = ContainerConstants.ROLE_USER_ID_LIST, type = MappingType.ORDER_OF_KEYS) + public List listUserIdByRoleId(Long roleId) { + return baseMapper.selectUserIdByRoleId(roleId); + } + @Override public boolean isRoleIdExists(List roleIds) { return baseMapper.lambdaQuery().in(UserRoleDO::getRoleId, roleIds).exists(); diff --git a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserServiceImpl.java b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserServiceImpl.java index cf0ca055..b0813c8e 100644 --- a/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserServiceImpl.java +++ b/zayac-admin-system/src/main/java/com/zayac/admin/system/service/impl/UserServiceImpl.java @@ -262,6 +262,11 @@ public class UserServiceImpl extends BaseServiceImpl new LabelValueResp<>(r.getUsername(), r.getId())).toList(); } + @Override + public List getAllEnabledUsers() { + return baseMapper.lambdaQuery().eq(UserDO::getStatus, DisEnableStatusEnum.ENABLE.getValue()).list(); + } + @Override @Cached(key = "#id", cacheType = CacheType.BOTH, name = CacheConstants.USER_KEY_PREFIX, syncLocal = true) public String getNicknameById(Long id) { @@ -298,6 +303,20 @@ public class UserServiceImpl extends BaseServiceImpl getByDeptId(DisEnableStatusEnum status, Long deptId) { + QueryWrapper wrapper = new QueryWrapper().eq(null != status, "status", status.getValue()) + .and(q -> { + List deptIdList = deptService.listChildren(deptId) + .stream() + .map(DeptDO::getId) + .collect(Collectors.toList()); + deptIdList.add(deptId); + q.in("dept_id", deptIdList); + }); + return baseMapper.selectList(wrapper); + } + /** * 构建 QueryWrapper * diff --git a/zayac-admin-webapi/pom.xml b/zayac-admin-webapi/pom.xml index 9ea7c0fc..6fbdb17d 100644 --- a/zayac-admin-webapi/pom.xml +++ b/zayac-admin-webapi/pom.xml @@ -48,6 +48,12 @@ com.zayac zayac-admin-system + + + + com.zayac + zayac-admin-backend + diff --git a/zayac-admin-webapi/src/main/java/com/zayac/admin/ZayacAdminApplication.java b/zayac-admin-webapi/src/main/java/com/zayac/admin/ZayacAdminApplication.java index c87425d2..6daf64d5 100644 --- a/zayac-admin-webapi/src/main/java/com/zayac/admin/ZayacAdminApplication.java +++ b/zayac-admin-webapi/src/main/java/com/zayac/admin/ZayacAdminApplication.java @@ -29,6 +29,7 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import top.continew.starter.core.autoconfigure.project.ProjectProperties; @@ -52,6 +53,7 @@ import java.net.InetAddress; @RequiredArgsConstructor @EnableCrudRestController @EnableGlobalExceptionHandler +@EnableScheduling @EnableMethodCache(basePackages = "com.zayac.admin") public class ZayacAdminApplication implements ApplicationRunner { diff --git a/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/AccountController.java b/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/AccountController.java index 051249f5..daee5a98 100644 --- a/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/AccountController.java +++ b/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/AccountController.java @@ -1,19 +1,28 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.webapi.system; -import cn.hutool.core.util.ReUtil; -import com.zayac.admin.common.constant.RegexConstants; -import com.zayac.admin.common.util.SecureUtils; import com.zayac.admin.system.model.query.AccountQuery; import com.zayac.admin.system.model.req.AccountReq; -import com.zayac.admin.system.model.req.UserReq; import com.zayac.admin.system.model.resp.AccountDetailResp; import com.zayac.admin.system.model.resp.AccountResp; import com.zayac.admin.system.service.AccountService; import com.zayac.admin.system.service.PlatformService; import lombok.RequiredArgsConstructor; -import org.springframework.validation.annotation.Validated; -import top.continew.starter.core.util.ExceptionUtils; -import top.continew.starter.core.util.validate.ValidationUtils; import top.continew.starter.extension.crud.enums.Api; import io.swagger.v3.oas.annotations.tags.Tag; @@ -22,9 +31,6 @@ import org.springframework.web.bind.annotation.*; import top.continew.starter.extension.crud.annotation.CrudRequestMapping; import top.continew.starter.extension.crud.controller.BaseController; -import top.continew.starter.extension.crud.util.ValidateGroup; -import top.continew.starter.web.model.R; - /** * 账号管理 API @@ -39,20 +45,20 @@ import top.continew.starter.web.model.R; public class AccountController extends BaseController { private final PlatformService platformService; -/* @Override + /* @Override public R add(@Validated(ValidateGroup.Crud.Add.class) @RequestBody AccountReq req) { -// String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword())); -// ValidationUtils.throwIfNull(rawPassword, "密码解密失败"); + // String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword())); + // ValidationUtils.throwIfNull(rawPassword, "密码解密失败"); ValidationUtils.throwIf(!ReUtil .isMatch(RegexConstants.PASSWORD, req.getPassword()), "密码长度为 6 到 32 位,可以包含字母、数字、下划线,特殊字符,同时包含字母和数字"); req.setPlatformId(platformService.getByPlatformId(req.getType().getValue()).getId()); return super.add(req); } - + @Override public R update(@Validated(ValidateGroup.Crud.Update.class) @RequestBody AccountReq req, @PathVariable Long id) { -// String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword())); -// ValidationUtils.throwIfNull(rawPassword, "密码解密失败"); + // String rawPassword = ExceptionUtils.exToNull(() -> SecureUtils.decryptByRsaPrivateKey(req.getPassword())); + // ValidationUtils.throwIfNull(rawPassword, "密码解密失败"); ValidationUtils.throwIf(!ReUtil .isMatch(RegexConstants.PASSWORD, req.getPassword()), "密码长度为 6 到 32 位,可以包含字母、数字、下划线,特殊字符,同时包含字母和数字"); req.setPlatformId(platformService.getByPlatformId(req.getType().getValue()).getId()); diff --git a/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/PlatformController.java b/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/PlatformController.java index 37b662e0..caa5b9d6 100644 --- a/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/PlatformController.java +++ b/zayac-admin-webapi/src/main/java/com/zayac/admin/webapi/system/PlatformController.java @@ -1,3 +1,19 @@ +/* + * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.zayac.admin.webapi.system; import top.continew.starter.extension.crud.enums.Api; diff --git a/zayac-admin-webapi/src/main/resources/config/application.yml b/zayac-admin-webapi/src/main/resources/config/application.yml index e4359abf..a7ae7fa3 100644 --- a/zayac-admin-webapi/src/main/resources/config/application.yml +++ b/zayac-admin-webapi/src/main/resources/config/application.yml @@ -9,7 +9,7 @@ project: # 描述 description: 持续迭代优化的前后端分离中后台管理系统框架,开箱即用,持续提供舒适的开发体验。 # 基本包 - base-package: com.zayac + base-package: com.zayac.admin ## 作者信息配置 contact: name: zayac @@ -227,3 +227,13 @@ management.health: mail: # 关闭邮箱健康检查(邮箱配置错误或邮箱服务器不可用时,健康检查会报错) enabled: false + +webclient: + max-concurrent-requests: 60 + +spring: + rabbitmq: + host: mq.stupidpz.com + port: 5672 + username: bot + password: xiaomi@123