Light Blue Pointer
본문 바로가기

Developing/개발일지53

2023-12-18, Today I Leanred ⭐Java Split dot(".") -> ("\\.") Regex에 해당되어서 바꿔줘야 함 str.split("\\."); ⚠️⚠️ (EnumType.ORDINAL)으로 하면 0,1로 저장되는데 중간에 뭐가 들어오거나 순서가 바뀌면 다 틀어져서 실제로 실무에서는 쓰지 않는다고 함 @Entity public class Channel { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id", nullable = false) private Long id; private String name; @Enumerated(EnumType.ORDINAL) private Type type; public enum Type{ PUBLIC,PR.. 2023. 12. 18.
2023-12-15, Today I Learned 오늘 한 일 todolist 프로젝트 1. try catch문으로 가득한 controller -> @RestControllerAdvice 사용해서 예외 공동화 처리 2. service단의 interface와 구현체 분리함 Q. 왜 분리해야 할까? 좀 찾아봄 Purpose of service interface class in spring boot 1. The first and most important reason is testability. You can create mocks of service interface and test your code easily, if you cannot create mocks using a mocking library then you can create test stub.. 2023. 12. 15.
2023-12-14, Today I Learned WebSecurityConfig @Bean // 필터 public JwtAuthorizationFilter jwtAuthorizationFilter() { return new JwtAuthorizationFilter(jwtUtil, userDetailsService, objectMapper); } -> 저기서 objectMapper를 왜 넣어주는 건지 궁금해서 10분동안 뒤적뒤적 했는데 그냥 생성자로 주입해주는 거 같다 @RequiredArgsConstructor public class JwtAuthorizationFilter extends OncePerRequestFilter { private final JwtUtil jwtUtil; private final UserDetailsService userD.. 2023. 12. 14.
2023-12-12, Today I Learned ⭐How to update a value, given a key in a hashmap? map.put(key, map.get(key) + 1); 2023. 12. 12.
2023-12-11, Today I Learned ⭐Arraylist.contains() in Java // creating an Empty Integer ArrayList ArrayList arr = new ArrayList(4); // using add() to initialize values // [1, 2, 3, 4] arr.add(1); arr.add(2); arr.add(3); arr.add(4); // use contains() to check if the element // 2 exits or not boolean ans = arr.contains(2); if (ans) System.out.println("The list contains 2"); else System.out.println("The list does not contains .. 2023. 12. 11.
2023-12-08, Today I Learned 오늘 한 일 주문 승인처리, 배달 완료처리 Response타입 개선, 에러 처리, Price 형식 지정, 내가 찜한 아이템 보기 기능 구현, 로그아웃 기능 구현 오늘 개발하는데 레고 조립하는거같고 뭔가 엄청 재밌었다 ㅋㅋㅋㅋㅋㅋ 어떤건 글쓴이가 가능하면 안되고 어떤건 댓글 단 사람(주문 신청한 사람)만 가능해야 하고 어떤건 글쓴이만 가능해야 하고 구분하면서 코드짜는게 너무 재밌었음 ㅋㅋㅋ 로직 개발이 제일 재밌는 파트인 거 같다 요청 승인할때 이미 rejected/confirmed 된 거는 이제 변하면 안 되니까 boolean도 주고싶음 -> boolean으로 했다가 나중에 Status Enum으로 또 바꿨다 public void reject(){ if(this.completed == true){ thr.. 2023. 12. 8.
2023-12-07, Today I Leanred 오늘 한 일 오늘도 유사 당근마켓(햇살마켓) 개발을 계속 했다 1. User → Seller로 변경 UserId를 Item에 넣어두고 있었는데 판매자 프로필과 구매자 프로필을 따로따로 하기로 해서 Item에는 User대신 Seller를 넣었다 2. 주문(구매 요청) 기능 만들기 주문 CRUD는 오늘 다 했다! 내일 할 일 주문 승인처리, 배송 완료처리 1. User → Seller로 변경 @ManyToOne @JoinColumn(name = "seller_id") private Seller seller; 전에 User였던 것을 Seller로 바꾸니까 그냥 됐음 2. 주문(구매 요청) 기능 만들기 2-1. Order Entity를 생성함 @Getter @Entity @Table(name = "orders".. 2023. 12. 7.
2023-12-06, Today I Leanred 오늘 한 일 햇살마켓(유사 당근마켓 프로그램) 개발하면서 게시글 CRUD를 하고 Authorization이 넘어오면 로그인된 user정보 이용해서 유저 확인 후 수행하기() 오늘 알게된 것 ⭐ResponseDto에 Getter를 달지 않으면 객체가 Json으로 변환이 안 되는 것 같다 ⭐HttpStatus.CREATED → HttpStatusCode 임 ⭐HttpStatus.CREATED.value() → int임 ⭐db에는 created_at으로 저장되더라도 Entity에는 createdAt으로 써야한다 그렇지 않으면 찾지 못함 ⭐제너릭 타입으로 리턴타입을 감싸서 항상 공통적으로 덧붙여지는 정보를 전달해줄 수 있다 오늘 개선한 것 💡개선 : return 타입으로 commonresponse돌려보내고 싶어.. 2023. 12. 6.
2023-12-05, Today I Learned JSONArray items = jsonObject.getJSONArray("items"); List itemDtoList = new ArrayList(); for (Object item : items) { ItemDto itemDto = new ItemDto((JSONObject) item); itemDtoList.add(itemDto); } 이 코드를 보고 JSONObject를 꺼내는데 그냥 JSONObject로 받으면 되지 않나 왜 Object로 받아서 (JSONObject)로 type casting을 다시 하는지 의문이었는데 for each에서는 typecasitng을 못 쓴다고 함 JSONArray arr = ...; // 2023. 12. 5.