Adding the LayoutController that will store the DDL for the page layouts
Also adding the getById function in the BaseController so that all CRUD APIs will automatically support that API call.
This commit is contained in:
parent
f8b382940d
commit
cef6946859
|
|
@ -39,6 +39,7 @@ public class SecurityConfig {
|
|||
@Bean
|
||||
public SecurityWebFilterChain securityWebFilterChain(ServerHttpSecurity http) {
|
||||
return http
|
||||
.csrf().disable()
|
||||
.authorizeExchange()
|
||||
.anyExchange()
|
||||
.authenticated()
|
||||
|
|
|
|||
|
|
@ -5,4 +5,5 @@ public interface Url {
|
|||
String VERSION = "/v1";
|
||||
String WIDGET_URL = BASE_URL + VERSION + "/widgets";
|
||||
String TENANT_URL = BASE_URL + VERSION + "/tenants";
|
||||
String LAYOUT_URL = BASE_URL + VERSION + "/layouts";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,12 @@ public abstract class BaseController<S extends CrudService, T extends BaseDomain
|
|||
.map(resources -> new ResponseDto<>(HttpStatus.OK.value(), resources, null));
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public Mono<ResponseDto<T>> getById(@PathVariable ID id) {
|
||||
return service.getById(id)
|
||||
.map(resources -> new ResponseDto<>(HttpStatus.OK.value(), resources, null));
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public Mono<ResponseDto<T>> update(@PathVariable ID id, @RequestBody T resource) throws Exception {
|
||||
return service.update(id, resource)
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.mobtools.server.controllers;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.security.core.annotation.AuthenticationPrincipal;
|
||||
import org.springframework.security.oauth2.core.user.OAuth2User;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.mobtools.server.controllers;
|
||||
|
||||
import com.mobtools.server.constants.Url;
|
||||
import com.mobtools.server.domains.Layout;
|
||||
import com.mobtools.server.services.LayoutService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping(Url.LAYOUT_URL)
|
||||
public class LayoutController extends BaseController<LayoutService, Layout, String> {
|
||||
|
||||
@Autowired
|
||||
public LayoutController(LayoutService service) {
|
||||
super(service);
|
||||
}
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@ public class WidgetController extends BaseController<WidgetService, Widget, Stri
|
|||
this.widgetService = service;
|
||||
}
|
||||
|
||||
@GetMapping("/{name}")
|
||||
@GetMapping("/name/{name}")
|
||||
public Mono<ResponseDto<Widget>> getByName(@PathVariable String name) {
|
||||
return widgetService.getByName(name)
|
||||
.map(widget -> new ResponseDto<>(HttpStatus.OK.value(), widget, null));
|
||||
|
|
|
|||
|
|
@ -32,9 +32,6 @@ public abstract class BaseDomain implements Persistable<String> {
|
|||
|
||||
protected Boolean deleted = false;
|
||||
|
||||
// @Version
|
||||
// protected Long version;
|
||||
|
||||
@Override
|
||||
public boolean isNew() {
|
||||
return this.getId() == null;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
package com.mobtools.server.domains;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
import net.minidev.json.JSONObject;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
@NoArgsConstructor
|
||||
@Document
|
||||
public class Layout extends BaseDomain {
|
||||
|
||||
JSONObject data;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
package com.mobtools.server.repositories;
|
||||
|
||||
import com.mobtools.server.domains.Layout;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface LayoutRepository extends BaseRepository<Layout, String>{
|
||||
}
|
||||
|
|
@ -59,6 +59,11 @@ public abstract class BaseService<R extends BaseRepository, T extends BaseDomain
|
|||
return repository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<T> getById(ID id) {
|
||||
return repository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<T> create(T widget) {
|
||||
return repository.save(widget);
|
||||
|
|
|
|||
|
|
@ -11,4 +11,6 @@ public interface CrudService<T extends BaseDomain, ID> {
|
|||
Mono<T> create(T resource);
|
||||
|
||||
Mono<T> update(ID id, T resource) throws Exception;
|
||||
|
||||
Mono<T> getById(ID id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
package com.mobtools.server.services;
|
||||
|
||||
import com.mobtools.server.domains.Layout;
|
||||
|
||||
public interface LayoutService extends CrudService<Layout, String> {
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.mobtools.server.services;
|
||||
|
||||
import com.mobtools.server.domains.Layout;
|
||||
import com.mobtools.server.repositories.LayoutRepository;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
|
||||
import org.springframework.data.mongodb.core.convert.MongoConverter;
|
||||
import org.springframework.stereotype.Service;
|
||||
import reactor.core.scheduler.Scheduler;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
public class LayoutServiceImpl extends BaseService<LayoutRepository, Layout, String> implements LayoutService {
|
||||
|
||||
@Autowired
|
||||
public LayoutServiceImpl(Scheduler scheduler,
|
||||
MongoConverter mongoConverter,
|
||||
ReactiveMongoTemplate reactiveMongoTemplate,
|
||||
LayoutRepository repository) {
|
||||
super(scheduler, mongoConverter, reactiveMongoTemplate, repository);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user