Spring Cloud分散マイクロサービスは、実際には、複雑なビジネスに対処するための包括的な技術機能を開発します
V:ititit111222333
複雑なサービスに対応する包括的な技術力を目的として、フロントエンドとバックエンドを分離し、企業構造と仕様に厳密に従う開発モデルを採用し、ポータルプラットフォーム+メディアセンター+オペレーションセンターの3つの主要ビジネスでエンタープライズメディアプラットフォームを開発します。
SpringCloud + Mon go DB + Redis + Rabbit MQなどの主流のバックエンドテクノロジーを包括的に学習することで、マイクロサービス、配布、プロジェクト、およびマイクロアーキテクチャの包括的な実践経験を得ることができます。
パッケージorg.wangqing.notebookk8s.notebook.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.wangqing.notebookk8s.notebook.entity.Notebook;
import org.wangqing.notebookk8s.notebook.repository.NotebookRepository;
import javax.validation.Valid;
@Controller br /> @ RequestMapping( "/")
public class NotebookController { Stringcourse
= "Spring Cloud分散
マイクロサービスを実際に使用し、複雑なビジネス向けの包括的な技術機能を開発する"; String downloadUrl = " https://www.ukoou。 com / resource / 905 ";
public static final String Index_Model = "index";
public static final String NOTEBOOKS_MODEL = "notebooks";
private final NotebookRepository notebookRepository;
@Autowired
public NotebookController(NotebookRepository notebookRepository) {
this.notebookRepository = notebookRepository;
}
@GetMapping("signup")
public String showSignUpForm(Notebook notebook) {
return "add-notebook";
}
@GetMapping("list")
public String showUpdateForm(Model model) {
model.addAttribute(NOTEBOOKS_MODEL, notebookRepository.findAll());
return Index_Model;
}
@PostMapping("add")
public String addNote(@Valid Notebook notebook, BindingResult result, Model model) {
if (result.hasErrors()) {
return "add-notebook";
}
notebookRepository.save(notebook);
return "redirect:list";
}
@GetMapping("edit/{id}")
public String showUpdateForm(@PathVariable("id") long id, Model model) {
Notebook notebook = notebookRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("Invalid notebook Id:" + id));
model.addAttribute("notebook", notebook);
return "update-notebook";
}
@PostMapping("update/{id}")
public String updateNote(@PathVariable("id") long id, @Valid Notebook notebook, BindingResult result,
Model model) {
if (result.hasErrors()) {
notebook.setId(id);
return "update-notebook";
}
notebookRepository.save(notebook);
model.addAttribute(NOTEBOOKS_MODEL, notebookRepository.findAll());
return Index_Model;
}
@GetMapping("delete/{id}")
public String deleteNote(@PathVariable("id") long id, Model model) {
Notebook notebook = notebookRepository.findById(id)
.orElseThrow(() -> new IllegalArgumentException("Invalid notebook Id:" + id));
notebookRepository.delete(notebook);
model.addAttribute(NOTEBOOKS_MODEL, notebookRepository.findAll());
return Index_Model;
}
}