src/main/java/cn/pzhu/pserson/controller/HealthyController.java

(完整代码) 1KB

package cn.pzhu.pserson.controller;

import cn.pzhu.pserson.domain.Healthy;
import cn.pzhu.pserson.service.HealthyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class HealthyController {

    @Autowired
    private HealthyService healthyService;

    // 如果在目录下输入为空,则跳转到指定链接
    @RequestMapping(value = "/healthy/")
    public ModelAndView index2(ModelAndView mv) {
        mv.setViewName("/index");
        return mv;
    }

    // 如果在目录下输入任何不存在的参数,则跳转到list
    @RequestMapping(value = "/healthy/{formName}")
    public String index2(@PathVariable String formName) {
        String blank = "/index";
        return blank;
    }

    @RequestMapping(value = "/healthy/checkIn", method = RequestMethod.GET)
    public String add(Model model, Integer id) {
        if (id != null) {
            Healthy healthy = healthyService.get_HealthyInfo(id);
            model.addAttribute("logistic", healthy);
            model.addAttribute("update", healthy.getUserId());
        }
        return "/healthy/checkIn";
    }

    @RequestMapping(value = "/healthy/checkIn", method = RequestMethod.POST)
    public ModelAndView add(ModelAndView mv, @ModelAttribute Healthy healthy, Integer id) {
        if (id != null) {
            healthyService.update_HealthyInfo(healthy);
            mv.getModel().remove("update");
        } else {
            healthyService.insert_HealthyInfo(healthy);
        }
        return mv;
    }

}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。