In my controller, i have a method mapped with following mapping : 
@PostMapping("/").

This method expects a request body which i am trying to capture as mentioned below : 

public String create(@RequestBody Task task)

Task is a custom class i have created which maps to the structure of request body expected in the request.

I am new to spring boot and not sure how the best practice standards are.

My doubt here is in my method create() should i directly capture the request body in my entity class or should have a similar pojo to capture the request body and then i map it to my entity class?

Any suggestions would be helpful regarding the best practices and standard conventions.

Using both the approaches it works fine for me I am just in dilemma if accepting the request body directly in entity class is a good idea and a best practice to do.

Don't want to expose my entity class in controller class as i am not sure if it is a good idea.

```
@PostMapping("/")
public String create(@Valid @RequestBody Task task) {

}

```

Task.java

```
public final class Task {

@NonNull
private int id;

@NotBlank(message = "Name is a mandatory field")
private String name;

private String decription;

@NotBlank(message = "date is a mandatory field")
private String date;

private boolean status;

@NotBlank(message = "severenes is a mandatory field")
private String severenes;

public Task(int id, String name, String decription, String date, boolean status, String severenes) {
    super();
    this.id = id;
    this.name = name;
    this.decription = decription;
    this.date = date;
    this.status = status;
    this.severenes = severenes;
}

public int getId() {
    return id;
}

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

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getDecription() {
    return decription;
}

public void setDecription(String decription) {
    this.decription = decription;
}

public String getDate() {
    return date;
}

public void setDate(String date) {
    this.date = date;
}

public boolean isStatus() {
    return status;
}

public void setStatus(boolean status) {
    this.status = status;
}

public String getSeverenes() {
    return severenes;
}

public void setSeverenes(String severenes) {
    this.severenes = severenes;
}   

```

}

Tasks.java(Entity CLass)

```
@Entity
@Table(name = "tasks")
public class Tasks {

@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE)
@Column(name = "id")
private int id;

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

@Column(name = "description")
private String description;

@Column(name = "date")
private LocalDateTime date;

@Column(name = "status")
private boolean status;

@Column(name = "severenes")
private String severenes;

public int getId() {
    return id;
}

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

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

public String getDescription() {
    return description;
}

public void setDescription(String description) {
    this.description = description;
}

public LocalDateTime getDate() {
    return date;
}

public void setDate(LocalDateTime date) {
    this.date = date;
}

public boolean isStatus() {
    return status;
}

public void setStatus(boolean status) {
    this.status = status;
}

public String getSeverenes() {
    return severenes;
}

public void setSeverenes(String severenes) {
    this.severenes = severenes;
}

```

}

Both the mentioned approaches gives the same result, concern is more towards the best practices to be followed.