controller
/
*** 设置陌生人问题
** @return
*/
@PostMapping("questions")
public ResponseEntity<Void> saveQuestions(@RequestBody Map<String,保存 String> param) {
try {
String content = param.get("content");
this.myCenterService.saveQuestions(content);
return ResponseEntity.ok(null);
} catch (Exception e) {
e.printStackTrace();
}
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build();
}
=========================================================
service 获取controller传递请求线程 获取其中用户ID
public void saveQuestions(String content) {
User user = UserThreadLocal.get();
this.questionService.save(user.getId(), content);
}
==================================================
service 核心逻辑处理 问题service
public void save(Long userId, String content) {
Question question = this.queryQuestion(userId);
if(null != question){
question.setTxt(content);
this.questionMapper.updateById(question);
}else {
question = new Question();
question.setUserId(userId);
question.setTxt(content);
question.setCreated(new Date());
question.setUpdated(question.getCreated());
this.questionMapper.insert(question);
}
}
魔兽世界如何迅速提升影踪突袭营声望?(突袭忍者!魔兽世界影踪突袭营声望攻略大揭秘!)
DNF战斗法师改版加点参考 不懂的同学看过来!