메뉴 배너 관리
This commit is contained in:
@@ -0,0 +1,77 @@
|
|||||||
|
package com.caliverse.admin.domain.api;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.request.MenuRequest;
|
||||||
|
import com.caliverse.admin.domain.response.MenuResponse;
|
||||||
|
import com.caliverse.admin.domain.service.MenuService;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.http.HttpHeaders;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Tag(name = "메뉴", description = "메뉴 배너 조회 및 관리 api")
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@RequestMapping("/api/v1/menu")
|
||||||
|
public class MenuController {
|
||||||
|
|
||||||
|
private final MenuService menuService;
|
||||||
|
|
||||||
|
// 조회
|
||||||
|
@GetMapping("/banner/list")
|
||||||
|
public ResponseEntity<MenuResponse> getList(
|
||||||
|
@RequestParam Map<String, String> requestParam){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(menuService.getList(requestParam));
|
||||||
|
}
|
||||||
|
// 상세 조회
|
||||||
|
@GetMapping("/banner/detail/{id}")
|
||||||
|
public ResponseEntity<MenuResponse> getList(
|
||||||
|
@PathVariable("id") Long id){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(menuService.getdetail(id));
|
||||||
|
}
|
||||||
|
@PostMapping("/image-upload")
|
||||||
|
public ResponseEntity<MenuResponse> imageUpload(
|
||||||
|
@RequestParam("file") MultipartFile file){
|
||||||
|
return ResponseEntity.ok().body( menuService.imageUpload(file));
|
||||||
|
}
|
||||||
|
@GetMapping("/image-down")
|
||||||
|
public ResponseEntity<Resource> imageDown(
|
||||||
|
@RequestParam("file") String fileName){
|
||||||
|
Resource resource = menuService.fileDown(fileName);
|
||||||
|
HttpHeaders headers = new HttpHeaders();
|
||||||
|
headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=" + fileName);
|
||||||
|
|
||||||
|
return ResponseEntity.ok()
|
||||||
|
.headers(headers)
|
||||||
|
.body(resource);
|
||||||
|
}
|
||||||
|
@GetMapping("/image-delete")
|
||||||
|
public ResponseEntity<MenuResponse> imageDelete(
|
||||||
|
@RequestParam("file") String fileName){
|
||||||
|
return ResponseEntity.ok().body( menuService.imageDelete(fileName));
|
||||||
|
}
|
||||||
|
@PostMapping("/banner")
|
||||||
|
public ResponseEntity<MenuResponse> postMenuBanner(
|
||||||
|
@RequestBody MenuRequest menuRequest){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(menuService.postBanner(menuRequest));
|
||||||
|
}
|
||||||
|
@PutMapping("/banner/{id}")
|
||||||
|
public ResponseEntity<MenuResponse> updateMenuBanner(
|
||||||
|
@PathVariable("id")Long id, @RequestBody MenuRequest menuRequest){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(menuService.updateBanner(id, menuRequest));
|
||||||
|
}
|
||||||
|
@DeleteMapping("/banner/delete")
|
||||||
|
public ResponseEntity<MenuResponse> deleteMenuBanner(
|
||||||
|
@RequestBody MenuRequest menuRequest){
|
||||||
|
|
||||||
|
return ResponseEntity.ok().body(menuService.deleteMail(menuRequest));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.caliverse.admin.domain.dao.admin;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.MenuBanner;
|
||||||
|
import com.caliverse.admin.domain.entity.Message;
|
||||||
|
import com.caliverse.admin.domain.request.MenuRequest;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public interface MenuMapper {
|
||||||
|
|
||||||
|
List<MenuBanner> getBannerList(Map map);
|
||||||
|
int getTotal();
|
||||||
|
MenuBanner getBannerDetail(Long id);
|
||||||
|
List<Message> getMessage(Long id);
|
||||||
|
List<MenuBanner> getScheduleBannerList();
|
||||||
|
|
||||||
|
void insertBanner(MenuRequest mailRequest);
|
||||||
|
void insertMessage(Map map);
|
||||||
|
|
||||||
|
int updateBanner(MenuRequest mailRequest);
|
||||||
|
int updateBannerStatus(Map map);
|
||||||
|
|
||||||
|
int deleteMessage(Map map);
|
||||||
|
void deleteBanner(Map map);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -52,6 +52,9 @@ public enum HISTORYTYPE {
|
|||||||
LAND_OWNED_INITIALIZE("랜드 소유권 정보 초기화"),
|
LAND_OWNED_INITIALIZE("랜드 소유권 정보 초기화"),
|
||||||
LAND_DESC_INITIALIZE("랜드 정보 초기화"),
|
LAND_DESC_INITIALIZE("랜드 정보 초기화"),
|
||||||
LAND_AUCTION_INITIALIZE("랜드 경매 초기화"),
|
LAND_AUCTION_INITIALIZE("랜드 경매 초기화"),
|
||||||
|
MENU_BANNER_ADD("메뉴 배너 등록"),
|
||||||
|
MENU_BANNER_UPDATE("메뉴 배너 수정"),
|
||||||
|
MENU_BANNER_DELETE("메뉴 배너 삭제"),
|
||||||
;
|
;
|
||||||
private String historyType;
|
private String historyType;
|
||||||
HISTORYTYPE(String type) {
|
HISTORYTYPE(String type) {
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.caliverse.admin.domain.entity;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public class MenuBanner {
|
||||||
|
private Long id;
|
||||||
|
@JsonProperty("row_num")
|
||||||
|
private Long rowNum;
|
||||||
|
private String title;
|
||||||
|
private BANNER_STATUS status;
|
||||||
|
@JsonProperty("image_list")
|
||||||
|
private List<Message> imageList;
|
||||||
|
@JsonProperty("start_dt")
|
||||||
|
private LocalDateTime startDt;
|
||||||
|
@JsonProperty("end_dt")
|
||||||
|
private LocalDateTime endDt;
|
||||||
|
@JsonProperty("is_link")
|
||||||
|
private boolean isLink;
|
||||||
|
|
||||||
|
@JsonProperty("create_by")
|
||||||
|
private String createBy;
|
||||||
|
@JsonProperty("create_dt")
|
||||||
|
private LocalDateTime createDt;
|
||||||
|
@JsonProperty("update_by")
|
||||||
|
private String updateBy;
|
||||||
|
@JsonProperty("update_dt")
|
||||||
|
private LocalDateTime updateDt;
|
||||||
|
|
||||||
|
public static class Guid{
|
||||||
|
String guid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum BANNER_STATUS {
|
||||||
|
WAIT,
|
||||||
|
FINISH,
|
||||||
|
FAIL,
|
||||||
|
RUNNING,
|
||||||
|
;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.caliverse.admin.domain.request;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.Message;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MenuRequest {
|
||||||
|
|
||||||
|
private Long id;
|
||||||
|
private String title;
|
||||||
|
@JsonProperty("image_list")
|
||||||
|
private List<Message> imageList;
|
||||||
|
@JsonProperty("start_dt")
|
||||||
|
private LocalDateTime startDt;
|
||||||
|
@JsonProperty("end_dt")
|
||||||
|
private LocalDateTime endDt;
|
||||||
|
@JsonProperty("is_link")
|
||||||
|
private boolean isLink;
|
||||||
|
@JsonProperty("link_list")
|
||||||
|
private List<Message> linkList;
|
||||||
|
|
||||||
|
@JsonProperty("create_by")
|
||||||
|
private Long createBy;
|
||||||
|
@JsonProperty("create_dt")
|
||||||
|
private LocalDateTime createDt;
|
||||||
|
@JsonProperty("update_by")
|
||||||
|
private Long updateBy;
|
||||||
|
@JsonProperty("update_dt")
|
||||||
|
private LocalDateTime updateDt;
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public static class DeleteMailItem {
|
||||||
|
private String type;
|
||||||
|
private String guid;
|
||||||
|
@JsonProperty("mail_guid")
|
||||||
|
private String MailGuid;
|
||||||
|
@JsonProperty("item_id")
|
||||||
|
private Long itemId;
|
||||||
|
@JsonProperty("parrent_count")
|
||||||
|
private Double parrentCount;
|
||||||
|
private Double count;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package com.caliverse.admin.domain.response;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.MenuBanner;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
public class MenuResponse {
|
||||||
|
private int status;
|
||||||
|
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
@JsonProperty("data")
|
||||||
|
private ResultData resultData;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
|
public static class ResultData{
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
@JsonProperty("detail")
|
||||||
|
private MenuBanner banner;
|
||||||
|
|
||||||
|
@JsonProperty("list")
|
||||||
|
private List<MenuBanner> bannerList;
|
||||||
|
@JsonProperty("file_name")
|
||||||
|
private String fileName;
|
||||||
|
private int total;
|
||||||
|
@JsonProperty("total_all")
|
||||||
|
private int totalAll;
|
||||||
|
@JsonProperty("page_no")
|
||||||
|
private int pageNo;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,325 @@
|
|||||||
|
package com.caliverse.admin.domain.service;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.dao.admin.MenuMapper;
|
||||||
|
import com.caliverse.admin.domain.entity.*;
|
||||||
|
import com.caliverse.admin.domain.request.MenuRequest;
|
||||||
|
import com.caliverse.admin.domain.response.MenuResponse;
|
||||||
|
import com.caliverse.admin.global.common.code.CommonCode;
|
||||||
|
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||||
|
import com.caliverse.admin.global.common.code.SuccessCode;
|
||||||
|
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||||
|
import com.caliverse.admin.global.common.constants.MysqlConstants;
|
||||||
|
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||||
|
import com.caliverse.admin.global.common.utils.CommonUtils;
|
||||||
|
import com.caliverse.admin.global.common.utils.FileUtils;
|
||||||
|
import com.caliverse.admin.history.service.MysqlHistoryLogService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.core.io.ResourceLoader;
|
||||||
|
import org.springframework.core.io.UrlResource;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import software.amazon.awssdk.services.s3.model.S3Exception;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.MalformedURLException;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MenuService {
|
||||||
|
|
||||||
|
@Value("${excel.file-path}")
|
||||||
|
private String filePath;
|
||||||
|
@Value("${caliverse.file}")
|
||||||
|
private String samplePath;
|
||||||
|
private final FileUtils fileUtils;
|
||||||
|
private final MenuMapper menuMapper;
|
||||||
|
private final ResourceLoader resourceLoader;
|
||||||
|
private final MysqlHistoryLogService mysqlHistoryLogService;
|
||||||
|
private final S3Service s3Service;
|
||||||
|
|
||||||
|
public MenuResponse getList(Map requestParam){
|
||||||
|
|
||||||
|
//페이징 처리
|
||||||
|
requestParam = CommonUtils.pageSetting(requestParam);
|
||||||
|
|
||||||
|
List<MenuBanner> list = menuMapper.getBannerList(requestParam);
|
||||||
|
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.bannerList(list)
|
||||||
|
.total(menuMapper.getTotal())
|
||||||
|
.totalAll(list.size())
|
||||||
|
.pageNo(requestParam.get("page_no")!=null?
|
||||||
|
Integer.valueOf(requestParam.get("page_no").toString()):1)
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuResponse getdetail(Long id){
|
||||||
|
MenuBanner banner = menuMapper.getBannerDetail(id);
|
||||||
|
|
||||||
|
banner.setImageList(menuMapper.getMessage(id));
|
||||||
|
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.banner(banner)
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuResponse imageUpload(MultipartFile file){
|
||||||
|
if (file.isEmpty()) {
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_EXIT_FILE.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 파일을 서버에 저장
|
||||||
|
String fileName = fileUtils.saveFile(file);
|
||||||
|
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.message(SuccessCode.EXCEL_UPLOAD.getMessage())
|
||||||
|
.fileName(fileName)
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public MenuResponse imageDelete(String fileName){
|
||||||
|
if (fileName.isEmpty()) {
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_EXIT_FILE.getMessage() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// 서버 파일 삭제
|
||||||
|
boolean is_delete = fileUtils.deleteFile(fileName);
|
||||||
|
|
||||||
|
if(is_delete){
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.message(SuccessCode.FILE_DELETE.getMessage())
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.build();
|
||||||
|
}else{
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.message(ErrorCode.ERROR_FILE_DELETE.getMessage())
|
||||||
|
.build())
|
||||||
|
.status(CommonCode.ERROR.getHttpStatus())
|
||||||
|
.result(CommonCode.ERROR.getResult())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resource fileDown(String fileName) {
|
||||||
|
Path fileFullPath = Path.of(filePath+fileName);
|
||||||
|
try {
|
||||||
|
if(fileName.contains("sample")){
|
||||||
|
return resourceLoader.getResource(samplePath + fileName);
|
||||||
|
}
|
||||||
|
Resource resource = new UrlResource(fileFullPath.toUri());
|
||||||
|
if (resource.exists() && resource.isReadable()) {
|
||||||
|
return resource;
|
||||||
|
} else {
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_EXIT_EXCEL.getMessage());
|
||||||
|
}
|
||||||
|
}catch (MalformedURLException e){
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.NOT_EXIT_EXCEL.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(transactionManager = "transactionManager")
|
||||||
|
public MenuResponse postBanner(MenuRequest menuRequest){
|
||||||
|
menuRequest.setCreateBy(CommonUtils.getAdmin().getId());
|
||||||
|
|
||||||
|
menuMapper.insertBanner(menuRequest);
|
||||||
|
|
||||||
|
long banner_id = menuRequest.getId();
|
||||||
|
HashMap<String,String> map = new HashMap<>();
|
||||||
|
map.put("id",String.valueOf(banner_id));
|
||||||
|
|
||||||
|
//메시지 저장(title=이미지명, content=이미지 링크)
|
||||||
|
if(menuRequest.getImageList()!= null && !menuRequest.getImageList().isEmpty()){
|
||||||
|
menuRequest.getImageList().forEach(image -> {
|
||||||
|
String temp_file = image.getContent();
|
||||||
|
String contentType = fileUtils.getContentType(temp_file);
|
||||||
|
File file = fileUtils.loadFileObject(temp_file);
|
||||||
|
String fileUri = "";
|
||||||
|
try{
|
||||||
|
fileUri = s3Service.uploadFile(file, CommonConstants.S3_MENU_BANNER_DIRECTORY + banner_id, contentType);
|
||||||
|
}catch (S3Exception e) {
|
||||||
|
log.error("S3 오류: {}", e.getMessage());
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_FILE_S3_UPLOAD.getMessage());
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("파일 읽기 오류: {}", e.getMessage());
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_FILE_S3_UPLOAD.getMessage());
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("파일 업로드 중 예상치 못한 오류: {}", e.getMessage(), e);
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_FILE_S3_UPLOAD.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(fileUri.isEmpty()){
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_FILE_S3_UPLOAD.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
map.put("title", fileUri);
|
||||||
|
map.put("language", image.getLanguage());
|
||||||
|
if(menuRequest.isLink() && (menuRequest.getLinkList() != null && !menuRequest.getLinkList().isEmpty())){
|
||||||
|
String link = menuRequest.getLinkList().stream().filter(data -> data.getLanguage().equals(image.getLanguage())).findFirst().get().getContent();
|
||||||
|
map.put("content", link);
|
||||||
|
}else{
|
||||||
|
map.put("content", "");
|
||||||
|
}
|
||||||
|
menuMapper.insertMessage(map);
|
||||||
|
|
||||||
|
fileUtils.deleteFile(temp_file);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuBanner banner = menuMapper.getBannerDetail(menuRequest.getId());
|
||||||
|
|
||||||
|
mysqlHistoryLogService.insertHistoryLog(
|
||||||
|
HISTORYTYPE.MENU_BANNER_ADD,
|
||||||
|
MysqlConstants.TABLE_NAME_MENU_BANNER,
|
||||||
|
HISTORYTYPE.MENU_BANNER_ADD.name(),
|
||||||
|
banner,
|
||||||
|
CommonUtils.getAdmin().getEmail(),
|
||||||
|
CommonUtils.getClientIp()
|
||||||
|
);
|
||||||
|
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.message(SuccessCode.SAVE.getMessage())
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(transactionManager = "transactionManager")
|
||||||
|
public MenuResponse updateBanner(Long id, MenuRequest menuRequest) {
|
||||||
|
menuRequest.setId(id);
|
||||||
|
menuRequest.setUpdateBy(CommonUtils.getAdmin().getId());
|
||||||
|
menuRequest.setUpdateDt(LocalDateTime.now());
|
||||||
|
|
||||||
|
Long banner_id = menuRequest.getId();
|
||||||
|
MenuBanner before_info = menuMapper.getBannerDetail(banner_id);
|
||||||
|
List<Message> before_msg = menuMapper.getMessage(banner_id);
|
||||||
|
before_info.setImageList(before_msg);
|
||||||
|
|
||||||
|
log.info("updateBanner Update Before MenuBanner: {}, Images: {}", before_info, before_msg);
|
||||||
|
|
||||||
|
menuMapper.updateBanner(menuRequest);
|
||||||
|
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("id", String.valueOf(menuRequest.getId()));
|
||||||
|
|
||||||
|
menuMapper.deleteMessage(map);
|
||||||
|
|
||||||
|
if(menuRequest.getImageList()!= null && !menuRequest.getImageList().isEmpty()){
|
||||||
|
menuRequest.getImageList().forEach(image -> {
|
||||||
|
map.put("title", image.getContent());
|
||||||
|
map.put("language", image.getLanguage());
|
||||||
|
if(menuRequest.isLink() && menuRequest.getLinkList() != null && !menuRequest.getLinkList().isEmpty()){
|
||||||
|
String link = menuRequest.getLinkList().stream().filter(data -> data.getLanguage().equals(image.getLanguage())).findFirst().get().getContent();
|
||||||
|
map.put("content", link);
|
||||||
|
}
|
||||||
|
menuMapper.insertMessage(map);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
log.info("updateBanner Update After Banner: {}", menuRequest);
|
||||||
|
|
||||||
|
MenuBanner after_info = menuMapper.getBannerDetail(banner_id);
|
||||||
|
after_info.setImageList(menuMapper.getMessage(banner_id));
|
||||||
|
|
||||||
|
mysqlHistoryLogService.updateHistoryLog(
|
||||||
|
HISTORYTYPE.MENU_BANNER_UPDATE,
|
||||||
|
MysqlConstants.TABLE_NAME_MENU_BANNER,
|
||||||
|
HISTORYTYPE.MENU_BANNER_UPDATE.name(),
|
||||||
|
before_info,
|
||||||
|
after_info,
|
||||||
|
CommonUtils.getAdmin().getEmail(),
|
||||||
|
CommonUtils.getClientIp()
|
||||||
|
);
|
||||||
|
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.message(SuccessCode.UPDATE.getMessage())
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Transactional(transactionManager = "transactionManager")
|
||||||
|
public MenuResponse deleteMail(MenuRequest menuRequest){
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
|
||||||
|
// mailRequest.getList().forEach(
|
||||||
|
// item->{
|
||||||
|
// map.put("id",item.getId());
|
||||||
|
// mailMapper.deleteMail(map);
|
||||||
|
//
|
||||||
|
// // 스케줄에서 제거
|
||||||
|
// scheduleService.closeTask("mail-" + item.getId());
|
||||||
|
// log.info("deleteMail Mail: {}", item);
|
||||||
|
//
|
||||||
|
// //로그 기록
|
||||||
|
// List<Message> message = mailMapper.getMessage(Long.valueOf(item.getId()));
|
||||||
|
// map.put("adminId", CommonUtils.getAdmin().getId());
|
||||||
|
// map.put("name", CommonUtils.getAdmin().getName());
|
||||||
|
// map.put("mail", CommonUtils.getAdmin().getEmail());
|
||||||
|
// map.put("type", HISTORYTYPE.MAIL_DELETE);
|
||||||
|
// JSONObject jsonObject = new JSONObject();
|
||||||
|
// if(!message.isEmpty()){
|
||||||
|
// jsonObject.put("message",message.get(0).getTitle());
|
||||||
|
// }
|
||||||
|
// map.put("content",jsonObject.toString());
|
||||||
|
// historyMapper.saveLog(map);
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
return MenuResponse.builder()
|
||||||
|
.status(CommonCode.SUCCESS.getHttpStatus())
|
||||||
|
.result(CommonCode.SUCCESS.getResult())
|
||||||
|
.resultData(MenuResponse.ResultData.builder()
|
||||||
|
.message(SuccessCode.DELETE.getMessage())
|
||||||
|
.build())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<MenuBanner> getScheduleMailList(){
|
||||||
|
return menuMapper.getScheduleBannerList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Message> getMessageList(Long id){
|
||||||
|
return menuMapper.getMessage(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateStatus(Long id, MenuBanner.BANNER_STATUS status){
|
||||||
|
Map<String,Object> map = new HashMap<>();
|
||||||
|
map.put("id", id);
|
||||||
|
map.put("status", status.toString());
|
||||||
|
menuMapper.updateBannerStatus(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,12 +6,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import software.amazon.awssdk.core.sync.RequestBody;
|
||||||
import software.amazon.awssdk.services.s3.S3Client;
|
import software.amazon.awssdk.services.s3.S3Client;
|
||||||
import software.amazon.awssdk.services.s3.model.GetObjectAttributesRequest;
|
import software.amazon.awssdk.services.s3.model.*;
|
||||||
import software.amazon.awssdk.services.s3.model.GetObjectAttributesResponse;
|
|
||||||
import software.amazon.awssdk.services.s3.model.S3Exception;
|
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@@ -24,6 +28,9 @@ public class S3Service {
|
|||||||
@Value("${amazon.s3.bucket-name}")
|
@Value("${amazon.s3.bucket-name}")
|
||||||
private String bucketName;
|
private String bucketName;
|
||||||
|
|
||||||
|
@Value("${amazon.aws.region}")
|
||||||
|
private String region;
|
||||||
|
|
||||||
public Optional<GetObjectAttributesResponse> getObjectMetadata(String key) {
|
public Optional<GetObjectAttributesResponse> getObjectMetadata(String key) {
|
||||||
try {
|
try {
|
||||||
GetObjectAttributesRequest request = GetObjectAttributesRequest.builder()
|
GetObjectAttributesRequest request = GetObjectAttributesRequest.builder()
|
||||||
@@ -38,4 +45,42 @@ public class S3Service {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String uploadFile(File file, String directoryName, String contentType) throws IOException, S3Exception {
|
||||||
|
String fileName = UUID.randomUUID().toString() + "-" + file.getName();
|
||||||
|
|
||||||
|
// S3 객체 키 (경로 + 파일명)
|
||||||
|
String objectKey = directoryName + "/" + fileName;
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
PutObjectRequest putObjectRequest = PutObjectRequest.builder()
|
||||||
|
.bucket(bucketName)
|
||||||
|
.key(objectKey)
|
||||||
|
.contentType(contentType)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// 파일 업로드
|
||||||
|
PutObjectResponse response = s3Client.putObject(
|
||||||
|
putObjectRequest,
|
||||||
|
RequestBody.fromBytes(Files.readAllBytes(file.toPath()))
|
||||||
|
);
|
||||||
|
//https://metaverse-myhomeugc-test.s3.us-west-2.amazonaws.com/0002896883264fc9af5be62134939ce4/552ec8a4302348edb3fbf1496811d75f.ugcinfo
|
||||||
|
return "https://" + bucketName + ".s3." +
|
||||||
|
s3Client.serviceClientConfiguration().region().toString() +
|
||||||
|
".amazonaws.com/" + objectKey;
|
||||||
|
// return "s3://" + bucketName + objectKey;
|
||||||
|
}catch (S3Exception | IOException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFile(String fileUrl) {
|
||||||
|
String objectKey = fileUrl.substring(fileUrl.indexOf(".com/") + 5);
|
||||||
|
|
||||||
|
s3Client.deleteObject(builder -> builder
|
||||||
|
.bucket(bucketName)
|
||||||
|
.key(objectKey)
|
||||||
|
.build());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,11 @@ public enum ErrorCode {
|
|||||||
DUPLICATE_EXCEL("중복된 유저 정보가 있습니다."),
|
DUPLICATE_EXCEL("중복된 유저 정보가 있습니다."),
|
||||||
USERTYPE_CHECK_EXCEL("타입을 확인해주세요."),
|
USERTYPE_CHECK_EXCEL("타입을 확인해주세요."),
|
||||||
|
|
||||||
|
NOT_EXIT_FILE("파일을 선택해주세요."),
|
||||||
|
ERROR_FILE_UPLOAD("파일 업로드중 오류 발생하였습니다."),
|
||||||
|
ERROR_FILE_S3_UPLOAD("파일을 S3로 업로드중 오류 발생하였습니다."),
|
||||||
|
ERROR_FILE_DELETE("파일 삭제중 오류 발생하였습니다."),
|
||||||
|
|
||||||
ERROR_API_CALL("API 호출에 실패하였습니다."),
|
ERROR_API_CALL("API 호출에 실패하였습니다."),
|
||||||
|
|
||||||
ERROR_HISTORY_SAVE("히스토리로그 저장 실패"),
|
ERROR_HISTORY_SAVE("히스토리로그 저장 실패"),
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public enum SuccessCode {
|
|||||||
INIT("비밀번호 초기화 하였습니다."),
|
INIT("비밀번호 초기화 하였습니다."),
|
||||||
NULL_DATA("조회된 데이터가 없습니다."),
|
NULL_DATA("조회된 데이터가 없습니다."),
|
||||||
EXCEL_UPLOAD("파일 업로드 하였습니다."),
|
EXCEL_UPLOAD("파일 업로드 하였습니다."),
|
||||||
|
FILE_DELETE("파일을 삭제 하였습니다."),
|
||||||
REGISTRATION("등록 하였습니다."),
|
REGISTRATION("등록 하였습니다."),
|
||||||
ITEM_EXIST("아이템이 존재합니다"),
|
ITEM_EXIST("아이템이 존재합니다"),
|
||||||
SUCCESS("성공 하였습니다."),
|
SUCCESS("성공 하였습니다."),
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ public class CommonConstants {
|
|||||||
public static final String LAND_EVENT = "event";
|
public static final String LAND_EVENT = "event";
|
||||||
public static final String SYSTEM_MAIL_LAND_TRANS_KEY = "LandTrans";
|
public static final String SYSTEM_MAIL_LAND_TRANS_KEY = "LandTrans";
|
||||||
public static final int DYNAMODB_PAGING_SIZE = 30;
|
public static final int DYNAMODB_PAGING_SIZE = 30;
|
||||||
|
public static final String S3_MENU_BANNER_DIRECTORY = "banner-";
|
||||||
|
|
||||||
public static final String FORMAT_DATE_ISO_DATETIME_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
public static final String FORMAT_DATE_ISO_DATETIME_MILLIS = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
|
||||||
public static final String FORMAT_DATE_ISO_DATETIME_MILLIS_NANO = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'";
|
public static final String FORMAT_DATE_ISO_DATETIME_MILLIS_NANO = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSS'Z'";
|
||||||
@@ -24,4 +25,6 @@ public class CommonConstants {
|
|||||||
public static final String FORMAT_DATE_MAIL_DATETIME = "yyyy/MM/dd/HH:mm:ss:SS";
|
public static final String FORMAT_DATE_MAIL_DATETIME = "yyyy/MM/dd/HH:mm:ss:SS";
|
||||||
|
|
||||||
public static final String TRANSACTION_ID_KEY = "TRANSACTION_ID";
|
public static final String TRANSACTION_ID_KEY = "TRANSACTION_ID";
|
||||||
|
|
||||||
|
public static final int AI_MESSAGE_LIMIT_SIZE = 50;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ public class MysqlConstants {
|
|||||||
public static String TABLE_NAME_LAND_OWNER_CHANGE = "land_ownership_changes";
|
public static String TABLE_NAME_LAND_OWNER_CHANGE = "land_ownership_changes";
|
||||||
public static String TABLE_NAME_CALIUM_REQUEST = "calium_request";
|
public static String TABLE_NAME_CALIUM_REQUEST = "calium_request";
|
||||||
public static String TABLE_NAME_EVENT = "event";
|
public static String TABLE_NAME_EVENT = "event";
|
||||||
|
public static String TABLE_NAME_MENU_BANNER = "menu_banner";
|
||||||
public static String TABLE_NAME_MAIL = "mail";
|
public static String TABLE_NAME_MAIL = "mail";
|
||||||
public static String TABLE_NAME_NOTICE = "notice";
|
public static String TABLE_NAME_NOTICE = "notice";
|
||||||
public static String TABLE_NAME_BATTLE_EVENT = "battle_event";
|
public static String TABLE_NAME_BATTLE_EVENT = "battle_event";
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.*;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.*;
|
import java.util.regex.*;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.AI.AIRole;
|
||||||
import com.caliverse.admin.domain.entity.DiffStatus;
|
import com.caliverse.admin.domain.entity.DiffStatus;
|
||||||
import com.caliverse.admin.global.common.code.CommonCode;
|
import com.caliverse.admin.global.common.code.CommonCode;
|
||||||
import com.caliverse.admin.global.common.constants.CommonConstants;
|
import com.caliverse.admin.global.common.constants.CommonConstants;
|
||||||
@@ -383,4 +384,8 @@ public class CommonUtils {
|
|||||||
return "\"" + value.toString().replace("\"", "\\\"") + "\"";
|
return "\"" + value.toString().replace("\"", "\\\"") + "\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> getAIMessage(AIRole role, String message){
|
||||||
|
return Map.of("role", role.toString(), "content", message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,168 @@
|
|||||||
|
package com.caliverse.admin.global.common.utils;
|
||||||
|
|
||||||
|
import com.caliverse.admin.domain.entity.Currencys;
|
||||||
|
import com.caliverse.admin.domain.entity.Excel;
|
||||||
|
import com.caliverse.admin.domain.entity.ROUTE;
|
||||||
|
import com.caliverse.admin.domain.response.IndicatorsResponse;
|
||||||
|
import com.caliverse.admin.global.common.code.CommonCode;
|
||||||
|
import com.caliverse.admin.global.common.code.ErrorCode;
|
||||||
|
import com.caliverse.admin.global.common.exception.RestApiException;
|
||||||
|
import com.fasterxml.jackson.databind.exc.InvalidFormatException;
|
||||||
|
import jakarta.servlet.ServletOutputStream;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.formula.eval.ErrorEval;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFColor;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFFont;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class FileUtils {
|
||||||
|
|
||||||
|
@Value("${excel.file-path}")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
public byte[] loadFileByte(String fileName) {
|
||||||
|
try {
|
||||||
|
String localFilePath = filePath + File.separator + fileName;
|
||||||
|
Path sourcePath = Path.of(localFilePath);
|
||||||
|
|
||||||
|
if (!Files.exists(sourcePath)) {
|
||||||
|
throw new RuntimeException("파일을 찾을 수 없습니다: " + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Files.readAllBytes(sourcePath);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException("파일 로드 중 오류 발생: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileInputStream loadFileStream(String fileName){
|
||||||
|
String fullPath = filePath + fileName;
|
||||||
|
|
||||||
|
try (FileInputStream fis = new FileInputStream(new File(fullPath))) {
|
||||||
|
return fis;
|
||||||
|
}catch(Exception e){
|
||||||
|
log.error(e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public File loadFileObject(String fileName){
|
||||||
|
String fullPath = filePath + fileName;
|
||||||
|
|
||||||
|
File file = new File(fullPath);
|
||||||
|
|
||||||
|
if (!file.exists() || !file.isFile()) {
|
||||||
|
throw new RuntimeException("파일을 찾을 수 없습니다: " + fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String saveFile(MultipartFile file){
|
||||||
|
try{
|
||||||
|
String fileName = CommonUtils.setFileName(file.getOriginalFilename());
|
||||||
|
String path = filePath + File.separator + fileName;
|
||||||
|
Path destinationPath = Path.of(path);
|
||||||
|
|
||||||
|
Files.copy(file.getInputStream(), destinationPath, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
||||||
|
return fileName;
|
||||||
|
}catch (IOException e){
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_FILE_UPLOAD.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteFile(String fileName) {
|
||||||
|
try {
|
||||||
|
String path = filePath + File.separator + fileName;
|
||||||
|
Path fileToDelete = Path.of(path);
|
||||||
|
|
||||||
|
if (!Files.exists(fileToDelete)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Files.deleteIfExists(fileToDelete);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RestApiException(CommonCode.ERROR.getHttpStatus(), ErrorCode.ERROR_FILE_DELETE.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean hasDuplicates(List<String> dataList) {
|
||||||
|
Set<String> uniqueValues = new HashSet<>();
|
||||||
|
|
||||||
|
for (String value : dataList) {
|
||||||
|
if (uniqueValues.contains(value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
uniqueValues.add(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isString32Characters(String input) {
|
||||||
|
if (input == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return input.length() == 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContentType(String fileName) {
|
||||||
|
String extension = "";
|
||||||
|
int i = fileName.lastIndexOf('.');
|
||||||
|
if (i > 0) {
|
||||||
|
extension = fileName.substring(i + 1).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (extension) {
|
||||||
|
case "jpg":
|
||||||
|
case "jpeg":
|
||||||
|
return "image/jpeg";
|
||||||
|
case "png":
|
||||||
|
return "image/png";
|
||||||
|
case "gif":
|
||||||
|
return "image/gif";
|
||||||
|
case "pdf":
|
||||||
|
return "application/pdf";
|
||||||
|
case "txt":
|
||||||
|
return "text/plain";
|
||||||
|
case "html":
|
||||||
|
return "text/html";
|
||||||
|
case "doc":
|
||||||
|
return "application/msword";
|
||||||
|
case "docx":
|
||||||
|
return "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
|
||||||
|
case "xls":
|
||||||
|
return "application/vnd.ms-excel";
|
||||||
|
case "xlsx":
|
||||||
|
return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
||||||
|
default:
|
||||||
|
return "application/octet-stream"; // 기본 바이너리 타입
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.caliverse.admin.global.configuration;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
|
||||||
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class JacksonConfig {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public ObjectMapper objectMapper() {
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.registerModule(new JavaTimeModule());
|
||||||
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE); // 필요시
|
||||||
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||||
|
return mapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
146
src/main/resources/mappers/MenuMapper.xml
Normal file
146
src/main/resources/mappers/MenuMapper.xml
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.caliverse.admin.domain.dao.admin.MenuMapper">
|
||||||
|
<resultMap id="MenuResultMap" type="com.caliverse.admin.domain.entity.MenuBanner">
|
||||||
|
<id property="id" column="id"/>
|
||||||
|
<result property="rowNum" column="row_num"/>
|
||||||
|
<result property="title" column="title"/>
|
||||||
|
<result property="isLink" column="is_link"/>
|
||||||
|
<result property="status" column="status"/>
|
||||||
|
<result property="startDt" column="start_dt"/>
|
||||||
|
<result property="endDt" column="end_dt"/>
|
||||||
|
<result property="createBy" column="create_by"/>
|
||||||
|
<result property="createDt" column="create_dt"/>
|
||||||
|
<result property="updateBy" column="update_by"/>
|
||||||
|
<result property="updateDt" column="update_dt"/>
|
||||||
|
</resultMap>
|
||||||
|
<resultMap id="MessageResultMap" type="com.caliverse.admin.domain.entity.Message">
|
||||||
|
<result property="title" column="title"/>
|
||||||
|
<result property="language" column="language"/>
|
||||||
|
<result property="content" column="content"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!--리스트 조회-->
|
||||||
|
<select id="getBannerList" resultMap="MenuResultMap" parameterType="map">
|
||||||
|
SELECT (@row_number:=@row_number + 1) AS row_num , c.*
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
a.id
|
||||||
|
, a.title
|
||||||
|
, a.is_link
|
||||||
|
, a.status
|
||||||
|
, a.start_dt
|
||||||
|
, a.end_dt
|
||||||
|
, (SELECT email FROM admin WHERE id = a.create_by ) AS create_by
|
||||||
|
, a.create_dt
|
||||||
|
, (SELECT email FROM admin WHERE id = a.update_by ) AS update_by
|
||||||
|
, a.update_dt
|
||||||
|
FROM menu_banner a
|
||||||
|
WHERE 1 = 1
|
||||||
|
AND a.deleted = 0
|
||||||
|
|
||||||
|
<if test="search_data != null and search_data != ''">
|
||||||
|
AND a.title LIKE CONCAT('%',#{search_data},'%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
<choose>
|
||||||
|
<when test="status != 'ALL' ">
|
||||||
|
AND a.status = #{status}
|
||||||
|
</when>
|
||||||
|
</choose>
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<if test="start_dt != null and start_dt != '' and end_dt !=null and end_dt!= ''">
|
||||||
|
AND a.start_dt >= #{start_dt, jdbcType=TIMESTAMP}
|
||||||
|
AND a.end_dt <= #{end_dt, jdbcType=TIMESTAMP}
|
||||||
|
</if>
|
||||||
|
|
||||||
|
ORDER BY a.create_dt
|
||||||
|
)c
|
||||||
|
, (SELECT @row_number:=0) AS t
|
||||||
|
<if test="orderby != null and orderby != ''">
|
||||||
|
ORDER BY row_num ${orderby}
|
||||||
|
</if>
|
||||||
|
<if test="pageSize != null and pageSize != ''">
|
||||||
|
LIMIT ${pageSize} OFFSET ${offset}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getTotal" resultType="java.lang.Integer" parameterType="map">
|
||||||
|
SELECT count(*) FROM menu_banner WHERE deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getBannerDetail" parameterType="java.lang.Long" resultMap="MenuResultMap" >
|
||||||
|
SELECT
|
||||||
|
a.id
|
||||||
|
, a.title
|
||||||
|
, a.is_link
|
||||||
|
, a.start_dt
|
||||||
|
, a.end_dt
|
||||||
|
, a.status
|
||||||
|
, (SELECT email FROM admin WHERE id = a.create_by ) AS create_by
|
||||||
|
, a.create_dt
|
||||||
|
, (SELECT email FROM admin WHERE id = a.update_by ) AS update_by
|
||||||
|
, a.update_dt
|
||||||
|
FROM menu_banner a
|
||||||
|
WHERE a.id = #{id}
|
||||||
|
AND deleted = 0
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getMessage" parameterType="java.lang.Long" resultMap="MessageResultMap" >
|
||||||
|
SELECT
|
||||||
|
*
|
||||||
|
FROM message
|
||||||
|
WHERE target_id = #{id}
|
||||||
|
AND type = 'BANNER'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertBanner" parameterType="com.caliverse.admin.domain.request.MenuRequest" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO menu_banner (title, is_link, start_dt, end_dt)
|
||||||
|
VALUES (#{title}, #{isLink}, #{startDt}, #{endDt})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="insertMessage" parameterType="map">
|
||||||
|
INSERT INTO message (target_id, type, title, content, language)
|
||||||
|
VALUES (#{id}, 'BANNER', #{title}, #{content}, #{language})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateBanner" parameterType="com.caliverse.admin.domain.request.MenuRequest">
|
||||||
|
UPDATE menu_banner SET target = #{target}
|
||||||
|
, is_reserve = #{isReserve}
|
||||||
|
, receive_type = #{receiveType}
|
||||||
|
, send_type =#{sendType}
|
||||||
|
, mail_type = #{mailType}
|
||||||
|
, send_dt = #{sendDt}
|
||||||
|
, update_by = #{updateBy}
|
||||||
|
, update_dt = NOW()
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteMessage" parameterType="map">
|
||||||
|
DELETE FROM message
|
||||||
|
WHERE target_id = #{mailId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="deleteBanner" parameterType="map">
|
||||||
|
UPDATE menu_banner SET deleted = 1
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getScheduleBannerList" resultMap="MenuResultMap">
|
||||||
|
SELECT id,
|
||||||
|
, a.title
|
||||||
|
, a.is_link
|
||||||
|
, a.start_dt
|
||||||
|
, a.end_dt
|
||||||
|
FROM menu_banner
|
||||||
|
WHERE send_status = 'WAIT'
|
||||||
|
AND deleted = false
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateBannerStatus" parameterType="map">
|
||||||
|
UPDATE menu_banner SET status = #{status}
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Reference in New Issue
Block a user