SpringDemo/src/main/java/com/example/springdemo/controller/MerchantsController.java

51 lines
1.7 KiB
Java
Raw Normal View History

2023-10-06 15:32:28 +00:00
package com.example.springdemo.controller;
import com.example.springdemo.entities.Merchants;
import com.example.springdemo.entities.password.MerchantsPassword;
2023-10-06 15:32:28 +00:00
import com.example.springdemo.service.MerchantsService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
2023-10-06 15:32:28 +00:00
@RestController
@RequestMapping("/merchants")
public class MerchantsController {
@Resource
private MerchantsService merchantsService;
@PostMapping("/add")
public Merchants addMerchants(@RequestBody Merchants merchants,
@RequestBody MerchantsPassword merchantsPassword) {
return merchantsService.addMerchants(merchants, merchantsPassword);
2023-10-06 15:32:28 +00:00
}
@DeleteMapping("/delete/{id}")
public void deleteMerchants(@PathVariable("id") Long merchantID) {
merchantsService.deleteMerchantsById(merchantID);
}
@PutMapping("/update/info")
public Merchants updateMerchants(@RequestBody Merchants merchants) {
return merchantsService.updateMerchants(merchants);
2023-10-06 15:32:28 +00:00
}
@GetMapping("/find")
2023-10-26 03:33:56 +00:00
public Iterable<Merchants> getMerchants() {
return merchantsService.findAllMerchants();
}
@GetMapping("/find/{name}")
public Merchants getMerchantsByName(@PathVariable("name") String name) {
return merchantsService.findByName(name);
2023-10-06 15:32:28 +00:00
}
@GetMapping("/find/{id}")
public Merchants getMerchantsById(@PathVariable("id") Long merchantID) {
return merchantsService.findById(merchantID);
}
@PutMapping("/update/password")
public void updatePassword(@RequestParam String password, @RequestParam Long merchantID) {
merchantsService.updatePassword(password, merchantID);
2023-10-06 15:32:28 +00:00
}
}