Skip to content

Commit 7f00599

Browse files
committed
refactor: 重构内部 API 依赖模式(降低耦合,公众号投票结论),在 common 模块新增 api 包,在对应 biz 模块增加实现
1 parent 3af43ef commit 7f00599

File tree

30 files changed

+781
-128
lines changed

30 files changed

+781
-128
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.common.api.system;
18+
19+
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
20+
21+
import java.util.List;
22+
23+
/**
24+
* 字典业务 API
25+
*
26+
* @author Charles7c
27+
* @since 2025/7/26 10:16
28+
*/
29+
public interface DictApi {
30+
31+
/**
32+
* 查询字典列表
33+
*
34+
* @return 字典列表(包含枚举字典列表)
35+
*/
36+
List<LabelValueResp> listAll();
37+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
package top.continew.admin.common.service;
17+
package top.continew.admin.common.api.system;
1818

1919
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
2020

2121
import java.util.List;
2222

2323
/**
24-
* 公共字典项业务接口
24+
* 字典项业务 API
2525
*
2626
* @author Charles7c
2727
* @since 2025/4/9 20:17
2828
*/
29-
public interface CommonDictItemService {
29+
public interface DictItemApi {
3030

3131
/**
3232
* 根据字典编码查询
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.common.api.system;
18+
19+
import cn.hutool.core.lang.tree.Tree;
20+
21+
import java.util.List;
22+
23+
/**
24+
* 菜单业务 API
25+
*
26+
* @author Charles7c
27+
* @since 2025/7/26 9:53
28+
*/
29+
public interface MenuApi {
30+
31+
/**
32+
* 查询树结构列表
33+
*
34+
* @param excludeMenuIds 排除的菜单 ID 列表
35+
* @return 树结构列表
36+
*/
37+
List<Tree<Long>> listTree(List<Long> excludeMenuIds);
38+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.common.api.system;
18+
19+
/**
20+
* 角色业务 API
21+
*
22+
* @author Charles7c
23+
* @since 2025/7/26 9:39
24+
*/
25+
public interface RoleApi {
26+
27+
/**
28+
* 根据编码查询 ID
29+
*
30+
* @param code 编码
31+
* @return 角色 ID
32+
*/
33+
Long getIdByCode(String code);
34+
35+
/**
36+
* 更新用户上下文
37+
*
38+
* @param roleId 角色 ID
39+
*/
40+
void updateUserContext(Long roleId);
41+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.common.api.system;
18+
19+
import java.util.List;
20+
import java.util.Set;
21+
22+
/**
23+
* 角色和菜单关联业务 API
24+
*
25+
* @author Charles7c
26+
* @since 2025/7/26 9:39
27+
*/
28+
public interface RoleMenuApi {
29+
30+
/**
31+
* 根据菜单 ID 列表查询角色 ID 列表
32+
*
33+
* @param menuIds 菜单 ID 列表(Not In)
34+
* @return 角色 ID 列表
35+
*/
36+
Set<Long> listRoleIdByNotInMenuIds(List<Long> menuIds);
37+
38+
/**
39+
* 根据角色 ID 列表查询菜单 ID 列表
40+
*
41+
* @param roleIds 角色 ID 列表
42+
* @return 菜单 ID 列表
43+
*/
44+
List<Long> listMenuIdByRoleIds(List<Long> roleIds);
45+
46+
/**
47+
* 根据菜单 ID 列表删除
48+
*
49+
* @param menuIds 菜单 ID 列表(Not In)
50+
*/
51+
void deleteByNotInMenuIds(List<Long> menuIds);
52+
53+
/**
54+
* 新增
55+
*
56+
* @param menuIds 菜单 ID 列表
57+
* @param roleId 角色 ID
58+
* @return 是否新增成功(true:成功;false:无变更/失败)
59+
*/
60+
boolean add(List<Long> menuIds, Long roleId);
61+
}
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@
1414
* limitations under the License.
1515
*/
1616

17-
package top.continew.admin.common.service;
17+
package top.continew.admin.common.api.system;
1818

1919
import cn.crane4j.annotation.ContainerMethod;
2020
import cn.crane4j.annotation.MappingType;
2121
import top.continew.admin.common.constant.ContainerConstants;
2222

2323
/**
24-
* 公共用户业务接口
24+
* 用户业务 API
2525
*
2626
* @author Charles7c
2727
* @since 2025/1/9 20:17
2828
*/
29-
public interface CommonUserService {
29+
public interface UserApi {
3030

3131
/**
3232
* 根据 ID 查询昵称
@@ -40,4 +40,12 @@ public interface CommonUserService {
4040
*/
4141
@ContainerMethod(namespace = ContainerConstants.USER_NICKNAME, type = MappingType.ORDER_OF_KEYS)
4242
String getNicknameById(Long id);
43+
44+
/**
45+
* 重置密码
46+
*
47+
* @param newPassword 新密码
48+
* @param id ID
49+
*/
50+
void resetPassword(String newPassword, Long id);
4351
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.common.api.tenant;
18+
19+
import java.util.List;
20+
21+
/**
22+
* 套餐和菜单关联业务 API
23+
*
24+
* @author Charles7c
25+
* @since 2025/7/23 21:13
26+
*/
27+
public interface PackageMenuApi {
28+
29+
/**
30+
* 根据套餐 ID 查询
31+
*
32+
* @param packageId 套餐 ID
33+
* @return 菜单 ID 列表
34+
*/
35+
List<Long> listMenuIdsByPackageId(Long packageId);
36+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2022-present Charles7c Authors. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package top.continew.admin.common.api.tenant;
18+
19+
/**
20+
* 租户业务 API
21+
*
22+
* @author Charles7c
23+
* @since 2025/7/23 21:13
24+
*/
25+
public interface TenantApi {
26+
27+
/**
28+
* 绑定租户管理员用户
29+
*
30+
* @param tenantId 租户 ID
31+
* @param userId 用户 ID
32+
*/
33+
void bindAdminUser(Long tenantId, Long userId);
34+
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@
1414
* limitations under the License.
1515
*/
1616

17-
package top.continew.admin.tenant.handler;
17+
package top.continew.admin.common.api.tenant;
1818

19-
import top.continew.admin.tenant.model.req.TenantReq;
19+
import top.continew.admin.common.model.dto.TenantDTO;
2020

2121
/**
22-
* 租户数据处理器
22+
* 租户数据 API
2323
*
2424
* @author 小熊
2525
* @author Charles7c
2626
* @since 2024/12/2 20:08
2727
*/
28-
public interface TenantDataHandler {
28+
public interface TenantDataApi {
2929

3030
/**
3131
* 初始化数据
3232
*
3333
* @param tenant 租户信息
3434
*/
35-
void init(TenantReq tenant);
35+
void init(TenantDTO tenant);
3636

3737
/**
3838
* 清除数据

continew-common/src/main/java/top/continew/admin/common/config/excel/ExcelDictConverter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import cn.idev.excel.metadata.data.ReadCellData;
2525
import cn.idev.excel.metadata.data.WriteCellData;
2626
import cn.idev.excel.metadata.property.ExcelContentProperty;
27-
import top.continew.admin.common.service.CommonDictItemService;
27+
import top.continew.admin.common.api.system.DictItemApi;
2828
import top.continew.starter.core.constant.StringConstants;
2929
import top.continew.starter.extension.crud.model.resp.LabelValueResp;
3030

@@ -86,7 +86,7 @@ private List<LabelValueResp> getDictCode(ExcelContentProperty contentProperty) {
8686
if (dictExcelProperty == null) {
8787
throw new IllegalArgumentException("Excel 字典转换器异常:请为字段添加 @DictExcelProperty 注解");
8888
}
89-
CommonDictItemService dictItemService = SpringUtil.getBean(CommonDictItemService.class);
90-
return dictItemService.listByDictCode(dictExcelProperty.value());
89+
DictItemApi dictItemApi = SpringUtil.getBean(DictItemApi.class);
90+
return dictItemApi.listByDictCode(dictExcelProperty.value());
9191
}
9292
}

0 commit comments

Comments
 (0)