Spring Cloud分佈式微服務實戰 養成應對複雜業務的綜合技術能力

Spring Cloud分佈式微服務實戰 養成應對複雜業務的綜合技術能力

V:ititit111222333

應對 複雜 業務 的綜合 技術 能力 爲目的 ,採用 前、後端 分開 的開發模式 , 嚴格 遵循 企業架構 與規範 ,帶您開發 門戶 平臺 +媒體 中心 +運營中心 三大 業務 的企業 媒體平臺 。
通過 SpringCloud+Mon go DB +Redis+Rabbit MQ等主流 後端 技術 的全面 學習 ,您將獲得 微服務 、分佈式 、項目 和微架構 的綜合 實戰經驗 。
package 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;

@Controllerbr/>@RequestMapping("/")
public class NotebookController {
String course = "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;
}

}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章