EnableSpringDataWebSupport for PageDto
This commit is contained in:
parent
a678cf3416
commit
baa42f0cc8
@ -20,10 +20,7 @@ export class Subscribed<T> {
|
|||||||
|
|
||||||
set value(value: T | null) {
|
set value(value: T | null) {
|
||||||
if (!this.isSame(value)) {
|
if (!this.isSame(value)) {
|
||||||
if (this.subscription) {
|
this.unsubscribe();
|
||||||
this.subscription.unsubscribe();
|
|
||||||
this.subscription = null;
|
|
||||||
}
|
|
||||||
if (value) {
|
if (value) {
|
||||||
this.subscription = this.subscribe(value, next => this.value = next);
|
this.subscription = this.subscribe(value, next => this.value = next);
|
||||||
}
|
}
|
||||||
@ -31,6 +28,13 @@ export class Subscribed<T> {
|
|||||||
this._value = value;
|
this._value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public unsubscribe() {
|
||||||
|
if (this.subscription) {
|
||||||
|
this.subscription.unsubscribe();
|
||||||
|
this.subscription = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private isSame(value: T | null) {
|
private isSame(value: T | null) {
|
||||||
if (this._value === null) {
|
if (this._value === null) {
|
||||||
return value === null;
|
return value === null;
|
||||||
|
|||||||
@ -17,10 +17,10 @@ export class Page<T> {
|
|||||||
|
|
||||||
static fromJson<T>(fromJson: FromJson<T>): FromJson<Page<T>> {
|
static fromJson<T>(fromJson: FromJson<T>): FromJson<Page<T>> {
|
||||||
return (json: any) => new Page<T>(
|
return (json: any) => new Page<T>(
|
||||||
validateNumber(json.size),
|
validateNumber(json.page.size),
|
||||||
validateNumber(json.number),
|
validateNumber(json.page.number),
|
||||||
validateNumber(json.totalPages),
|
validateNumber(json.page.totalPages),
|
||||||
validateNumber(json.totalElements),
|
validateNumber(json.page.totalElements),
|
||||||
validateList(json.content, fromJson),
|
validateList(json.content, fromJson),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,7 @@ export class GroupComponent implements OnInit, OnDestroy {
|
|||||||
this.timer.unsubscribe();
|
this.timer.unsubscribe();
|
||||||
this.timer = undefined;
|
this.timer = undefined;
|
||||||
}
|
}
|
||||||
|
this.group.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected changeTitle(group: Group, title: string) {
|
protected changeTitle(group: Group, title: string) {
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.ClassPathResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
|
import org.springframework.data.web.config.EnableSpringDataWebSupport;
|
||||||
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
|
||||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||||
@ -18,8 +19,11 @@ import org.springframework.web.servlet.resource.PathResourceResolver;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.springframework.data.web.config.EnableSpringDataWebSupport.PageSerializationMode.VIA_DTO;
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
@EnableSpringDataWebSupport(pageSerializationMode = VIA_DTO)
|
||||||
public class WebConfig implements WebMvcConfigurer {
|
public class WebConfig implements WebMvcConfigurer {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user