refactor base smartproc
This commit is contained in:
@ -0,0 +1,30 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.CreationTimestamp;
|
||||
import org.hibernate.annotations.UpdateTimestamp;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.MappedSuperclass;
|
||||
import java.io.Serializable;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Data
|
||||
@MappedSuperclass
|
||||
public class BaseEntity implements Serializable {
|
||||
|
||||
@Column(name = "created_by", length = 50)
|
||||
private String createdBy;
|
||||
|
||||
@Column(name = "created_time", nullable = false, updatable=false)
|
||||
@CreationTimestamp
|
||||
private Timestamp createdTime;
|
||||
|
||||
@Column(name = "updated_by", length = 50)
|
||||
private String updatedBy;
|
||||
|
||||
@Column(name = "updated_time")
|
||||
@UpdateTimestamp
|
||||
private Timestamp updatedTime;
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public interface BaseInterfaceRequest extends Serializable {
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public interface BaseInterfaceResponse extends Serializable {
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class BasePaginationRequest extends BaseRequest{
|
||||
|
||||
|
||||
private Integer pageSize;
|
||||
private Integer pageNumber;
|
||||
private String sortBy;
|
||||
private String sortType;
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import com.iconplus.smartproc.helper.model.Pagination;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class BasePaginationResponse extends BaseResponse{
|
||||
|
||||
private Pagination pagination;
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class BaseRequest implements Serializable {
|
||||
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package com.iconplus.smartproc.helper.base;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||
public class BaseResponse implements Serializable {
|
||||
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.iconplus.smartproc.helper.model;
|
||||
|
||||
import com.iconplus.smartproc.helper.base.BaseRequest;
|
||||
|
||||
public class EmptyRequest extends BaseRequest {
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.iconplus.smartproc.helper.model;
|
||||
|
||||
import brave.internal.Nullable;
|
||||
import com.iconplus.smartproc.helper.base.BaseResponse;
|
||||
|
||||
@Nullable
|
||||
public class EmptyResponse extends BaseResponse {
|
||||
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.iconplus.smartproc.helper.model;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class Pagination implements Serializable {
|
||||
private Integer pageSize;
|
||||
private Integer currentPage;
|
||||
private Integer totalPages;
|
||||
private Long totalRecords;
|
||||
private Boolean isFirstPage;
|
||||
private Boolean isLastPage;
|
||||
}
|
||||
|
@ -0,0 +1,8 @@
|
||||
package com.iconplus.smartproc.helper.service;
|
||||
|
||||
import com.iconplus.smartproc.helper.base.BaseInterfaceRequest;
|
||||
import com.iconplus.smartproc.helper.base.BaseInterfaceResponse;
|
||||
|
||||
public interface BaseInterfaceService<T extends BaseInterfaceRequest, V extends BaseInterfaceResponse> {
|
||||
V execute(T input);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.iconplus.smartproc.helper.service;
|
||||
|
||||
import com.iconplus.smartproc.helper.base.BasePaginationRequest;
|
||||
import com.iconplus.smartproc.helper.base.BasePaginationResponse;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public abstract class BasePaginationService<T extends BasePaginationRequest, V extends BasePaginationResponse> implements BaseService<T, V>{
|
||||
|
||||
@Value("${default.page.size}")
|
||||
private Integer pageSize;
|
||||
|
||||
@Value("${default.page.number}")
|
||||
private Integer pageNumber;
|
||||
|
||||
@Value("${default.page.sortBy}")
|
||||
private String sortBy;
|
||||
|
||||
@Value("${default.page.sortType}")
|
||||
private String sortType;
|
||||
|
||||
@Value("${default.page.maxPageSize}")
|
||||
private Integer maxPageSize;
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.iconplus.smartproc.helper.service;
|
||||
|
||||
|
||||
import com.iconplus.smartproc.helper.base.BaseRequest;
|
||||
import com.iconplus.smartproc.helper.base.BaseResponse;
|
||||
|
||||
public interface BaseService<T extends BaseRequest, V extends BaseResponse> {
|
||||
V execute(T input);
|
||||
}
|
Reference in New Issue
Block a user