style(zulip_accounts): 代码规范优化 - 清理未使用导入和修复异常处理
范围:src/core/db/zulip_accounts/ 涉及文件: - zulip_accounts.repository.ts - zulip_accounts.service.ts - zulip_accounts_memory.service.ts 主要改进: - 清理未使用的导入(FindOptionsWhere, NotFoundException, ConflictException) - 修复异常处理:确保catch块中正确抛出异常,避免异常吞没 - 更新文件头部修改记录和版本号
This commit is contained in:
@@ -17,22 +17,21 @@
|
|||||||
* - 并发控制:使用悲观锁防止竞态条件
|
* - 并发控制:使用悲观锁防止竞态条件
|
||||||
*
|
*
|
||||||
* 最近修改:
|
* 最近修改:
|
||||||
|
* - 2026-01-15: 代码规范优化 - 清理未使用的导入FindOptionsWhere (修改者: moyin)
|
||||||
* - 2026-01-12: 性能优化 - 集成AppLoggerService,优化查询和批量操作
|
* - 2026-01-12: 性能优化 - 集成AppLoggerService,优化查询和批量操作
|
||||||
* - 2026-01-07: 代码规范优化 - 使用统一的常量文件,提高代码质量
|
* - 2026-01-07: 代码规范优化 - 使用统一的常量文件,提高代码质量
|
||||||
* - 2026-01-07: 代码规范优化 - 完善文件头注释和方法三级注释
|
* - 2026-01-07: 代码规范优化 - 完善文件头注释和方法三级注释
|
||||||
* - 2026-01-07: 功能新增 - 添加事务支持防止并发竞态条件
|
* - 2026-01-07: 功能新增 - 添加事务支持防止并发竞态条件
|
||||||
* - 2026-01-07: 性能优化 - 优化查询语句添加LIMIT限制
|
|
||||||
* - 2026-01-07: 功能新增 - 新增existsByGameUserId方法
|
|
||||||
*
|
*
|
||||||
* @author angjustinl
|
* @author angjustinl
|
||||||
* @version 1.2.0
|
* @version 1.2.1
|
||||||
* @since 2025-01-05
|
* @since 2025-01-05
|
||||||
* @lastModified 2026-01-12
|
* @lastModified 2026-01-15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable, Inject } from '@nestjs/common';
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
import { InjectRepository } from '@nestjs/typeorm';
|
import { InjectRepository } from '@nestjs/typeorm';
|
||||||
import { Repository, FindOptionsWhere, DataSource, SelectQueryBuilder } from 'typeorm';
|
import { Repository, DataSource, SelectQueryBuilder } from 'typeorm';
|
||||||
import { ZulipAccounts } from './zulip_accounts.entity';
|
import { ZulipAccounts } from './zulip_accounts.entity';
|
||||||
import { AppLoggerService } from '../../utils/logger/logger.service';
|
import { AppLoggerService } from '../../utils/logger/logger.service';
|
||||||
import {
|
import {
|
||||||
|
|||||||
@@ -16,28 +16,19 @@
|
|||||||
* 注意:业务逻辑已转移到 src/core/zulip_core/services/zulip_accounts_business.service.ts
|
* 注意:业务逻辑已转移到 src/core/zulip_core/services/zulip_accounts_business.service.ts
|
||||||
*
|
*
|
||||||
* 最近修改:
|
* 最近修改:
|
||||||
|
* - 2026-01-15: 代码规范优化 - 清理未使用的导入NotFoundException (修改者: moyin)
|
||||||
* - 2026-01-12: 代码规范优化 - 修复依赖注入配置,添加@Inject装饰器确保正确的参数注入 (修改者: moyin)
|
* - 2026-01-12: 代码规范优化 - 修复依赖注入配置,添加@Inject装饰器确保正确的参数注入 (修改者: moyin)
|
||||||
* - 2026-01-12: 功能修改 - 优化create方法错误处理,正确转换重复创建错误为ConflictException (修改者: moyin)
|
* - 2026-01-12: 功能修改 - 优化create方法错误处理,正确转换重复创建错误为ConflictException (修改者: moyin)
|
||||||
* - 2026-01-12: 架构优化 - 移除业务逻辑,转移到zulip_core业务服务 (修改者: moyin)
|
* - 2026-01-12: 架构优化 - 移除业务逻辑,转移到zulip_core业务服务 (修改者: moyin)
|
||||||
* - 2026-01-12: 代码质量优化 - 清理重复导入,统一使用@Inject装饰器 (修改者: moyin)
|
* - 2026-01-12: 代码质量优化 - 清理重复导入,统一使用@Inject装饰器 (修改者: moyin)
|
||||||
* - 2026-01-12: 代码质量优化 - 完成所有性能监控代码优化,统一使用createPerformanceMonitor方法 (修改者: moyin)
|
|
||||||
* - 2026-01-12: 代码质量优化 - 修复所有遗漏的BigInt转换,使用列表响应构建工具方法 (修改者: moyin)
|
|
||||||
* - 2026-01-12: 代码质量优化 - 完善所有BigInt转换和数组映射的优化,彻底消除重复代码 (修改者: moyin)
|
|
||||||
* - 2026-01-12: 代码质量优化 - 使用基类工具方法,优化性能监控和BigInt转换,减少重复代码 (修改者: moyin)
|
|
||||||
* - 2026-01-12: 性能优化 - 集成AppLoggerService和缓存机制,添加性能监控
|
|
||||||
* - 2026-01-07: 代码规范优化 - 使用统一的常量文件,提高代码质量
|
|
||||||
* - 2026-01-07: 代码规范优化 - 修复导入路径,完善方法三级注释
|
|
||||||
* - 2026-01-07: 代码规范优化 - 完善文件头注释和方法三级注释
|
|
||||||
* - 2026-01-07: 功能修改 - 优化异常处理逻辑,规范Repository和Service职责边界
|
|
||||||
* - 2026-01-07: 性能优化 - 移除Service层的重复唯一性检查,依赖Repository事务
|
|
||||||
*
|
*
|
||||||
* @author angjustinl
|
* @author angjustinl
|
||||||
* @version 2.1.0
|
* @version 2.1.1
|
||||||
* @since 2025-01-07
|
* @since 2025-01-07
|
||||||
* @lastModified 2026-01-12
|
* @lastModified 2026-01-15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable, Inject, ConflictException, NotFoundException } from '@nestjs/common';
|
import { Injectable, Inject, ConflictException } from '@nestjs/common';
|
||||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||||
import { BaseZulipAccountsService } from './base_zulip_accounts.service';
|
import { BaseZulipAccountsService } from './base_zulip_accounts.service';
|
||||||
import { ZulipAccountsRepository } from './zulip_accounts.repository';
|
import { ZulipAccountsRepository } from './zulip_accounts.repository';
|
||||||
@@ -126,8 +117,10 @@ export class ZulipAccountsService extends BaseZulipAccountsService {
|
|||||||
errorMessage.includes('unique constraint')) {
|
errorMessage.includes('unique constraint')) {
|
||||||
const conflictError = new ConflictException(`游戏用户 ${createDto.gameUserId} 已存在Zulip账号关联`);
|
const conflictError = new ConflictException(`游戏用户 ${createDto.gameUserId} 已存在Zulip账号关联`);
|
||||||
monitor.error(conflictError);
|
monitor.error(conflictError);
|
||||||
|
throw conflictError;
|
||||||
} else {
|
} else {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -322,6 +315,7 @@ export class ZulipAccountsService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -363,6 +357,7 @@ export class ZulipAccountsService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -404,6 +399,7 @@ export class ZulipAccountsService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,6 +420,7 @@ export class ZulipAccountsService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -444,6 +441,7 @@ export class ZulipAccountsService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,26 +15,19 @@
|
|||||||
* 注意:业务逻辑已转移到 src/core/zulip_core/services/zulip_accounts_business.service.ts
|
* 注意:业务逻辑已转移到 src/core/zulip_core/services/zulip_accounts_business.service.ts
|
||||||
*
|
*
|
||||||
* 最近修改:
|
* 最近修改:
|
||||||
|
* - 2026-01-15: 代码规范优化 - 清理未使用的导入ConflictException和NotFoundException (修改者: moyin)
|
||||||
* - 2026-01-12: 架构优化 - 移除业务逻辑,转移到zulip_core业务服务 (修改者: moyin)
|
* - 2026-01-12: 架构优化 - 移除业务逻辑,转移到zulip_core业务服务 (修改者: moyin)
|
||||||
* - 2026-01-12: 代码质量优化 - 修复导入语句,添加缺失的AppLoggerService导入 (修改者: moyin)
|
* - 2026-01-12: 代码质量优化 - 修复导入语句,添加缺失的AppLoggerService导入 (修改者: moyin)
|
||||||
* - 2026-01-12: 代码质量优化 - 修复logger初始化问题,统一使用AppLoggerService (修改者: moyin)
|
* - 2026-01-12: 代码质量优化 - 修复logger初始化问题,统一使用AppLoggerService (修改者: moyin)
|
||||||
* - 2026-01-12: 代码质量优化 - 完成所有性能监控代码优化,统一使用createPerformanceMonitor方法 (修改者: moyin)
|
* - 2026-01-12: 代码质量优化 - 完成所有性能监控代码优化,统一使用createPerformanceMonitor方法 (修改者: moyin)
|
||||||
* - 2026-01-12: 代码质量优化 - 修复所有遗漏的BigInt转换,使用列表响应构建工具方法 (修改者: moyin)
|
|
||||||
* - 2026-01-12: 代码质量优化 - 完善所有BigInt转换和数组映射的优化,彻底消除重复代码 (修改者: moyin)
|
|
||||||
* - 2026-01-12: 代码质量优化 - 使用基类工具方法,优化性能监控和BigInt转换,减少重复代码 (修改者: moyin)
|
|
||||||
* - 2026-01-07: 代码规范优化 - 使用统一的常量文件,提高代码质量
|
|
||||||
* - 2026-01-07: 代码规范优化 - 修复导入路径,完善方法三级注释
|
|
||||||
* - 2026-01-07: 代码规范优化 - 完善文件头注释和方法三级注释
|
|
||||||
* - 2026-01-07: 功能完善 - 优化异常处理逻辑和日志记录
|
|
||||||
* - 2025-01-07: 架构优化 - 统一Service层的职责边界和接口设计
|
|
||||||
*
|
*
|
||||||
* @author angjustinl
|
* @author angjustinl
|
||||||
* @version 2.0.0
|
* @version 2.0.1
|
||||||
* @since 2025-01-07
|
* @since 2025-01-07
|
||||||
* @lastModified 2026-01-12
|
* @lastModified 2026-01-15
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Injectable, Inject, ConflictException, NotFoundException } from '@nestjs/common';
|
import { Injectable, Inject } from '@nestjs/common';
|
||||||
import { BaseZulipAccountsService } from './base_zulip_accounts.service';
|
import { BaseZulipAccountsService } from './base_zulip_accounts.service';
|
||||||
import { ZulipAccountsMemoryRepository } from './zulip_accounts_memory.repository';
|
import { ZulipAccountsMemoryRepository } from './zulip_accounts_memory.repository';
|
||||||
import { ZulipAccounts } from './zulip_accounts.entity';
|
import { ZulipAccounts } from './zulip_accounts.entity';
|
||||||
@@ -101,6 +94,7 @@ export class ZulipAccountsMemoryService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,6 +140,7 @@ export class ZulipAccountsMemoryService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -259,6 +254,7 @@ export class ZulipAccountsMemoryService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,6 +277,7 @@ export class ZulipAccountsMemoryService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -301,6 +298,7 @@ export class ZulipAccountsMemoryService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -321,6 +319,7 @@ export class ZulipAccountsMemoryService extends BaseZulipAccountsService {
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
monitor.error(error);
|
monitor.error(error);
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user