|
@@ -7,6 +7,7 @@ import edu.travel.resp.BaseResponse;
|
|
|
import edu.travel.resp.PageResponse;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.Errors;
|
|
|
import org.springframework.validation.ObjectError;
|
|
@@ -14,6 +15,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
@@ -21,7 +23,11 @@ public class BaseController<T> {
|
|
|
@Autowired
|
|
|
@Lazy
|
|
|
private IService<T> service;
|
|
|
-
|
|
|
+ @GetMapping("/getById")
|
|
|
+ public BaseResponse getById(String id) {
|
|
|
+ T byId = service.getById(id);
|
|
|
+ return PageResponse.out(HttpStatus.OK.value(), HttpStatus.OK.getReasonPhrase(), byId);
|
|
|
+ }
|
|
|
@PostMapping("/updateById")
|
|
|
@Transactional
|
|
|
public BaseResponse<T> updateTargetById(@Validated(UpdateGroups.class) @RequestBody T entity, Errors errors) {
|