Commit 172fc5b6 authored by Jorge Vega's avatar Jorge Vega

todo

parent 7f7a13a4
This source diff could not be displayed because it is too large. You can view the blob instead.
angular.module('crudApp').factory('Employee',Employee);
Employee.$inject=['$resource'];
function Employee($resource){
var resourceUrl='npi/employee/:id';
return $resource(resourceUrl,{},{
'update':{
method:'PUT'
}
});
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
package espe.edu.ec.angularjsrestapidemo.repository;
public interface EmployeeRepository {
}
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.5
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
package espe.edu.ec.angularjsrestapidemo.service;
import javax.persistence.EntityExistsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import antlr.collections.List;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.repository.EmployeeRepository;
@Service
public class EmployeeService {
private EmployeeRepository employeeRepository;
@Autowired
public EmployeeService(EmployeeRepository employeeRepository) {
this.employeeRepository=employeeRepository;
}
public Employee save(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public Employee update(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
}
package espe.edu.ec.angularjsrestapidemo.model;
public class Employee {
}
package espe.edu.ec.angularjsrestapidemo.controller;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) throws URISyntaxException {
try {
Employee result=employeeService.save(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
return new ResponseEntity<Employee>(HttpStatus.CONFLICT);
}
}
@RequestMapping(value="employee",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> updateEmployee(@RequestBody Employee employee) throws URISyntaxException {
if (employee.getId()==null) {
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
}
try {
Employee result=employeeService.update(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
}
}
}
package espe.edu.ec.angularjsrestapidemo.service;
import javax.persistence.EntityExistsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import antlr.collections.List;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.repository.EmployeeRepository;
@Service
public class EmployeeService {
private EmployeeRepository employeeRepository;
@Autowired
public EmployeeService(EmployeeRepository employeeRepository) {
this.employeeRepository=employeeRepository;
}
public Employee save(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public Employee update(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public List<Employee> findAll(){
return employeeRepository.findAll();
}
public Employee findOne(Integer id) {
return employeeRepository.findOne(id);
}
public void delete(Integer id ) {
employeeRepository.delete(id);
}
}
package espe.edu.ec.angularjsrestapidemo.model;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@Entity
@Table(name="Employee")
@EntityListeners(AuditingEntityListener.class)
public class Employee {
}
package espe.edu.ec.angularjsrestapidemo.service;
public class EmployeeService {
}
var app-angular.module("crudApp",['ngResource']);
\ No newline at end of file
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>espe.edu.ec</groupId>
<artifactId>AngularJsRestApiDemo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>AngularJsRestApiDemo Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>AngularJsRestApiDemo</finalName>
</build>
</project>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.letsstartcoding</groupId>
<artifactId>angularjsrestapidemo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>angularjsrestapidemo Maven Webapp</name>
<url>http://maven.apache.org</url>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>angularjsrestapidemo</finalName>
</build>
</project>
var app=angular.module("crudApp",['ngResource']);
\ No newline at end of file
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.5
package espe.edu.ec.angularjsrestapidemo.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeService(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
}
package espe.edu.ec.angularjsrestapidemo.controller;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) throws URISyntaxException {
try {
Employee result=employeeService.save(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
return new ResponseEntity<Employee>(HttpStatus.CONFLICT);
}
}
}
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
package espe.edu.ec.angularjsrestapidemo.controller;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) throws URISyntaxException {
try {
Employee result=employeeService.save(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
return new ResponseEntity<Employee>(HttpStatus.CONFLICT);
}
}
@RequestMapping(value="employee",method=RequestMethod.PUT,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> updateEmployee(@RequestBody Employee employee) throws URISyntaxException {
if (employee.getId()==null) {
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
}
try {
Employee result=employeeService.update(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
}
}
@RequestMapping(value="/employee/{id}",method=RequestMethod.DELETE,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Void> deleteEmployee(@PathVariable Integer id){
employeeService.delete(id);
return ResponseEntity.ok().build();
}
}
package espe.edu.ec.angularjsrestapidemo.controller;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) throws URISyntaxException {
try {
Employee result=employeeService.save(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
// TODO: handle exception
}
}
}
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
package espe.edu.ec.angularjsrestapidemo.repository;
import org.springframework.data.jpa.repository.JpaRepository;
public interface EmployeeRepository extends JpaRepository<Employee, Integer> {
}
var app-angular.module("crudApp",['ngResource']);
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
</body>
</html>
\ No newline at end of file
package espe.edu.ec.angularjsrestapidemo.controller;
import java.net.URISyntaxException;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) throws URISyntaxException {
try {
Employee result=employeeService.save(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
// TODO: handle exception
}
}
}
package espe.edu.ec.angularjsrestapidemo.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
public interface EmployeeRepository extends JpaRepository<Employee, Integer> {
}
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<property name="context-root" value="AngularJsRestApiDemo"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
package espe.edu.ec.angularjsrestapidemo.service;
import javax.persistence.EntityExistsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.repository.EmployeeRepository;
@Service
public class EmployeeService {
private EmployeeRepository employeeRepository;
@Autowired
public EmployeeService(EmployeeRepository employeeRepository) {
this.employeeRepository=employeeRepository;
}
public Employee save(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public Employee update(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public java.util.List<Employee> findAll(){
return employeeRepository.findAll();
}
public Employee findOne(Integer id) {
return employeeRepository.findOne(id);
}
public void delete(Integer id ) {
employeeRepository.delete(id);
}
}
var app;-angular.module("crudApp",['ngResource']);
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId">
<wb-module deploy-name="AngularJsRestApiDemo"/>
</project-modules>
angular.module("crudApp").controller("GeneralController",GeneralController);
GeneralController.inject=['$scope','Employee'];
function GeneralController($scope,Employee) {
$scope.employees=Employee.query();
$scope.employee={};
$scope.buttonText="Submit";
$scope.saveEmployee=function(){
if ($scope.employee.id!==undefined) {
Employee.update($scope,employee,function(){
$scope.employees=Employee.query();
$scope.employee={};
$scope.buttonText="Submit";
});
}else {
Employee.save($scope,employee,function(){
$scope.employees=Employee.query();
$scope.employee={};
});
}
}
$scope.updateEmployeeInit=function(employee){
$scope.buttonText="Update";
$scope.employee=employee;
}
$scope.deleteEmployee=function(employee){
employee.$delete({id:employee.id},function(){
$scope.employees=Employee.query();
});
}
}
\ No newline at end of file
package espe.edu.ec.angularjsrestapidemo.service;
import javax.persistence.EntityExistsException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import antlr.collections.List;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.repository.EmployeeRepository;
@Service
public class EmployeeService {
private EmployeeRepository employeeRepository;
@Autowired
public EmployeeService(EmployeeRepository employeeRepository) {
this.employeeRepository=employeeRepository;
}
public Employee save(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public Employee update(Employee employee) {
if(employee.getId()!=null&&employeeRepository.exists(employee.getId())) {
throw new EntityExistsException("Ya se encuentra un registro con ese id en la base de datos");
}
return employeeRepository.save(employee);
}
public java.util.List<Employee> findAll(){
return employeeRepository.findAll();
}
public Employee findOne(Integer id) {
return employeeRepository.findOne(id);
}
public void delete(Integer id ) {
employeeRepository.delete(id);
}
}
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
package espe.edu.ec.angularjsrestapidemo.model;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@Entity
@Table(name="Employee")
@EntityListeners(AuditingEntityListener.class)
public class Employee {
}
package espe.edu.ec.angularjsrestapidemo;
public class CrudApp {
}
package espe.edu.ec.angularjsrestapidemo.controller;
public class EmployeeResource {
}
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:mysql://localhost:3306/world?useSSL=false
spring.datasource.username = root
spring.datasource.password = varun123
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
package espe.edu.ec.angularjsrestapidemo.controller;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
}
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
var app-angular.module("crudApp",['ngResource']);
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
package espe.edu.ec.angularjsrestapidemo.controller;
import java.util.List;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import espe.edu.ec.angularjsrestapidemo.model.Employee;
import espe.edu.ec.angularjsrestapidemo.service.EmployeeService;
@RestController
@RequestMapping("/api")
public class EmployeeResource {
private EmployeeService employeeService;
public EmployeeResource(EmployeeService employeeService) {
this.employeeService=employeeService;
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public List<Employee> getAllEmployees(){
return employeeService.findAll();
}
@RequestMapping(value="employee",method=RequestMethod.GET,produces=MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Employee> createEmployee(@RequestBody Employee employee) throws URISyntaxException {
try {
Employee result=employeeService.save(employee);
return ResponseEntity.created(new URI("/api/employee/"+result.getId())).body(result);
} catch (Exception e) {
// TODO: handle exception
}
}
}
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AngularJsRestApiDemo">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="context-root" value="AngularJsRestApiDemo"/>
<property name="java-output-path" value="/AngularJsRestApiDemo/target/classes"/>
</wb-module>
</project-modules>
eclipse.preferences.version=1
org.eclipse.debug.ui.PREF_LAUNCH_PERSPECTIVES=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<launchPerspectives/>\r\n
preferredTargets=default\:default|default,org.eclipse.wst.jsdt.chromium.debug.ui.toggleTargetId\:default|
core_autoIgnoreDerivedResources=false
eclipse.preferences.version=1
CatalogDescriptor=http\://marketplace.eclipse.org
eclipse.preferences.version=1
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=
org.eclipse.jdt.core.classpathVariable.JRE_LIB=C\:/Program Files/Java/jdk1.8.0_77/jre/lib/rt.jar
org.eclipse.jdt.core.classpathVariable.JRE_SRC=C\:/Program Files/Java/jdk1.8.0_77/src.zip
org.eclipse.jdt.core.classpathVariable.JRE_SRCROOT=
org.eclipse.jdt.core.codeComplete.visibilityCheck=enabled
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
eclipse.preferences.version=1
org.eclipse.jdt.junit.content_assist_favorite_static_members_migrated=true
eclipse.preferences.version=1
org.eclipse.jdt.launching.PREF_VM_XML=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?>\r\n<vmSettings defaultVM\="57,org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType13,1550781041276">\r\n<vmType id\="org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType">\r\n<vm id\="1550758519369" name\="jre1.8.0_201" path\="C\:\\Program Files\\Java\\jre1.8.0_201"/>\r\n<vm id\="1550781041276" javadocURL\="https\://docs.oracle.com/javase/8/docs/api/" name\="jdk1.8.0_77" path\="C\:\\Program Files\\Java\\jdk1.8.0_77"/>\r\n</vmType>\r\n</vmSettings>\r\n
content_assist_favorite_static_members=org.assertj.core.api.Assertions.*;org.mockito.Matchers.*;org.mockito.Mockito.*;org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestBuilders.*;org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.*;org.springframework.security.test.web.servlet.response.SecurityMockMvcResultMatchers.*;org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.*;org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.*;org.springframework.test.web.client.match.MockRestRequestMatchers.*;org.springframework.test.web.client.response.MockRestResponseCreators.*;org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;org.hamcrest.CoreMatchers.*;org.junit.Assert.*
content_assist_number_of_computers=23
content_assist_proposals_background=255,255,255
content_assist_proposals_foreground=0,0,0
eclipse.preferences.version=1
org.eclipse.jdt.internal.ui.navigator.layout=2
org.eclipse.jdt.internal.ui.navigator.librariesnode=true
org.eclipse.jdt.ui.formatterprofiles.version=15
org.eclipse.jdt.ui.text.code_templates_migrated=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
org.eclipse.jdt.ui.text.custom_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
org.eclipse.jdt.ui.text.templates_migrated=true
spelling_locale_initialized=true
useAnnotationsPrefPage=true
useQuickDiffPrefPage=true
eclipse.preferences.version=1
org.eclipse.jsch.core.hasChangedDefaultWin32SshHome=true
eclipse.preferences.version=1
org.eclipse.jst.jsp.core.internal.java.search.JSPIndexManager=JSP Index v3.10_20180412_01
eclipse.preferences.version=1
locationorg.eclipse.jst.server.tomcat.runtime.70=C\:/xampp/tomcat
eclipse.preferences.version=1
org.eclipse.m2e.discovery.pref.projects=
eclipse.preferences.version=1
org.eclipse.mylyn.monitor.activity.tracking.enabled.checked=true
eclipse.preferences.version=1
migrated.task.repositories.secure.store=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching=true
org.eclipse.mylyn.tasks.ui.filters.nonmatching.encouraged=true
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment