|
@@ -4,13 +4,13 @@ import com.example.user.domain.Details;
|
|
|
import com.example.user.domain.User;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.bson.types.ObjectId;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.mongodb.core.MongoTemplate;
|
|
|
+import org.springframework.data.mongodb.core.query.Criteria;
|
|
|
+import org.springframework.data.mongodb.core.query.Query;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
@RestController
|
|
|
@RequestMapping("/details")
|
|
@@ -23,4 +23,14 @@ public class DetailsController {
|
|
|
public Details add(@Validated @RequestBody Details details){
|
|
|
return mongoTemplate.insert( details );
|
|
|
}
|
|
|
+ @ApiOperation("根据detailsId查询内容")
|
|
|
+ @GetMapping("/{detailsId}")
|
|
|
+ public Details get(@PathVariable String detailsId){
|
|
|
+ ObjectId objectId = new ObjectId(detailsId);
|
|
|
+ Details details = mongoTemplate.findById(,Details.class, "details");
|
|
|
+ System.out.println(details);
|
|
|
+ return details;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|