srishti-it / Card-Verify

0 stars 0 forks source link

code enhancements #1

Open kaushal-bhatt opened 2 years ago

kaushal-bhatt commented 2 years ago

package com.card.entities;

import javax.persistence.*;

@Entity @Table(name="CARD_NUMBER") public class CardNumber {

public CardNumber(String cardNumber,Long id) {
    this.cardNumber = cardNumber;
    this.id=id;
}

public String getCardNumber() {
    return cardNumber;
}

public void setCardNumber(String cardNumber) {
    this.cardNumber = cardNumber;
}

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;

public Long getId() {
    return id;
}

public void setId(Long id) {
    this.id = id;
}

@Column(name = "card_number")
private String cardNumber;

public CardNumber() {

}

}

try this for you entity file

and in controller do like this and check your mistakes

@RestController public class CardController {

@Autowired 
private CardRepo cardRepo;

    @GetMapping("/getForm")
    public String getForm() {
        return "card";
    }
    @PostMapping("/savecard")
    public String saveDetails(@RequestBody CardNumber cardNumber) {
        // write your code to save details
        System.out.println(cardNumber.toString());
        cardRepo.save(cardNumber);
        return "saved "+ cardNumber.getCardNumber();
    }

}

kaushal-bhatt commented 2 years ago

For now promoted to next round be prepared