-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Mywallet #61
base: master
Are you sure you want to change the base?
Update Mywallet #61
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Push thừa: thư mục .idea, target
|
||
|
||
@PostMapping(value = "/add") | ||
public String addName(@RequestParam(value = "id"/*, required = false*/) int id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addName
: tên chưa đúng với chức năng của method, e có thể sửa lại thành addCustomer
@RequestParam(value = "password") String pass, | ||
Model model | ||
){ | ||
List<Customer> customerList = customerService.findAll(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cách này đúng nhưng chưa ổn, e phải lấy hết tất cả user xong rồi tìm kiếm trong đó => mất công
e nên tạo câu query để tìm kiếm Customer
dựa vào username
và password
, nếu tìm thấy Customer
thì trả về userInfo
, sai thì báo lỗi.
(tạo findByUsernameAndPassword(String username, String password)
trong repository)
|
||
return "redirect:/"; | ||
} | ||
return "errorTransfer"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) nên sửa thành:
if(customerService.getOne(fromid).getBalance() < amount ) return "errorTransfer";
Customer fromCustomer = customerService.getOne(fromid);
Customer toCustomer = customerService.getOne(id);
//....
return "redirect:/";
=> khi đó code sẽ dễ nhìn hơn ^^
model.addAttribute("customerList", customers); | ||
return "home"; | ||
} | ||
return "notFound"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tương tự comment trên, để code dễ nhìn, nên sửa thành
if(customers.size() <= 0 ) return "notFound";
model.addAttribute("customerList", customers);
return "home";
public void save(Customer customer){ customerRepository.save(customer);} | ||
public Customer getOne(int id){return customerRepository.getOne(id);} | ||
public void deleteCustomer(int id){ | ||
customerRepository.delete(customerRepository.getOne(id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nên kiểm tra xem có tìm thấy Customer không trước khi xóa nhé
nếu không tồn tại Customer thì sẽ thành .delete(null)
=> exception
No description provided.