Commit 5c69f55e authored by Phạm Duy Phi's avatar Phạm Duy Phi

no message

parent a98ad627
......@@ -5,6 +5,7 @@ import com.itsol.quantrivanphong.report.leaveform.business.LeaveFormBusiness;
import com.itsol.quantrivanphong.report.leaveform.dto.LeaveFormDTO;
import com.itsol.quantrivanphong.model.LeaveForm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
......@@ -22,9 +23,8 @@ public class LeaveFormController {
}
@PostMapping(path = "/leaveform/add", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> addLeaveForm(@RequestBody LeaveFormDTO leaveFormDTO) {
public ResponseEntity addLeaveForm(@RequestBody LeaveFormDTO leaveFormDTO) {
String message;
try {
if (leaveFormDTO.getTitle().trim().equals("")) throw new InputException("Tiêu đề không được để trống");
if (leaveFormDTO.getContent().trim().equals("")) throw new InputException("Nội dung không được để trống");
......@@ -33,16 +33,16 @@ public class LeaveFormController {
message = e.getMessage();
}
return ResponseEntity.ok(message);
return ResponseEntity.ok(new Notification(200, message));
}
@DeleteMapping("/leaveform/delete/{leaveformId}")
public ResponseEntity<String> deleteLeaveForm(@PathVariable int leaveformId) {
return ResponseEntity.ok(leaveFormBusiness.deleteLeaveForm(leaveformId));
public ResponseEntity deleteLeaveForm(@PathVariable int leaveformId) {
return ResponseEntity.ok(new Notification(200, leaveFormBusiness.deleteLeaveForm(leaveformId)));
}
@PostMapping(path = "/leaveform/update", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> updateLeaveForm(@RequestBody LeaveFormDTO leaveFormDTO) {
public ResponseEntity updateLeaveForm(@RequestBody LeaveFormDTO leaveFormDTO) {
String message;
try {
......@@ -53,14 +53,14 @@ public class LeaveFormController {
message = e.getMessage();
}
return ResponseEntity.ok(message);
return ResponseEntity.ok(new Notification(200, message));
}
@PostMapping(path = "/leaveform/{leaveformId}/status")
public ResponseEntity<String> updateLeaveFormStatus(@PathVariable int leaveformId) {
public ResponseEntity updateLeaveFormStatus(@PathVariable int leaveformId) {
String message;
message = leaveFormBusiness.updateLeaveFormStatus(leaveformId);
return ResponseEntity.ok(message);
return ResponseEntity.ok(new Notification(200, message));
}
@GetMapping("/leaveform/show/{employeeId}")
......
package com.itsol.quantrivanphong.report.leaveform.controller;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Notification {
private int status;
private String view;
}
......@@ -21,11 +21,7 @@ public class TimeSheetBusiness {
EProjectRepository eProjectRepository;
@Autowired
EmployeeRepository employeeRepository;
<<<<<<< HEAD
public String insertTimeSheet(TimeSheetDTO timeSheetDTO) {
=======
public String addTimeSheet(TimeSheetDTO timeSheetDTO) {
>>>>>>> master
String message;
Employee employee = employeeRepository.findEmployeeById(timeSheetDTO.getEmployeeId());
Eproject eproject = eProjectRepository.findEprojectByIdAndEmployee(timeSheetDTO.getEprojectId(), employee);
......@@ -38,7 +34,7 @@ public class TimeSheetBusiness {
timeSheet1.setContent(timeSheetDTO.getContent());
timeSheet1.setNote(timeSheetDTO.getNote());
timeSheet1.setEproject(eproject);
timeSheet1.setChecked("");
timeSheet1.setChecked("unapproved");
timeSheet1.setStatus(true);
TimeSheet timeSheet = timeSheetRepository.save(timeSheet1);
......@@ -53,17 +49,6 @@ public class TimeSheetBusiness {
return message;
}
<<<<<<< HEAD
public String deleteTimeSheet(int timesheetId) {
String message;
// Employee employee = employeeRepository.findEmployeeById(timeSheetDTO.getEmployeeId());
// Eproject eproject = eProjectRepository.findEprojectByEmployee(employee);
// TimeSheet timeSheet = timeSheetRepository.findTimeSheetByEprojectAndId(eproject, timeSheetDTO.getId());
TimeSheet timeSheet = timeSheetRepository.findTimeSheetById(timesheetId);
if (timeSheet != null) {
timeSheetRepository.delete(timeSheet);
if (timeSheetRepository.findTimeSheetById(timesheetId) == null) {
=======
public String deleteTimeSheet(int timeSheetId) {
String message;
// Employee employee = employeeRepository.findEmployeeById(employee_Id);
......@@ -72,7 +57,6 @@ public class TimeSheetBusiness {
if (timeSheet != null) {
timeSheetRepository.delete(timeSheet);
if (timeSheetRepository.findTimeSheetById(timeSheetId) == null) {
>>>>>>> master
message = "Delete success";
} else {
message = "Delete failed";
......
......@@ -2,6 +2,7 @@ package com.itsol.quantrivanphong.report.timesheet.controller;
import com.itsol.quantrivanphong.exception.InputException;
import com.itsol.quantrivanphong.model.TimeSheet;
import com.itsol.quantrivanphong.report.leaveform.controller.Notification;
import com.itsol.quantrivanphong.report.timesheet.business.TimeSheetBusiness;
import com.itsol.quantrivanphong.report.timesheet.dto.TimeSheetDTO;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,26 +16,18 @@ import java.util.List;
public class TimeSheetController {
@Autowired
TimeSheetBusiness timeSheetBusiness;
<<<<<<< HEAD
@PostMapping(path = "/timesheet", consumes = "application/json", produces = "application/json")
=======
@PostMapping(path = "/timesheet/add", consumes = "application/json", produces = "application/json")
>>>>>>> master
public ResponseEntity<String> addTimeSheet(@RequestBody TimeSheetDTO timeSheetDTO) {
public ResponseEntity addTimeSheet(@RequestBody TimeSheetDTO timeSheetDTO) {
String message;
try {
if (timeSheetDTO.getTitle().trim().equals("")) throw new InputException("Tiêu đề không được để trống");
if (timeSheetDTO.getContent().trim().equals("")) throw new InputException("Nội dung không được để trống");
<<<<<<< HEAD
message = timeSheetBusiness.insertTimeSheet(timeSheetDTO);
=======
message = timeSheetBusiness.addTimeSheet(timeSheetDTO);
>>>>>>> master
} catch (InputException e) {
message = e.getMessage();
}
return ResponseEntity.ok(message);
return ResponseEntity.ok(new Notification(200, message));
}
// @PostMapping(path = "/timesheet", consumes = "application/json", produces = "application/json")
// public ResponseEntity<String> insertTimeSheet(@RequestBody TimeSheetDTO timeSheetDTO) {
......@@ -51,8 +44,8 @@ public class TimeSheetController {
// }
@DeleteMapping("/timesheet/delete/{timesheetId}")
public ResponseEntity<String> deleteTimeSheet(@PathVariable int timesheetId) {
return ResponseEntity.ok(timeSheetBusiness.deleteTimeSheet(timesheetId));
public ResponseEntity deleteTimeSheet(@PathVariable int timesheetId) {
return ResponseEntity.ok(new Notification(200, timeSheetBusiness.deleteTimeSheet(timesheetId)));
}
@GetMapping(path = "/timesheet/show")
......@@ -61,7 +54,7 @@ public class TimeSheetController {
}
@PostMapping(path = "/timesheet/update", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> updateTimeSheet(@RequestBody TimeSheetDTO timeSheetDTO) {
public ResponseEntity updateTimeSheet(@RequestBody TimeSheetDTO timeSheetDTO) {
String message;
try {
......@@ -72,7 +65,7 @@ public class TimeSheetController {
message = e.getMessage();
}
return ResponseEntity.ok(message);
return ResponseEntity.ok(new Notification(200, message));
}
// @PostMapping(path = "/update-status", consumes = "application/json", produces = "application/json")
......@@ -82,11 +75,6 @@ public class TimeSheetController {
// return ResponseEntity.ok(message);
// }
<<<<<<< HEAD
@GetMapping("/timesheet/show/{employee_Id}")
public ResponseEntity<List<TimeSheet>> showTimeSheetById(@PathVariable int employee_Id) {
return ResponseEntity.ok(timeSheetBusiness.findTimeSheetById(employee_Id));
=======
@GetMapping("/timesheet/show/{employeeId}")
public ResponseEntity<List<TimeSheet>> showTimeSheetByEmployeeId(@PathVariable int employeeId) {
return ResponseEntity.ok(timeSheetBusiness.findTimeSheetByEmployeeId(employeeId));
......@@ -101,6 +89,5 @@ public class TimeSheetController {
@PostMapping(path = "/timesheet/update/check", consumes = "application/json", produces = "application/json")
public ResponseEntity<String> updateCheck(@RequestBody TimeSheetDTO timeSheetDTO) {
return ResponseEntity.ok(timeSheetBusiness.updateCheck(timeSheetDTO));
>>>>>>> master
}
}
\ No newline at end of file
......@@ -8,14 +8,15 @@ import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface EProjectRepository extends JpaRepository<Eproject, Integer> {
//--------------------------------- Phi ----------------------------------------//
// Eproject findEprojectById(int id);
Eproject findEprojectByEmployee(Employee employee);
Eproject findEprojectByIdAndEmployee(int eProject_Id, Employee employee);
//--------------------------------- Phi ----------------------------------------//
//======================================================================================================
// Hieunv
......
......@@ -11,10 +11,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
public interface TimeSheetRepository extends JpaRepository<TimeSheet, Integer> {
<<<<<<< HEAD
//------------------------------------ Phi ---------------------------------//
=======
>>>>>>> master
TimeSheet findTimeSheetById(int id);
// @Query("select ts from TimeSheet ts order by ts.createdAt desc")
......@@ -35,12 +31,7 @@ public interface TimeSheetRepository extends JpaRepository<TimeSheet, Integer> {
@Query("select ts from TimeSheet ts where ts.eproject = ?1")
List<TimeSheet> showTimeSheetByEproject(Eproject eproject);
<<<<<<< HEAD
TimeSheet findTimeSheetByEprojectAndId(Eproject eproject, int timeSheet_Id);
//------------------------------------ Phi ---------------------------------//
=======
TimeSheet findTimeSheetByEprojectAndId(Eproject eproject, int timeSheetId);
>>>>>>> master
//==================================================================================================================
......
......@@ -5,13 +5,8 @@
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/quantrivanphong
spring.datasource.username=root
<<<<<<< HEAD
spring.datasource.password=ahihi123
=======
spring.datasource.password= ahihi123
>>>>>>> master
# ===============================
# JPA / HIBERNATE
# ===============================
......
......@@ -18,6 +18,7 @@
<script src="js/jquery-3.2.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/angular.js"></script>
<script src="js/angular-route.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<script src="js/app.js"></script>
......@@ -30,7 +31,6 @@
<script src="pages/leaveform/leaveFormDetailController.js"></script>
<script src="pages/timesheet/timeSheetDetailController.js"></script>
<!-- <script src="js/angular-resource.js"></script>-->
<script>
function showAddTimeSheetFunction() {
const x = document.getElementById("addDivTS");
......@@ -44,7 +44,6 @@
}
}
</script>
<script>
function showAddLeaveFormFunction() {
const x = document.getElementById("addDivLF");
......@@ -58,14 +57,8 @@
}
}
</script>
</head>
<body ng-app="myApp">
<<<<<<< HEAD
<div class="container">
=======
>>>>>>> master
<div ui-view="layout">
<div style="margin-left:5px;margin-top:10px" ng-controller="timeSheetController">
......@@ -73,6 +66,5 @@
</div>
</div>
</body>
</html>
\ No newline at end of file
/**
*
*/
angular.module("myApp", ["ui.router"]).config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
angular.module("myApp", ["ui.router", 'ngRoute']).config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.hashPrefix('');
$urlRouterProvider.otherwise("/employees");
......@@ -126,11 +126,19 @@ angular.module("myApp", ["ui.router"]).config(function ($stateProvider, $urlRout
// }
// }
// })
.state("gioithieu", {
parent: 'app',
url: "/gioithieu",
views:{
"content":{
templateUrl: "pages/gioithieu/gioithieu.htm",
controller: "gioithieuController"
}
}
})
});
<<<<<<< HEAD
// .state("lienhe", {
// parent: 'app',
// url: "/lienhe",
......@@ -142,19 +150,7 @@ angular.module("myApp", ["ui.router"]).config(function ($stateProvider, $urlRout
// }
// })
.state("gioithieu", {
parent: 'app',
url: "/gioithieu",
views:{
"content":{
templateUrl: "pages/gioithieu/gioithieu.htm",
controller: "gioithieuController"
}
}
})
});
=======
// myApp.directive('ngConfirmClick', [ function() {
// return {
// link : function(scope, element, attr) {
......@@ -168,4 +164,3 @@ angular.module("myApp", ["ui.router"]).config(function ($stateProvider, $urlRout
// }
// };
// } ])
>>>>>>> master
......@@ -116,9 +116,9 @@
<td>{{lf.status}}</td>
<td><a ui-sref="leaveFormDetail({id: lf.id})">Xem</a></td>
<td><a href="/#/leaveform" ng-click="getLf(lf);" onclick="document.getElementById('updateDivLF').style.display = 'block'">Sửa</a></td>
<td><a href="/#/leaveform" ng-click="delete(lf);">Xoá</a></td>
<td><a href="/#/leaveform" ng-click="updateStatus(lf)">Duyệt</a></td>
<td><a href="#" ng-click="getLf(lf);" onclick="document.getElementById('updateDivLF').style.display = 'block'">Sửa</a></td>
<td><a ui-sref="leaveForm" ng-click="delete(lf); leaveFormController.reloadDataTable();">Xoá</a></td>
<td><a href="#" ng-click="updateStatus(lf)">Duyệt</a></td>
</tr>
</tbody>
</table>
......
......@@ -2,7 +2,7 @@
*/
angular.module("myApp").controller("leaveFormController", function($scope, $http, $state) {
angular.module("myApp").controller("leaveFormController", function($scope, $http, $route, $state) {
console.log("Leave Form controller");
$scope.lf = {
......@@ -41,8 +41,10 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
url : "http://localhost:8080/employee/leaveform/delete/" + lf.id
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
};
......@@ -56,9 +58,9 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
}).then(function successCallback(response) {
console.log(response);
$state.reload();
// $window.location.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
......@@ -79,8 +81,10 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
data: $scope.lfdto
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
......@@ -92,8 +96,10 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
// data: $scope.lfdto
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
});
\ No newline at end of file
......@@ -2,7 +2,7 @@
*/
angular.module("myApp").controller("leaveFormDetailController", function($scope, $http, $stateParams) {
angular.module("myApp").controller("leaveFormDetailController", function($scope, $http, $stateParams, $state) {
console.log("Leave Form Detail Controller");
$http({
method : 'GET',
......@@ -21,8 +21,10 @@ angular.module("myApp").controller("leaveFormDetailController", function($scope,
url : "http://localhost:8080/employee/leaveform/"+id+"/status",
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
});
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" ng-app = "quantrivanphong">
<head>
<meta charset="UTF-8">
<title>Report</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="//unpkg.com/@uirouter/angularjs/release/angular-ui-router.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.7.8/angular.min.js"></script>
<script src="app.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
\ No newline at end of file
......@@ -20,7 +20,7 @@
<br><br>
<div>
<tr>
<h3>Nhận xét</h3>
<h3>Trạng thái</h3>
<td>{{timeSheetDetail.checked}}</td>
</tr>
</div>
......
......@@ -2,7 +2,7 @@
*/
angular.module("myApp").controller("timeSheetDetailController", function($scope, $http, $stateParams) {
angular.module("myApp").controller("timeSheetDetailController", function($scope, $http, $stateParams, $state) {
console.log("Time Sheet Detail Controller");
$scope.tsd = {
......@@ -30,8 +30,10 @@ angular.module("myApp").controller("timeSheetDetailController", function($scope,
data: $scope.tsd
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
});
\ No newline at end of file
/*
*/
angular.module("myApp").controller("timeSheetController", function($scope, $http) {
angular.module("myApp").controller("timeSheetController", function($scope, $http, $state) {
console.log("Time Sheet controller");
$scope.ts = {
......@@ -40,9 +40,10 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
url : "http://localhost:8080/eproject/timesheet/delete/" + ts.id
}).then(function successCallback(response) {
console.log(response);
$scope.config.timeSheets=response.data;
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
};
......@@ -56,8 +57,10 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
data: $scope.tsdto
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
......@@ -79,8 +82,10 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
data: $scope.tsdto
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response)
console.log(response);
$state.reload();
});
}
}).directive('pgnTable', ['$compile', function ($compile) {
......
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