feat: LocalDate Foramatter 설정 반영

dev
minuk926 3 years ago
parent 0e6a08795e
commit f376877179

@ -88,8 +88,9 @@ public class ParkingController {
@Valid @Valid
@RequestBody @RequestBody
final MinSimsaTargetDto dto) { final MinSimsaTargetDto dto) {
service.saveParkingSimsaTargets2(dto); return RestResponse.of(service.saveParkingSimsaTargets(dto));
return RestResponse.of(HttpStatus.OK); //service.saveParkingSimsaTargets(dto);
//return RestResponse.of(HttpStatus.OK);
} }
@Operation(summary = "주정차의견진술심의등록" , description = "주정차의견진술심의등록") @Operation(summary = "주정차의견진술심의등록" , description = "주정차의견진술심의등록")

@ -1,5 +1,6 @@
package com.xit.biz.ctgy.dto; package com.xit.biz.ctgy.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
@ -52,19 +53,22 @@ public class MinSimsaTargetDto {
private String rcDate; private String rcDate;
@Schema(title = "심사시작일", example = "2022-03-23", description = "Input Description...") @Schema(title = "심사시작일", example = "2022-03-23", description = "Input Description...")
@DateTimeFormat(pattern="yyyy-MM-dd") //@DateTimeFormat(pattern="yyyy-MM-dd")
@JsonFormat(pattern="yyyy-MM-dd")
private LocalDate msSdate; private LocalDate msSdate;
@Schema(title = "심사시작시간", example = " ", description = "Input Description...") @Schema(title = "심사시작시간", example = " ", description = "Input Description...")
private String msStartsi; private String msStartsi;
@Schema(title = "심사종료일", example = "2022-03-24", description = "Input Description...") @Schema(title = "심사종료일", example = "2022-03-24", description = "Input Description...")
@DateTimeFormat(pattern="yyyy-MM-dd") //@DateTimeFormat(pattern="yyyy-MM-dd")
private Date msEdate; @JsonFormat(pattern="yyyy-MM-dd")
private LocalDate msEdate;
@Schema(title = "심사마감일", example = "2022-03-25", description = "Input Description...") @Schema(title = "심사마감일", example = "2022-03-25", description = "Input Description...")
@DateTimeFormat(pattern="yyyy-MM-dd") //@DateTimeFormat(pattern="yyyy-MM-dd")
private Date msCdate; @JsonFormat(pattern="yyyy-MM-dd")
private LocalDate msCdate;
@Schema(title = "심사마감시간", example = " ", description = "Input Description...") @Schema(title = "심사마감시간", example = " ", description = "Input Description...")
private String msClosesi; private String msClosesi;

@ -53,8 +53,8 @@ public interface IParkingRepository extends JpaRepository<MinSimsa680, Long>, IP
@Nonnull @Param("msChasu") Long msChasu, @Nonnull @Param("msChasu") Long msChasu,
@Nonnull @Param("msSdate") LocalDate msSdate, @Nonnull @Param("msSdate") LocalDate msSdate,
@Nonnull @Param("msStartsi") String msStartsi, @Nonnull @Param("msStartsi") String msStartsi,
@Nonnull @Param("msEdate") Date msEdate, @Nonnull @Param("msEdate") LocalDate msEdate,
@Nonnull @Param("msCdate") Date msCdate, @Nonnull @Param("msCdate") LocalDate msCdate,
@Nonnull @Param("msClosesi") String msClosesi, @Nonnull @Param("msClosesi") String msClosesi,
@Nonnull @Param("msResult") String msResult); @Nonnull @Param("msResult") String msResult);
} }

@ -0,0 +1,8 @@
package com.xit.biz.ctgy.repository;
import com.xit.biz.ctgy.entity.MinInfoBoard680;
import com.xit.biz.ctgy.entity.Tf680Recall;
import org.springframework.data.jpa.repository.JpaRepository;
public interface ITf680RecallRepository extends JpaRepository<Tf680Recall, Long> {
}

@ -19,9 +19,7 @@ public interface IParkingService {
Page<MinSimsa680> findAll(final MinSimsa680 minSimsa680, Pageable pageable); Page<MinSimsa680> findAll(final MinSimsa680 minSimsa680, Pageable pageable);
void saveParkingSimsaTargets2(MinSimsaTargetDto dto); List<MinSimsaTargetDto> saveParkingSimsaTargets(MinSimsaTargetDto dto);
void saveParkingSimsaTargets(MinSimsaTargetDto dto);
Page<MinSimsaReviewGroupDto> findMinSimsa680s2(final MinSimsa680 minSimsa680, Pageable pageable); Page<MinSimsaReviewGroupDto> findMinSimsa680s2(final MinSimsa680 minSimsa680, Pageable pageable);

@ -61,36 +61,7 @@ public class ParkingService implements IParkingService {
} }
@Override @Override
@Transactional public List<MinSimsaTargetDto> saveParkingSimsaTargets(MinSimsaTargetDto dto) {
@Modifying
public void saveParkingSimsaTargets(MinSimsaTargetDto dto) {
boolean isFirst = true;
for(Long rcCode : dto.getRcCodes()){
dto.setRcCode(rcCode);
if(isFirst) {
dto.setMsYear(dto.getMsSdate().toString().substring(0,4));
dto.setMsResult("0");
isFirst = false;
}
repository.insertSimsaTargetIntoSelect(dto.getMsYear(),
dto.getRcCode(),
dto.getMsChasu(),
dto.getMsSdate(),
dto.getMsStartsi(),
dto.getMsEdate(),
dto.getMsCdate(),
dto.getMsClosesi(),
dto.getMsResult());
}
}
@Override
public void saveParkingSimsaTargets2(MinSimsaTargetDto dto) {
boolean isFirst = true; boolean isFirst = true;
for(Long rcCode : dto.getRcCodes()) { for(Long rcCode : dto.getRcCodes()) {
@ -103,7 +74,9 @@ public class ParkingService implements IParkingService {
} }
mapper.insertSimsaTargetIntoSelect(dto); mapper.insertSimsaTargetIntoSelect(dto);
} }
return repository.findSimsaTargets(dto);
} }

@ -33,7 +33,6 @@ import org.springframework.web.servlet.i18n.CookieLocaleResolver;
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor; import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
import net.rakugakibox.util.YamlResourceBundle; import net.rakugakibox.util.YamlResourceBundle;
import java.time.Duration;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.MissingResourceException; import java.util.MissingResourceException;

@ -1,39 +0,0 @@
package com.xit.core.config.support;
import lombok.NonNull;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.datetime.DateFormatter;
import org.springframework.format.datetime.DateFormatterRegistrar;
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.format.support.FormattingConversionService;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import java.time.format.DateTimeFormatter;
/**
* LocalDate / LocalDateTime type
* 2022-03-24T11:30:09.184Z -> 2022-03-24 11:30:09
*/
@Configuration
public class DateTimeConfig extends WebMvcConfigurationSupport {
@NonNull
@Bean
@Override
public FormattingConversionService mvcConversionService() {
DefaultFormattingConversionService conversionService = new DefaultFormattingConversionService(false);
DateTimeFormatterRegistrar dateTimeRegistrar = new DateTimeFormatterRegistrar();
dateTimeRegistrar.setDateFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
dateTimeRegistrar.setDateTimeFormatter(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
dateTimeRegistrar.registerFormatters(conversionService);
DateFormatterRegistrar dateRegistrar = new DateFormatterRegistrar();
dateRegistrar.setFormatter(new DateFormatter("yyyy-MM-dd"));
dateRegistrar.registerFormatters(conversionService);
return conversionService;
}
}

@ -0,0 +1,28 @@
package com.xit.core.config.support;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.time.format.DateTimeFormatter;
/**
* LocalDate, LocalDateTime formatter
* Swagger WebMvcConfigurationSupport
*/
@Configuration
public class DateTimeFormatterConfig {
private static final String dateFormat = "yyyy-MM-dd";
private static final String dateTimeFormat = "yyyy-MM-dd HH:mm:ss";
@Bean
public Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {
return builder -> {
builder.simpleDateFormat(dateTimeFormat);
builder.serializers(new LocalDateSerializer(DateTimeFormatter.ofPattern(dateFormat)));
builder.serializers(new LocalDateTimeSerializer(DateTimeFormatter.ofPattern(dateTimeFormat)));
};
}
}

@ -24,6 +24,9 @@ import java.util.Collections;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE; import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
/**
* WebMvcConfigurationSupport extends swagger-ui
*/
@Configuration @Configuration
public class SpringDocApiConfig { public class SpringDocApiConfig {

@ -8,17 +8,19 @@ import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;
import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder; import org.springframework.security.crypto.scrypt.SCryptPasswordEncoder;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays;
//@Order(1) //@Order(1)
@Component //@Component
@Slf4j @Slf4j
public class XitFrameworkApplicationCommandLineRunner implements CommandLineRunner { public class XitFrameworkApplicationCommandLineRunner implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
// log.info("====================================================================================="); log.info("=====================================================================================");
// log.info("XitFrameworkApplicationCommandLineRunner Args: " + Arrays.toString(args)); log.info("XitFrameworkApplicationCommandLineRunner Args: " + Arrays.toString(args));
// log.info("====================================================================================="); log.info("=====================================================================================");
System.out.println(new BCryptPasswordEncoder().encode("gnadmin")); System.out.println(new BCryptPasswordEncoder().encode("gnadmin"));
//System.out.println(new SCryptPasswordEncoder().encode("gnadmin")); //System.out.println(new SCryptPasswordEncoder().encode("gnadmin"));

@ -13,9 +13,11 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*; import javax.persistence.*;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
/** /**
* *
* LocalDate foramtter
* @see com.xit.core.support.jpa.AuditorAwareConfig * @see com.xit.core.support.jpa.AuditorAwareConfig
*/ */
@Schema(name = "AuditEntity", description = "감사 필드 정의") @Schema(name = "AuditEntity", description = "감사 필드 정의")
@ -62,6 +64,16 @@ public class AuditEntity implements Serializable {
@ColumnDefault(value = "'Y'") @ColumnDefault(value = "'Y'")
private String useYn = "Y"; private String useYn = "Y";
@PrePersist
public void onPrePersist(){
this.createdBy = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
this.modifiedBy = this.createdBy;
}
@PreUpdate
public void onPreUpdate(){
this.modifiedBy = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
}
// @PrePersist // @PrePersist
// protected void onCreate() { // protected void onCreate() {

Loading…
Cancel
Save