ssm+bootstrap+angularjs练习

package com.frank.util;


import java.util.HashMap;
import java.util.Map;


public class Msg {


private int code;//状态码:100表示成功,200表示失败
private String result;//操作成功、操作失败
private Map data = new HashMap();


//返回成功结果的方法
public static Msg success(){
Msg msg = new Msg();
msg.setCode(100);
msg.setResult("操作成功");
return msg;
}
//返回失败结果的方法
public static Msg fail(){
Msg msg = new Msg();
msg.setCode(200);
msg.setResult("操作失败");
return msg;
}

//存放数据,支持链式操作
public Msg add(String key,Object value){
this.getData().put(key, value);
return this;
}


public Msg() {
super();
}
public Msg(int code, String result, Map data) {
super();
this.code = code;
this.result = result;
this.data = data;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getResult() {
return result;
}
public void setResult(String result) {
this.result = result;
}
public Map getData() {
return data;
}
public void setData(Map data) {
this.data = data;
}



}


================================================================
package com.frank.dao;


import java.util.List;


import com.bw.bean.Dept;
import com.bw.bean.Emp;


public interface EmpDaoMapper {

//添加
public void addEmp(Emp emp);
//批量删除
public void batchDel(String eids);

//根据id删除
public void deleteByEid(Integer emp_id);

//查询所有
public List selectAllEmps();


//根据id查询员工
public Emp selectById(Integer emp_id);

//修改
public void updateEmp(Emp emp);

//查询所有部门
public List selectAllDepts();
}
============================================================

PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">







insert into t_emp(emp_name,gender,email,d_id) 
values(#{emp_name},#{gender},#{email},#{dept.dept_id})




update t_emp set 
emp_name=#{emp_name},
gender=#{gender},
email=#{email},
d_id=#{dept.dept_id} 
where emp_id = #{emp_id}




delete from t_emp where emp_id = #{emp_id}






delete from t_emp where emp_id in (${value})






















=================================


package com.frank.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.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import com.frank.bean.Dept;
import com.frank.bean.Emp;
import com.frank.service.EmpService;
import com.frank.util.Msg;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;


@Controller
@RequestMapping("/emp")
public class EmpController {


@Autowired
private EmpService empService;


@RequestMapping("/selectPage")
@ResponseBody
public Msg selectEmpsWithJson(
@RequestParam(value="pageno",defaultValue="1")Integer pageno
,@RequestParam(value="pagesize",defaultValue="2")Integer pagesize){
//指定查询的页码和每页的条数
PageHelper.startPage(pageno, pagesize);
//查询所有的员工数据
List empList = empService.selectAllEmps();
//将员工数据封装在pageInfo中
PageInfo pageInfo = new PageInfo(empList);
return Msg.success().add("pageInfo", pageInfo);
}



@RequestMapping(value="/selectDepts",method=RequestMethod.POST)
@ResponseBody
public Msg selectDepts(){
List depts = empService.selectAllDepts();
for (Dept dept : depts) {
System.out.println(dept);
}
return Msg.success().add("deptList", depts);
}



@RequestMapping("/save")
@ResponseBody
public Msg saveEmp(Emp emp){
empService.addEmp(emp);
return Msg.success();
}

@RequestMapping("/update")
@ResponseBody
public Msg updateEmp(Emp emp){
empService.updateEmp(emp);
return Msg.success();
}

@RequestMapping("delEmp")
@ResponseBody
public Msg delete(String eids){
if(eids.contains(",")){
empService.batchDel(eids);
}else{
empService.deleteByEid(Integer.parseInt(eids));
}
return Msg.success();
}

@RequestMapping("/selectEmp")
@ResponseBody
public Msg selectEmp(@RequestParam(value="emp_id")Integer emp_id){
Emp emp = empService.selectById(emp_id);
return Msg.success().add("emp", emp);
}

}
==================================
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>




 
   
      综合案例--员工信息管理












 
  





 
 
 
 







 

 

 

 

员工信息管理


 

 
 
 

 

 
 
 
 
 

 

   

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
id 员工姓名 性别 邮箱 所属部门 操作
{{emp.emp_id }} {{emp.emp_name}} {{emp.gender}} {{emp.email}} {{emp.dept.dept_name}}  
   


   
   

   

   

   
   
   
   

   
共有{{pageInfo.total}}条数据,共有{{pageInfo.pages}}页

   
   
   

   

   
 


你可能感兴趣的:(AngularJS)