mirror of
http://git.mhez-qa.uplus.co.kr/hubez/hubez-admin.git
synced 2025-12-07 00:17:26 +09:00
공지사항 삭제 기능 추가
This commit is contained in:
@@ -38,138 +38,153 @@ 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.api.sendNumMgt.dto.DeleteNumberReqDto;
|
||||
import kr.co.uplus.ez.api.sendNumMgt.dto.DeleteNumberResDto;
|
||||
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")
|
||||
@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 : 공지사항 조회.
|
||||
* date : 2022. 10. 18. auth : kjh desc : 공지사항 조회.
|
||||
*
|
||||
* @param noticeListReqDto
|
||||
* @return NoticeListResDto
|
||||
*/
|
||||
@ApiOperation(value = "noticeList", notes = "공지사항 조회")
|
||||
@ApiOperation(value = "/noticeList", notes = "공지사항 조회")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "noticeList", method = {RequestMethod.POST})
|
||||
@RequestMapping(value = "/noticeList", method = { RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public NoticeListResDto noticeList(@RequestBody @Valid NoticeListReqDto noticeListReqDto, BindingResult bindingResult, HttpServletResponse response) {
|
||||
|
||||
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 : 공지사항 등록.
|
||||
* date : 2022. 10. 21. auth : kjh desc : 공지사항 등록.
|
||||
*
|
||||
* @param insertNoticeReqDto
|
||||
* @return InsertNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "insertNotice", notes = "공지사항 등록")
|
||||
@ApiOperation(value = "/insertNotice", notes = "공지사항 등록")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "insertNotice", method = {RequestMethod.POST})
|
||||
@RequestMapping(value = "/insertNotice", method = { RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public InsertNoticeResDto insertNotice(@RequestPart(value = "key") InsertNoticeReqDto insertNoticeReqDto,
|
||||
MultipartHttpServletRequest multipartRequest) {
|
||||
|
||||
return homeService.insertNotice(insertNoticeReqDto ,multipartRequest);
|
||||
|
||||
return homeService.insertNotice(insertNoticeReqDto, multipartRequest);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 24.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 수정.
|
||||
* date : 2022. 10. 24. auth : kjh desc : 공지사항 수정.
|
||||
*
|
||||
* @param updateNoticeReqDto
|
||||
* @return UpdateNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "updateNotice", notes = "공지사항 수정")
|
||||
@ApiOperation(value = "/updateNotice", notes = "공지사항 수정")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "updateNotice", method = {RequestMethod.POST})
|
||||
@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 이미지 업로드 후 링크 리턴.
|
||||
* date : 2022. 10. 24.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 삭제.
|
||||
* @param deleteNoticeReqDto
|
||||
* @return DeleteNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "/deleteNotice", notes = "공지사항 삭제")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "/deleteNotice", method = { RequestMethod.POST })
|
||||
@ResponseBody
|
||||
public DeleteNoticeResDto deleteNotice(@RequestBody @Valid DeleteNoticeReqDto deleteNoticeReqDto, BindingResult bindingResult) {
|
||||
if (validComponents.validParameter(bindingResult)) {
|
||||
return new DeleteNoticeResDto(ApiResponseCode.CM_PARAMETER_ERROR);
|
||||
}
|
||||
|
||||
return homeService.deleteNotice(deleteNoticeReqDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 10. 24. auth : kjh desc : 공지사항 editor 이미지 업로드 후 링크 리턴.
|
||||
*
|
||||
* @param updateNoticeReqDto
|
||||
* @return UpdateNoticeResDto
|
||||
*/
|
||||
@ApiOperation(value = "getImageUrl", notes = "공지사항 editor 이미지 업로드 후 링크 리턴")
|
||||
@ApiOperation(value = "/getImageUrl", notes = "공지사항 editor 이미지 업로드 후 링크 리턴")
|
||||
@ApiResponses({ @ApiResponse(code = HttpServletResponse.SC_OK, message = "SUCESS") })
|
||||
@RequestMapping(value = "getImageUrl", method = {RequestMethod.POST})
|
||||
@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 {
|
||||
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 );
|
||||
FileIoUtils.fileDownload(file, request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ApiOperation(value = "이미지 미리보기", notes = "이미지 미리보기")
|
||||
@GetMapping(value = "/preview/{imgurl}", produces=MediaType.APPLICATION_OCTET_STREAM_VALUE)
|
||||
@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];
|
||||
|
||||
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());
|
||||
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) {
|
||||
} catch (Exception e) {
|
||||
logger.error("imgurl err, e={}, e", e.getMessage());
|
||||
return new ResponseEntity<byte[]>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
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;
|
||||
@@ -26,4 +27,6 @@ public interface HomeMgtMapper {
|
||||
|
||||
void delNoticeFile(DelNoticeReqDto delNoticeReqDto);
|
||||
|
||||
int deleteNotice(DeleteNoticeReqDto deleteNoticeReqDto);
|
||||
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ 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;
|
||||
@@ -21,9 +19,8 @@ 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 {
|
||||
@@ -144,8 +141,6 @@ public class HomeMgtService {
|
||||
insertNoticeFileDto.setRegId(insertNoticeReqDto.getRegId());
|
||||
insertNoticeFileDto.setChgId(insertNoticeReqDto.getRegId());
|
||||
|
||||
System.out.println("insertNoticeFileDto.getFilePath() :::: " + insertNoticeFileDto.getFilePath());
|
||||
|
||||
homeMgtMapper.insertNoticeFile(insertNoticeFileDto);
|
||||
idx++;
|
||||
}
|
||||
@@ -171,9 +166,6 @@ public class HomeMgtService {
|
||||
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);
|
||||
@@ -228,15 +220,11 @@ public class HomeMgtService {
|
||||
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);
|
||||
@@ -254,9 +242,7 @@ public class HomeMgtService {
|
||||
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) +
|
||||
@@ -272,8 +258,7 @@ public class HomeMgtService {
|
||||
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;
|
||||
uploadFile = path + File.separator + fileNm;
|
||||
}
|
||||
|
||||
}catch(Exception e) {
|
||||
@@ -283,4 +268,24 @@ public class HomeMgtService {
|
||||
return new FileResDto(ApiResponseCode.SUCCESS, uploadFile);
|
||||
}
|
||||
|
||||
/**
|
||||
* date : 2022. 11. 02.
|
||||
* auth : kjh
|
||||
* desc : 공지사항 삭제
|
||||
* @param deleteNoticeReqDto
|
||||
* @return
|
||||
*/
|
||||
public DeleteNoticeResDto deleteNotice(DeleteNoticeReqDto deleteNoticeReqDto) {
|
||||
|
||||
HomeMgtMapper homeMgtMapper = sqlSessionSlave.getMapper(HomeMgtMapper.class);
|
||||
|
||||
try {
|
||||
homeMgtMapper.deleteNotice(deleteNoticeReqDto);
|
||||
} catch (Exception e) {
|
||||
return new DeleteNoticeResDto(ApiResponseCode.CM_DB_QUERY_ERR);
|
||||
}
|
||||
|
||||
return new DeleteNoticeResDto(ApiResponseCode.SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
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 DeleteNotice implements Serializable{
|
||||
|
||||
@ApiModelProperty(example = "공지사항 번호", name = "공지사항 번호", dataType = "int")
|
||||
private int ntNo;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package kr.co.uplus.ez.api.homeMgt.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
@Data
|
||||
public class DeleteNoticeReqDto implements Serializable{
|
||||
|
||||
private List<DeleteNotice> list;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
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 DeleteNoticeResDto extends ResponseMessage implements Serializable{
|
||||
|
||||
|
||||
// 데이터.
|
||||
private Object data;
|
||||
|
||||
public DeleteNoticeResDto() {
|
||||
this.retCode = ApiResponseCode.SUCCESS.getResultCode();
|
||||
this.retMsg = ApiResponseCode.SUCCESS.getResultMsg();
|
||||
}
|
||||
|
||||
public DeleteNoticeResDto(ApiResponseCode returnStr) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
}
|
||||
|
||||
public DeleteNoticeResDto(ApiResponseCode returnStr, Object data) {
|
||||
this.retCode = returnStr.getResultCode();
|
||||
this.retMsg = returnStr.getResultMsg();
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -196,10 +196,26 @@
|
||||
|
||||
<!-- 첨부파일 삭제 -->
|
||||
<delete id="delNoticeFile" parameterType="kr.co.uplus.ez.api.homeMgt.dto.DelNoticeReqDto">
|
||||
/* homeMgt-mapper.xml(delNoticeFile) */
|
||||
DELETE FROM hubez_common.EZ_BBS_FATC
|
||||
WHERE BBS_NO = #{ntNo}
|
||||
AND FILE_NO = #{fileNo}
|
||||
</delete>
|
||||
|
||||
<!-- 공지사항 삭제 -->
|
||||
<delete id="deleteNotice" parameterType="kr.co.uplus.ez.api.homeMgt.dto.DeleteNoticeReqDto">
|
||||
/* homeMgt-mapper.xml(deleteNotice) */
|
||||
DELETE
|
||||
FROM
|
||||
hubez_common.EZ_NTBBS
|
||||
<where>
|
||||
NT_NO IN
|
||||
<foreach collection="list" item="item" index="i" open="("
|
||||
separator="," close=")">
|
||||
#{item.ntNo}
|
||||
</foreach>
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
|
||||
<sql id="NoticeListCondition">
|
||||
|
||||
Reference in New Issue
Block a user