Skip to content
Open
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
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@
- https://habr.com/ru/articles/259055/

Список выполненных задач:
...
2. Удалить социальные сети: vk, yandex.
3. Вынести чувствительную информацию в отдельный проперти файл
4. Переделать тесты так, чтоб во время тестов использовалась in memory БД (H2), а не PostgreSQL
5. Написать тесты для всех публичных методов контроллера ProfileRestController
6. Сделать рефакторинг метода com.javarush.jira.bugtracking.attachment.FileUtil#upload
7. Добавить новый функционал: добавления тегов к задаче (REST API + реализация на сервисе)
8. Добавить подсчет времени сколько задача находилась в работе и тестировании
7 changes: 3 additions & 4 deletions config/_application-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ app:
host-url: http://localhost
spring:
datasource:
url: jdbc:postgresql://localhost:5432/jira
username: jira
password: JiraRush

url: ${DATABASE_URL}
username: ${DATABASE_USERNAME}
password: ${DATABASE_PASSWORD}
5 changes: 5 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@
<artifactId>junit-platform-launcher</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
12 changes: 0 additions & 12 deletions resources/static/fontawesome/css/all.css
Original file line number Diff line number Diff line change
Expand Up @@ -8603,10 +8603,6 @@ readers do not read off random characters that represent icons */
content: "\f3e8";
}

.fa-vk:before {
content: "\f189";
}

.fa-untappd:before {
content: "\f405";
}
Expand Down Expand Up @@ -9955,10 +9951,6 @@ readers do not read off random characters that represent icons */
content: "\f3bc";
}

.fa-yandex:before {
content: "\f413";
}

.fa-readme:before {
content: "\f4d5";
}
Expand Down Expand Up @@ -10183,10 +10175,6 @@ readers do not read off random characters that represent icons */
content: "\f7c6";
}

.fa-yandex-international:before {
content: "\f414";
}

.fa-cc-amex:before {
content: "\f1f3";
}
Expand Down
8 changes: 0 additions & 8 deletions resources/view/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,6 @@ <h3 class="mb-3">Sign in</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
8 changes: 0 additions & 8 deletions resources/view/unauth/register.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,6 @@ <h3 class="mb-3">Registration</h3>
type="button">
<i class="fa-brands fa-google"></i>
</a>
<a class="btn btn-primary btn-lg me-2" href="/oauth2/authorization/vk" style="padding-left: 17px; padding-right: 17px;"
type="button">
<i class="fa-brands fa-vk"></i>
</a>
<a class="btn btn-danger btn-lg me-2" href="/oauth2/authorization/yandex" style="padding-left: 21px; padding-right: 21px;"
type="button">
<i class="fa-brands fa-yandex"></i>
</a>
<a class="btn btn-dark btn-lg me-2" href="/oauth2/authorization/github" type="button">
<i class="fa-brands fa-github"></i>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import org.springframework.core.io.UrlResource;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import java.net.MalformedURLException;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -25,14 +22,13 @@ public static void upload(MultipartFile multipartFile, String directoryPath, Str
throw new IllegalRequestDataException("Select a file to upload.");
}

File dir = new File(directoryPath);
if (dir.exists() || dir.mkdirs()) {
File file = new File(directoryPath + fileName);
try (OutputStream outStream = new FileOutputStream(file)) {
outStream.write(multipartFile.getBytes());
} catch (IOException ex) {
throw new IllegalRequestDataException("Failed to upload file" + multipartFile.getOriginalFilename());
}
Path dirPath = Paths.get(directoryPath);
try {
Files.createDirectories(dirPath);
Path filePath = dirPath.resolve(fileName);
Files.write(filePath, multipartFile.getBytes());
} catch (IOException e) {
throw new IllegalRequestDataException("Failed to upload file" + multipartFile.getOriginalFilename());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;
import java.util.List;

@Transactional(readOnly = true)
Expand All @@ -13,4 +14,10 @@ public interface ActivityRepository extends BaseRepository<Activity> {

@Query("SELECT a FROM Activity a JOIN FETCH a.author WHERE a.taskId =:taskId AND a.comment IS NOT NULL ORDER BY a.updated DESC")
List<Activity> findAllComments(long taskId);

@Query("SELECT a FROM Activity a JOIN FETCH a.author WHERE a.taskId =:taskId AND a.statusCode=:statusCode ORDER BY a.updated ASC")
List<Activity> findByTaskIdAndStatusCodeOrderByUpdatedAsc(long taskId, String statusCode);

@Query("SELECT a FROM Activity a JOIN FETCH a.author WHERE a.taskId =:taskId AND a.statusCode=:statusCode AND a.updated > :updatedAfter ORDER BY a.updated ASC")
List<Activity> findByTaskIdAndStatusCodeAndUpdatedAfterOrderByUpdatedAsc(long taskId, String statusCode, LocalDateTime updatedAfter);
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import jakarta.annotation.Nullable;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand All @@ -23,6 +24,7 @@
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import static com.javarush.jira.common.BaseHandler.createdResponse;

Expand Down Expand Up @@ -151,6 +153,50 @@ public void delete(@PathVariable long id) {
activityService.delete(id);
}

@GetMapping("/{id}/tags")
public Set<String> getTags(@PathVariable(name = "id") Long taskId) {
return taskService.getTaskTags(taskId);
}

@PostMapping("/{id}/tags")
@ResponseStatus(HttpStatus.CREATED)
public Set<String> addTag(
@PathVariable(name = "id") Long taskId,
@Valid @RequestParam String tag) {
return taskService.addTagToTask(taskId, tag);
}

@PostMapping("/{id}/tags/batch")
@ResponseStatus(HttpStatus.CREATED)
public Set<String> addTags(
@PathVariable(name = "id") Long taskId,
@Valid @RequestBody Set<@Size(min = 2, max = 32) String> tags) {
return taskService.addTagsToTask(taskId, tags);
}

@DeleteMapping("/{id}/tags")
public Set<String> deleteTag(
@PathVariable(name = "id") Long taskId,
@RequestParam String tag) {
return taskService.removeTagFromTask(taskId, tag);
}

@DeleteMapping("/{id}/tags/batch")
public Set<String> deleteTags(
@PathVariable(name = "id") Long taskId,
@RequestBody Set<@Size(min = 2, max = 32) String> tags) {
log.info("Remove tags {} from task {}", tags, taskId);
return taskService.removeTagsFromTask(taskId, tags);
}

@PutMapping("/{id}/tags/batch")
public Set<String> replaceTags(
@PathVariable(name = "id") Long taskId,
@Valid @RequestBody Set<@Size(min = 2, max = 32) String> tags) {
log.info("Replace tags for task {} with {}", taskId, tags);
return taskService.replaceTaskTags(taskId, tags);
}

private record TaskTreeNode(TaskTo taskTo, List<TaskTreeNode> subNodes) implements ITreeNode<TaskTo, TaskTreeNode> {
public TaskTreeNode(TaskTo taskTo) {
this(taskTo, new LinkedList<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import java.util.List;
import java.util.Optional;
import java.util.Set;

@Transactional(readOnly = true)
public interface TaskRepository extends BaseRepository<Task> {
Expand Down Expand Up @@ -37,4 +38,7 @@ WITH RECURSIVE task_with_subtasks AS (
WHERE id IN (SELECT child FROM task_with_subtasks)
""", nativeQuery = true)
void setTaskAndSubTasksSprint(long taskId, Long sprintId);

@Query("SELECT t.tags FROM Task t WHERE t.id =:id")
Set<String> getTaskTags(long id);
}
Loading