Project management related changes
This commit is contained in:
47
scratch/patch_project_controller.py
Normal file
47
scratch/patch_project_controller.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import re
|
||||
|
||||
with open('kifi-api/src/main/java/com/kifi/api/controller/ProjectController.java', 'r') as f:
|
||||
content = f.read()
|
||||
|
||||
# Add import
|
||||
content = content.replace(
|
||||
'import com.kifi.api.entity.project.ProjectTask;',
|
||||
'import com.kifi.api.entity.project.ProjectTask;\nimport com.kifi.api.entity.project.ProjectTaskComment;'
|
||||
)
|
||||
|
||||
# Add endpoints
|
||||
endpoints = """
|
||||
@GetMapping("/tasks/{taskId}/comments")
|
||||
public Flux<ProjectTaskComment> getComments(@PathVariable Long taskId) {
|
||||
return projectService.getCommentsForTask(taskId);
|
||||
}
|
||||
|
||||
@PostMapping("/tasks/{taskId}/comments")
|
||||
public Mono<ProjectTaskComment> addComment(
|
||||
@PathVariable Long taskId,
|
||||
@RequestBody CreateCommentRequest request,
|
||||
Authentication authentication) {
|
||||
Long userId = Long.valueOf(authentication.getDetails().toString());
|
||||
return projectService.addComment(taskId, userId, request.getContent(), request.getImagesJson());
|
||||
}
|
||||
|
||||
@Data
|
||||
static class CreateProjectRequest {
|
||||
"""
|
||||
|
||||
content = content.replace(' @Data\n static class CreateProjectRequest {', endpoints)
|
||||
|
||||
# Add request class
|
||||
request_class = """
|
||||
@Data
|
||||
static class CreateCommentRequest {
|
||||
private String content;
|
||||
private String imagesJson;
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
content = re.sub(r'}\s*$', request_class.strip() + '\n', content)
|
||||
|
||||
with open('kifi-api/src/main/java/com/kifi/api/controller/ProjectController.java', 'w') as f:
|
||||
f.write(content)
|
||||
Reference in New Issue
Block a user