@llryiop/avatar-boot-cli 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@llryiop/avatar-boot-cli",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "CLI tool for scaffolding AvatarBoot Java microservice projects",
5
5
  "main": "src/index.js",
6
6
  "bin": {
@@ -144,106 +144,71 @@
144
144
  项目采用 API + Service 双模块结构,每个功能模块在两个工程中都有对应的独立包结构:
145
145
 
146
146
  ```
147
- avatar-scaffold-project/
148
- ├── avatar-scaffold-api/ # API 模块(接口定义)
149
- │ └── src/main/java/com/iflytek/avatar/
150
- ├── common/ # 公共模块(跨功能共享)
151
- │ ├── constant/ # 系统级常量
152
- │ │ │ └── ApiConstant.java
153
- ├── enums/ # 公共枚举
154
- └── ResultCodeEnum.java
155
- │ ├── exception/ # 公共异常
156
- │ │ ├── BusinessException.java
157
- └── ErrorCode.java
158
- │ └── dto/ # 公共DTO
159
- ├── PageRequest.java # 分页请求基类
160
- │ └── PageResponse.java # 分页响应基类
161
-
162
- ├── login/ # 登录功能模块
163
- ├── api/ # Feign接口定义
164
- └── LoginFeignClient.java
165
- ├── constant/ # 模块常量
166
- │ │ └── LoginConstant.java
167
- ├── enums/ # 模块枚举
168
- └── LoginTypeEnum.java
169
- │ ├── exception/ # 模块异常
170
- │ │ └── LoginException.java
171
- └── dto/ # **DTO目录(统一命名)**
172
- │ ├── request/ # 请求DTO
173
- │ │ │ ├── LoginRequest.java
174
- │ │ └── RefreshTokenRequest.java
175
- │ └── response/ # 响应DTO
176
- ├── LoginResponse.java
177
- └── TokenInfoResponse.java
178
-
179
- └── user/ # 用户功能模块
180
- ├── api/
181
- └── UserFeignClient.java
182
- ├── constant/
183
- └── UserConstant.java
184
- ├── enums/
185
- └── UserStatusEnum.java
186
- ├── exception/
187
- └── UserException.java
188
- └── dto/
189
- ├── request/
190
- ├── CreateUserRequest.java
191
- ├── UpdateUserRequest.java
192
- │ └── UserQueryRequest.java
193
- └── response/
194
- ├── UserDetailResponse.java
195
- └── UserSimpleResponse.java
196
-
197
- └── avatar-scaffold-service/ # Service 模块(业务实现)
198
- └── src/main/java/com/iflytek/avatar/
199
- ├── common/ # 公共实现
200
- ├── config/ # 全局配置
201
- │ ├── MyBatisConfig.java
202
- ├── RedisConfig.java
203
- └── SwaggerConfig.java
204
- ├── utils/ # 公共工具类
205
- ├── JwtUtils.java
206
- └── RedisUtils.java
207
- └── interceptor/ # 全局拦截器
208
- └── LoginInterceptor.java
209
-
210
- ├── login/ # 登录功能实现
211
- │ ├── config/ # 模块配置
212
- │ │ └── LoginConfig.java
213
- │ ├── controller/ # REST控制器(实现API)
214
- │ │ └── LoginController.java
215
- │ ├── service/ # 业务逻辑层
216
- │ │ ├── LoginService.java # 接口
217
- │ │ └── impl/
218
- │ │ └── LoginServiceImpl.java # 实现
219
- │ ├── repository/ # **数据访问层(使用repository)**
220
- │ │ ├── mapper/ # MyBatis Mapper接口
221
- │ │ │ └── UserLoginMapper.java
222
- │ │ └── entity/ # **数据库实体(统一用entity)**
223
- │ │ ├── UserLoginEntity.java # 用户登录表实体
224
- │ │ └── UserTokenEntity.java # 用户Token表实体
225
- │ ├── converter/ # **对象转换器(DO <-> DTO)**
226
- │ │ └── LoginConverter.java
227
- │ └── utils/ # 模块工具类
228
- │ └── LoginUtils.java
229
-
230
- └── user/ # 用户功能实现
231
- ├── controller/
232
- │ └── UserController.java
233
- ├── service/
234
- │ ├── UserService.java
235
- │ └── impl/
236
- │ └── UserServiceImpl.java
237
- ├── repository/
238
- │ ├── mapper/
239
- │ │ └── UserMapper.java
240
- │ └── entity/
241
- │ ├── UserEntity.java # 用户主表实体
242
- │ └── UserProfileEntity.java # 用户档案表实体
243
- ├── converter/
244
- │ └── UserConverter.java
245
- └── validator/ # **参数校验器**
246
- └── UserValidator.java
147
+ avatar-scaffold-project/
148
+ ├── pom.xml # POM,聚合模块管理
149
+ ├── CLAUDE.md # AI 开发规范文档
150
+ ├── README.md # 项目说明文档
151
+
152
+ ├── avatar-scaffold-api/ # API 模块(接口定义层)
153
+ │ ├── pom.xml
154
+ │ └── src/main/java/com/iflytek/avatar/
155
+ └── login/
156
+ ├── api/
157
+ │ └── LoginFeignClient.java # Feign 客户端
158
+ ├── constant/
159
+ └── LoginConstant.java # 业务常量
160
+ ├── dto/
161
+ ├── request/
162
+ │ │ ├── LoginRequest.java
163
+ │ └── RefreshTokenRequest.java
164
+ │ └── response/
165
+ ├── LoginResponse.java
166
+ └── TokenInfoResponse.java
167
+ ├── enums/
168
+ │ └── LoginTypeEnum.java # 登录类型枚举
169
+ └── exception/
170
+ ├── LoginErrorCode.java # ★ 新增:错误码枚举/常量
171
+ └── LoginException.java # 业务异常定义
172
+
173
+ ├── avatar-scaffold-service/ # Service 模块(业务实现层)
174
+ ├── pom.xml
175
+ ├── k8s-app/
176
+ ├── Dockerfile # x86 镜像构建
177
+ └── Dockerfile-arm64 # ARM64 镜像构建
178
+ ├── packaging/
179
+ └── assembly.xml # Maven Assembly 打包配置
180
+ ├── logs/ # 本地运行日志
181
+ │ └── src/main/
182
+ ├── java/com/iflytek/avatar/
183
+ ├── Application.java # Spring Boot 启动类
184
+ │ └── login/
185
+ ├── config/
186
+ │ │ └── LoginConfig.java # 登录配置 Bean
187
+ ├── controller/
188
+ │ │ └── LoginController.java # REST 接口实现
189
+ ├── converter/
190
+ └── LoginConverter.java # Entity ↔ DTO 转换
191
+ ├── feign/
192
+ └── DemoFeign.java # 调用其他服务的 Feign 客户端
193
+ │ ├── repository/
194
+ │ │ ├── UserLoginRepository.java # Repository 封装
195
+ │ │ ├── entity/
196
+ │ │ │ ├── UserLoginEntity.java
197
+ │ │ │ │ └── UserTokenEntity.java
198
+ │ │ │ └── mapper/
199
+ │ │ │ └── UserLoginMapper.java # MyBatis Plus Mapper
200
+ ├── service/
201
+ ├── LoginService.java # Service 接口
202
+ └── impl/
203
+ └── LoginServiceImpl.java
204
+ │ └── utils/
205
+ └── LoginUtils.java
206
+ └── resources/
207
+ ├── application.yaml # 主配置(激活 profile)
208
+ ├── application-local.yaml
209
+ ├── application-dev.yaml
210
+ ├── application-test.yaml
211
+ └── └── application-prod.yaml
247
212
  ```
248
213
 
249
214
  ### 架构规则
@@ -16,6 +16,8 @@ import org.springframework.web.bind.annotation.RequestBody;
16
16
  @FeignClient(
17
17
  name = "avatar-scaffold-service",
18
18
  path = "/api/login",
19
+ contextId = "loginFeignClient",
20
+ url = "${avatar.login-service.url}",
19
21
  configuration = com.iflytek.avatar.boot.config.FeignLoggingConfiguration.class
20
22
  )
21
23
  public interface LoginFeignClient {
@@ -0,0 +1,25 @@
1
+ package com.iflytek.avatar.login.exception;
2
+
3
+ import com.iflytek.avatar.boot.entity.response.IResultCode;
4
+ import lombok.AllArgsConstructor;
5
+ import lombok.Getter;
6
+
7
+ @Getter
8
+ @AllArgsConstructor
9
+ public enum LoginErrorCode implements IResultCode {
10
+ LOGIN_ERROR_CODE(40000001, "登录失败")
11
+ ;
12
+
13
+ private final int code;
14
+ private final String message;
15
+
16
+ @Override
17
+ public int getCode() {
18
+ return code;
19
+ }
20
+
21
+ @Override
22
+ public String getMessage() {
23
+ return message;
24
+ }
25
+ }
@@ -9,7 +9,10 @@ import org.springframework.web.bind.annotation.RequestParam;
9
9
 
10
10
  import java.util.Map;
11
11
 
12
- @FeignClient(name = "demo", url = "http://127.0.0.1:8888", configuration = FeignLoggingConfiguration.class)
12
+ @FeignClient(name = "demo",
13
+ url = "http://127.0.0.1:8888",
14
+ contextId = "demoFeign",
15
+ configuration = FeignLoggingConfiguration.class)
13
16
  public interface DemoFeign {
14
17
 
15
18
  @GetMapping("/demo")
@@ -0,0 +1,10 @@
1
+ package com.iflytek.avatar.login.repository;
2
+
3
+ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+ import com.iflytek.avatar.login.repository.entity.UserLoginEntity;
5
+ import com.iflytek.avatar.login.repository.mapper.UserLoginMapper;
6
+ import org.springframework.stereotype.Component;
7
+
8
+ @Component
9
+ public class UserLoginRepository extends ServiceImpl<UserLoginMapper, UserLoginEntity> {
10
+ }
@@ -1,12 +1,15 @@
1
1
  package com.iflytek.avatar.login.repository.mapper;
2
2
 
3
+ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
4
  import com.iflytek.avatar.login.repository.entity.UserLoginEntity;
5
+ import org.apache.ibatis.annotations.Mapper;
4
6
 
5
7
  /**
6
8
  * 用户登录 Mapper(MyBatis)
7
9
  * 启用 avatar-boot-starter-mysql 后添加 @Mapper 并编写 XML/注解 SQL;当前为 Demo 接口定义。
8
10
  */
9
- public interface UserLoginMapper {
11
+ @Mapper
12
+ public interface UserLoginMapper extends BaseMapper<UserLoginEntity> {
10
13
 
11
14
  /**
12
15
  * 插入登录记录
@@ -11,21 +11,28 @@ spring:
11
11
  discovery:
12
12
  enabled: false
13
13
 
14
- # ============================================
15
- # 本地数据库配置
16
- # ============================================
17
14
  datasource:
18
- driver-class-name: com.mysql.cj.jdbc.Driver
19
- url: jdbc:mysql://localhost:3306/avatar_scaffold?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true
20
- username: ${DB_USERNAME:root}
21
- password: ${DB_PASSWORD:root}
22
- type: com.zaxxer.hikari.HikariDataSource
23
- hikari:
24
- minimum-idle: 5
25
- maximum-pool-size: 20
26
- connection-timeout: 30000
27
- idle-timeout: 600000
28
- max-lifetime: 1800000
15
+ dynamic:
16
+ primary: master # 指定主数据源
17
+ strict: false # 非严格模式,未匹配到数据源时使用主数据源
18
+ datasource:
19
+ master:
20
+ driver-class-name: com.mysql.cj.jdbc.Driver
21
+ username: root
22
+ password: youshengsql
23
+ url: jdbc:mysql://172.31.101.165:3306/avatar_zhizuo?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
24
+ type: com.alibaba.druid.pool.DruidDataSource
25
+ druid:
26
+ initial-size: 5
27
+ min-idle: 5
28
+ max-active: 20
29
+ max-wait: 60000
30
+ time-between-eviction-runs-millis: 60000
31
+ min-evictable-idle-time-millis: 300000
32
+ validation-query: SELECT 1
33
+ test-while-idle: true
34
+ test-on-borrow: false
35
+ test-on-return: false
29
36
 
30
37
  # ============================================
31
38
  # 本地 Redis 配置
@@ -52,10 +59,3 @@ mybatis-plus:
52
59
  map-underscore-to-camel-case: true
53
60
  cache-enabled: false
54
61
  log-impl: org.apache.ibatis.logging.slf4j.Slf4jImpl
55
-
56
- # 日志配置
57
- logging:
58
- level:
59
- com.iflytek.avatar: DEBUG
60
- com.alibaba.nacos: ERROR
61
- com.alibaba.cloud.nacos: ERROR