Skip to content

Commit

Permalink
Merge pull request #361 from ungzzang/master
Browse files Browse the repository at this point in the history
배너 승인 및 각각의 사진들(배너) 활성화/비활성화 가능
  • Loading branch information
Leejungmin0426 authored Feb 27, 2025
2 parents fd74cff + 8c21e9c commit 65fadc9
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@

import com.green.acamatch.entity.banner.BannerPic;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public interface BannerPicRepository extends JpaRepository<BannerPic, Long> {

//배너 사진별로 비활성화/활성화
@Transactional
@Modifying
@Query(" update BannerPic a set a.bannerShow =:bannerShow where a.banner.acaId =:acaId and a.bannerPosition =:bannerPosition")
int updateBannerPicShowByAcaIdAndBannerPosition(Long acaId, int bannerPosition, int bannerShow);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.green.acamatch.academy.Controller;

import com.green.acamatch.academy.Service.BannerService;
import com.green.acamatch.academy.banner.model.BannerPicShowUpdateReq;
import com.green.acamatch.academy.banner.model.BannerTypeUpdateReq;
import com.green.acamatch.academy.banner.model.BannerPostReq;
import com.green.acamatch.academy.model.JW.AcademyMessage;
Expand Down Expand Up @@ -33,13 +34,23 @@ public ResultResponse<Integer> postBanner(@RequestPart MultipartFile topBannerPi
.build();
}

@PostMapping("agree")
@PutMapping("agree")
@Operation(summary = "배너승인")
public ResultResponse<Integer> putBannerAgree(@RequestBody BannerTypeUpdateReq req) {
public ResultResponse<Integer> putBannerType(@RequestBody BannerTypeUpdateReq req) {
bannerService.updateBannerType(req.getAcaId(), req.getBannerType());
return ResultResponse.<Integer>builder()
.resultMessage(academyMessage.getMessage())
.resultData(1)
.build();
}

@PutMapping
@Operation(summary = "배너 각각 활성화/비활성화", description = "position은 상: 1, 하: 2, 좌: 3, 우:4, show는 활성화: 1, 비활성화: 2")
public ResultResponse<Integer> putBannerShow(@RequestBody BannerPicShowUpdateReq req) {
bannerService.updateBannerShow(req.getAcaId(), req.getBannerPosition(), req.getBannerShow());
return ResultResponse.<Integer>builder()
.resultMessage(academyMessage.getMessage())
.resultData(1)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,15 @@ public int updateBannerType(Long acaId, int bannerType) {
academyMessage.setMessage("배너 승인이 완료되었습니다.");
return 1;
}

@Transactional
public int updateBannerShow(Long acaId, int bannerPosition, int bannerShow) {
bannerPicRepository.updateBannerPicShowByAcaIdAndBannerPosition(acaId, bannerPosition, bannerShow);
if(bannerShow == 1) {
academyMessage.setMessage("배너가 활성화 되었습니다.");
}else {
academyMessage.setMessage("배너가 비활성화 되었습니다.");
}
return 1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.green.acamatch.academy.banner.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
public class BannerPicShowUpdateReq {
@Schema(title = "학원pk")
private Long acaId;
@Schema(title = "배너위치", description = "상: 1, 하: 2, 좌: 3, 우: 4")
private int bannerPosition;
@Schema(title = "배너 활성화/비활성화", description = "활성화: 1, 비활성화: 0")
private int bannerShow;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.green.acamatch.academy.banner.model;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
Expand All @@ -8,6 +9,8 @@
@Setter
@ToString
public class BannerTypeUpdateReq {
@Schema(title = "학원pk")
private Long acaId;
@Schema(title = "배너승인여부")
private int bannerType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class BannerPic extends CreatedAt {
private Banner banner;

@Column(nullable = false)
private Integer bannerShow = 0;
private Integer bannerShow = 1;

@Column
private int bannerPosition;
Expand Down

0 comments on commit 65fadc9

Please sign in to comment.