mirror of
http://git.mhez-qa.uplus.co.kr/hubez/hubez-admin.git
synced 2025-12-12 01:34:19 +09:00
공지사항 신규 개발
This commit is contained in:
177
src/main/java/kr/co/uplus/ez/api/homeMgt/HomeMgtController.java
Normal file
177
src/main/java/kr/co/uplus/ez/api/homeMgt/HomeMgtController.java
Normal file
@@ -0,0 +1,177 @@
|
||||
package kr.co.uplus.ez.api.homeMgt;
|
||||
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import io.swagger.annotations.ApiResponse;
|
||||
import io.swagger.annotations.ApiResponses;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ContentDisposition;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import kr.co.uplus.ez.api.homeMgt.dto.*;
|
||||
import kr.co.uplus.ez.common.components.ValidComponents;
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.utils.FileIoUtils;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(value ="api/v1/bo/homeMgt")
|
||||
public class HomeMgtController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomeMgtController.class);
|
||||
|
||||
@Autowired
|
||||
HomeMgtService homeService;
|
||||
|
||||
@Autowired
|
||||
ValidComponents validComponents;
|
||||
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 18.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 조회.
|
||||
* @param noticeListReqDto
|
||||
* @return NoticeListResDto
|
||||
*/
|
||||
@ApiOperation(value = "noticeList", notes = "공지사항 조회")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "noticeList", method = {RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public NoticeListResDto noticeList(@RequestBody @Valid NoticeListReqDto noticeListReqDto, BindingResult bindingResult, HttpServletResponse response) {
|
||||
|
||||
if (validComponents.validParameter(bindingResult)) {
|
||||
return new NoticeListResDto(ApiResponseCode.CM_PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
return homeService.noticeList(noticeListReqDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 21.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 등록.
|
||||
* @param insertNoticeReqDto
|
||||
* @return InsertNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "insertNotice", notes = "공지사항 등록")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "insertNotice", method = {RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public InsertNoticeResDto insertNotice(@RequestPart(value = "key") InsertNoticeReqDto insertNoticeReqDto,
|
||||
MultipartHttpServletRequest multipartRequest) {
|
||||
|
||||
return homeService.insertNotice(insertNoticeReqDto ,multipartRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 24.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 수정.
|
||||
* @param updateNoticeReqDto
|
||||
* @return UpdateNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "updateNotice", notes = "공지사항 수정")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "updateNotice", method = {RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public UpdateNoticeResDto updateNotice(@RequestPart(value = "key") UpdateNoticeReqDto updateNoticeReqDto,
|
||||
MultipartHttpServletRequest multipartRequest) {
|
||||
|
||||
return homeService.updateNotice(updateNoticeReqDto, multipartRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 24.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 editor 이미지 업로드 후 링크 리턴.
|
||||
* @param updateNoticeReqDto
|
||||
* @return UpdateNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "getImageUrl", notes = "공지사항 editor 이미지 업로드 후 링크 리턴")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "getImageUrl", method = {RequestMethod.POST})
|
||||
@ResponseBody
|
||||
public FileResDto fileResDto(MultipartHttpServletRequest multipartRequest) {
|
||||
|
||||
return homeService.fileResDto(multipartRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
* 파일 다운로드
|
||||
* @throws IOException
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@RequestMapping("filedownload")
|
||||
public void filedownload(@RequestBody LinkedHashMap param, HttpServletRequest request, HttpServletResponse response) throws IOException {
|
||||
logger.debug(param.toString());
|
||||
|
||||
File file = new File(param.get("filePath") + File.separator + param.get("fileNm"));
|
||||
System.out.println("file ::::: " +file);
|
||||
System.out.println("file.exists() ::::: " + file.exists());
|
||||
if (file.exists()) {
|
||||
FileIoUtils.fileDownload(file, request, response );
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "이미지 미리보기", notes = "이미지 미리보기")
|
||||
@GetMapping(value = "/preview/{imgurl}", produces=MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
public ResponseEntity<byte[]> previewImageResource(@PathVariable @ApiParam(value = "이미지 경로") String imgurl) {
|
||||
System.out.println("imgurl :::: " + imgurl);
|
||||
System.out.println("call previewImageResource");
|
||||
try {
|
||||
String imgurldec = URLDecoder.decode(imgurl);
|
||||
|
||||
String imgurlreplace = imgurldec.replaceAll("\\|", "/");
|
||||
logger.debug("preview image imgurl={} imgurldecode={} imgurlreplace={}", imgurl, imgurldec, imgurlreplace);
|
||||
|
||||
Path path = Paths.get(imgurlreplace);
|
||||
String contentType = Files.probeContentType(path);
|
||||
|
||||
String fileNameOnly = imgurlreplace;
|
||||
String[] fileNameArr = imgurlreplace.split("/");
|
||||
if(fileNameArr != null && fileNameArr.length != 0) fileNameOnly = fileNameArr[fileNameArr.length-1];
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.setContentDisposition(
|
||||
ContentDisposition.builder("attachment")
|
||||
.filename(fileNameOnly, StandardCharsets.UTF_8)
|
||||
.build());
|
||||
headers.add(HttpHeaders.CONTENT_TYPE, contentType);
|
||||
|
||||
byte[] b = Files.readAllBytes(path);
|
||||
|
||||
return new ResponseEntity<byte[]>(b, headers, HttpStatus.OK);
|
||||
}catch(Exception e) {
|
||||
logger.error("imgurl err, e={}, e", e.getMessage());
|
||||
return new ResponseEntity<byte[]>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/main/java/kr/co/uplus/ez/api/homeMgt/HomeMgtMapper.java
Normal file
29
src/main/java/kr/co/uplus/ez/api/homeMgt/HomeMgtMapper.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package kr.co.uplus.ez.api.homeMgt;
|
||||
|
||||
import kr.co.uplus.ez.api.homeMgt.dto.*;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface HomeMgtMapper {
|
||||
|
||||
int selectNoticeTotalCnt(NoticeListReqDto noticeListReqDto);
|
||||
|
||||
List<NoticeDto> selectNoticeList(NoticeListReqDto noticeListReqDto);
|
||||
|
||||
int selectNoticeNumber(NoticeListReqDto noticeListReqDto);
|
||||
|
||||
void insertNotice(InsertNoticeReqDto insertNoticeReqDto);
|
||||
|
||||
int insertNoticeNtNo();
|
||||
|
||||
int updateNotice(UpdateNoticeReqDto updateNoticeReqDto);
|
||||
|
||||
int updateNoticeFileMaxNum(UpdateNoticeReqDto updateNoticeReqDto);
|
||||
|
||||
void insertNoticeFile(InsertNoticeFileDto insertNoticeFileDto);
|
||||
|
||||
void delNoticeFile(DelNoticeReqDto delNoticeReqDto);
|
||||
|
||||
}
|
||||
286
src/main/java/kr/co/uplus/ez/api/homeMgt/HomeMgtService.java
Normal file
286
src/main/java/kr/co/uplus/ez/api/homeMgt/HomeMgtService.java
Normal file
@@ -0,0 +1,286 @@
|
||||
package kr.co.uplus.ez.api.homeMgt;
|
||||
|
||||
import kr.co.uplus.ez.api.homeMgt.dto.*;
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.data.Paging;
|
||||
import kr.co.uplus.ez.common.utils.DateUtils;
|
||||
import kr.co.uplus.ez.common.utils.FileIoUtils;
|
||||
import kr.co.uplus.ez.common.utils.FileUtil;
|
||||
|
||||
//import kr.co.uplus.ez.common.utils.EncryptionUtil;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
import org.mybatis.spring.SqlSessionTemplate;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
//import java.util.HashMap;
|
||||
import java.util.List;
|
||||
//import java.util.Map;
|
||||
|
||||
@Service
|
||||
public class HomeMgtService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(HomeMgtService.class);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("sqlSessionTemplateDb1")
|
||||
private SqlSessionTemplate sqlSessionMaster;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("sqlSessionTemplateDb2")
|
||||
private SqlSessionTemplate sqlSessionSlave;
|
||||
|
||||
@Value("${file-resource.info.notice.path:/efs/admin/notice/}")
|
||||
private String noticeFilePath;
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 18.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 목록 조회
|
||||
* @param noticeListReqDto
|
||||
* @return NoticeListResDto
|
||||
*/
|
||||
public NoticeListResDto noticeList(NoticeListReqDto noticeListReqDto) {
|
||||
|
||||
HomeMgtMapper homeMgtMapper = sqlSessionSlave.getMapper(HomeMgtMapper.class);
|
||||
|
||||
String nowPage = String.valueOf(noticeListReqDto.getPage());
|
||||
int totalCnt = homeMgtMapper.selectNoticeTotalCnt(noticeListReqDto);
|
||||
|
||||
|
||||
if(totalCnt == 0) {
|
||||
Paging paging = new Paging();
|
||||
paging.setPage(nowPage);
|
||||
paging.setTotalCnt(String.valueOf(totalCnt));
|
||||
NoticeListRes NoticeListRes = new NoticeListRes();
|
||||
NoticeListRes.setList(new ArrayList<>());
|
||||
NoticeListRes.setPaging(paging);
|
||||
return new NoticeListResDto(ApiResponseCode.CM_NOT_FOUND, NoticeListRes);
|
||||
}
|
||||
|
||||
int page = noticeListReqDto.getPage();
|
||||
int pagePerRows = noticeListReqDto.getPagePerRows();
|
||||
page = (page -1) * pagePerRows;
|
||||
noticeListReqDto.setPage(page);
|
||||
|
||||
List<NoticeDto> noticeDto = homeMgtMapper.selectNoticeList(noticeListReqDto);
|
||||
|
||||
Paging paging = new Paging();
|
||||
paging.setPage(nowPage);
|
||||
paging.setTotalCnt(String.valueOf(totalCnt));
|
||||
|
||||
NoticeListRes NoticeListRes = new NoticeListRes();
|
||||
NoticeListRes.setList(noticeDto);
|
||||
NoticeListRes.setPaging(paging);
|
||||
|
||||
return new NoticeListResDto(ApiResponseCode.SUCCESS, NoticeListRes);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 21.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 목록 등록
|
||||
* @param insertNoticeReqDto
|
||||
* @return InsertNoticeResDto
|
||||
*/
|
||||
public InsertNoticeResDto insertNotice(InsertNoticeReqDto insertNoticeReqDto, MultipartHttpServletRequest multipartRequest) {
|
||||
|
||||
HomeMgtMapper homeMgtMapper = sqlSessionSlave.getMapper(HomeMgtMapper.class);
|
||||
|
||||
List<MultipartFile> files = multipartRequest.getFiles("files");
|
||||
String yyyyMMddHHmmss = DateUtils.date2strYMDHMS();
|
||||
int NT_NO = 0;
|
||||
|
||||
//공지사항 등록
|
||||
try {
|
||||
homeMgtMapper.insertNotice(insertNoticeReqDto);
|
||||
NT_NO = homeMgtMapper.insertNoticeNtNo();
|
||||
}catch(Exception e){
|
||||
return new InsertNoticeResDto(ApiResponseCode.CM_DB_QUERY_ERR);
|
||||
}
|
||||
|
||||
//공지사항 등록 완료시 파일 저장
|
||||
int idx = 1;
|
||||
String yyyyMMdd = DateUtils.date2strYMD();
|
||||
// Path : efs/admin/notice/yyyy/mm/
|
||||
String path = noticeFilePath + yyyyMMdd.substring(0, 4) +
|
||||
File.separator + yyyyMMdd.substring(4, 6) +
|
||||
File.separator + yyyyMMdd.substring(6, 8);
|
||||
File dir = new File(path);
|
||||
if(!dir.isDirectory()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
try {
|
||||
for(int i=0; i<files.size(); i++){
|
||||
|
||||
// NOTICE FILE UPLOAD.
|
||||
String ext = FileIoUtils.getExtension(files.get(i).getOriginalFilename());
|
||||
// File Nm : [reg_req_no]_[doc_no]_[doc_tp_cd].확장자
|
||||
String fileNm = yyyyMMddHHmmss + "_noticeFile_" + idx +"." + ext;
|
||||
String titleNm = files.get(i).getOriginalFilename();
|
||||
long fileSize = files.get(i).getSize();
|
||||
|
||||
|
||||
// File Upload.
|
||||
FileUtil.upload(files.get(i), fileNm, path);
|
||||
|
||||
InsertNoticeFileDto insertNoticeFileDto = new InsertNoticeFileDto();
|
||||
insertNoticeFileDto.setBbsDivCd("02"); // 게시판 구분 코드 (01:일대일문의,02:공지사항,03:FAQ)
|
||||
insertNoticeFileDto.setBbsNo(NT_NO);
|
||||
insertNoticeFileDto.setFileNo(idx);
|
||||
insertNoticeFileDto.setFileTitle(titleNm);
|
||||
insertNoticeFileDto.setFileNm(fileNm);
|
||||
insertNoticeFileDto.setFileSize(fileSize);
|
||||
insertNoticeFileDto.setFilePath(path.replace("C:/Users/admin/git/hubez-admin/frontend/public", ""));
|
||||
insertNoticeFileDto.setRegId(insertNoticeReqDto.getRegId());
|
||||
insertNoticeFileDto.setChgId(insertNoticeReqDto.getRegId());
|
||||
|
||||
System.out.println("insertNoticeFileDto.getFilePath() :::: " + insertNoticeFileDto.getFilePath());
|
||||
|
||||
homeMgtMapper.insertNoticeFile(insertNoticeFileDto);
|
||||
idx++;
|
||||
}
|
||||
|
||||
}catch(Exception e) {
|
||||
return new InsertNoticeResDto(ApiResponseCode.CM_DB_QUERY_ERR);
|
||||
}
|
||||
|
||||
|
||||
return new InsertNoticeResDto(ApiResponseCode.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 24.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 목록 수정
|
||||
* @param updateNoticeReqDto
|
||||
* @return UpdateNoticeResDto
|
||||
*/
|
||||
public UpdateNoticeResDto updateNotice(UpdateNoticeReqDto updateNoticeReqDto, MultipartHttpServletRequest multipartRequest) {
|
||||
HomeMgtMapper homeMgtMapper = sqlSessionMaster.getMapper(HomeMgtMapper.class);
|
||||
|
||||
List<MultipartFile> files = multipartRequest.getFiles("files");
|
||||
String yyyyMMddHHmmss = DateUtils.date2strYMDHMS();
|
||||
|
||||
System.out.println(" files len :::: " + files.size());
|
||||
System.out.println(" legacyFiles :::: " + updateNoticeReqDto.getLegacyFiles());
|
||||
|
||||
// 공지사항 수정
|
||||
try {
|
||||
homeMgtMapper.updateNotice(updateNoticeReqDto);
|
||||
} catch (Exception e) {
|
||||
return new UpdateNoticeResDto(ApiResponseCode.CM_DB_QUERY_ERR);
|
||||
}
|
||||
|
||||
// 공지사항 수정 완료시 파일 저장
|
||||
int idx = homeMgtMapper.updateNoticeFileMaxNum(updateNoticeReqDto); // 해당 게시물의 최상위 파일 번호 + 1을 가져온다.
|
||||
String yyyyMMdd = DateUtils.date2strYMD(); // Path : efs/admin/notice/yyyy/mm/
|
||||
String path = noticeFilePath + yyyyMMdd.substring(0, 4) +
|
||||
File.separator + yyyyMMdd.substring(4, 6) +
|
||||
File.separator + yyyyMMdd.substring(6, 8);
|
||||
File dir = new File(path);
|
||||
if(!dir.isDirectory()) dir.mkdirs(); // dir 생성
|
||||
|
||||
try {
|
||||
for(int i=0; i<files.size(); i++){
|
||||
|
||||
// NOTICE FILE UPLOAD.
|
||||
String ext = FileIoUtils.getExtension(files.get(i).getOriginalFilename());
|
||||
// File Nm : [reg_req_no]_[doc_no]_[doc_tp_cd].확장자
|
||||
String fileNm = yyyyMMddHHmmss + "_noticeFile_" + idx +"." + ext;
|
||||
String titleNm = files.get(i).getOriginalFilename();
|
||||
long fileSize = files.get(i).getSize();
|
||||
|
||||
|
||||
// File Upload.
|
||||
FileUtil.upload(files.get(i), fileNm, path);
|
||||
|
||||
InsertNoticeFileDto insertNoticeFileDto = new InsertNoticeFileDto();
|
||||
insertNoticeFileDto.setBbsDivCd("02"); // 게시판 구분 코드 (01:일대일문의,02:공지사항,03:FAQ)
|
||||
insertNoticeFileDto.setBbsNo(updateNoticeReqDto.getNtNo());
|
||||
insertNoticeFileDto.setFileNo(idx);
|
||||
insertNoticeFileDto.setFileTitle(titleNm);
|
||||
insertNoticeFileDto.setFileNm(fileNm);
|
||||
insertNoticeFileDto.setFileSize(fileSize);
|
||||
insertNoticeFileDto.setFilePath(path.replace("C:/Users/admin/git/hubez-admin/frontend/public", ""));
|
||||
insertNoticeFileDto.setRegId(updateNoticeReqDto.getChgId());
|
||||
insertNoticeFileDto.setChgId(updateNoticeReqDto.getChgId());
|
||||
|
||||
homeMgtMapper.insertNoticeFile(insertNoticeFileDto);
|
||||
idx++;
|
||||
}
|
||||
|
||||
}catch(Exception e) {
|
||||
return new UpdateNoticeResDto(ApiResponseCode.CM_DB_QUERY_ERR);
|
||||
}
|
||||
|
||||
// 첨부파일 삭제
|
||||
|
||||
if(!updateNoticeReqDto.getDelFileNo().isEmpty()) {
|
||||
String[] delFile = updateNoticeReqDto.getDelFileNo().split(",");
|
||||
for(int j=0; j<delFile.length; j++){
|
||||
System.out.println("delFile :::: " + delFile[j]);
|
||||
DelNoticeReqDto delNoticeReqDto = new DelNoticeReqDto();
|
||||
delNoticeReqDto.setFileNo(Integer.parseInt(delFile[j]));
|
||||
delNoticeReqDto.setNtNo(updateNoticeReqDto.getNtNo());
|
||||
System.out.println(delNoticeReqDto);
|
||||
homeMgtMapper.delNoticeFile(delNoticeReqDto);
|
||||
}
|
||||
}else {
|
||||
System.out.println("파일이 빈 상태입니다.");
|
||||
}
|
||||
|
||||
return new UpdateNoticeResDto(ApiResponseCode.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 21.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 editor 이미지 등록시 URL 리턴
|
||||
* @param insertNoticeFileDto
|
||||
* @return FileResDto
|
||||
*/
|
||||
public FileResDto fileResDto(MultipartHttpServletRequest multipartRequest) {
|
||||
|
||||
HomeMgtMapper homeMgtMapper = sqlSessionSlave.getMapper(HomeMgtMapper.class);
|
||||
|
||||
List<MultipartFile> files = multipartRequest.getFiles("files");
|
||||
System.out.println(" files len :::: " + files.size());
|
||||
String yyyyMMddHHmmss = DateUtils.date2strYMDHMS();
|
||||
|
||||
String yyyyMMdd = DateUtils.date2strYMD(); // Path : efs/admin/notice/yyyy/mm/
|
||||
String path = noticeFilePath + yyyyMMdd.substring(0, 4) +
|
||||
File.separator + yyyyMMdd.substring(4, 6) +
|
||||
File.separator + yyyyMMdd.substring(6, 8);
|
||||
File dir = new File(path);
|
||||
String uploadFile = "";
|
||||
if(!dir.isDirectory()) dir.mkdirs(); // dir 생성
|
||||
|
||||
try {
|
||||
for(int i=0; i<files.size(); i++){
|
||||
|
||||
String ext = FileIoUtils.getExtension(files.get(i).getOriginalFilename());
|
||||
String fileNm = yyyyMMddHHmmss + "_noticeEditFile." + ext;
|
||||
// File Upload.
|
||||
FileUtil.upload(files.get(i), fileNm, path);
|
||||
path = path.replace("C:/Users/admin/git/hubez-admin/frontend/public", "");
|
||||
uploadFile = path.replace("\\","/") + File.separator + fileNm;
|
||||
}
|
||||
|
||||
}catch(Exception e) {
|
||||
return new FileResDto(ApiResponseCode.CM_DB_QUERY_ERR);
|
||||
}
|
||||
|
||||
return new FileResDto(ApiResponseCode.SUCCESS, uploadFile);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class DelNoticeReqDto implements Serializable{
|
||||
|
||||
@ApiModelProperty(example = "공지사항 번호", name = "공지사항 번호", dataType = "Int")
|
||||
private int ntNo;
|
||||
|
||||
@ApiModelProperty(example = "파일 번호", name = "파일 번호", dataType = "Int")
|
||||
private int fileNo;
|
||||
|
||||
}
|
||||
31
src/main/java/kr/co/uplus/ez/api/homeMgt/dto/FileResDto.java
Normal file
31
src/main/java/kr/co/uplus/ez/api/homeMgt/dto/FileResDto.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.data.ResponseMessage;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class FileResDto extends ResponseMessage implements Serializable {
|
||||
// 데이터.
|
||||
private Object data;
|
||||
|
||||
public FileResDto() {
|
||||
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
|
||||
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
|
||||
}
|
||||
|
||||
public FileResDto(ApiResponseCode returnStr) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
}
|
||||
|
||||
public FileResDto(ApiResponseCode returnStr, Object data) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class InsertNoticeFileDto implements Serializable {
|
||||
|
||||
@ApiModelProperty(example = "게시판 구분코드", name = "게시판 구분코드", dataType = "String")
|
||||
private String bbsDivCd;
|
||||
|
||||
@ApiModelProperty(example = "게시판 식별번호", name = "게시판 식별번호", dataType = "Int")
|
||||
private int bbsNo;
|
||||
|
||||
@ApiModelProperty(example = "파일 번호", name = "파일 번호", dataType = "Int")
|
||||
private int fileNo;
|
||||
|
||||
@ApiModelProperty(example = "파일 제목", name = "파일 제목", dataType = "String")
|
||||
private String fileTitle;
|
||||
|
||||
@ApiModelProperty(example = "파일 명", name = "파일 명", dataType = "String")
|
||||
private String fileNm;
|
||||
|
||||
@ApiModelProperty(example = "파일 명", name = "파일 명", dataType = "Long")
|
||||
private Long fileSize;
|
||||
|
||||
@ApiModelProperty(example = "파일 경로", name = "파일 경로", dataType = "String")
|
||||
private String filePath;
|
||||
|
||||
@ApiModelProperty(example = "등록 ID", name = "등록 ID", dataType = "String")
|
||||
private String regId;
|
||||
|
||||
@ApiModelProperty(example = "수정 ID", name = "수정 ID", dataType = "String")
|
||||
private String chgId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class InsertNoticeReqDto implements Serializable {
|
||||
|
||||
@ApiModelProperty(example = "분류 코드", name = "분류 코드", dataType = "String")
|
||||
private String ctgCd;
|
||||
|
||||
@ApiModelProperty(example = "긴급 여부", name = "긴급 여부", dataType = "String")
|
||||
private String emgYn;
|
||||
|
||||
@ApiModelProperty(example = "제목", name = "제목", dataType = "String")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(example = "공지 내용", name = "공지 내용", dataType = "String")
|
||||
private String ntSbst;
|
||||
|
||||
@ApiModelProperty(example = "등록자", name = "등록자", dataType = "String")
|
||||
private String regr;
|
||||
|
||||
@ApiModelProperty(example = "사용 여부", name = "사용 여부", dataType = "String")
|
||||
private String useYn;
|
||||
|
||||
@ApiModelProperty(example = "등록 ID", name = "등록 ID", dataType = "String")
|
||||
private String regId;
|
||||
|
||||
@ApiModelProperty(example = "변경 ID", name = "변경 ID", dataType = "String")
|
||||
private String chgId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.data.ResponseMessage;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class InsertNoticeResDto extends ResponseMessage implements Serializable{
|
||||
|
||||
// 데이터.
|
||||
private Object data;
|
||||
|
||||
public InsertNoticeResDto() {
|
||||
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
|
||||
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
|
||||
}
|
||||
|
||||
public InsertNoticeResDto(ApiResponseCode returnStr) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
}
|
||||
|
||||
public InsertNoticeResDto(ApiResponseCode returnStr, Object data) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
82
src/main/java/kr/co/uplus/ez/api/homeMgt/dto/NoticeDto.java
Normal file
82
src/main/java/kr/co/uplus/ez/api/homeMgt/dto/NoticeDto.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class NoticeDto implements Serializable {
|
||||
|
||||
@ApiModelProperty(example = "리스트 번호", name = "리스트 번호", dataType = "Integer")
|
||||
private Integer no;
|
||||
|
||||
@ApiModelProperty(example = "공지 번호", name = "공지 번호", dataType = "int")
|
||||
private int ntNo;
|
||||
|
||||
@ApiModelProperty(example = "분류코드", name = "분류코드", dataType = "String")
|
||||
private String ctgCd;
|
||||
|
||||
@ApiModelProperty(example = "분류코드명", name = "분류코드명", dataType = "String")
|
||||
private String ctgCdNm;
|
||||
|
||||
@ApiModelProperty(example = "긴급여부(Y/N)", name = "긴급여부(Y/N)", dataType = "String")
|
||||
private String emgYn;
|
||||
|
||||
@ApiModelProperty(example = "제목", name = "제목", dataType = "String")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(example = "공지 내용", name = "공지 내용", dataType = "String")
|
||||
private String ntSbst;
|
||||
|
||||
@ApiModelProperty(example = "등록자", name = "등록자", dataType = "String")
|
||||
private String regr;
|
||||
|
||||
@ApiModelProperty(example = "사용 여부", name = "사용 여부", dataType = "String")
|
||||
private String useYn;
|
||||
|
||||
@ApiModelProperty(example = "조회수", name = "조회수", dataType = "Int")
|
||||
private String retvCnt;
|
||||
|
||||
@ApiModelProperty(example = "등록 ID", name = "등록 ID", dataType = "String")
|
||||
private String regId;
|
||||
|
||||
@ApiModelProperty(example = "등록 일시", name = "등록 일시", dataType = "String")
|
||||
private String regDt;
|
||||
|
||||
@ApiModelProperty(example = "변경 ID", name = "변경 ID", dataType = "String")
|
||||
private String chgId;
|
||||
|
||||
@ApiModelProperty(example = "변경 일시", name = "변경 일시", dataType = "String")
|
||||
private String chgDt;
|
||||
|
||||
@ApiModelProperty(example = "파일 제목", name = "파일 제목", dataType = "String")
|
||||
private String fileTitle;
|
||||
|
||||
@ApiModelProperty(example = "파일 이름", name = "파일 이름", dataType = "String")
|
||||
private String fileNm;
|
||||
|
||||
@ApiModelProperty(example = "파일 경로", name = "파일 경로", dataType = "String")
|
||||
private String filePath;
|
||||
|
||||
@ApiModelProperty(example = "파일 개수", name = "파일 개수", dataType = "String")
|
||||
private String fileCount;
|
||||
|
||||
@ApiModelProperty(example = "파일 유무", name = "파일 유무", dataType = "String")
|
||||
private String fileYn;
|
||||
|
||||
@ApiModelProperty(example = "파일 번호", name = "파일 번호", dataType = "String")
|
||||
private String fileNo;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "페이지당 조회할 목록 수",notes = "페이지당 조회할 목록 수", name = "페이지당 조회할 목록 수", dataType = "int")
|
||||
private int pagePerRows;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "현재 페이지", name = "현재 페이지", dataType = "int")
|
||||
private int page;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class NoticeListReqDto implements Serializable {
|
||||
|
||||
@ApiModelProperty(example = "분류 코드", name = "분류 코드", dataType = "String")
|
||||
private String searchType1;
|
||||
|
||||
@ApiModelProperty(example = "제목 검색어", name = "제목 검색어", dataType = "String")
|
||||
private String searchText1;
|
||||
|
||||
@ApiModelProperty(example = "분류코드", name = "분류코드", dataType = "String")
|
||||
private String ctgCd;
|
||||
|
||||
@ApiModelProperty(example = "긴급여부(Y/N)", name = "긴급여부(Y/N)", dataType = "String")
|
||||
private String emgYn;
|
||||
|
||||
@ApiModelProperty(example = "제목", name = "제목", dataType = "String")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(example = "공지 내용", name = "공지 내용", dataType = "String")
|
||||
private String ntSbst;
|
||||
|
||||
@ApiModelProperty(example = "사용 여부", name = "사용 여부", dataType = "String")
|
||||
private String useYn;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "페이지당 조회할 목록 수",notes = "페이지당 조회할 목록 수", name = "페이지당 조회할 목록 수", dataType = "int")
|
||||
private int pagePerRows;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "현재 페이지", name = "현재 페이지", dataType = "int")
|
||||
private int page;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import kr.co.uplus.ez.common.data.Paging;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class NoticeListRes implements Serializable {
|
||||
|
||||
private Paging paging;
|
||||
private List<NoticeDto> list;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.data.ResponseMessage;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class NoticeListResDto extends ResponseMessage implements Serializable {
|
||||
// 데이터.
|
||||
private NoticeListRes data;
|
||||
|
||||
public NoticeListResDto() {
|
||||
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
|
||||
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
|
||||
}
|
||||
|
||||
public NoticeListResDto(ApiResponseCode returnStr) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
}
|
||||
|
||||
public NoticeListResDto(ApiResponseCode returnStr, NoticeListRes data) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class UpdateNoticeReqDto implements Serializable {
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(example = "공지 번호", name = "공지 번호", dataType = "int")
|
||||
private int ntNo;
|
||||
|
||||
@ApiModelProperty(example = "분류 코드", name = "분류 코드", dataType = "String")
|
||||
private String ctgCd;
|
||||
|
||||
@ApiModelProperty(example = "긴급 여부", name = "긴급 여부", dataType = "String")
|
||||
private String emgYn;
|
||||
|
||||
@ApiModelProperty(example = "제목", name = "제목", dataType = "String")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(example = "공지 내용", name = "공지 내용", dataType = "String")
|
||||
private String ntSbst;
|
||||
|
||||
@ApiModelProperty(example = "사용 여부", name = "사용 여부", dataType = "String")
|
||||
private String useYn;
|
||||
|
||||
@ApiModelProperty(example = "변경 ID", name = "변경 ID", dataType = "String")
|
||||
private String chgId;
|
||||
|
||||
@ApiModelProperty(example = "업로드된 파일", name = "업로드된 파일", dataType = "String")
|
||||
private String legacyFiles;
|
||||
|
||||
@ApiModelProperty(example = "삭제 파일", name = "삭제 파일", dataType = "Int")
|
||||
private String delFileNo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import kr.co.uplus.ez.common.data.ApiResponseCode;
|
||||
import kr.co.uplus.ez.common.data.ResponseMessage;
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class UpdateNoticeResDto extends ResponseMessage implements Serializable{
|
||||
// 데이터.
|
||||
private Object data;
|
||||
|
||||
public UpdateNoticeResDto() {
|
||||
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
|
||||
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
|
||||
}
|
||||
|
||||
public UpdateNoticeResDto(ApiResponseCode returnStr) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
}
|
||||
|
||||
public UpdateNoticeResDto(ApiResponseCode returnStr, Object data) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -58,8 +58,9 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
"/v3/api-docs/**",
|
||||
"/",
|
||||
"/socket/**",
|
||||
"/api/v1/bo/sendNumMgt/filedownload"
|
||||
,"/common/healthChk"
|
||||
"/api/v1/bo/sendNumMgt/filedownload",
|
||||
"/api/v1/bo/homeMgt/filedownload",
|
||||
"/common/healthChk"
|
||||
};
|
||||
|
||||
private static final String[] AUTH_URL_ARRAY = {
|
||||
@@ -72,6 +73,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
"/api/v1/bo/mntrng/**",
|
||||
"/api/v1/bo/riskMgt/sendNum/**",
|
||||
"/api/v1/bo/stats/**",
|
||||
"/api/v1/bo/homeMgt/**",
|
||||
"/view/error/**"
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user