51 lines
1.7 KiB
Java
51 lines
1.7 KiB
Java
package com.example.springdemo.controller;
|
|
|
|
import com.example.springdemo.entities.Merchants;
|
|
import com.example.springdemo.entities.password.MerchantsPassword;
|
|
import com.example.springdemo.service.MerchantsService;
|
|
import jakarta.annotation.Resource;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
@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);
|
|
}
|
|
|
|
@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);
|
|
}
|
|
|
|
@GetMapping("/find")
|
|
public Iterable<Merchants> 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 merchantID) {
|
|
return merchantsService.findById(merchantID);
|
|
}
|
|
|
|
@PutMapping("/update/password")
|
|
public void updatePassword(@RequestParam String password, @RequestParam Long merchantID) {
|
|
merchantsService.updatePassword(password, merchantID);
|
|
}
|
|
}
|