首页>代码>基于SSM的高校运动会管理系统的设计与实现(毕设)>/sportmeetingmanagementsystem-master/src/main/java/com/handy/controller/BorrowController.java
package com.handy.controller;

import com.handy.domain.Borrow;
import com.handy.domain.Equipment;
import com.handy.service.BorrowService;
import com.handy.service.EquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("/borrow")
public class BorrowController {

    @Autowired
    private BorrowService borrowService;

    @Autowired
    private EquipmentService equipmentService;

    /**
     * 借还信息管理
     *
     * @return
     */
    @RequestMapping("/manage.do")
    public ModelAndView manage() {
        ModelAndView mv = new ModelAndView();
        List<Borrow> borrowList = borrowService.findAll();
        mv.addObject("borrow", borrowList);
        mv.setViewName("borrow-manage");
        return mv;
    }

    /**
     * 借出列表
     *
     * @return
     */
    @RequestMapping("/borrow.do")
    public ModelAndView borrow() {
        ModelAndView mv = new ModelAndView();
        List<Equipment> equipmentList = equipmentService.findAll();
        mv.addObject("equipment", equipmentList);
        mv.setViewName("borrow");
        return mv;
    }

    /**
     * 归还列表
     *
     * @return
     */
    @RequestMapping("/return.do")
    public ModelAndView returnTo() {
        ModelAndView mv = new ModelAndView();
        List<Borrow> borrowList = borrowService.findAllOff();
        mv.addObject("borrow", borrowList);
        mv.setViewName("return");
        return mv;
    }

    /**
     * 器材借出登记
     *
     * @param borrow
     * @return
     */
    @RequestMapping(value = "/insert.do", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
    @ResponseBody
    public String insert(@RequestBody Borrow borrow) {
        try {
            borrowService.insert(borrow);
        } catch (Exception e) {
            return "新增失败!";
        }
        return "200";
    }


    /**
     * 删除借还记录
     *
     * @param id
     * @return
     */
    @RequestMapping("/deleteById.do")
    public String deleteByIds(Integer[] id) {
        borrowService.deleteById(id);
        return "redirect:manage.do";
    }

    /**
     * 器材归还登记
     *
     * @param id
     * @return
     */
    @RequestMapping("/update.do")
    public String update(Integer[] id) {
        borrowService.update(id);
        return "redirect:return.do";
    }

}
最近下载更多
wangjiayu11111  LV1 4月2日
邱丘丘qiuqq  LV1 3月1日
admin_z  LV22 2月4日
qwertyuiop1379  LV3 1月24日
森sdfgf  LV8 1月8日
微笑刺客  LV15 2023年12月22日
yichang123  LV1 2023年12月3日
流连瓦盖法  LV7 2023年11月29日
1308530161  LV4 2023年11月13日
czsczd  LV3 2023年9月9日
最近浏览更多
yangyuer  LV1 4月28日
清横白川玉  LV6 4月23日
dhcpsl  LV2 4月10日
demo_001 4月2日
暂无贡献等级
wangjiayu11111  LV1 4月2日
自由吃柚子  LV2 3月26日
zolscy  LV12 3月24日
yuanhong 3月7日
暂无贡献等级
玖零定制问题修复  LV34 3月3日
邱丘丘qiuqq  LV1 3月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友