bug fix: Ambiguous mapping. Cannot map ‘***’ method

This commit is contained in:
myh 2023-11-11 20:19:04 +08:00
parent 02dddf6699
commit 469253559e

View File

@ -1,12 +1,11 @@
package com.example.springdemo.controller; package com.example.springdemo.controller;
import com.example.springdemo.entities.Merchants; import com.example.springdemo.entities.Merchants;
import com.example.springdemo.entities.password.MerchantsPassword;
import com.example.springdemo.service.MerchantsService; import com.example.springdemo.service.MerchantsService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.Optional;
@RestController @RestController
@RequestMapping("/merchants") @RequestMapping("/merchants")
public class MerchantsController { public class MerchantsController {
@ -14,16 +13,17 @@ public class MerchantsController {
private MerchantsService merchantsService; private MerchantsService merchantsService;
@PostMapping("/add") @PostMapping("/add")
public Merchants addMerchants(@RequestBody Merchants merchants) { public Merchants addMerchants(@RequestBody Merchants merchants,
return merchantsService.addMerchants(merchants); @RequestBody MerchantsPassword merchantsPassword) {
return merchantsService.addMerchants(merchants, merchantsPassword);
} }
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
public void deleteMerchants(@PathVariable("id") Long id) { public void deleteMerchants(@PathVariable("id") Long merchantID) {
merchantsService.deleteMerchantsById(id); merchantsService.deleteMerchantsById(merchantID);
} }
@PutMapping("/update") @PutMapping("/update/info")
public Merchants updateMerchants(@RequestBody Merchants merchants) { public Merchants updateMerchants(@RequestBody Merchants merchants) {
return merchantsService.updateMerchants(merchants); return merchantsService.updateMerchants(merchants);
} }
@ -39,7 +39,12 @@ public class MerchantsController {
} }
@GetMapping("/find/{id}") @GetMapping("/find/{id}")
public Merchants getMerchantsById(@PathVariable("id") Long id) { public Merchants getMerchantsById(@PathVariable("id") Long merchantID) {
return merchantsService.findById(id); return merchantsService.findById(merchantID);
}
@PutMapping("/update/password")
public void updatePassword(@RequestParam String password, @RequestParam Long merchantID) {
merchantsService.updatePassword(password, merchantID);
} }
} }