Spring Cloud distributed microservices actually develop comprehensive technical capabilities to deal with complex businesses

Spring Cloud distributed microservices actually develop comprehensive technical capabilities to deal with complex businesses

V : ititit111222333

For the purpose of comprehensive technical capabilities to deal with complex businesses, we adopt a development model that separates front and back ends, strictly follow the corporate structure and specifications, and lead you to develop an enterprise media platform with three major businesses: portal platform + media center + operation center.
Through comprehensive learning of mainstream back-end technologies such as SpringCloud+Mon go DB+Redis+Rabbit MQ, you will gain comprehensive practical experience in microservices, distributed, projects and microarchitectures.
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;

@Controller br/>@RequestMapping("/")
public class NotebookController {
String course = "Spring Cloud distributed
microservices in practice, develop comprehensive technical capabilities for complex businesses"; 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;
}

}

Guess you like

Origin blog.51cto.com/15055311/2576381