Skip to content

Commit

Permalink
Merge pull request #35 from SSUDevelog/feat/#33
Browse files Browse the repository at this point in the history
[Add] checkBlankAndSpecial
  • Loading branch information
kikuke authored Nov 7, 2023
2 parents e22c0a0 + fc72f0d commit 163205a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main/java/com/easyvel/server/tag/TagController.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public List<PostDto> getUserTagPostList(@RequestParam String search,
}

@ApiOperation(value = "현재 인기있는 태그 목록", notes = "vol 파라미터에 받을 태그 수량을 입력")
@EasyvelTokenApiImplicitParams
@GetMapping("/hot-tag")
public TagList getHotTagList(@RequestParam(defaultValue = "10") int vol) throws IOException {
return tagService.getHotTagList(vol);
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/easyvel/server/tag/TagService.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;

@Slf4j
@Service
Expand All @@ -43,13 +44,22 @@ public void addTag(String uid, String tagName) {
User user = getUserByUid(uid);
Tag tag = getElseMakeTag(tagName);

checkBlankAndSpecial(tagName);

if (containsTag(user, tag))
throw new IllegalArgumentException("이미 추가한 태그입니다.");

UserTag userTag = new UserTag(user, tag);
userTagRepository.save(userTag);
}

//Todo: 다른 곳에서도 필요할지도..? 이후 추가 적용하기
private void checkBlankAndSpecial(String tagName) {
String pattern = "^[0-9|a-z|A-Z|ㄱ-ㅎ|ㅏ-ㅣ|가-힣]*$";
if (!Pattern.matches(pattern, tagName))
throw new IllegalArgumentException("공백, 특수문자는 허용되지 않습니다.");
}

public void deleteTag(String uid, String tagName) {
User user = getUserByUid(uid);
Tag tag = getElseMakeTag(tagName);
Expand All @@ -69,6 +79,7 @@ public void deleteTag(String uid, String tagName) {
* @throws IOException
*/
public List<PostDto> getPostDtoListByTag(String uid, String tag) throws IOException {
//Todo: 없는 태그를 긁어오려할 경우 체크하는 로직 만들기
List<String> userSubscribeList = getSubscribeNameList(uid);
Elements postsElements = getTagPostsElements(tag);

Expand Down

0 comments on commit 163205a

Please sign in to comment.