首页>代码>基于ssm(spring+springmvc+mybatis)的餐厅员工管理系统>/z_sias/src/com/sias/ll/controller/EmployeeController.java
package com.sias.ll.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 com.sias.ll.pojo.Employee;
import com.sias.ll.service.EmployeeService;
/**
 *餐厅员工控制器
 */

@Controller
@RequestMapping("employee")
public class EmployeeController {

	@Autowired
	private EmployeeService employeeService;
	
	
	@RequestMapping("login")
	public String returnLogin(){
		return "index";
	}

	@RequestMapping("empmenu")
	public String showEmpMenu(){
		return "employee";
	}

	
	//查询所有餐厅员工的信息
	@RequestMapping("selectAllEmp")
	public String showAllEmp(){
		return null;
	}
	
	
	//根据主键查询
	@RequestMapping("selectById")
	public String selectById(Integer employeeid,Model model) {
		Employee employee = employeeService.selectByPrimaryKey(employeeid);
		model.addAttribute("emp", employee);
		return "UpdateEmp";
	}
	
	//查询所有员工信息
	@RequestMapping("selectAll")
	public String selectAllemp(Model model) {
		List<Employee> employees = employeeService.selectByAllemp();
		model.addAttribute("employees",employees);
		model.addAttribute("allEmp", "全部");
		return "ShowEmpByPosition";
	}
	
	//根据部职位查询
	@RequestMapping(value="selectByPosition")
	public String selectByPosition(Model model,
			@RequestParam(value = "position", required = true) String name) {
		List<Employee> employees = employeeService.selectByPosition(name);
		model.addAttribute("employees", employees);
		model.addAttribute("allEmp", null);
		return "ShowEmpByPosition";
	} 
	
	//模糊查询
	@RequestMapping("selectName")
	public List<Employee> selectByName(Employee employee) {
		employee.setName("on");
		List<Employee> employees = employeeService.selectByName(employee);
		return employees;
	}
	//添加
	@RequestMapping("insert")
	public String insertEmployee(Employee employee) {
		employeeService.insertEmployee(employee);
		return "success"; 
	}
	//删除
	@RequestMapping("delete")
	public String deleteEmployee(Integer employeeid) {
		employeeService.deleteByPrimaryKey(employeeid);
		return "success";
	}
	//修改
	@RequestMapping("update")
	public String updateEmployee(Employee employee) {
		employeeService.updateByPrimaryKeySelective(employee);
		return "success";
	}
}
最近下载更多
海棠花瘦  LV9 2023年5月9日
LCL10086  LV3 2023年1月15日
001128wxw  LV3 2022年12月15日
微信网友_6108289352863744  LV4 2022年9月16日
and123456  LV11 2022年7月15日
Hsy605  LV9 2022年6月22日
zzwwjjmm  LV2 2022年6月7日
qwer123546  LV13 2022年5月12日
ferrymen  LV6 2022年4月20日
591231555  LV20 2022年4月18日
最近浏览更多
yangyuer  LV1 昨天
wddq123 4月2日
暂无贡献等级
WBelong  LV7 4月1日
13188866605  LV12 3月26日
jiangxiaohia 3月1日
暂无贡献等级
小海脑洞大开  LV11 2月4日
Camellia-while  LV1 1月2日
微信网友_6786501704093696 2023年12月20日
暂无贡献等级
123456lxw 2023年12月17日
暂无贡献等级
shuangfu  LV24 2023年12月2日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友