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

new page

parent 8b8c4034
...@@ -2,6 +2,7 @@ package com.itsol.quantrivanphong.model; ...@@ -2,6 +2,7 @@ package com.itsol.quantrivanphong.model;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
...@@ -14,6 +15,7 @@ import java.util.List; ...@@ -14,6 +15,7 @@ import java.util.List;
@NoArgsConstructor @NoArgsConstructor
@Entity @Entity
@Table(name = "leave_type") @Table(name = "leave_type")
@Builder
public class LeaveType { public class LeaveType {
@Id @Id
......
...@@ -6,7 +6,7 @@ import com.itsol.quantrivanphong.model.LeaveForm; ...@@ -6,7 +6,7 @@ import com.itsol.quantrivanphong.model.LeaveForm;
import com.itsol.quantrivanphong.model.LeaveType; import com.itsol.quantrivanphong.model.LeaveType;
import com.itsol.quantrivanphong.report.leaveform.dto.LeaveFormDTO; import com.itsol.quantrivanphong.report.leaveform.dto.LeaveFormDTO;
import com.itsol.quantrivanphong.report.leaveform.repository.LeaveFormRepository; import com.itsol.quantrivanphong.report.leaveform.repository.LeaveFormRepository;
import com.itsol.quantrivanphong.report.leaveform.repository.LeaveTypeRepository; import com.itsol.quantrivanphong.report.leavetype.repository.LeaveTypeRepository;
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.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
......
package com.itsol.quantrivanphong.report.leavetype.business;
import com.itsol.quantrivanphong.model.LeaveType;
import com.itsol.quantrivanphong.report.leavetype.dto.LeaveTypeDTO;
import com.itsol.quantrivanphong.report.leavetype.repository.LeaveTypeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
@Service
public class LeaveTypeBusiness {
@Autowired
LeaveTypeRepository leaveTypeRepository;
public String addLeaveType(LeaveTypeDTO leaveTypeDTO) {
String message;
LeaveType leaveType = leaveTypeRepository.save(LeaveType.builder()
.name(leaveTypeDTO.getName())
.descriptions(leaveTypeDTO.getDescriptions())
.status(true)
.build());
if (leaveType != null) {
message = "Insert leave type success";
} else {
message = "Insert leave type failed";
}
return message;
}
@Transactional
public String deleteLeaveType(int leaveTypeId) {
String message;
LeaveType leaveType = leaveTypeRepository.findLeaveTypeById(leaveTypeId);
if (leaveType != null) {
leaveTypeRepository.delete(leaveType);
if (leaveTypeRepository.findLeaveTypeById(leaveTypeId) != null) {
message = "Delete failed!";
} else {
message = "Delete success!";
}
} else {
message = "Leave Form does not exist";
}
return message;
}
@Transactional
public String updateLeaveType(LeaveTypeDTO leaveTypeDTO) {
String message;
LeaveType leaveType = leaveTypeRepository.findLeaveTypeById(leaveTypeDTO.getId());
if (leaveType != null) {
int i = leaveTypeRepository.updateLeaveType(leaveTypeDTO.getName(), leaveTypeDTO.getDescriptions(), leaveTypeDTO.getId());
if (i == 1) {
message = "Update success";
} else {
message = "Update failed";
}
} else {
message = "Leave Type does not exist";
}
return message;
}
public List<LeaveType> getLeaveTypeList() {
return leaveTypeRepository.findAll();
}
}
package com.itsol.quantrivanphong.report.leavetype.controller;
import com.itsol.quantrivanphong.exception.InputException;
import com.itsol.quantrivanphong.model.LeaveType;
import com.itsol.quantrivanphong.report.leaveform.controller.Notification;
import com.itsol.quantrivanphong.report.leavetype.business.LeaveTypeBusiness;
import com.itsol.quantrivanphong.report.leavetype.dto.LeaveTypeDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping(path = "/leavetype")
public class LeaveTypeController {
@Autowired
LeaveTypeBusiness leaveTypeBusiness;
@PostMapping(path = "/add", consumes = "application/json", produces = "application/json")
public ResponseEntity addLeaveForm(@RequestBody LeaveTypeDTO leaveTypeDTO) {
String message;
try {
if (leaveTypeDTO.getName().trim().equals("")) throw new InputException("Tên không được để trống");
if (leaveTypeDTO.getDescriptions().trim().equals("")) throw new InputException("Mô tả không được để trống");
message = leaveTypeBusiness.addLeaveType(leaveTypeDTO);
} catch (InputException e) {
message = e.getMessage();
}
return ResponseEntity.ok(new Notification(200, message));
}
@DeleteMapping("/delete/{leaveTypeId}")
public ResponseEntity deleteLeaveForm(@PathVariable int leaveTypeId) {
return ResponseEntity.ok(new Notification(200, leaveTypeBusiness.deleteLeaveType(leaveTypeId)));
}
@PostMapping(path = "/update", consumes = "application/json", produces = "application/json")
public ResponseEntity updateLeaveForm(@RequestBody LeaveTypeDTO leaveTypeDTO) {
String message;
try {
if (leaveTypeDTO.getName().trim().equals("")) throw new InputException("Tiêu đề không được để trống");
if (leaveTypeDTO.getDescriptions().trim().equals("")) throw new InputException("Nội dung không được để trống");
message = leaveTypeBusiness.updateLeaveType(leaveTypeDTO);
} catch (InputException e) {
message = e.getMessage();
}
return ResponseEntity.ok(new Notification(200, message));
}
@GetMapping(path = "/getAll")
public ResponseEntity<List<LeaveType>> getAllLeaveType() {
return ResponseEntity.ok(leaveTypeBusiness.getLeaveTypeList());
}
}
package com.itsol.quantrivanphong.report.leavetype.dto;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LeaveTypeDTO {
private int id;
private String name;
private String descriptions;
private boolean status;
}
package com.itsol.quantrivanphong.report.leaveform.repository; package com.itsol.quantrivanphong.report.leavetype.repository;
import com.itsol.quantrivanphong.model.LeaveType; import com.itsol.quantrivanphong.model.LeaveType;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
public interface LeaveTypeRepository extends JpaRepository<LeaveType, Integer> { public interface LeaveTypeRepository extends JpaRepository<LeaveType, Integer> {
LeaveType findLeaveTypeById(int id); LeaveType findLeaveTypeById(int id);
@Modifying
@Query("update LeaveType lt set lt.name = ?1, lt.descriptions = ?2 where lt.id = ?3")
int updateLeaveType(String name, String descriptions, int id);
} }
...@@ -8,10 +8,10 @@ import org.springframework.data.jpa.repository.Query; ...@@ -8,10 +8,10 @@ import org.springframework.data.jpa.repository.Query;
import java.util.List; import java.util.List;
public interface EProjectRepository extends JpaRepository<Eproject, Integer> { public interface EProjectRepository extends JpaRepository<Eproject, Integer> {
// Eproject findEprojectById(int id); Eproject findEprojectById(int id);
Eproject findEprojectByEmployee(Employee employee); Eproject findEprojectByEmployee(Employee employee);
Eproject findEprojectByIdAndEmployee(int eProject_Id, Employee employee); Eproject findEprojectByIdAndEmployee(int eProjectId, Employee employee);
......
...@@ -101,7 +101,7 @@ angular.module("myApp", ["ngAnimate","ngResource", "ui.router", "ui.bootstrap"]) ...@@ -101,7 +101,7 @@ angular.module("myApp", ["ngAnimate","ngResource", "ui.router", "ui.bootstrap"])
url:"/timesheetDetail/:id", url:"/timesheetDetail/:id",
views:{ views:{
"content":{ "content":{
templateUrl:"page/timesheet/timeSheetDetail.html", templateUrl:"pages/timesheet/timeSheetDetail.html",
controller:"timeSheetDetailController" controller:"timeSheetDetailController"
} }
} }
......
...@@ -25,7 +25,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http ...@@ -25,7 +25,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
//get all leave form //get all leave form
$http({ $http({
method : 'GET', method : 'GET',
url : "http://localhost:8080/employee/leaveform/show" url : "http://localhost:8081/employee/leaveform/show"
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$scope.leaveForms=response.data; $scope.leaveForms=response.data;
...@@ -36,7 +36,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http ...@@ -36,7 +36,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
//get all leave type //get all leave type
$http({ $http({
method : 'GET', method : 'GET',
url : "http://localhost:8080/employee/leaveType/getAll" url : "http://localhost:8081/employee/leaveType/getAll"
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$scope.leaveTypeList=response.data; $scope.leaveTypeList=response.data;
...@@ -47,7 +47,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http ...@@ -47,7 +47,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
$scope.delete = function (lf) { $scope.delete = function (lf) {
$http({ $http({
method : 'DELETE', method : 'DELETE',
url : "http://localhost:8080/employee/leaveform/delete/" + lf.id url : "http://localhost:8081/employee/leaveform/delete/" + lf.id
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$state.reload(); $state.reload();
...@@ -62,7 +62,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http ...@@ -62,7 +62,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
console.log($scope.lfdto); console.log($scope.lfdto);
$http({ $http({
method : 'POST', method : 'POST',
url : "http://localhost:8080/timesheet/leaveform/add", url : "http://localhost:8081/employee/leaveform/add",
data: $scope.lfdto data: $scope.lfdto
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
...@@ -86,7 +86,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http ...@@ -86,7 +86,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
function update(){ function update(){
$http({ $http({
method : 'POST', method : 'POST',
url : "http://localhost:8080/timesheet/leaveform/update", url : "http://localhost:8081/employee/leaveform/update",
data: $scope.lfdto data: $scope.lfdto
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
...@@ -101,7 +101,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http ...@@ -101,7 +101,7 @@ angular.module("myApp").controller("leaveFormController", function($scope, $http
function updateStatus(lf){ function updateStatus(lf){
$http({ $http({
method : 'POST', method : 'POST',
url : "http://localhost:8080/timesheet/leaveform/"+lf.id+"/status", url : "http://localhost:8081/employee/leaveform/"+lf.id+"/status",
// data: $scope.lfdto // data: $scope.lfdto
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
<div> <div>
<tr> <tr>
<!-- <input type="submit" name="submit" value="Duyệt" ui-sref="leaveForm" ng-click="updateStatus(leaveFormDetail.id)"/>--> <!-- <input type="submit" name="submit" value="Duyệt" ui-sref="leaveForm" ng-click="updateStatus(leaveFormDetail.id)"/>-->
<input type="submit" name="submit" value="Quay lại" ui-sref="leaveForm"/> <input type="submit" name="submit" value="Quay lại" ui-sref="leaveform"/>
</tr> </tr>
</div> </div>
<br><br> <br><br>
......
...@@ -5,7 +5,7 @@ angular.module("myApp").controller("leaveFormDetailController", function($scope, ...@@ -5,7 +5,7 @@ angular.module("myApp").controller("leaveFormDetailController", function($scope,
console.log("Leave Form Detail Controller"); console.log("Leave Form Detail Controller");
$http({ $http({
method : 'GET', method : 'GET',
url : "http://localhost:8080/timesheet/leaveform/" + $stateParams.id url : "http://localhost:8081/employee/leaveform/" + $stateParams.id
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$scope.leaveFormDetail=response.data; $scope.leaveFormDetail=response.data;
...@@ -17,7 +17,7 @@ angular.module("myApp").controller("leaveFormDetailController", function($scope, ...@@ -17,7 +17,7 @@ angular.module("myApp").controller("leaveFormDetailController", function($scope,
function updateStatus(id){ function updateStatus(id){
$http({ $http({
method : 'POST', method : 'POST',
url : "http://localhost:8080/timesheet/leaveform/"+id+"/status", url : "http://localhost:8081/employee/leaveform/"+id+"/status",
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$state.reload(); $state.reload();
......
/* /*
*/ */
angular.module("myApp").controller("timeSheetController", function($scope, $http,$window) { angular.module("myApp").controller("timeSheetController", function($scope, $http, $state) {
console.log("Time Sheet controller"); console.log("Time Sheet controller");
$scope.ts = { $scope.ts = {
...@@ -22,7 +22,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http ...@@ -22,7 +22,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
//function getAllTimesheet(){ //function getAllTimesheet(){
$http({ $http({
method: 'GET', method: 'GET',
url: "http://localhost:8080/eproject/timesheet/show" url: "http://localhost:8081/eproject/timesheet/show"
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$scope.myTimeSheets = response.data; $scope.myTimeSheets = response.data;
...@@ -34,7 +34,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http ...@@ -34,7 +34,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
//get all eproject //get all eproject
$http({ $http({
method: 'GET', method: 'GET',
url: "http://localhost:8080/eproject/getAll" url: "http://localhost:8081/eproject/getAll"
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$scope.eProjectList = response.data; $scope.eProjectList = response.data;
...@@ -45,7 +45,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http ...@@ -45,7 +45,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
$scope.delete = function (ts) { $scope.delete = function (ts) {
$http({ $http({
method: 'DELETE', method: 'DELETE',
url: "http://localhost:8080/eproject/timesheet/delete/" + ts.id url: "http://localhost:8081/eproject/timesheet/delete/" + ts.id
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$state.reload(); $state.reload();
...@@ -62,7 +62,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http ...@@ -62,7 +62,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
console.log($scope.tsdto); console.log($scope.tsdto);
$http({ $http({
method: 'POST', method: 'POST',
url: "http://localhost:8080/eproject/timesheet/add", url: "http://localhost:8081/eproject/timesheet/add",
data: $scope.tsdto data: $scope.tsdto
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
...@@ -89,7 +89,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http ...@@ -89,7 +89,7 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
$http({ $http({
headers: "content-type: application/json", headers: "content-type: application/json",
method: 'POST', method: 'POST',
url: "http://localhost:8080/eproject/timesheet/update", url: "http://localhost:8081/eproject/timesheet/update",
data: $scope.tsdto data: $scope.tsdto
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
...@@ -99,84 +99,4 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http ...@@ -99,84 +99,4 @@ angular.module("myApp").controller("timeSheetController", function($scope, $http
$state.reload(); $state.reload();
}); });
} }
// $scope.myTimeSheets = [];
// $scope.save = save;
// $scope.currentPage = 1;
// $scope.timesheetPerPage = 3;
// $scope.maxSize = 5;
// this.myTimeSheets = $scope.myTimeSheets;
// $scope.numOfPage = numOfPage;
// $scope.dataHasLoaded = false;
// $scope.makeTimesheet = function () {
// $scope.myTimeSheets = [];
// for (let i = 1; i <=50 ; i++) {
// $scope.myTimeSheets.push( {text : 'ts'+ i , done:false});
// }
//
// };
// $scope.makeTimesheet();
// $scope.getAllTimesheet = getAllTimesheet;
// //$scope.getTotalTimesheet = getTotalTimesheet;
// getAllTimesheet();
// $scope.pageChangedIndex = pageChangedIndex;
// function pageChangedIndex() {
// console.log($scope.currentPage);
// }
// function numOfPage() {
// return Math.ceil($scope.myTimeSheets.length/ $scope.timesheetPerPage);
//
// }
}); });
// }).directive('pgnTable', ['$compile', function ($compile) {
// return {
// restrict: 'EA',
// templateUrl: 'pages/timesheet/timeSheet.html',
// replace: true,
// scope: {
// pages: "=pgnTable"
// },
// controller: function ($scope) {
// $scope.currentPage=1;
// $scope.numLimit=5;
// $scope.start = 0;
// $scope.$watch("pages",function(newVal){
// if(newVal){
// $scope.pages=Math.ceil($scope.pages.length/$scope.numLimit);
// }
// });
// $scope.hideNext=function(){
// if(($scope.start + $scope.numLimit) < $scope.pages.length){
// return false;
// }
// else
// return true;
// };
// $scope.hidePrev=function(){
// if($scope.start===0){
// return true;
// }
// else
// return false;
// };
// $scope.nextPage=function(){
// console.log("next pages");
// $scope.currentPage++;
// $scope.start=$scope.start+ $scope.numLimit;
// console.log( $scope.start)
// };
// $scope.PrevPage=function(){
// if($scope.currentPage>1){
// $scope.currentPage--;
// }
// console.log("next pages");
// $scope.start=$scope.start - $scope.numLimit;
// console.log( $scope.start)
// };
// },
// compile: function(elem) {
// return function(ielem, $scope) {
// $compile(ielem)($scope);
// };
// }
// };
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
<tr> <tr>
<input type="text" name="check" placeholder="Nhận xét" ng-model="check"/> <input type="text" name="check" placeholder="Nhận xét" ng-model="check"/>
<input type="submit" name="submit" value="Xác nhận" ng-click="updateCheck(timeSheetDetail.id, check);" ui-sref="leaveFormDetail"/> <input type="submit" name="submit" value="Xác nhận" ng-click="updateCheck(timeSheetDetail.id, check);" ui-sref="leaveFormDetail"/>
<input type="submit" name="submit" value="Quay lại" ui-sref="timeSheet"/> <input type="submit" name="submit" value="Quay lại" ui-sref="timesheet"/>
</tr> </tr>
</div> </div>
<br><br> <br><br>
......
...@@ -11,7 +11,7 @@ angular.module("myApp").controller("timeSheetDetailController", function($scope, ...@@ -11,7 +11,7 @@ angular.module("myApp").controller("timeSheetDetailController", function($scope,
$http({ $http({
method : 'GET', method : 'GET',
url : "http://localhost:8080/eproject/timesheet/" + $stateParams.id url : "http://localhost:8081/eproject/timesheet/" + $stateParams.id
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
$scope.timeSheetDetail=response.data; $scope.timeSheetDetail=response.data;
...@@ -25,7 +25,7 @@ angular.module("myApp").controller("timeSheetDetailController", function($scope, ...@@ -25,7 +25,7 @@ angular.module("myApp").controller("timeSheetDetailController", function($scope,
$http({ $http({
headers: {"Content-Type": "application/json"}, headers: {"Content-Type": "application/json"},
method : 'POST', method : 'POST',
url : "http://localhost:8080/eproject/timesheet/update/check", url : "http://localhost:8081/eproject/timesheet/update/check",
data: $scope.tsd data: $scope.tsd
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response); console.log(response);
......
...@@ -119,7 +119,7 @@ ...@@ -119,7 +119,7 @@
<th>Title</th> <th>Title</th>
<th>Content</th> <th>Content</th>
<th>Note</th> <th>Note</th>
<th>Employee</th> <th>Project</th>
<th>Create at</th> <th>Create at</th>
<th colspan="3"></th> <th colspan="3"></th>
</tr> </tr>
...@@ -133,7 +133,7 @@ ...@@ -133,7 +133,7 @@
<td>{{ts.eproject.project.name}}</td> <td>{{ts.eproject.project.name}}</td>
<td>{{ts.updatedAt}}</td> <td>{{ts.updatedAt}}</td>
<td><a ui-sref="timeSheetDetail({id: ts.id})"data-toggle="modal"><i class="fa fa-eye" data-toggle="tooltip" title="View"></i></a></td> <td><a ui-sref="timesheetDetail({id: ts.id})"data-toggle="modal"><i class="fa fa-eye" data-toggle="tooltip" title="View"></i></a></td>
<td><a ui-sref="timeSheet" ng-click="getTs(ts);" onclick="document.getElementById('updateDivTS').style.display = 'block'"class="edit" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Edit">&#xE254;</i></a></td> <td><a ui-sref="timeSheet" ng-click="getTs(ts);" onclick="document.getElementById('updateDivTS').style.display = 'block'"class="edit" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Edit">&#xE254;</i></a></td>
<td><a ui-sref="timeSheet" ng-click="delete(ts);"class="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete">&#xE872;</i></a></td> <td><a ui-sref="timeSheet" ng-click="delete(ts);"class="delete" data-toggle="modal"><i class="material-icons" data-toggle="tooltip" title="Delete">&#xE872;</i></a></td>
</tr> </tr>
......
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