mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2026-01-20 16:51:03 -05:00
moving packages
This commit is contained in:
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Query projections for the catalog domain.
|
||||
*/
|
||||
package group.goforward.battlbuilder.catalog.query;
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Command line runners and CLI utilities.
|
||||
*/
|
||||
package group.goforward.battlbuilder.cli;
|
||||
@@ -1,74 +1,74 @@
|
||||
package group.goforward.battlbuilder.utils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
*/
|
||||
public class ApiResponse<T> {
|
||||
|
||||
private static final String API_SUCCESS = "success";
|
||||
private static final String API_FAILURE = "failure";
|
||||
private static final String API_ERROR = "error";
|
||||
private String[] messages;
|
||||
private T data;
|
||||
|
||||
|
||||
|
||||
private String status;
|
||||
private LocalDateTime timestamp;
|
||||
private ApiResponse(String status, String[] message, T data) {
|
||||
this.status = status;
|
||||
this.messages = message;
|
||||
this.data = data;
|
||||
this.timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String message, T data) {
|
||||
String[] msg = {message}; // ✅ Include the message
|
||||
return new ApiResponse<>(API_ERROR, msg, data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success(T data, String emailSentSuccessfully) {
|
||||
String[] msg = {};
|
||||
return new ApiResponse<>(API_SUCCESS, msg, data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String[] messages) {
|
||||
return new ApiResponse<>(API_ERROR, messages, null);
|
||||
}
|
||||
public static <T> ApiResponse<T> error(String message) {
|
||||
String[] msg = {};
|
||||
return new ApiResponse<>(API_ERROR, msg, null);
|
||||
}
|
||||
|
||||
|
||||
public String[] getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public void setMessages(String[] messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
public T getData() {return data;}
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
package group.goforward.battlbuilder.utils;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
*/
|
||||
public class ApiResponse<T> {
|
||||
|
||||
private static final String API_SUCCESS = "success";
|
||||
private static final String API_FAILURE = "failure";
|
||||
private static final String API_ERROR = "error";
|
||||
private String[] messages;
|
||||
private T data;
|
||||
|
||||
|
||||
|
||||
private String status;
|
||||
private LocalDateTime timestamp;
|
||||
private ApiResponse(String status, String[] message, T data) {
|
||||
this.status = status;
|
||||
this.messages = message;
|
||||
this.data = data;
|
||||
this.timestamp = LocalDateTime.now();
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String message, T data) {
|
||||
String[] msg = {message}; // ✅ Include the message
|
||||
return new ApiResponse<>(API_ERROR, msg, data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> success(T data, String emailSentSuccessfully) {
|
||||
String[] msg = {};
|
||||
return new ApiResponse<>(API_SUCCESS, msg, data);
|
||||
}
|
||||
|
||||
public static <T> ApiResponse<T> error(String[] messages) {
|
||||
return new ApiResponse<>(API_ERROR, messages, null);
|
||||
}
|
||||
public static <T> ApiResponse<T> error(String message) {
|
||||
String[] msg = {};
|
||||
return new ApiResponse<>(API_ERROR, msg, null);
|
||||
}
|
||||
|
||||
|
||||
public String[] getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
public void setMessages(String[] messages) {
|
||||
this.messages = messages;
|
||||
}
|
||||
|
||||
public T getData() {return data;}
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public LocalDateTime getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(LocalDateTime timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
@@ -1,20 +1,20 @@
|
||||
package group.goforward.battlbuilder.utils;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
public class Counter {
|
||||
|
||||
Integer count = 0;
|
||||
public void addOne() {
|
||||
count +=1;
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
private void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
}
|
||||
package group.goforward.battlbuilder.utils;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
public class Counter {
|
||||
|
||||
Integer count = 0;
|
||||
public void addOne() {
|
||||
count +=1;
|
||||
}
|
||||
|
||||
public Integer getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
private void setCount(Integer count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,22 +1,22 @@
|
||||
package group.goforward.battlbuilder.configuration;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class CacheConfig {
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager() {
|
||||
// Must match the @Cacheable value(s) used in controllers/services.
|
||||
// ProductV1Controller uses: "gunbuilderProductsV1"
|
||||
return new ConcurrentMapCacheManager(
|
||||
"gunbuilderProductsV1",
|
||||
"gunbuilderProducts" // keep if anything else still references it
|
||||
);
|
||||
}
|
||||
package group.goforward.battlbuilder.configuration;
|
||||
|
||||
import org.springframework.cache.CacheManager;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cache.concurrent.ConcurrentMapCacheManager;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@EnableCaching
|
||||
public class CacheConfig {
|
||||
|
||||
@Bean
|
||||
public CacheManager cacheManager() {
|
||||
// Must match the @Cacheable value(s) used in controllers/services.
|
||||
// ProductV1Controller uses: "gunbuilderProductsV1"
|
||||
return new ConcurrentMapCacheManager(
|
||||
"gunbuilderProductsV1",
|
||||
"gunbuilderProducts" // keep if anything else still references it
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,84 @@
|
||||
// src/main/java/com/example/config/CorsConfig.java
|
||||
package group.goforward.battlbuilder.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
|
||||
// Allow credentials
|
||||
config.setAllowCredentials(true);
|
||||
|
||||
// Allow Angular development server
|
||||
config.setAllowedOrigins(Arrays.asList(
|
||||
"http://localhost:4200",
|
||||
"http://localhost:4201",
|
||||
"http://localhost:8070",
|
||||
"https://localhost:8070",
|
||||
"http://localhost:8080",
|
||||
"https://localhost:8080",
|
||||
"http://localhost:3000",
|
||||
"https://localhost:3000",
|
||||
"https://localhost:3000/gunbuilder",
|
||||
"http://localhost:3000/gunbuilder",
|
||||
"https://localhost:3000/builder",
|
||||
"http://localhost:3000/builder"
|
||||
));
|
||||
|
||||
// Allow all headers
|
||||
config.addAllowedHeader("*");
|
||||
|
||||
// Allow all HTTP methods
|
||||
config.setAllowedMethods(Arrays.asList(
|
||||
"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"
|
||||
));
|
||||
|
||||
// Expose headers
|
||||
config.setExposedHeaders(Arrays.asList(
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"X-Total-Count"
|
||||
));
|
||||
|
||||
// Max age for preflight cache (1 hour)
|
||||
config.setMaxAge(3600L);
|
||||
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Alternative using WebMvcConfigurer:
|
||||
/*
|
||||
package group.goforward.citysites.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/api/**")
|
||||
.allowedOrigins("http://localhost:4200")
|
||||
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
||||
// src/main/java/com/example/config/CorsConfig.java
|
||||
package group.goforward.battlbuilder.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.cors.CorsConfiguration;
|
||||
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
|
||||
import org.springframework.web.filter.CorsFilter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@Configuration
|
||||
public class CorsConfig {
|
||||
|
||||
@Bean
|
||||
public CorsFilter corsFilter() {
|
||||
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
|
||||
CorsConfiguration config = new CorsConfiguration();
|
||||
|
||||
// Allow credentials
|
||||
config.setAllowCredentials(true);
|
||||
|
||||
// Allow Angular development server
|
||||
config.setAllowedOrigins(Arrays.asList(
|
||||
"http://localhost:4200",
|
||||
"http://localhost:4201",
|
||||
"http://localhost:8070",
|
||||
"https://localhost:8070",
|
||||
"http://localhost:8080",
|
||||
"https://localhost:8080",
|
||||
"http://localhost:3000",
|
||||
"https://localhost:3000",
|
||||
"https://localhost:3000/gunbuilder",
|
||||
"http://localhost:3000/gunbuilder",
|
||||
"https://localhost:3000/builder",
|
||||
"http://localhost:3000/builder"
|
||||
));
|
||||
|
||||
// Allow all headers
|
||||
config.addAllowedHeader("*");
|
||||
|
||||
// Allow all HTTP methods
|
||||
config.setAllowedMethods(Arrays.asList(
|
||||
"GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS"
|
||||
));
|
||||
|
||||
// Expose headers
|
||||
config.setExposedHeaders(Arrays.asList(
|
||||
"Authorization",
|
||||
"Content-Type",
|
||||
"X-Total-Count"
|
||||
));
|
||||
|
||||
// Max age for preflight cache (1 hour)
|
||||
config.setMaxAge(3600L);
|
||||
|
||||
source.registerCorsConfiguration("/**", config);
|
||||
return new CorsFilter(source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Alternative using WebMvcConfigurer:
|
||||
/*
|
||||
package group.goforward.citysites.config;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.CorsRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
@Configuration
|
||||
public class WebConfig implements WebMvcConfigurer {
|
||||
|
||||
@Override
|
||||
public void addCorsMappings(CorsRegistry registry) {
|
||||
registry.addMapping("/api/**")
|
||||
.allowedOrigins("http://localhost:4200")
|
||||
.allowedMethods("GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS")
|
||||
.allowedHeaders("*")
|
||||
.allowCredentials(true)
|
||||
.maxAge(3600);
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,10 +1,10 @@
|
||||
package group.goforward.battlbuilder.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
@Configuration
|
||||
|
||||
public class JpaConfig {
|
||||
// Enables @CreatedDate / @LastModifiedDate processing
|
||||
package group.goforward.battlbuilder.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
//import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
|
||||
|
||||
@Configuration
|
||||
|
||||
public class JpaConfig {
|
||||
// Enables @CreatedDate / @LastModifiedDate processing
|
||||
}
|
||||
@@ -1,50 +1,50 @@
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.Brand;
|
||||
import group.goforward.battlbuilder.repos.BrandRepository;
|
||||
import group.goforward.battlbuilder.services.BrandService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/v1/brands", "/api/brands"})
|
||||
public class BrandController {
|
||||
@Autowired
|
||||
private BrandRepository repo;
|
||||
@Autowired
|
||||
private BrandService brandService;
|
||||
//@Cacheable(value="getAllStates")
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<Brand>> getAllBrands() {
|
||||
List<Brand> brand = repo.findAll();
|
||||
return ResponseEntity.ok(brand);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Brand> getAllBrandsById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public ResponseEntity<Brand> createbrand(@RequestBody Brand item) {
|
||||
Brand created = brandService.save(item);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
|
||||
return brandService.findById(id)
|
||||
.map(item -> {
|
||||
brandService.deleteById(id);
|
||||
return ResponseEntity.noContent().<Void>build();
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.Brand;
|
||||
import group.goforward.battlbuilder.repos.BrandRepository;
|
||||
import group.goforward.battlbuilder.services.BrandService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/v1/brands", "/api/brands"})
|
||||
public class BrandController {
|
||||
@Autowired
|
||||
private BrandRepository repo;
|
||||
@Autowired
|
||||
private BrandService brandService;
|
||||
//@Cacheable(value="getAllStates")
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<Brand>> getAllBrands() {
|
||||
List<Brand> brand = repo.findAll();
|
||||
return ResponseEntity.ok(brand);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Brand> getAllBrandsById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public ResponseEntity<Brand> createbrand(@RequestBody Brand item) {
|
||||
Brand created = brandService.save(item);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
|
||||
return brandService.findById(id)
|
||||
.map(item -> {
|
||||
brandService.deleteById(id);
|
||||
return ResponseEntity.noContent().<Void>build();
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
@@ -1,34 +1,34 @@
|
||||
package group.goforward.battlbuilder.controllers.api;
|
||||
|
||||
import group.goforward.battlbuilder.model.Build;
|
||||
import group.goforward.battlbuilder.repos.BuildRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/api/builds")
|
||||
public class BuildController {
|
||||
@Autowired
|
||||
private BuildRepository repo;
|
||||
@Autowired
|
||||
// private BuildsService service;
|
||||
//@Cacheable(value="getAllStates")
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<Build>> getAll() {
|
||||
List<Build> builds = repo.findAll();
|
||||
return ResponseEntity.ok(builds);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Build> getAllBuildsById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package group.goforward.battlbuilder.controllers.api;
|
||||
|
||||
import group.goforward.battlbuilder.model.Build;
|
||||
import group.goforward.battlbuilder.repos.BuildRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/v1/api/builds")
|
||||
public class BuildController {
|
||||
@Autowired
|
||||
private BuildRepository repo;
|
||||
@Autowired
|
||||
// private BuildsService service;
|
||||
//@Cacheable(value="getAllStates")
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<Build>> getAll() {
|
||||
List<Build> builds = repo.findAll();
|
||||
return ResponseEntity.ok(builds);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Build> getAllBuildsById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,40 +1,40 @@
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.services.MerchantFeedImportService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/admin/imports", "/api/v1/admin/imports"})
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class ImportController {
|
||||
|
||||
private final MerchantFeedImportService merchantFeedImportService;
|
||||
|
||||
public ImportController(MerchantFeedImportService merchantFeedImportService) {
|
||||
this.merchantFeedImportService = merchantFeedImportService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full product + offer import for a merchant.
|
||||
*
|
||||
* POST /admin/imports/{merchantId}
|
||||
*/
|
||||
@PostMapping("/{merchantId}")
|
||||
public ResponseEntity<Void> importMerchant(@PathVariable Integer merchantId) {
|
||||
merchantFeedImportService.importMerchantFeed(merchantId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Offers-only sync (price/stock) for a merchant.
|
||||
*
|
||||
* POST /admin/imports/{merchantId}/offers-only
|
||||
*/
|
||||
@PostMapping("/{merchantId}/offers-only")
|
||||
public ResponseEntity<Void> syncOffersOnly(@PathVariable Integer merchantId) {
|
||||
merchantFeedImportService.syncOffersOnly(merchantId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.services.MerchantFeedImportService;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/admin/imports", "/api/v1/admin/imports"})
|
||||
|
||||
@CrossOrigin(origins = "http://localhost:3000")
|
||||
public class ImportController {
|
||||
|
||||
private final MerchantFeedImportService merchantFeedImportService;
|
||||
|
||||
public ImportController(MerchantFeedImportService merchantFeedImportService) {
|
||||
this.merchantFeedImportService = merchantFeedImportService;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full product + offer import for a merchant.
|
||||
*
|
||||
* POST /admin/imports/{merchantId}
|
||||
*/
|
||||
@PostMapping("/{merchantId}")
|
||||
public ResponseEntity<Void> importMerchant(@PathVariable Integer merchantId) {
|
||||
merchantFeedImportService.importMerchantFeed(merchantId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Offers-only sync (price/stock) for a merchant.
|
||||
*
|
||||
* POST /admin/imports/{merchantId}/offers-only
|
||||
*/
|
||||
@PostMapping("/{merchantId}/offers-only")
|
||||
public ResponseEntity<Void> syncOffersOnly(@PathVariable Integer merchantId) {
|
||||
merchantFeedImportService.syncOffersOnly(merchantId);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,25 @@
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.Merchant;
|
||||
import group.goforward.battlbuilder.repos.MerchantRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/admin", "/api/v1/admin"})
|
||||
public class MerchantDebugController {
|
||||
|
||||
private final MerchantRepository merchantRepository;
|
||||
|
||||
public MerchantDebugController(MerchantRepository merchantRepository) {
|
||||
this.merchantRepository = merchantRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/debug/merchants")
|
||||
public List<Merchant> listMerchants() {
|
||||
return merchantRepository.findAll();
|
||||
}
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.Merchant;
|
||||
import group.goforward.battlbuilder.repos.MerchantRepository;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/admin", "/api/v1/admin"})
|
||||
public class MerchantDebugController {
|
||||
|
||||
private final MerchantRepository merchantRepository;
|
||||
|
||||
public MerchantDebugController(MerchantRepository merchantRepository) {
|
||||
this.merchantRepository = merchantRepository;
|
||||
}
|
||||
|
||||
@GetMapping("/debug/merchants")
|
||||
public List<Merchant> listMerchants() {
|
||||
return merchantRepository.findAll();
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,56 @@
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.web.dto.ProductOfferDto;
|
||||
import group.goforward.battlbuilder.web.dto.ProductSummaryDto;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LEGACY CONTROLLER (Deprecated)
|
||||
*
|
||||
* Do not add new features here.
|
||||
* Canonical API lives in ProductV1Controller (/api/v1/products).
|
||||
*
|
||||
* This exists only to keep older clients working temporarily.
|
||||
* Disable by default using:
|
||||
* app.api.legacy.enabled=false
|
||||
*
|
||||
* NOTE:
|
||||
* Even when disabled, Spring still compiles this class. So it must not reference
|
||||
* missing services/methods.
|
||||
*/
|
||||
@Deprecated
|
||||
@RestController
|
||||
@RequestMapping({"/api/products", "/api/v1/products"})
|
||||
@CrossOrigin
|
||||
@ConditionalOnProperty(name = "app.api.legacy.enabled", havingValue = "true", matchIfMissing = false)
|
||||
public class ProductController {
|
||||
|
||||
private static final String MSG =
|
||||
"Legacy endpoint disabled. Use /api/v1/products instead.";
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<?> getProducts(
|
||||
@RequestParam(defaultValue = "AR-15") String platform,
|
||||
@RequestParam(required = false, name = "partRoles") List<String> partRoles
|
||||
) {
|
||||
// Legacy disabled by design (Option B cleanup)
|
||||
return ResponseEntity.status(410).body(MSG);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/offers")
|
||||
public ResponseEntity<?> getOffersForProduct(@PathVariable("id") Integer productId) {
|
||||
return ResponseEntity.status(410).body(MSG);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<?> getProductById(@PathVariable("id") Integer productId) {
|
||||
return ResponseEntity.status(410).body(MSG);
|
||||
}
|
||||
|
||||
// If you *really* need typed responses for an old client, we can re-add
|
||||
// a real service layer once we align on the actual ProductQueryService API.
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.web.dto.ProductOfferDto;
|
||||
import group.goforward.battlbuilder.web.dto.ProductSummaryDto;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* LEGACY CONTROLLER (Deprecated)
|
||||
*
|
||||
* Do not add new features here.
|
||||
* Canonical API lives in ProductV1Controller (/api/v1/products).
|
||||
*
|
||||
* This exists only to keep older clients working temporarily.
|
||||
* Disable by default using:
|
||||
* app.api.legacy.enabled=false
|
||||
*
|
||||
* NOTE:
|
||||
* Even when disabled, Spring still compiles this class. So it must not reference
|
||||
* missing services/methods.
|
||||
*/
|
||||
@Deprecated
|
||||
@RestController
|
||||
@RequestMapping({"/api/products", "/api/v1/products"})
|
||||
@CrossOrigin
|
||||
@ConditionalOnProperty(name = "app.api.legacy.enabled", havingValue = "true", matchIfMissing = false)
|
||||
public class ProductController {
|
||||
|
||||
private static final String MSG =
|
||||
"Legacy endpoint disabled. Use /api/v1/products instead.";
|
||||
|
||||
@GetMapping
|
||||
public ResponseEntity<?> getProducts(
|
||||
@RequestParam(defaultValue = "AR-15") String platform,
|
||||
@RequestParam(required = false, name = "partRoles") List<String> partRoles
|
||||
) {
|
||||
// Legacy disabled by design (Option B cleanup)
|
||||
return ResponseEntity.status(410).body(MSG);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}/offers")
|
||||
public ResponseEntity<?> getOffersForProduct(@PathVariable("id") Integer productId) {
|
||||
return ResponseEntity.status(410).body(MSG);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<?> getProductById(@PathVariable("id") Integer productId) {
|
||||
return ResponseEntity.status(410).body(MSG);
|
||||
}
|
||||
|
||||
// If you *really* need typed responses for an old client, we can re-add
|
||||
// a real service layer once we align on the actual ProductQueryService API.
|
||||
}
|
||||
@@ -1,55 +1,55 @@
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.State;
|
||||
import group.goforward.battlbuilder.repos.StateRepository;
|
||||
import group.goforward.battlbuilder.services.admin.StatesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/states", "/api/v1/states"})
|
||||
public class StateController {
|
||||
@Autowired
|
||||
private StateRepository repo;
|
||||
@Autowired
|
||||
private StatesService statesService;
|
||||
//@Cacheable(value="getAllStates")
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<State>> getAllStates() {
|
||||
List<State> state = repo.findAll();
|
||||
return ResponseEntity.ok(state);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<State> getAllStatesById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
@GetMapping("/byAbbrev/{abbreviation}")
|
||||
public ResponseEntity<State> getAllStatesByAbbreviation(@PathVariable String abbreviation) {
|
||||
return repo.findByAbbreviation(abbreviation)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
@PostMapping("/addState")
|
||||
public ResponseEntity<State> createState(@RequestBody State item) {
|
||||
State created = statesService.save(item);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
@DeleteMapping("/deleteState/{id}")
|
||||
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
|
||||
return statesService.findById(id)
|
||||
.map(item -> {
|
||||
statesService.deleteById(id);
|
||||
return ResponseEntity.noContent().<Void>build();
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.State;
|
||||
import group.goforward.battlbuilder.repos.StateRepository;
|
||||
import group.goforward.battlbuilder.services.admin.StatesService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/states", "/api/v1/states"})
|
||||
public class StateController {
|
||||
@Autowired
|
||||
private StateRepository repo;
|
||||
@Autowired
|
||||
private StatesService statesService;
|
||||
//@Cacheable(value="getAllStates")
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<State>> getAllStates() {
|
||||
List<State> state = repo.findAll();
|
||||
return ResponseEntity.ok(state);
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<State> getAllStatesById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
@GetMapping("/byAbbrev/{abbreviation}")
|
||||
public ResponseEntity<State> getAllStatesByAbbreviation(@PathVariable String abbreviation) {
|
||||
return repo.findByAbbreviation(abbreviation)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
@PostMapping("/addState")
|
||||
public ResponseEntity<State> createState(@RequestBody State item) {
|
||||
State created = statesService.save(item);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
@DeleteMapping("/deleteState/{id}")
|
||||
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
|
||||
return statesService.findById(id)
|
||||
.map(item -> {
|
||||
statesService.deleteById(id);
|
||||
return ResponseEntity.noContent().<Void>build();
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
@@ -1,52 +1,52 @@
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.User;
|
||||
import group.goforward.battlbuilder.repos.UserRepository;
|
||||
import group.goforward.battlbuilder.services.admin.UsersService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/user", "/api/v1/user"})
|
||||
public class UserController {
|
||||
private final UserRepository repo;
|
||||
private final UsersService usersService;
|
||||
|
||||
public UserController(UserRepository repo, UsersService usersService) {
|
||||
this.repo = repo;
|
||||
this.usersService = usersService;
|
||||
}
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<User>> getAllUsers() {
|
||||
List<User> data = repo.findAll();
|
||||
return ResponseEntity.ok(data);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/byId/{id}")
|
||||
public ResponseEntity<User> getAllStatesById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
@PostMapping("/addUser")
|
||||
public ResponseEntity<User> createUser(@RequestBody User item) {
|
||||
User created = usersService.save(item);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
@DeleteMapping("/deleteUser/{id}")
|
||||
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
|
||||
return usersService.findById(id)
|
||||
.map(item -> {
|
||||
usersService.deleteById(id);
|
||||
return ResponseEntity.noContent().<Void>build();
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
package group.goforward.battlbuilder.controllers;
|
||||
|
||||
import group.goforward.battlbuilder.model.User;
|
||||
import group.goforward.battlbuilder.repos.UserRepository;
|
||||
import group.goforward.battlbuilder.services.admin.UsersService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/api/user", "/api/v1/user"})
|
||||
public class UserController {
|
||||
private final UserRepository repo;
|
||||
private final UsersService usersService;
|
||||
|
||||
public UserController(UserRepository repo, UsersService usersService) {
|
||||
this.repo = repo;
|
||||
this.usersService = usersService;
|
||||
}
|
||||
|
||||
@GetMapping("/all")
|
||||
public ResponseEntity<List<User>> getAllUsers() {
|
||||
List<User> data = repo.findAll();
|
||||
return ResponseEntity.ok(data);
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/byId/{id}")
|
||||
public ResponseEntity<User> getAllStatesById(@PathVariable Integer id) {
|
||||
return repo.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
@PostMapping("/addUser")
|
||||
public ResponseEntity<User> createUser(@RequestBody User item) {
|
||||
User created = usersService.save(item);
|
||||
return ResponseEntity.status(HttpStatus.CREATED).body(created);
|
||||
}
|
||||
|
||||
@DeleteMapping("/deleteUser/{id}")
|
||||
public ResponseEntity<Void> deleteItem(@PathVariable Integer id) {
|
||||
return usersService.findById(id)
|
||||
.map(item -> {
|
||||
usersService.deleteById(id);
|
||||
return ResponseEntity.noContent().<Void>build();
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user