Skip to content

Commit

Permalink
Feat/qr uri 생성 기능 구현 (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
wonjunYou authored Feb 13, 2024
1 parent 2da650f commit 608e0f8
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 3 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/ddingdong-dev-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ on:
branches:
- develop # develop에 push될 때 실행

pull_request:
branches:
- develop

jobs:
build:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ public SecurityFilterChain filterChain(HttpSecurity http, JwtAuthService authSer
http
.authorizeHttpRequests()
.antMatchers(API_PREFIX + "/auth/**",
API_PREFIX + "/qr-stamps/**")
.permitAll()
API_PREFIX + "/qr-stamps/**")

.permitAll()
.antMatchers(GET,
API_PREFIX + "/clubs/**",
API_PREFIX + "/notices/**",
API_PREFIX + "/events/**",
API_PREFIX + "/banners/**")
.permitAll()
.antMatchers(API_PREFIX + "/admin/**").hasRole("ADMIN")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package ddingdong.ddingdongBE.common.utils;

import ddingdong.ddingdongBE.domain.event.controller.dto.response.EventQrResponse;
import org.springframework.stereotype.Component;

@Component
public class EventQrGenerator {

public static final String URI_PREFIX = "https://chart.apis.google.com/chart?cht=qr&chs=250x250&chl=";

public EventQrResponse generateQrCodeUri(String studentName, String studentNumber) {
String uri = URI_PREFIX + "https://ddingdong.club/event?studentName=" + studentName + "%26" + "studentNumber=" + studentNumber;

return EventQrResponse.of(uri);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ddingdong.ddingdongBE.domain.event.controller;

import ddingdong.ddingdongBE.common.utils.EventQrGenerator;
import ddingdong.ddingdongBE.domain.event.controller.dto.response.EventQrResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@RequestMapping("/server/events")
public class EventController {

private final EventQrGenerator eventQrGenerator;

@GetMapping("/qr")
public EventQrResponse generateQrCode(
@RequestParam("studentName") String studentName,
@RequestParam("studentNumber") String studentNumber
) {
return eventQrGenerator.generateQrCodeUri(studentName, studentNumber);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package ddingdong.ddingdongBE.domain.event.controller.dto.response;

import lombok.Builder;
import lombok.Getter;

@Getter
public class EventQrResponse {

private String uri;

@Builder
public EventQrResponse(String uri) {
this.uri = uri;
}

public static EventQrResponse of(String uri) {
return EventQrResponse.builder()
.uri(uri)
.build();
}
}
2 changes: 1 addition & 1 deletion src/main/resources/application-local.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ spring:
on-profile: local

datasource:
url: jdbc:h2:tcp://localhost/~/projects/ddingdong/ddingdong;
url: jdbc:h2:tcp://localhost/~/projects/ddingdong/ddingdong;NON_KEYWORDS=user;
driver-class-name: org.h2.Driver
username: sa
password:
Expand Down

0 comments on commit 608e0f8

Please sign in to comment.