package com.example.springdemo.controller; import com.example.springdemo.entities.Merchants; import com.example.springdemo.service.MerchantsService; import jakarta.annotation.Resource; import org.springframework.web.bind.annotation.*; import java.util.Optional; @RestController @RequestMapping("/merchants") public class MerchantsController { @Resource private MerchantsService merchantsService; @PostMapping("/add") public Merchants addMerchants(@RequestBody Merchants merchants) { return merchantsService.addMerchants(merchants); } @DeleteMapping("/delete/{id}") public void deleteMerchants(@PathVariable("id") Long id) { merchantsService.deleteMerchantsById(id); } @PutMapping("/update") public Merchants updateMerchants(@RequestBody Merchants merchants) { return merchantsService.updateMerchants(merchants); } @GetMapping("/find") public Iterable getMerchants() { return merchantsService.findAllMerchants(); } @GetMapping("/find/{name}") public Merchants getMerchantsByName(@PathVariable("name") String name) { return merchantsService.findByName(name); } @GetMapping("/find/{id}") public Merchants getMerchantsById(@PathVariable("id") Long id) { return merchantsService.findById(id); } }