Commit f6b6b75d authored by đinh thị đầm's avatar đinh thị đầm

Merge branch 'dinhdam'

# Conflicts:
#	pom.xml
parents 3f8b818a 3fe93122
...@@ -44,6 +44,13 @@ ...@@ -44,6 +44,13 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/log4j/log4j -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
</dependencies> </dependencies>
......
...@@ -2,13 +2,14 @@ package com.itsol.quantrivanphong.access.homepage.controller; ...@@ -2,13 +2,14 @@ package com.itsol.quantrivanphong.access.homepage.controller;
import com.itsol.quantrivanphong.access.homepage.business.CatalogiBusiness; import com.itsol.quantrivanphong.access.homepage.business.CatalogiBusiness;
import com.itsol.quantrivanphong.access.homepage.business.NewsBusiness; import com.itsol.quantrivanphong.access.homepage.business.NewsBusiness;
import com.itsol.quantrivanphong.employee.bussiness.EmployeeBussiness;
import com.itsol.quantrivanphong.business.EmployeeBusiness;
import com.itsol.quantrivanphong.exception.ResourceNotFoundException; import com.itsol.quantrivanphong.exception.ResourceNotFoundException;
import com.itsol.quantrivanphong.model.Employee; import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.model.News; import com.itsol.quantrivanphong.model.News;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -25,7 +26,7 @@ public class NewsController { ...@@ -25,7 +26,7 @@ public class NewsController {
private CatalogiBusiness catalogiBusiness; private CatalogiBusiness catalogiBusiness;
@Autowired @Autowired
private EmployeeBussiness employeeBusiness; private EmployeeBusiness employeeBusiness;
// get All news // get All news
@GetMapping("/news") @GetMapping("/news")
public ResponseEntity<List<News>> getAllNews(){ public ResponseEntity<List<News>> getAllNews(){
...@@ -48,10 +49,9 @@ public class NewsController { ...@@ -48,10 +49,9 @@ public class NewsController {
@PostMapping("/news/employees/{employeeId}") @PostMapping("/news/employees/{employeeId}")
public News createNews(@PathVariable (value = "employeeId") int employeeId, public News createNews(@PathVariable (value = "employeeId") int employeeId,
@Valid @RequestBody News news) { @Valid @RequestBody News news) {
return employeeBusiness.findById(employeeId).map(employee -> { Employee employee = employeeBusiness.findById(employeeId);
news.setEmployee(employee); news.setEmployee(employee);
return newsBusiness.save(news); return newsBusiness.save(news);
}).orElseThrow(() -> new ResourceNotFoundException("Employee" ,"employeeId",employeeId));
} }
// Edit news by EmployeeId // Edit news by EmployeeId
...@@ -59,7 +59,7 @@ public class NewsController { ...@@ -59,7 +59,7 @@ public class NewsController {
public News updateNews(@PathVariable (value = "employeeId") int employeeId, public News updateNews(@PathVariable (value = "employeeId") int employeeId,
@PathVariable (value = "newsId") int newsId, @PathVariable (value = "newsId") int newsId,
@Valid @RequestBody News newsRequest) { @Valid @RequestBody News newsRequest) {
if(!employeeBusiness.findById(employeeId).isPresent()) { if(employeeBusiness.findById(employeeId) == null) {
throw new ResourceNotFoundException("Employee" ,"employeeId",employeeId); throw new ResourceNotFoundException("Employee" ,"employeeId",employeeId);
} }
if (!newsBusiness.findById(newsId).isPresent()) { if (!newsBusiness.findById(newsId).isPresent()) {
......
package com.itsol.quantrivanphong.service; package com.itsol.quantrivanphong.business;
import com.itsol.quantrivanphong.model.Employee; import com.itsol.quantrivanphong.model.Employee;
import org.springframework.validation.Validator; import org.springframework.validation.Validator;
import java.util.List; import java.util.List;
public interface EmployeeService extends Validator { public interface EmployeeBusiness extends Validator {
List<Employee> findAll(); List<Employee> findAll();
Employee findById(int id); Employee findById(int id);
......
package com.itsol.quantrivanphong.service.impl; package com.itsol.quantrivanphong.business.impl;
import com.itsol.quantrivanphong.model.Employee; import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.repository.EmployeeRepository; import com.itsol.quantrivanphong.repository.EmployeeRepository;
import com.itsol.quantrivanphong.service.EmployeeService; import com.itsol.quantrivanphong.business.EmployeeBusiness;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.validation.Errors; import org.springframework.validation.Errors;
...@@ -11,7 +11,7 @@ import org.springframework.validation.Errors; ...@@ -11,7 +11,7 @@ import org.springframework.validation.Errors;
import java.util.List; import java.util.List;
@Service @Service
public class EmployeeServiceImpl implements EmployeeService { public class EmployeeBusinessImpl implements EmployeeBusiness {
@Autowired @Autowired
private EmployeeRepository employeeRepository; private EmployeeRepository employeeRepository;
......
package com.itsol.quantrivanphong.controller; package com.itsol.quantrivanphong.controller;
import com.itsol.quantrivanphong.model.Employee; import com.itsol.quantrivanphong.model.Employee;
import com.itsol.quantrivanphong.service.EmployeeService; import com.itsol.quantrivanphong.business.EmployeeBusiness;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
...@@ -15,34 +15,34 @@ import java.util.List; ...@@ -15,34 +15,34 @@ import java.util.List;
public class EmployeeController { public class EmployeeController {
@Autowired @Autowired
//Retrieve Employee by id //Retrieve Employee by id
private EmployeeService employeeService; private EmployeeBusiness employeeBusiness;
@RequestMapping(value = "/employee/{id}", method = RequestMethod.GET) @RequestMapping(value = "/employee/{id}", method = RequestMethod.GET)
public ResponseEntity<Employee> getEmployee(@PathVariable("id") int id) { public ResponseEntity<Employee> getEmployee(@PathVariable("id") int id) {
System.out.println("Fetching employee with id " + id); System.out.println("Fetching employee with id " + id);
Employee employee = employeeService.findById(id); Employee employee = employeeBusiness.findById(id);
if (employee == null) { if (employee == null) {
System.out.println("Employee with id : " + id + " not found"); System.out.println("Employee with id : " + id + " not found");
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND); return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
} }
return new ResponseEntity<Employee>( employee , null,HttpStatus.OK); return new ResponseEntity<Employee>( employee ,HttpStatus.OK);
} }
//Retrieve all employee //Retrieve all employee
@RequestMapping(value = "/list_employee", method = RequestMethod.GET) @RequestMapping(value = "/list_employee", method = RequestMethod.GET)
public ResponseEntity<List<Employee>> listAllEmployee() { public ResponseEntity<List<Employee>> listAllEmployee() {
List<Employee> employees = employeeService.findAll(); List<Employee> employees = employeeBusiness.findAll();
if (employees == null) { if (employees == null) {
return new ResponseEntity<List<Employee>>(HttpStatus.NO_CONTENT); return new ResponseEntity<List<Employee>>(HttpStatus.NO_CONTENT);
} }
return new ResponseEntity<List<Employee>>( employees , null ,HttpStatus.OK); return new ResponseEntity<List<Employee>>( employees , null ,HttpStatus.OK);
} }
//Update Employee //Update a Employee
@RequestMapping(value = "/employee/{id}", method = RequestMethod.PUT) @RequestMapping(value = "/employee/{id}", method = RequestMethod.PUT)
public ResponseEntity<Employee> updateEmployee(@PathVariable("id") int id, @RequestBody Employee employee) { public ResponseEntity<Employee> updateEmployee(@PathVariable("id") int id, @RequestBody Employee employee) {
System.out.println("Update Employee " + id); System.out.println("Update Employee " + id);
Employee currentEmployee = employeeService.findById(id); Employee currentEmployee = employeeBusiness.findById(id);
if (employee == null) { if (employee == null) {
System.out.println("Employee with id :" + id + "not found"); System.out.println("Employee with id :" + id + "not found");
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND); return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
...@@ -62,20 +62,34 @@ public class EmployeeController { ...@@ -62,20 +62,34 @@ public class EmployeeController {
currentEmployee.setDepartment(employee.getDepartment()); currentEmployee.setDepartment(employee.getDepartment());
currentEmployee.setGraduationYear(employee.getGraduationYear()); currentEmployee.setGraduationYear(employee.getGraduationYear());
currentEmployee.setPicture(employee.getPicture()); currentEmployee.setPicture(employee.getPicture());
employeeService.save(currentEmployee); employeeBusiness.save(currentEmployee);
return new ResponseEntity<Employee>( currentEmployee ,HttpStatus.OK); return new ResponseEntity<Employee>( currentEmployee ,HttpStatus.OK);
} }
//create new Employee //Create a Employee
@RequestMapping(value = "/list_employee", method = RequestMethod.POST) @RequestMapping(value = "/list_employee", method = RequestMethod.POST)
public ResponseEntity<Void> createEmployee(@RequestBody Employee employee, public ResponseEntity<Void> createEmployee(@RequestBody Employee employee,
UriComponentsBuilder uriComponentsBuilder){ UriComponentsBuilder uriComponentsBuilder){
System.out.println("Create Employee "+ employee.getUsername()); System.out.println("Create Employee "+ employee.getUsername());
employeeService.save(employee); employeeBusiness.save(employee);
HttpHeaders httpHeaders = new HttpHeaders(); HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.setLocation(uriComponentsBuilder.path("/employee/{id}").buildAndExpand(employee.getId()).toUri()); httpHeaders.setLocation(uriComponentsBuilder.path("/employee/{id}").buildAndExpand(employee.getId()).toUri());
return new ResponseEntity<Void>( httpHeaders ,HttpStatus.CREATED); return new ResponseEntity<Void>( httpHeaders ,HttpStatus.CREATED);
} }
//Delete a Employee
@RequestMapping(value = "/employee/{id}" , method = RequestMethod.DELETE)
public ResponseEntity<Employee> deleteEmployee(@PathVariable("id") int id){
System.out.println("Fetching and deleting Employee with id :" + id );
Employee employee = employeeBusiness.findById(id);
if(employee == null) {
System.out.println("Unable to delete. Employee with id :" + id + "not found");
return new ResponseEntity<Employee>(HttpStatus.NOT_FOUND);
}
employeeBusiness.deleteById(id);
return new ResponseEntity<Employee>(HttpStatus.NO_CONTENT);
}
} }
package com.itsol.quantrivanphong.employee.bussiness;
import com.itsol.quantrivanphong.employee.repository.EmployeeRepository;
import com.itsol.quantrivanphong.model.Employee;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Optional;
@Service
public class EmployeeBussiness {
@Autowired
EmployeeRepository employeeRepository;
// public List<Employee> findAll(){
// return employeeRepository.findAll();
// }
//
public Optional<Employee> findById(int newsId){
return employeeRepository.findById(newsId);
}
// public User save(User user){
// return userRepository.save(user);
// }
// public User updateUser(Long newsId, User signUpDTO){
// User user = userRepository.findUserById(newsId);
// user.setUsername(signUpDTO.getUsername());
// user.setPassword(signUpDTO.getPassword());
// user.setEmail(signUpDTO.getEmail());
// user.setFullname(signUpDTO.getFullname());
// user.setImage(signUpDTO.getImage());
// user.setKnowledge(signUpDTO.getKnowledge());
// user.setUniversity(signUpDTO.getUniversity());
// user.setPhonenumber(signUpDTO.getPhonenumber());
// user.setPosition(signUpDTO.getPosition());
// user.setVillage(signUpDTO.getVillage());
// user.setYearOfGraduation(signUpDTO.getYearOfGraduation());
// user.setRole(signUpDTO.getRole());
// return userRepository.save(user);
// }
//
// public void deleteUser(Long newsId){
// userRepository.deleteById(newsId);
// }
}
//package com.itsol.quantrivanphong.employee.controller;
//
//import com.example.easynotes.exception.ResourceNotFoundException;
//import com.example.easynotes.login.model.User;
//import com.example.easynotes.users.bussiness.UserBussiness;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.http.ResponseEntity;
//import org.springframework.web.bind.annotation.*;
//
//import javax.validation.Valid;
//import java.util.List;
//
//@RestController
//@RequestMapping("/api")
//public class UserController {
//
// @Autowired
// private UserBussiness userBussiness;
//
// @GetMapping("/users")
// public List<User> getAllUser(){ return userBussiness.findAll();}
//
// @GetMapping("/users/{id}")
// public User getUserById(@PathVariable(value = "id") Long userId){
// return userBussiness.findById(userId).orElseThrow(()-> new ResourceNotFoundException("News", "id", userId));
// }
//
// @PutMapping("/users/{id}")
// public ResponseEntity<User> updateUser(@PathVariable(value = "id") Long userId,
// @Valid @RequestBody User userDetails) {
// if (!userBussiness.findById(userId).isPresent()) {
// throw new ResourceNotFoundException("User", "id", userId);
// }
// return ResponseEntity.ok(userBussiness.updateUser(userId,userDetails));
// }
//}
package com.itsol.quantrivanphong.employee.repository;
import com.itsol.quantrivanphong.model.Employee;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
public interface EmployeeRepository extends JpaRepository<Employee,Integer> {
@Query("SELECT u FROM Employee u where u.id=:id")
Employee findEmployeeById(int id);
}
<!DOCTYPE html>
<!DOCTYPE HTML>
<html> <html>
<head> <head>
<meta charset="UTF-8"> <title>Business_Blog a Blogging Category Flat Bootstrap Responsive Website Template | World :: w3layouts</title>
<title>Quản Trị Văn Phòng</title> <meta name="viewport" content="width=device-width, initial-scale=1">
<!-- angular --> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="angularjs/angular.js"></script> <meta name="keywords" content="Business_Blog Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template,
<!-- Custom fonts for this template--> Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyErricsson, Motorola web design" />
<script type="applijewelleryion/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </script>
<link href="https://use.fontawesome.com/releases/v5.6.3/css/all.css" <link href="css/bootstrap.css" rel='stylesheet' type='text/css' />
rel="stylesheet" type="text/css"> <!-- Custom Theme files -->
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700" rel='stylesheet' type='text/css'>
<link href="admin/css/all.min.css" rel="stylesheet" <link href="https://fonts.googleapis.com/css?family=Open+Sans" type='text/css'>
type="text/css"> <link href="css/style.css" rel='stylesheet' type='text/css' />
<!-- Page level plugin CSS--> <!--Khai báo các thư viện-->
<link href="admin/css/dataTables.bootstrap4.css" <script src="js/jquery-3.2.1.min.js"></script>
rel="stylesheet"> <script src="js/bootstrap.min.js"></script>
<script src="js/angular.js"></script>
<!-- Custom styles for this template--> <script src="js/angular-ui-router.min.js"></script>
<link href="admin/css/sb-admin.css" rel="stylesheet"> <!--End khai báo thư viện-->
<!--Khai báo các file js-->
<script src="js/app.js"></script>
<!--End khai báo các file js-->
<!-- khai báo các controllers -->
<script src="pages/employee/employeeController.js"></script>
<!--End khai báo controllers-->
</head> </head>
<body ng-app="myApp">
<!--start-main-->
<div class="container">
<body ng-app=""> </div>
<!-- header -->
<div ng-include=" 'common/admin/header.html' "></div>
<!--end header -->
<div id="wrapper">
<!-- menu -->
<div ng-include=" 'common/admin/menu.html' "></div>
<!-- end menu -->
<div class="container-fluid">
<!-- Content -->
<div class="card mb-3">
<div class="card-header">
<i class="fas fa-table"></i> Danh Sách Dự Án
</div>
<div class="card-body" ng-app="ProjectApiModule">
<div class="table-responsive" ng-controller="showProject">
<a href="#" class="btn btn-primary btn-circle btn-sm" style="margin-bottom: 10px;"> Thêm </a>
<table class="table table-bordered" id="dataTable" width="100%"
cellspacing="0">
<thead>
<tr>
<th>Tên Dự Án</th>
<th>Mô tả ngắn</th>
<th>Ngày bắt đầu</th>
<th>Hạn giao</th>
<th>Trạng Thái</th>
<th>Thao Tác</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="project in listProject">
<td>{{ project.name }}</td>
<td>{{ project.descriptions }}</td>
<td>{{ project.startDate | date:"dd/MM/yyyy" }}</td>
<td>{{ project.endDate | date:"dd/MM/yyyy" }}</td>
<td>{{ project.statusGet }}</td>
<td><a data-ng-href="#" class="btn btn-info btn-circle btn-sm">
Xem </a> <a data-ng-href="#" class="btn btn-warning btn-circle btn-sm">
Sửa </a> <a data-ng-href="#" class="btn btn-danger btn-circle btn-sm">Xóa</a>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<!--End Content -->
</div>
<!-- footer -->
<div ng-include=" 'common/admin/footer.html' "></div>
</div>
<!--end footer -->
<!-- Js -->
<!-- Bootstrap core JavaScript-->
<script src="admin/js/jquery.min.js"></script>
<script src="admin/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="admin/js/jquery.easing.min.js"></script>
<!-- Page level plugin JavaScript-->
<script src="admin/js/Chart.min.js"></script>
<script src="admin/js/jquery.dataTables.js"></script>
<script src="admin/js/dataTables.bootstrap4.js"></script>
<!-- Custom scripts for all pages-->
<script src="admin/js/sb-admin.min.js"></script>
<!--angular js-->
<script src="components/project/projectController.js"></script>
</body> </body>
</html> </html>
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/**
*
*/
angular.module("myApp", ["ui.router"]).config(function($stateProvider, $urlRouterProvider,$locationProvider) {
$locationProvider.hashPrefix('');
$urlRouterProvider.otherwise("/index");
$stateProvider
//index layout riêng
.state("index", {
url: "/index",
views:{
"index":{
templateUrl: "pages/index/index.htm",
controller: "indexController"
},
"banner":{
templateUrl: "pages/index/banner.htm"
}
}
})
// State chứa layout chung cho các trang
.state('app', {
abstract: true,
views: {
'main_layout': {
templateUrl: 'main_layout.html',
}
}
})
// Các state bên dưới kế thừa state app
.state("tintuc", { // Khai báo một state
parent: 'app',
url: "/tintuc", // URL hiển thị
views:{
"content":{
templateUrl: "pages/tintuc/tintuc.htm",
controller: "tintucController" // khai báo controller
}
}
})
.state("tuyendung", {
parent: 'app',
url: "/tuyendung",
views:{
"content":{
templateUrl: "pages/tuyendung/tuyendung.htm",
controller: "tuyendungController"
}
}
})
// .state("lienhe", {
// parent: 'app',
// url: "/lienhe",
// views:{
// "content":{
// templateUrl: "pages/lienhe/lienhe.htm",
// controller: "lienheController"
// }
// }
// })
.state("gioithieu", {
parent: 'app',
url: "/gioithieu",
views:{
"content":{
templateUrl: "pages/gioithieu/gioithieu.htm",
controller: "gioithieuController"
}
}
})
});
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<!-- technology -->
<div class="technology-1">
<div class="container">
<div class="col-md-9 technology-left">
<div ui-view="content">
<!-- nội dung các trang -->
</div>
</div>
<!-- technology-right -->
<div class="col-md-3 technology-right-1">
<div class="blo-top">
<div class="tech-btm">
<img src="images/banner1.jpg" class="img-responsive" alt=""/>
</div>
</div>
<div class="blo-top">
<div class="tech-btm">
<h4>Sign up to our newsletter</h4>
<p>Pellentesque dui, non felis. Maecenas male</p>
<div class="name">
<form>
<input type="text" placeholder="Email" required="">
</form>
</div>
<div class="button">
<form>
<input type="submit" value="Subscribe">
</form>
</div>
<div class="clearfix"> </div>
</div>
</div>
<div class="blo-top1">
<div class="tech-btm">
<h4>Tin tức nổi bật </h4>
<div class="blog-grids">
<div class="blog-grid-left">
<a href="singlepage.html"><img src="images/6.jpg" class="img-responsive" alt=""/></a>
</div>
<div class="blog-grid-right">
<h5><a href="singlepage.html">Pellentesque dui, non felis. Maecenas male</a> </h5>
</div>
<div class="clearfix"> </div>
</div>
<div class="blog-grids">
<div class="blog-grid-left">
<a href="singlepage.html"><img src="images/7.jpg" class="img-responsive" alt=""/></a>
</div>
<div class="blog-grid-right">
<h5><a href="singlepage.html">Pellentesque dui, non felis. Maecenas male</a> </h5>
</div>
<div class="clearfix"> </div>
</div>
<div class="blog-grids">
<div class="blog-grid-left">
<a href="singlepage.html"><img src="images/11.jpg" class="img-responsive" alt=""/></a>
</div>
<div class="blog-grid-right">
<h5><a href="singlepage.html">Pellentesque dui, non felis. Maecenas male</a> </h5>
</div>
<div class="clearfix"> </div>
</div>
<div class="blog-grids">
<div class="blog-grid-left">
<a href="singlepage.html"><img src="images/9.jpg" class="img-responsive" alt=""/></a>
</div>
<div class="blog-grid-right">
<h5><a href="singlepage.html">Pellentesque dui, non felis. Maecenas male</a> </h5>
</div>
<div class="clearfix"> </div>
</div>
<div class="blog-grids">
<div class="blog-grid-left">
<a href="singlepage.html"><img src="images/10.jpg" class="img-responsive" alt=""/></a>
</div>
<div class="blog-grid-right">
<h5><a href="singlepage.html">Pellentesque dui, non felis. Maecenas male</a> </h5>
</div>
<div class="clearfix"> </div>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<!-- technology-right -->
</div>
</div>
<!-- technology -->
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-8">
<div>
<legend>Employee Details</legend>
<table>
<tr>
<td><label>User Name</label></td>
<td>
<input type="text" maxlength="29" ng-model="emp.username"/>
</td>
</tr>
<tr>
<td><label>First Name</label></td>
<td>
<input type="text" maxlength="29" ng-model="emp.firstName"/>
</td>
</tr>
<tr>
<td><label>Last Name</label></td>
<td>
<input type="text" maxlength="29" ng-model="emp.lastName"/>
</td>
</tr>
<tr>
<td><label id="email" for="email">Email</label> </td>
<td>
<input type="email" maxlength="150" ng-model="emp.emailAddress"/>
</td>
</tr>
<tr>
<td><label>Phone</label></td>
<td>
<input type="text" maxlength="10" value="" ng-model="emp.phoneNumber"/>
</td>
</tr>
<tr>
<td><label>education:</label></td>
<td>
<input ng-model="emp.education"/>
</td>
</tr>
<tr>
<td><label >home town:</label></td>
<td> <input type="text" ng-model="emp.homeTown"/></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submit" value="submit" ng-click="save();"/>
<input type="submit" name="clear" value="clear" ng-click=" emp = null"/>
</td>
</tr>
</table>
</div>
<div>
<table class="table">
<thead>
<tr>
<th>ID</th>
<th>User Name</th>
<th>First Name</th>
<th>Last Name</th>
<th>EmailAddress</th>
<th>Phone</th>
<th>Education</th>
<th>Home Town</th>
</tr>
</thead>
<tbody>
<tr class="vide" ng-repeat="emp in employess">
<td>{{$index + 1}}</td>
<td>{{emp.username}}</td>
<td>{{emp.firstName}}</td>
<td>{{emp.lastName}}</td>
<td>{{emp.emailAddress}}</td>
<td>{{emp.phoneNumber}}</td>
<td>{{emp.education}}</td>
<td>{{emp.homeTown}}</td>
<td><a href="#" ng-click="update(emp);">Update</a>
<td><a href="#" confirmed-click="delete(employee);" ng-confirm-click=" Do you want to delete this user?">Delete</a></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
/**
*
*/
angular.module("myApp",[]).controller("tintucController", function($scope, $http,$window) {
console.log("Tin tức controller");
$scope.emp= {
"username": "",
"password": "",
"firstName": "",
"lastName": "",
"emailAddress": "",
"phoneNumber": "",
"homeTown": "",
"education": ""
};
$scope.save = save;
function save(){
console.log($scope.emp);
$http({
method : 'POST',
url : "http://localhost:8081/list_employee/",
data: $scope.emp
}).then(function successCallback(response) {
console.log(response);
// $window.location.href ='http://localhost:8081/#/tintuc';
}, function errorCallback(response) {
console.log(response)
});
}
$scope.update = update;
function update(employee){
$scope.employee = employee;
list_employee();
}
$scope.deleteEmployee = function (employee) {
$http({
method : 'DELETE',
url : 'http://localhost:8081/deleteEmployee/' + employee.id
}).then(_success, _error);
}
$http({
method : 'GET',
url : "http://localhost:8081/list_employee/",
}).then(function successCallback(response) {
console.log(response)
$scope.employess=response.data;
}, function errorCallback(response) {
console.log(response)
});
});
\ No newline at end of file
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