Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ci-cd 파이프라인 수정 #13

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/be-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ jobs: # 실행할 작업을 정의합니다.
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Remove any existing .env.production file
run: rm -f .env.production

- name: Create .env file from secrets
run: |
Expand Down
7 changes: 7 additions & 0 deletions src/memory/dto/edit-memory.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { IsNotEmpty, IsString } from 'class-validator';

export class EditMemoryDto {
@IsString()
@IsNotEmpty({ message: 'Description cannot be empty, null, or undefined.' })
description: string;
}
32 changes: 32 additions & 0 deletions src/memory/memory.controller.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import {
Body,
Controller,
Delete,
Get,
Param,
Put,
Res,
Response,
UseGuards,
UsePipes,
ValidationPipe,
} from '@nestjs/common';
import { MemoryService } from './memory.service';
import { JwtAuthGuard } from 'src/auth/guard/jwt-access.guard';
import { EditMemoryDto } from 'src/memory/dto/edit-memory.dto';

@Controller('memory')
export class MemoryController {
Expand All @@ -32,4 +38,30 @@ export class MemoryController {
memories: memories,
});
}

@Put('/:memoryId')
@UseGuards(JwtAuthGuard)
@UsePipes(new ValidationPipe())
async updateMemory(
@Param('memoryId') memoryId: string,
@Body() @Response() editMemoryDto: EditMemoryDto,
@Res() res,
) {
console.log('editMemoryDto', editMemoryDto);
const memory = await this.memoryService.updateMemory(
memoryId,
editMemoryDto,
);
if (memory) {
return res.json({
success: true,
description: memory.description,
id: memory.id,
});
} else {
return res.json({
success: false,
});
}
}
}
17 changes: 15 additions & 2 deletions src/memory/memory.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MemoryEntity } from 'src/memory/entities/memory.entity';
import { Repository } from 'typeorm';
import { UserProfileParams } from 'src/constants/function_calling';
import { UserProfileDetailEntity } from 'src/memory/entities/user-profile-detail.entity';
import { EditMemoryDto } from 'src/memory/dto/edit-memory.dto';

@Injectable()
export class MemoryService {
Expand Down Expand Up @@ -159,11 +160,23 @@ export class MemoryService {

// 변경된 MemoryEntity 저장
await this.userProfileDetailRepository.save(memory);
console.log('memory', memory);
const memories = await this.userProfileDetailRepository.find({
where: { memory: memory.memory },
});
console.log('memories', memories);
return memories.filter((value) => value.isShow);
}

async updateMemory(memoryId: string, editMemoryDto: EditMemoryDto) {
const memory = await this.userProfileDetailRepository.findOne({
where: { id: memoryId },
});

if (!memory) {
throw new Error('Memory not found');
}

memory.description = editMemoryDto.description;

return await this.userProfileDetailRepository.save(memory);
}
}
Loading