回想最初

package controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import service.EmployeeService;
import entity.Employee;
import entity.FenYe;

@Controller
public class EmployeeController {
    @Autowired
    private EmployeeService employeeService;
    
    @ResponseBody
    @RequestMapping("/login")
    public Object login(String username,String password){
        if("admin".equals(username) && "admin".equals(password)){
            return 1;
        }else{
            return 0;
        }
    }
    
    @RequestMapping("/update")
    public String update(Employee employee){
        employeeService.update(employee);
        return "index";
    }
    
    @RequestMapping("/insert")
    public String insert(Employee employee){
        employeeService.insert(employee);
        return "index";
    }
    
    @RequestMapping("/delete")
    public String delete(int id){
        employeeService.delete(id);
        return "index";
    }
    
    @RequestMapping("/findAllByPage")
    public String findAllByPage(@RequestParam(defaultValue = "1")String page,
            @RequestParam(defaultValue = "")String name,Model model){
        FenYe fenye = new FenYe(page, 3, employeeService.count(name));
        List<Employee> list = employeeService.findAllByPage((fenye.getCurrentPage()-1)*3, 3, name);
        model.addAttribute("fenye", fenye.show());
        model.addAttribute("list", list);
        return "index";
    }
}

猜你喜欢

转载自blog.csdn.net/ly_959/article/details/81950911