This commit is contained in:
2025-07-25 17:30:34 +09:00
parent a3f591ab3a
commit 3864eaa965
30 changed files with 241 additions and 63 deletions

View File

@@ -3,3 +3,10 @@ export declare class UserInfoResponseDto {
name: string;
email?: string;
}
export declare class ProfileResponseDto {
bio?: string;
avatarUrl?: string;
}
export declare class UserWithProfileResponseDto extends UserInfoResponseDto {
profile?: ProfileResponseDto;
}

View File

@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.UserInfoResponseDto = void 0;
exports.UserWithProfileResponseDto = exports.ProfileResponseDto = exports.UserInfoResponseDto = void 0;
const openapi = require("@nestjs/swagger");
const swagger_1 = require("@nestjs/swagger");
class UserInfoResponseDto {
@@ -33,4 +33,31 @@ __decorate([
(0, swagger_1.ApiProperty)({ description: '사용자 이메일', example: 'user@email.com' }),
__metadata("design:type", String)
], UserInfoResponseDto.prototype, "email", void 0);
class ProfileResponseDto {
bio;
avatarUrl;
static _OPENAPI_METADATA_FACTORY() {
return { bio: { required: false, type: () => String }, avatarUrl: { required: false, type: () => String } };
}
}
exports.ProfileResponseDto = ProfileResponseDto;
__decorate([
(0, swagger_1.ApiProperty)({ description: '프로필 내용', example: 'bio...' }),
__metadata("design:type", String)
], ProfileResponseDto.prototype, "bio", void 0);
__decorate([
(0, swagger_1.ApiProperty)({ description: '프로필 아바타 주소', example: 'http://...' }),
__metadata("design:type", String)
], ProfileResponseDto.prototype, "avatarUrl", void 0);
class UserWithProfileResponseDto extends UserInfoResponseDto {
profile;
static _OPENAPI_METADATA_FACTORY() {
return { profile: { required: false, type: () => require("./user-info-response.dto").ProfileResponseDto } };
}
}
exports.UserWithProfileResponseDto = UserWithProfileResponseDto;
__decorate([
(0, swagger_1.ApiProperty)({ description: '프로필', type: ProfileResponseDto }),
__metadata("design:type", ProfileResponseDto)
], UserWithProfileResponseDto.prototype, "profile", void 0);
//# sourceMappingURL=user-info-response.dto.js.map

View File

@@ -1 +1 @@
{"version":3,"file":"user-info-response.dto.js","sourceRoot":"","sources":["../../../src/users/dto/user-info-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAE9C,MAAa,mBAAmB;IAE9B,EAAE,CAAS;IAGX,IAAI,CAAS;IAGb,KAAK,CAAU;;;;CAChB;AATD,kDASC;AAPC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CACzC;AAGX;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;;iDAC/C;AAGb;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;;kDACpD"}
{"version":3,"file":"user-info-response.dto.js","sourceRoot":"","sources":["../../../src/users/dto/user-info-response.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA8C;AAE9C,MAAa,mBAAmB;IAE9B,EAAE,CAAS;IAGX,IAAI,CAAS;IAGb,KAAK,CAAU;;;;CAChB;AATD,kDASC;AAPC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;;+CACzC;AAGX;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;;iDAC/C;AAGb;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,gBAAgB,EAAE,CAAC;;kDACpD;AAGjB,MAAa,kBAAkB;IAE7B,GAAG,CAAU;IAGb,SAAS,CAAU;;;;CACpB;AAND,gDAMC;AAJC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;;+CAC7C;AAGb;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;;qDAC/C;AAGrB,MAAa,0BAA2B,SAAQ,mBAAmB;IAEjE,OAAO,CAAsB;;;;CAC9B;AAHD,gEAGC;AADC;IADC,IAAA,qBAAW,EAAC,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC;8BACpD,kBAAkB;2DAAC"}

View File

@@ -1,7 +1,9 @@
import { TimestampedEntity } from 'src/common/entities/timestamped.entity';
import { Profile } from 'src/profiles/profile.entity';
export declare class User extends TimestampedEntity {
id: number;
name: string;
email?: string;
password: string;
profile: Profile;
}

View File

@@ -12,14 +12,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.User = void 0;
const openapi = require("@nestjs/swagger");
const timestamped_entity_1 = require("../common/entities/timestamped.entity");
const profile_entity_1 = require("../profiles/profile.entity");
const typeorm_1 = require("typeorm");
let User = class User extends timestamped_entity_1.TimestampedEntity {
id;
name;
email;
password;
profile;
static _OPENAPI_METADATA_FACTORY() {
return { id: { required: true, type: () => Number }, name: { required: true, type: () => String }, email: { required: false, type: () => String }, password: { required: true, type: () => String } };
return { id: { required: true, type: () => Number }, name: { required: true, type: () => String }, email: { required: false, type: () => String }, password: { required: true, type: () => String }, profile: { required: true, type: () => require("../profiles/profile.entity").Profile } };
}
};
exports.User = User;
@@ -39,6 +41,11 @@ __decorate([
(0, typeorm_1.Column)(),
__metadata("design:type", String)
], User.prototype, "password", void 0);
__decorate([
(0, typeorm_1.OneToOne)(() => profile_entity_1.Profile, (profile) => profile.user, { cascade: true }),
(0, typeorm_1.JoinColumn)(),
__metadata("design:type", profile_entity_1.Profile)
], User.prototype, "profile", void 0);
exports.User = User = __decorate([
(0, typeorm_1.Entity)()
], User);

View File

@@ -1 +1 @@
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../src/users/user.entity.ts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CAAC;IACrE,IAAA,oBAAU,GAAE;8BACJ,wBAAO;qCAAC;eAfN,IAAI;IADhB,IAAA,gBAAM,GAAE;GACI,IAAI,CAgBhB"}

View File

@@ -2,7 +2,7 @@ import { User } from './user.entity';
import { Repository } from 'typeorm';
import { CreateUserDto } from './dto/create-user.dto';
import { ChangePasswordDto } from './dto/change-password.dto';
import { UserInfoResponseDto } from './dto/user-info-response.dto';
import { UserInfoResponseDto, UserWithProfileResponseDto } from './dto/user-info-response.dto';
export declare class UsersService {
private repo;
constructor(repo: Repository<User>);
@@ -12,4 +12,5 @@ export declare class UsersService {
create(dto: CreateUserDto): Promise<User>;
changePassword(userId: number, dto: ChangePasswordDto): Promise<void>;
findUserInfoByIdOrFail(id: number): Promise<UserInfoResponseDto>;
findUserWithProfileByIdOrFail(id: number): Promise<UserWithProfileResponseDto>;
}

View File

@@ -60,6 +60,20 @@ let UsersService = class UsersService {
email: user.email,
};
}
async findUserWithProfileByIdOrFail(id) {
const user = await this.repo.findOne({ where: { id }, relations: ['profile'] });
if (!user)
throw new common_1.NotFoundException('User not found');
return {
id: user.id,
name: user.name,
email: user.email,
profile: {
bio: user.profile?.bio,
avatarUrl: user.profile?.avatarUrl,
},
};
}
};
exports.UsersService = UsersService;
exports.UsersService = UsersService = __decorate([

View File

@@ -1 +1 @@
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAKwB;AACxB,6CAAmD;AACnD,+CAAqC;AACrC,qCAAqC;AAGrC,mCAAmC;AAI5B,IAAM,YAAY,GAAlB,MAAM,YAAY;IACqB;IAA5C,YAA4C,IAAsB;QAAtB,SAAI,GAAJ,IAAI,CAAkB;IAAG,CAAC;IAEtE,KAAK,CAAC,QAAQ,CAAC,EAAU;QACvB,OAAO,MAAM,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;I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