견문보고 작업중.

- 보고일, 비고 컬럼 추가.
 - 해시태그 기능 추가.
강석 최 2022-09-23 16:34:16 +09:00
parent b3db6f0fce
commit f627a03d83
10 changed files with 90 additions and 7 deletions

View File

@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartHttpServletRequest; import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -159,6 +160,7 @@ public class AffairController { // 첩보수집활동 > 외사경찰 견문관
affairBoard.setWrtUserSeq(loginUser.getUserSeq()); affairBoard.setWrtUserSeq(loginUser.getUserSeq());
affairBoard.setWrtUserNm(loginUser.getUserNm()); affairBoard.setWrtUserNm(loginUser.getUserNm());
affairBoard.setWrtDt(LocalDateTime.now()); affairBoard.setWrtDt(LocalDateTime.now());
affairBoard.setReportDt(LocalDate.now());
} }
mav.addObject("affair", affairBoard); mav.addObject("affair", affairBoard);
return mav; return mav;

View File

@ -11,4 +11,6 @@ public interface AffairMapper {
List<AffairBoard> selectAffairBoardList(AffairBoard affair); List<AffairBoard> selectAffairBoardList(AffairBoard affair);
Integer selectAffairBoardCnt(AffairBoard affair); Integer selectAffairBoardCnt(AffairBoard affair);
String selectHashTags(Integer affairKey);
} }

View File

@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.persistence.*; import javax.persistence.*;
import java.time.LocalDate;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
@ -50,8 +51,15 @@ public class AffairBoard extends BaseModel {
private LocalDateTime wrtDt; private LocalDateTime wrtDt;
@Column(name = "wrt_user_seq") @Column(name = "wrt_user_seq")
private Integer wrtUserSeq; private Integer wrtUserSeq;
@Column(name = "etc")
private String etc;
@Column(name = "report_dt")
@DateTimeFormat(pattern = "yyyy-MM-dd")
private LocalDate reportDt;
@Transient
private String hashTags;
@Transient @Transient
private Integer fileCnt; private Integer fileCnt;
@Transient @Transient

View File

@ -5,4 +5,5 @@ import org.springframework.data.jpa.repository.JpaRepository;
public interface HashTagLinkRepository extends JpaRepository<HashTagLink, HashTagLink.HashTagLinkId> { public interface HashTagLinkRepository extends JpaRepository<HashTagLink, HashTagLink.HashTagLinkId> {
void deleteByAffairKey(Integer affairKey);
} }

View File

@ -3,7 +3,10 @@ package com.dbnt.faisp.fpiMgt.affair.repository;
import com.dbnt.faisp.fpiMgt.affair.model.HashTag; import com.dbnt.faisp.fpiMgt.affair.model.HashTag;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import java.util.Optional;
public interface HashTagRepository extends JpaRepository<HashTag, Integer> { public interface HashTagRepository extends JpaRepository<HashTag, Integer> {
Optional<HashTag> findByTagNm(String tagNm);
} }

View File

@ -3,9 +3,7 @@ package com.dbnt.faisp.fpiMgt.affair.service;
import com.dbnt.faisp.config.BaseService; import com.dbnt.faisp.config.BaseService;
import com.dbnt.faisp.fpiMgt.affair.mapper.AffairMapper; import com.dbnt.faisp.fpiMgt.affair.mapper.AffairMapper;
import com.dbnt.faisp.fpiMgt.affair.model.AffairBoard; import com.dbnt.faisp.fpiMgt.affair.model.*;
import com.dbnt.faisp.fpiMgt.affair.model.AffairFile;
import com.dbnt.faisp.fpiMgt.affair.model.AffairRating;
import com.dbnt.faisp.fpiMgt.affair.repository.*; import com.dbnt.faisp.fpiMgt.affair.repository.*;
import com.dbnt.faisp.fpiMgt.affairPlan.model.PlanApprv; import com.dbnt.faisp.fpiMgt.affairPlan.model.PlanApprv;
import com.dbnt.faisp.fpiMgt.affairPlan.model.PlanBoard; import com.dbnt.faisp.fpiMgt.affairPlan.model.PlanBoard;
@ -38,6 +36,7 @@ public class AffairService extends BaseService { // 견문보고
public AffairBoard selectAffairBoard(Integer affairKey){ public AffairBoard selectAffairBoard(Integer affairKey){
AffairBoard affair = affairBoardRepository.findById(affairKey).orElse(null); AffairBoard affair = affairBoardRepository.findById(affairKey).orElse(null);
if(affair != null){ if(affair != null){
affair.setHashTags(affairMapper.selectHashTags(affairKey));
affair.setFileList(affairFileRepository.findByAffairKey(affairKey)); affair.setFileList(affairFileRepository.findByAffairKey(affairKey));
affair.setRateList(affairRatingRepository.findByAffairKey(affairKey)); affair.setRateList(affairRatingRepository.findByAffairKey(affairKey));
} }
@ -46,6 +45,10 @@ public class AffairService extends BaseService { // 견문보고
@Transactional @Transactional
public Integer saveAffairBoard(AffairBoard affair, List<Integer> deleteFileSeq){ public Integer saveAffairBoard(AffairBoard affair, List<Integer> deleteFileSeq){
Integer affairKey = affairBoardRepository.save(affair).getAffairKey(); Integer affairKey = affairBoardRepository.save(affair).getAffairKey();
String[] hashTagAry = affair.getHashTags().split(" ");
if(hashTagAry.length>0){
saveHashTagLink(affairKey, hashTagAry);
}
if(deleteFileSeq != null && deleteFileSeq.size()>0){ if(deleteFileSeq != null && deleteFileSeq.size()>0){
deleteAffairFile(affairKey, deleteFileSeq); deleteAffairFile(affairKey, deleteFileSeq);
} }
@ -55,6 +58,24 @@ public class AffairService extends BaseService { // 견문보고
return affairKey; return affairKey;
} }
private void saveHashTagLink(Integer affairKey, String[] hashTagAry){
hashTagLinkRepository.deleteByAffairKey(affairKey);
for(String tagNm : hashTagAry){
HashTag savedTag = hashTagRepository.findByTagNm(tagNm).orElse(null);
Integer tagKey;
if(savedTag==null){
HashTag tag = new HashTag();
tag.setTagNm(tagNm);
tagKey = hashTagRepository.save(tag).getTagKey();
}else{
tagKey = savedTag.getTagKey();
}
HashTagLink hashTagLink = new HashTagLink();
hashTagLink.setAffairKey(affairKey);
hashTagLink.setTagKey(tagKey);
hashTagLinkRepository.save(hashTagLink);
}
}
private void deleteAffairFile(Integer affairKey, List<Integer> deleteFileSeq) { private void deleteAffairFile(Integer affairKey, List<Integer> deleteFileSeq) {
List<AffairFile> affairFileList = affairFileRepository.findByAffairKey(affairKey); List<AffairFile> affairFileList = affairFileRepository.findByAffairKey(affairKey);
for(AffairFile file: affairFileList){ for(AffairFile file: affairFileList){

View File

@ -62,4 +62,13 @@
from affair_board a from affair_board a
<include refid="selectAffairBoardWhere"></include> <include refid="selectAffairBoardWhere"></include>
</select> </select>
<select id="selectHashTags" resultType="string" parameterType="int">
select aa.hashTags
from (select a.affair_key,
array_to_string(array_agg(b.tag_nm), ' ') as hashTags
from hash_tag_link a
inner join hash_tag b on a.tag_key = b.tag_key
where a.affair_key = #{affairKey}
group by a.affair_key) aa
</select>
</mapper> </mapper>

View File

@ -60,9 +60,13 @@ function getAffairEditModal(affairKey){
success: function(html){ success: function(html){
$("#affairEditModalContent").empty().append(html) $("#affairEditModalContent").empty().append(html)
$("#affairEditModal").modal('show'); $("#affairEditModal").modal('show');
$("#reportDt").datepicker({
format: "yyyy-mm-dd",
language: "ko"
});
$("#content").summernote({ $("#content").summernote({
lang:'ko-KR', lang:'ko-KR',
height: 390, height: 300,
disableDragAndDrop: true, disableDragAndDrop: true,
toolbar: [ toolbar: [
['style', ['style']], ['style', ['style']],

View File

@ -22,6 +22,10 @@
<div class="col-sm-2"> <div class="col-sm-2">
<input type="text" class="form-control" id="wrtDt" name="wrtDt" th:value="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly> <input type="text" class="form-control" id="wrtDt" name="wrtDt" th:value="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly>
</div> </div>
<label for="reportDt" class="col-sm-1 col-form-label text-center">보고일자</label>
<div class="col-sm-2">
<input type="text" class="form-control" id="reportDt" name="reportDt" th:value="${#temporals.format(affair.reportDt, 'yyyy-MM-dd')}" readonly>
</div>
</div> </div>
<div class="mb-3 row"> <div class="mb-3 row">
<label for="affairType1" class="col-sm-1 col-form-label text-center">분야1</label> <label for="affairType1" class="col-sm-1 col-form-label text-center">분야1</label>
@ -67,10 +71,23 @@
<input type="text" class="form-control" id="title" name="title" th:value="${affair.title}"> <input type="text" class="form-control" id="title" name="title" th:value="${affair.title}">
</div> </div>
</div> </div>
<div class="mb-3 row">
<label for="hashTags" class="col-sm-1 col-form-label text-center">해시태그</label>
<div class="col-sm-11">
<input type="text" class="form-control" id="hashTags" name="hashTags" th:value="${affair.hashTags}"
placeholder="띄어쓰기로 각 태그를 구분합니다. 한 태그 내에서는 띄어쓰기 없이 입력해주세요. ex)태그1 태그2">
</div>
</div>
<div class="mb-3 row"> <div class="mb-3 row">
<label for="title" class="col-sm-1 col-form-label text-center">내용</label> <label for="title" class="col-sm-1 col-form-label text-center">내용</label>
<div class="col-sm-11"> <div class="col-sm-11">
<textarea id="content" name="content" th:value="${affair.content}"></textarea> <textarea id="content" name="content" th:utext="${affair.content}"></textarea>
</div>
</div>
<div class="mb-3 row">
<label for="etc" class="col-sm-1 col-form-label text-center">비고</label>
<div class="col-sm-11">
<input type="text" class="form-control" id="etc" name="etc" th:value="${affair.title}">
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">

View File

@ -19,6 +19,10 @@
<div class="col-sm-2"> <div class="col-sm-2">
<input type="text" class="form-control border-0" id="wrtDt" name="wrtDt" th:value="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly> <input type="text" class="form-control border-0" id="wrtDt" name="wrtDt" th:value="${#temporals.format(affair.wrtDt, 'yyyy-MM-dd HH:mm')}" readonly>
</div> </div>
<label for="reportDt" class="col-sm-1 col-form-label text-center">보고일자</label>
<div class="col-sm-2">
<input type="text" class="form-control border-0" id="reportDt" name="reportDt" th:value="${#temporals.format(affair.reportDt, 'yyyy-MM-dd')}" readonly>
</div>
<label for="affairStatus" class="col-sm-1 col-form-label text-center">상태</label> <label for="affairStatus" class="col-sm-1 col-form-label text-center">상태</label>
<div class="col-sm-2"> <div class="col-sm-2">
<th:block th:each="commonCode:${session.commonCode.get('DST')}"> <th:block th:each="commonCode:${session.commonCode.get('DST')}">
@ -63,19 +67,31 @@
<hr> <hr>
<div class="row"> <div class="row">
<div class="col-8"> <div class="col-8">
<div class="mb-3 row"> <div class="row">
<label for="title" class="col-sm-2 col-form-label text-center">제목</label> <label for="title" class="col-sm-2 col-form-label text-center">제목</label>
<div class="col-sm-10"> <div class="col-sm-10">
<input type="text" class="form-control border-0" id="title" name="title" th:value="${affair.title}" readonly> <input type="text" class="form-control border-0" id="title" name="title" th:value="${affair.title}" readonly>
</div> </div>
</div> </div>
<hr>
<div class="mb-3 row"> <div class="mb-3 row">
<label for="hashTags" class="col-sm-2 col-form-label text-center">해시태그</label>
<div class="col-sm-10">
<input type="text" class="form-control border-0" id="hashTags" name="hashTags" th:value="${affair.hashTags}" readonly>
</div>
</div>
<hr>
<div class="row">
<label for="contentDiv" class="col-sm-2 col-form-label text-center">내용</label> <label for="contentDiv" class="col-sm-2 col-form-label text-center">내용</label>
<div class="col-sm-10" id="contentDiv"> <div class="col-sm-10" id="contentDiv">
<div th:utext="${affair.content}"></div> <div th:utext="${affair.content}"></div>
</div> </div>
</div> </div>
<div class="mb-3 row">
<label for="etc" class="col-sm-2 col-form-label text-center">비고</label>
<div class="col-sm-10">
<input type="text" class="form-control border-0" id="etc" name="etc" th:value="${affair.etc}" readonly>
</div>
</div>
</div> </div>
<div class="col-4"> <div class="col-4">
<table class="table"> <table class="table">