首页>代码>springboot+angularJS简单的增删改查Demo>/boot-angular/src/main/java/com/joe/angularweb/controller/EmployeeController.java
package com.joe.angularweb.controller;

import com.joe.angularweb.model.Employee;
import com.joe.angularweb.service.EmployeeService;
import com.joe.angularweb.utils.ResultVOUtil;
import com.joe.angularweb.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Created by 180297 on 2017/12/13.
 */
@RestController
public class EmployeeController {

    @Autowired
    private EmployeeService employeeService;

    @GetMapping("/emp/list")
    public ResultVO<List<Employee>> list() {
        List<Employee> employeeList = employeeService.findAll();
        return ResultVOUtil.success(employeeList);
    }

    @GetMapping(value = "/emp/{id}",produces = MediaType.APPLICATION_JSON_VALUE)
    public ResultVO<Employee> getEmployee(@PathVariable("id")Integer id){
        Employee employee = employeeService.findOne(id);
        if (employee == null) {
            return ResultVOUtil.error(400,"未找到相关记录");
        }
        return ResultVOUtil.success(employee);
    }

    @PostMapping("/emp/save")
    public ResultVO<Employee> save(@RequestBody Employee employee) {
        Employee result = employeeService.save(employee);
        return ResultVOUtil.success(result);
    }

    @DeleteMapping("/emp/del/{empId}")
    public ResultVO delEmp(@PathVariable("empId")Integer empId){
        employeeService.deleteByEmpId(empId);
        return ResultVOUtil.success();
    }



}
最近下载更多
oulingqiao  LV13 2023年12月10日
Van1999  LV1 2023年7月17日
Jianwei153  LV1 2021年12月28日
lyws1986  LV17 2021年12月21日
-leave-  LV1 2021年10月21日
f15732905127  LV1 2021年4月18日
aaaa5654  LV1 2021年4月17日
moluofan  LV1 2021年3月25日
SpringClouddddd  LV1 2021年2月26日
黄伟伟  LV4 2021年2月26日
最近浏览更多
可乐要加冰1  LV8 2024年6月20日
wwwww816  LV5 2024年5月22日
哪里的完整版  LV8 2023年12月15日
oulingqiao  LV13 2023年12月10日
Demo1111  LV30 2023年12月8日
fff2003  LV9 2023年11月20日
漫步的海星  LV4 2023年9月26日
张朕朕  LV3 2023年9月10日
Van1999  LV1 2023年7月17日
lele666  LV4 2023年4月17日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友