|
@@ -6,6 +6,7 @@ import edu.travel.interfaces.UpdateGroups;
|
|
|
import edu.travel.resp.BaseResponse;
|
|
|
import edu.travel.resp.PageResponse;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.Errors;
|
|
|
import org.springframework.validation.ObjectError;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -26,6 +27,7 @@ public class BaseController<T> {
|
|
|
* @return
|
|
|
*/
|
|
|
@PostMapping("/updateById")
|
|
|
+ @Transactional
|
|
|
public BaseResponse<T> updateById(@Validated(UpdateGroups.class) @RequestBody T entity, Errors errors) {
|
|
|
if (errors.hasErrors()) {
|
|
|
List<ObjectError> allErrors = errors.getAllErrors();
|
|
@@ -40,6 +42,7 @@ public class BaseController<T> {
|
|
|
return PageResponse.out(500,"error",entity);
|
|
|
}
|
|
|
@PostMapping("/save")
|
|
|
+ @Transactional
|
|
|
public BaseResponse<T> save(@Validated(InsertGroups.class) @RequestBody T entity, Errors errors) {
|
|
|
if (errors.hasErrors()) {
|
|
|
List<ObjectError> allErrors = errors.getAllErrors();
|
|
@@ -54,6 +57,7 @@ public class BaseController<T> {
|
|
|
return PageResponse.out(500,"error",entity);
|
|
|
}
|
|
|
@PostMapping("/deleteById")
|
|
|
+ @Transactional
|
|
|
public BaseResponse<T> deleteById(@RequestBody List<String> ids) {
|
|
|
if (ids == null || ids.isEmpty()) {
|
|
|
return PageResponse.out(404,"error,not found delete data",null);
|