Add POST endpoint to create new merchants via admin API

Enables merchant creation through the admin UI by adding a POST endpoint to MerchantAdminController. Also adds avantlinkMid field to MerchantAdminDto to satisfy the required database constraint.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-20 19:27:34 -05:00
parent 3f33d944e2
commit 5b65c73677
2 changed files with 24 additions and 0 deletions

View File

@@ -3,6 +3,7 @@ package group.goforward.battlbuilder.controllers.api.v1.admin;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
@@ -30,6 +31,19 @@ public class MerchantAdminController {
return merchantRepository.findAll().stream().map(this::toDto).toList();
}
@PostMapping
public MerchantAdminDto createMerchant(@RequestBody MerchantAdminDto payload) {
Merchant merchant = new Merchant();
merchant.setName(payload.getName());
merchant.setAvantlinkMid(payload.getAvantlinkMid());
merchant.setFeedUrl(payload.getFeedUrl());
merchant.setOfferFeedUrl(payload.getOfferFeedUrl());
merchant.setIsActive(payload.getIsActive() != null ? payload.getIsActive() : true);
merchant = merchantRepository.save(merchant);
return toDto(merchant);
}
@PutMapping("/{id}")
public MerchantAdminDto updateMerchant(
@PathVariable Integer id,
@@ -51,6 +65,7 @@ public class MerchantAdminController {
MerchantAdminDto dto = new MerchantAdminDto();
dto.setId(m.getId());
dto.setName(m.getName());
dto.setAvantlinkMid(m.getAvantlinkMid());
dto.setFeedUrl(m.getFeedUrl());
dto.setOfferFeedUrl(m.getOfferFeedUrl());
dto.setIsActive(m.getIsActive());

View File

@@ -6,6 +6,7 @@ import java.time.OffsetDateTime;
public class MerchantAdminDto {
private Integer id;
private String name;
private String avantlinkMid;
private String feedUrl;
private String offerFeedUrl;
private Boolean isActive;
@@ -28,6 +29,14 @@ public class MerchantAdminDto {
this.name = name;
}
public String getAvantlinkMid() {
return avantlinkMid;
}
public void setAvantlinkMid(String avantlinkMid) {
this.avantlinkMid = avantlinkMid;
}
public String getFeedUrl() {
return feedUrl;
}