zoukankan      html  css  js  c++  java
  • ssm使用全注解实现增删改查案例——DeptController

    package org.action;
    
    import org.entity.Dept;
    import org.service.IDeptService;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.servlet.ModelAndView;
    
    /**
     * 
    *    
    * 项目名称:test_myabtis_zhujie   
    * 类名称:DeptController   
    * 类描述:   Dept的控制器
    * 创建人:Mu Xiongxiong  
    * 创建时间:2018-3-16 下午4:21:26   
    * 修改人:Mu Xiongxiong   
    * 修改时间:2018-3-16 下午4:21:26   
    * 修改备注:   
    * @version    
    *
     */
    @Controller
    public class DeptController {
    
        //创建DeptService的初始化
        @Autowired
        private IDeptService deptService;
    
        /**
         * 
        * @Description: 该方法的主要作用:查询全部的部门信息
        * @Title: findDeptAll
        * @param  @return 设定文件  
        * @return  返回类型:ModelAndView   
        * @throws
         */
        @RequestMapping(value="findDeptAll")
        public ModelAndView findDeptAll(){
            ModelAndView modelAndView = new ModelAndView();
            //进行对象赋值,键值对的形式
            modelAndView.addObject("deptList",deptService.findDeptAll());
            //进行写入要跳转的视图
            modelAndView.setViewName("showDept");
            return modelAndView;
        }
    
        /**
         * 
        * @Description: 该方法的主要作用:添加部门信息
        * @Title: saveDept
        * @param  @param dept
        * @param  @return 设定文件  
        * @return  返回类型:ModelAndView   
        * @throws
         */
        @RequestMapping("saveDept")
        public ModelAndView saveDept(Dept dept){
            int id = ((Long)(System.currentTimeMillis())).intValue();
            dept.setId(id);
            deptService.insert(dept);
            return new ModelAndView("redirect:/findDeptAll.do");
        }
    
        /**
         * 
        * @Description: 该方法的主要作用:根据编号查询信息
        * @Title: findDeptById
        * @param  @param id
        * @param  @return 设定文件  
        * @return  返回类型:ModelAndView   
        * @throws
         */
        @RequestMapping("findDeptById")
        public ModelAndView findDeptById(int id){
            ModelAndView modelAndView = new ModelAndView();
            modelAndView.addObject("dept",deptService.selectByPrimaryKey(id));
            modelAndView.setViewName("updateDept");
            return modelAndView;
        }
    
        /**
         * 
        * @Description: 该方法的主要作用:修改部门
        * @Title: updateDept
        * @param  @param dept
        * @param  @return 设定文件  
        * @return  返回类型:ModelAndView   
        * @throws
         */
        @RequestMapping("updateDept")
        public ModelAndView updateDept(Dept dept){
            deptService.updateByPrimaryKey(dept);
            return new ModelAndView("redirect:/findDeptAll.do");
        }
    
        /**
         * 
        * @Description: 该方法的主要作用:删除部门信息
        * @Title: delDept
        * @param  @param id
        * @param  @return 设定文件  
        * @return  返回类型:ModelAndView   
        * @throws
         */
        @RequestMapping("delDept")
        public ModelAndView delDept(int id){
                deptService.deleteByPrimaryKey(id);
                return new  ModelAndView("redirect:findDeptAll.do");
        }
    
    }
    
    
  • 相关阅读:
    [CF] Final Exam Arrangement
    [原创]9宫格填数字
    第二次结对编程作业
    第11组 团队展示
    第一次结对编程作业
    第一次个人编程作业
    第一次博客作业
    第二次结对编程作业
    第10组 团队展示
    第一次个人编程作业
  • 原文地址:https://www.cnblogs.com/a1111/p/12816065.html
Copyright © 2011-2022 走看看