mirror of
https://gitea.gofwd.group/Forward_Group/ballistic-builder-spring.git
synced 2026-01-21 01:01:05 -05:00
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:
@@ -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.CrossOrigin;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
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.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
@@ -30,6 +31,19 @@ public class MerchantAdminController {
|
|||||||
return merchantRepository.findAll().stream().map(this::toDto).toList();
|
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}")
|
@PutMapping("/{id}")
|
||||||
public MerchantAdminDto updateMerchant(
|
public MerchantAdminDto updateMerchant(
|
||||||
@PathVariable Integer id,
|
@PathVariable Integer id,
|
||||||
@@ -51,6 +65,7 @@ public class MerchantAdminController {
|
|||||||
MerchantAdminDto dto = new MerchantAdminDto();
|
MerchantAdminDto dto = new MerchantAdminDto();
|
||||||
dto.setId(m.getId());
|
dto.setId(m.getId());
|
||||||
dto.setName(m.getName());
|
dto.setName(m.getName());
|
||||||
|
dto.setAvantlinkMid(m.getAvantlinkMid());
|
||||||
dto.setFeedUrl(m.getFeedUrl());
|
dto.setFeedUrl(m.getFeedUrl());
|
||||||
dto.setOfferFeedUrl(m.getOfferFeedUrl());
|
dto.setOfferFeedUrl(m.getOfferFeedUrl());
|
||||||
dto.setIsActive(m.getIsActive());
|
dto.setIsActive(m.getIsActive());
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import java.time.OffsetDateTime;
|
|||||||
public class MerchantAdminDto {
|
public class MerchantAdminDto {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
private String name;
|
private String name;
|
||||||
|
private String avantlinkMid;
|
||||||
private String feedUrl;
|
private String feedUrl;
|
||||||
private String offerFeedUrl;
|
private String offerFeedUrl;
|
||||||
private Boolean isActive;
|
private Boolean isActive;
|
||||||
@@ -28,6 +29,14 @@ public class MerchantAdminDto {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getAvantlinkMid() {
|
||||||
|
return avantlinkMid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvantlinkMid(String avantlinkMid) {
|
||||||
|
this.avantlinkMid = avantlinkMid;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFeedUrl() {
|
public String getFeedUrl() {
|
||||||
return feedUrl;
|
return feedUrl;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user