Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Update Mywallet #61

wants to merge 3 commits into from

Conversation

khahoangmkit
Copy link
Contributor

No description provided.

Copy link
Contributor

@quytm quytm left a 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,
Copy link
Contributor

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();
Copy link
Contributor

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 usernamepassword, 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";
Copy link
Contributor

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";
Copy link
Contributor

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));
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants