首页>代码>SpringBoot整合MyBatis实现记录孩子成长过程的博客系统>/babylog/src/main/java/net/vv2/admin/web/AdminHealthyController.java
package net.vv2.admin.web; import com.xiaoleilu.hutool.date.DateUtil; import net.vv2.baby.domain.Baby; import net.vv2.baby.domain.Healthy; import net.vv2.baby.service.impl.BabyServiceImpl; import net.vv2.baby.service.impl.HealthyServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import java.util.List; /** * @author J.Sky bosichong@qq.com * @create 2017-06-21 20:50 **/ @Controller @RequestMapping("/admin/healthy") public class AdminHealthyController { @Autowired private HealthyServiceImpl healthyService; @Autowired private BabyServiceImpl babyService; /** * 列表页 * @param model * @return */ @RequestMapping("/healthyList") public String healthyList(Model model){ List<Healthy> list = healthyService.selectAll(); model.addAttribute("list",list); return "/admin/healthy/healthyList"; } /** * 身高体重更新页 * @param id * @param model * @return */ @RequestMapping("/editHealthy/{id}") public String editHealthy(@PathVariable Integer id, Model model){ Healthy healthy = healthyService.selectHealthyById(id); model.addAttribute("healthy",healthy); return "/admin/healthy/editHealthy"; } /** * 更新数据 * @param id * @param height * @param weight * @param create_time * @param baby_id * @param mv * @return */ @RequestMapping("/updHealthy") public ModelAndView updHealthy(Integer id, Integer height, Float weight, String create_time, Integer baby_id, ModelAndView mv ){ Baby baby = babyService.selectBabyById(baby_id); Healthy healthy = new Healthy(); healthy.setId(id); healthy.setHeight(height); healthy.setWeight(weight); healthy.setCreate_time(DateUtil.parse(create_time)); healthy.setBaby(baby); return returnMv((healthyService.updateHealthy(healthy)>0),mv); } /** * 删除数据 * @param id * @param mv * @return */ @RequestMapping("/delHealthy/{id}") public ModelAndView delHealthy(@PathVariable Integer id, ModelAndView mv){ return returnMv((healthyService.deleteHealthy(id)>0),mv); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /** * 选择页面跳转 * * @param bl * @param mv * @return */ public ModelAndView returnMv(boolean bl, ModelAndView mv) { if (bl) { return updateDate(mv, "操作成功!", "<meta http-equiv=\"refresh\" content=\"2;url=/admin/healthy/healthyList\">", "/success"); } else { return updateDate(mv, "操作失败!", "<meta http-equiv=\"refresh\" content=\"2;url=/admin/healthy/healthyList\">", "/err"); } } /** * 页面跳转 * * @param mv * @param msg * @param url * @param viewName * @return */ public ModelAndView updateDate(ModelAndView mv, String msg, String url, String viewName) { mv.addObject("msg", msg); mv.addObject("url", url); mv.setViewName(viewName); return mv; } }

kk992127170 LV6
2022年12月27日
tgeuuy LV10
2022年10月25日
testuser1234567 LV24
2022年6月8日
zhos0212 LV19
2022年4月20日
zackery LV9
2022年4月19日
fantesy LV17
2022年3月3日
wang512237140 LV20
2021年12月21日
tansuo阿郎 LV8
2021年11月17日
尹恒yingying LV18
2021年10月22日
huaua7676 LV30
2021年9月25日

梁小贤 LV1
5月22日
微信网友_7442146341474304
3月27日
暂无贡献等级
ma406805131 LV19
2024年12月19日
citybird LV4
2024年11月18日
栾庆浩
2024年10月29日
暂无贡献等级
小小ffggyh LV1
2024年9月12日
嘻嘻不嘻嘻
2024年8月5日
暂无贡献等级
dapeng0011 LV15
2024年6月22日
f22m1a2b2 LV17
2024年6月8日
一只大笨熊啊
2024年6月8日
暂无贡献等级