[Vuejs]-How do I delete only the selected data?

0👍

Your controller is replacing all the data from the user and your vue.jsscript is not sending product data:

// Data sent by the front
var data = {
 id:this.currentUser.id,
 email:this.currentUser.email,
 delYn:this.currentUser.delYn,
 password:this.currentUser.password,
 username:this.currentUser.username,
 roles:this.currentUser.roles
};

// Controller PUT
 User _user = userData.get();
 // The front is not sending any productInfo
_user.setProductInfo(user.getProductInfo());

_user.setRoles(user.getRoles());
_user.setUsername(user.getUsername());
_user.setEmail(user.getEmail());
_user.setPassword(user.getPassword());
_user.setDelYn(user.isDelYn());
return new ResponseEntity<>(userRepository.save(_user), HttpStatus.OK);

Since you are not sending product info, the previous product info is deleted. Your front need to send the product info data that you want to preserve.

0👍

let me see user table’s data. i guess that your userInfo and your productInfo share one table; If you have a productinfo table, you shoud transfer a productId from vue page instead of userId

Leave a comment