Skip to content

Commit 993b2e6

Browse files
committed
add
1 parent 90cddff commit 993b2e6

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

javase/src/main/java/info/xiaomo/javase/controller/QuestionController.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,7 @@
1010
import io.swagger.annotations.ApiOperation;
1111
import org.springframework.beans.factory.annotation.Autowired;
1212
import org.springframework.http.MediaType;
13-
import org.springframework.web.bind.annotation.PathVariable;
14-
import org.springframework.web.bind.annotation.RequestMapping;
15-
import org.springframework.web.bind.annotation.RequestMethod;
16-
import org.springframework.web.bind.annotation.RestController;
13+
import org.springframework.web.bind.annotation.*;
1714

1815
/**
1916
* 把今天最好的表现当作明天最新的起点..~
@@ -47,7 +44,7 @@ public QuestionController(QuestionService service) {
4744
* @param id id
4845
* @return result
4946
*/
50-
@ApiOperation(value = "查找用户", notes = "查找用户", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
47+
@ApiOperation(value = "查找问题", notes = "查找问题", httpMethod = "GET", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
5148
@RequestMapping(value = "findById/{id}", method = RequestMethod.GET)
5249
@ApiImplicitParams({
5350
@ApiImplicitParam(name = "id", value = "唯一id", required = true, dataType = "Long", paramType = "path"),
@@ -60,4 +57,16 @@ public Result findUserById(@PathVariable("id") Long id) {
6057
return new Result<>(questionModel);
6158
}
6259

60+
/**
61+
* 根据id 查找用户
62+
*
63+
* @return result
64+
*/
65+
@ApiOperation(value = "添加", notes = "添加", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
66+
@RequestMapping(value = "findById/{id}", method = RequestMethod.POST)
67+
public Result addQuestion(@RequestBody QuestionModel questionModel) {
68+
boolean add = service.add(questionModel);
69+
return new Result<>(add);
70+
}
71+
6372
}

javase/src/main/java/info/xiaomo/javase/service/QuestionService.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ public interface QuestionService {
2424
* @return
2525
*/
2626
QuestionModel findById(Long id);
27+
28+
/**
29+
* 添加
30+
*
31+
* @param questionModel questionModel
32+
* @return
33+
*/
34+
boolean add(QuestionModel questionModel);
2735
}

javase/src/main/java/info/xiaomo/javase/service/impl/QuestionServiceImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ public QuestionServiceImpl(QuestionDao questionDao) {
3434
public QuestionModel findById(Long id) {
3535
return questionDao.findById(id);
3636
}
37+
38+
@Override
39+
public boolean add(QuestionModel questionModel) {
40+
QuestionModel save = questionDao.save(questionModel);
41+
return save != null;
42+
}
3743
}

0 commit comments

Comments
 (0)