AccountController.java
1 KB
package vion.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import vion.Global;
import vion.model.Account;
import vion.service.IAccountService;
@RestController
@RequestMapping(Global.BASE_URL)
@RequiredArgsConstructor
@Slf4j
public class AccountController {
private final IAccountService accountService;
@GetMapping("/accounts")
public Page<Account> getAccountList(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize) {
return accountService.page(Page.of(pageNum, pageSize));
}
@GetMapping("/account")
public Account getProductByID(Integer id) {
return accountService.getById(id);
}
@PostMapping("/accounts")
public Account saveOrUpdate(@RequestBody Account data) {
accountService.save(data);
return data;
}
}