Skip to content

Commit

Permalink
Merge pull request #92 from Triumers/feat/post
Browse files Browse the repository at this point in the history
  • Loading branch information
noctesilente authored Jun 12, 2024
2 parents a407828 + 7aa2989 commit 71c2f03
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,26 @@ public CmdPostAndTagsDTO registPost(CmdPostAndTagsDTO post) throws NotLoginExcep

public static String sanitizeHTML(String html) {

// 공백, 줄바꿈 대체
String spacePlaceholder = "___SPACE___";
String newlinePlaceholder = "___NEWLINE___";
String htmlWithPlaceholders = html
.replaceAll(" ", spacePlaceholder)
.replaceAll("\n", newlinePlaceholder)
.replaceAll("\r\n", newlinePlaceholder);

Whitelist whitelist = Whitelist.relaxed();
// 허용되지 않을 태그와 속성 추가
whitelist.removeTags("script", "style", "head", "header", "foot", "footer");
whitelist.removeAttributes( "style","onclick");
whitelist.removeAttributes("style", "onclick");

String cleanedHtmlWithPlaceholders = Jsoup.clean(htmlWithPlaceholders, whitelist);

String cleanedHtml = cleanedHtmlWithPlaceholders
.replaceAll(spacePlaceholder, " ")
.replaceAll(newlinePlaceholder, "\n");

String cleanedHTML = Jsoup.clean(html, whitelist);
return cleanedHTML;
return cleanedHtml;
}

public List<CmdTag> registTag(List<CmdTagDTO> tags, int postId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ public CmdTabServiceImpl(CmdJoinEmployeeRepository cmdJoinEmployeeRepository, Cm
@Override
@Transactional
public CmdJoinEmployeeDTO addEmployeeTab(CmdJoinEmployeeDTO employee) {
CmdJoinEmployee newEmployee = new CmdJoinEmployee(employee.getIsLeader(),employee.getEmployeeId(),
employee.getTabId());
cmdJoinEmployeeRepository.save(newEmployee);

CmdJoinEmployee newEmployee = cmdJoinEmployeeRepository.
findByEmployeeIdAndTabId(employee.getEmployeeId(), employee.getTabId());

if(newEmployee == null){
newEmployee = new CmdJoinEmployee(employee.getIsLeader(),employee.getEmployeeId(),
employee.getTabId());
cmdJoinEmployeeRepository.save(newEmployee);
}

CmdJoinEmployeeDTO joinEmployeeDTO = new CmdJoinEmployeeDTO(newEmployee.getId(), newEmployee.getIsLeader(), newEmployee.getEmployeeId(), newEmployee.getTabId());
return joinEmployeeDTO;
Expand All @@ -52,7 +58,8 @@ public CmdJoinEmployeeDTO deleteEmployeeTab(CmdJoinEmployeeDTO employee) {

cmdJoinEmployeeRepository.deleteById(deleteEmployee.getId());

CmdJoinEmployeeDTO deleteEmployeeDTO = new CmdJoinEmployeeDTO(deleteEmployee.getId(), deleteEmployee.getIsLeader(), deleteEmployee.getEmployeeId(), deleteEmployee.getTabId());
CmdJoinEmployeeDTO deleteEmployeeDTO = new CmdJoinEmployeeDTO(deleteEmployee.getId(), deleteEmployee.getIsLeader(),
deleteEmployee.getEmployeeId(), deleteEmployee.getTabId());
return deleteEmployeeDTO;
}

Expand All @@ -63,12 +70,16 @@ public CmdTabRelationDTO registTab(CmdTabRelationDTO tabRelation, int employeeId
CmdTabDTO topTab = registTopTab(tabRelation.getTopTab());
CmdTabDTO bottomTab = registBottomTab(tabRelation.getBottomTab());

CmdTabRelation newTab = new CmdTabRelation(tabRelation.getIsPublic(), bottomTab.getId(),
topTab.getId(), tabRelation.getTeamId());
cmdTabRelationRepository.save(newTab);
CmdTabRelation newTab = cmdTabRelationRepository.findByBottomTabIdAndTopTabIdAndTeamId(bottomTab.getId(), topTab.getId(), tabRelation.getTeamId());

CmdJoinEmployeeDTO joinEmployee = new CmdJoinEmployeeDTO(true, employeeId, newTab.getId());
addEmployeeTab(joinEmployee);
if(newTab == null){
newTab = new CmdTabRelation(tabRelation.getIsPublic(), bottomTab.getId(),
topTab.getId(), tabRelation.getTeamId());
cmdTabRelationRepository.save(newTab);

CmdJoinEmployeeDTO joinEmployee = new CmdJoinEmployeeDTO(true, employeeId, newTab.getId());
addEmployeeTab(joinEmployee);
}

CmdTabRelationDTO newTabRelation = new CmdTabRelationDTO(newTab.getId(), newTab.getIsPublic(),
bottomTab, topTab, newTab.getTeamId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@
public interface CmdTabRelationRepository extends JpaRepository<CmdTabRelation, Integer> {

CmdTabRelation findById(int id);

CmdTabRelation findByBottomTabIdAndTopTabIdAndTeamId(Integer bottomId, Integer topId, Integer teamId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
JOIN tbl_department AS dept ON team.DEPARTMENT_ID = dept.ID
JOIN tbl_center AS center ON dept.CENTER_ID = center.ID
WHERE emp.ID = #{employeeId}
OR (tabRel.TEAM_ID = (SELECT E.TEAM_ID FROM tbl_employee E WHERE E.ID = #{employeeId})
AND tabRel.TOP_TAB_ID = 2);
</select>

<select id="findGroupIdByEmployeeId" parameterType="int">
Expand Down

0 comments on commit 71c2f03

Please sign in to comment.