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

new page

parent 19c5ecee
package com.itsol.quantrivanphong.access.homepage.business;
import com.itsol.quantrivanphong.access.homepage.repository.CatalogiRepository;
import com.itsol.quantrivanphong.exception.ResourceNotFoundException;
import com.itsol.quantrivanphong.model.Catalogi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -23,4 +24,13 @@ public class CatalogiBusiness {
public Catalogi save(Catalogi catalogi){
return catalogiRepository.save(catalogi);
}
public String deleteCatalogi(int catalogiId){
Catalogi catalogi = catalogiRepository.findCatalogiById(catalogiId);
if(catalogi == null){
throw new ResourceNotFoundException("News" ,"newsId",catalogiId);
}
catalogiRepository.delete(catalogi);
return "ok";
}
}
......@@ -30,9 +30,17 @@ public class CatalogiController {
return catalogi;
}
@PostMapping("/catalogi")
@PostMapping("HR/catalogi")
public Catalogi createCatalogi(@Valid@RequestBody Catalogi catalogi) {
return catalogiBusiness.save(catalogi);
}
@DeleteMapping("HR/catalogi/{catalogiId}")
public ResponseEntity<?> deleteNews(@PathVariable (value = "catalogiId") int catalogiId) {
if(catalogiBusiness.findCatalogiById(catalogiId)== null){
throw new ResourceNotFoundException("News","newsId",catalogiId);
}
return ResponseEntity.ok(catalogiBusiness.deleteCatalogi(catalogiId));
}
}
package com.itsol.quantrivanphong.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
......@@ -31,9 +30,9 @@ public class Catalogi {
private String descriptions;
@JsonIgnore
@OneToMany(mappedBy = "catalogi", fetch = FetchType.LAZY, cascade = CascadeType.ALL)
private List<News> newsList = new ArrayList<>();
@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "catalogi")
private List<News> news = new ArrayList<>();
}
package com.itsol.quantrivanphong.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.itsol.quantrivanphong.audit.DateAudit;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.OnDelete;
import org.hibernate.annotations.OnDeleteAction;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
......@@ -14,7 +17,7 @@ import javax.persistence.*;
@AllArgsConstructor
@NoArgsConstructor
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(value = {"createdAt", "updatedAt"},allowGetters = true)
@JsonIgnoreProperties(value = {"createdAt", "updatedAt"}, allowGetters = true)
@Table(name = "news")
public class News extends DateAudit {
......@@ -37,16 +40,17 @@ public class News extends DateAudit {
@Column(name = "status")
private boolean status;
// @JsonIgnore
@ManyToOne(fetch = FetchType.EAGER)
// @JoinColumn(name = "catalogid", nullable = false)
@ManyToOne(fetch = FetchType.LAZY, optional = false)
@JoinColumn(name = "catalogi_id", nullable = false)
@OnDelete(action = OnDeleteAction.CASCADE)
@JsonIgnore
private Catalogi catalogi;
// @JsonIgnore
@ManyToOne(fetch = FetchType.EAGER)
// @JoinColumn(name = "employeeid", nullable = false)
private Employee employee;
private Employee employee;
}
......@@ -33,6 +33,7 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular.js"></script>
<script src="js/angular-route.js"></script>
<script src="js/angular-ui-router.min.js"></script>
<script src="js/angular-resource.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-animate.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.6.1/angular-sanitize.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-1.3.3.js"></script>
......@@ -45,9 +46,10 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony
<script src="pages/issue/IssueAddControlelr.js"></script>
<script src="pages/issue/IssueController.js"></script>
<script src="pages/issue/IssuesDetailController.js"></script>
<script src="pages/issue/IssuesDeleteController.js"></script>>
<script src="pages/issue/IssuesDeleteController.js"></script>
<script src="pages/leaveform/leaveFormController.js"></script>
<script src="pages/homepage/homeController.js"></script>
<script src="pages/homepage/MyHomeController.js"></script>
<script src="pages/homepage/HomeService.js"></script>
<script src="pages/timesheet/timeSheetController.js"></script>
<script src="pages/timesheet/timeSheetDetailController.js"></script>
<script src="pages/leaveform/leaveFormDetailController.js"></script>
......@@ -119,6 +121,7 @@ SmartPhone Compatible web template, free WebDesigns for Nokia, Samsung, LG, Sony
</script>
</head>
<body class="cbp-spmenu-push" ng-app="myApp">
<div ui-view="layout"></div>
......
This diff is collapsed.
/**
*
*/
angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
angular.module("myApp", ["ngAnimate","ngResource", "ui.router", "ui.bootstrap"]).config(function ($stateProvider, $urlRouterProvider, $locationProvider) {
$locationProvider.hashPrefix('');
$urlRouterProvider.otherwise("/employees");
......@@ -107,13 +107,50 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
})
.state("news",{
.state("CatagoriManagement",{
parent:'layout1',
url:"/news",
url:"/management/catagori",
views:{
"content":{
templateUrl:"pages/homepage/catagoriManagements.html",
controller:"homeController"
templateUrl: "pages/homepage/catagoriManagements.html",
controller: "MyHomeController"
}
}
})
.state("newsManagement",{
parent:'layout1',
url:"/management/catagori/:myCatagoriId",
params:{
myCatagoriId : null
},
views:{
"content":{
templateUrl: "pages/homepage/newsManagements.html",
controller: "MyHomeController"
}
}
})
.state("newsEditManagement",{
parent:'layout1',
url:"/management/catagori/:myCatagoriEditId/news/:myNewsEditId",
views:{
"content":{
templateUrl: "pages/homepage/newsEditManagement.html",
controller: "MyHomeController"
}
}
})
.state("newsAddManagement",{
parent:'layout1',
url:"/management/HR/:employeeId/catagori/:myCatagoriAddId/createNews",
views:{
"content":{
templateUrl: "pages/homepage/newsAddManagement.html",
controller: "MyHomeController"
}
}
})
......@@ -195,9 +232,6 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
})
//danh sách các dự án
.state("project", {
parent: 'layout1',
url: "/project",
......@@ -208,7 +242,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
//thêm mới dự án
.state("addproject", {
parent: 'layout1',
url: "/addproject",
......@@ -219,7 +253,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
//sửa thông tin dự án
.state("editproject", {
parent: 'layout1',
url: "/editproject/:ID",
......@@ -230,7 +264,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
//danh sách thành viên trong nhóm dự án
.state("groupProjectByProjectId", {
parent: 'layout1',
url: "/groupProjectByProjectId/:ID",
......@@ -242,7 +276,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
//thêm thành viên vào nhóm dự án
.state("addEmployeeProject", {
parent: 'layout1',
url: "/addEmployeeProject",
......@@ -253,7 +287,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
//sửa thông tin nhân viên trong nhóm
.state("editEmployeeProject", {
parent: 'layout1',
url: "/editEmployeeProject/:ID",
......@@ -264,7 +298,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
// danh sách project vào các issues
.state("issues", {
parent: 'layout1',
url: "/issues",
......@@ -275,7 +309,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
// thêm mới issues
.state("addIssues", {
parent: 'layout1',
url: "/addIssues",
......@@ -286,7 +320,7 @@ angular.module("myApp", ["ngAnimate", "ui.router", "ui.bootstrap"]).config(funct
}
}
})
// thêm mới issues
.state("IssuesComment", {
parent: 'layout1',
url: "/issuescomment/:IssuesId",
......
......@@ -50,7 +50,7 @@
<!-- END DUng-->
<li class="treeview">
<li class="treeview">
<a ui-sref="news">
<a ui-sref="CatagoriManagement">
<i class="fa fa-newspaper-o" aria-hidden="true"></i>
<span>News</span>
</a>
......
<div class="container">
<table class="table">
<form>
<div class="form-row">
<div class="col">
<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 class="form-check-label" 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>
</div>
<div class="col">
<tr>
<td><label>Education</label></td>
<td>
<input type="text" 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><label>Department</label></td>
<td><input type="text" ng-model="emp.department"/></td>
</tr>
<tr>
<td><label>Position</label></td>
<td><input type="text" ng-model="emp.position"/></td>
</tr>
<tr>
</div>
<table class="table">
<form>
<div class="form-row">
<div class="col">
<tr>
<td><label>User Name</label></td>
<td>
<input type="text" maxlength="29" ng-model="emp.username"/>
<span style="color:red" ng-show="myForm.emp.username.$dirty && myForm.emp.username.$invalid">
<span ng-show="myForm.emp.username.$error.required">Username is required.</span>
</span>
</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 class="form-check-label" 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>
</div>
<div class="col">
<tr>
<td><label>Education</label></td>
<td>
<input type="text" 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><label>Department</label></td>
<td><input type="text" ng-model="emp.department"/></td>
</tr>
<tr>
<td><label>Position</label></td>
<td><input type="text" ng-model="emp.position"/></td>
</tr>
<tr>
</div>
</form>
<td></td>
<td>
<input class="btn btn-primary" type="submit" name="submit" value="submit" ng-click="save();"/>
<input class="btn btn-primary" type="submit" name="clear" value="clear" ng-click=" emp = null"/>
</td>
</tr>
</table>
</div>
</form>
<td></td>
<td>
<input class="btn btn-primary" type="submit" name="submit" value="submit" ng-click="save();"/>
<input class="btn btn-primary" type="submit" name="clear" value="clear" ng-click=" emp = null"/>
</td>
</tr>
</table>
</div>
\ No newline at end of file
angular.module("myApp").factory('News', function ($resource) {
return $resource('http://localhost:8080/api/news/:id', {id: '@myNewsId'},{
return $resource('http://localhost:8081/api/news/:id', {id: '@myNewsId'},{
'get': {
method: 'GET',
isArray: false
......@@ -9,11 +9,11 @@ angular.module("myApp").factory('News', function ($resource) {
});
angular.module('myApp').factory('Catagories', function ($resource) {
return $resource('http://localhost:8080/api/catalogies/:id', {id: '@myCatagoriesId'});
return $resource('http://localhost:8081/api/catalogies/:id', {id: '@myCatagoriesId'});
});
angular.module('myApp').factory('LatestNews', function ($resource) {
return $resource('http://localhost:8080/api/catalogi/:id/latestNews', {id: '@CatagoriesId'},{
return $resource('http://localhost:8081/api/catalogi/:id/latestNews', {id: '@CatagoriesId'},{
'get': {
method: 'GET',
isArray: true
......@@ -22,7 +22,7 @@ angular.module('myApp').factory('LatestNews', function ($resource) {
});
angular.module('myApp').factory('NewsByCatagori', function ($resource) {
return $resource('http://localhost:8080/api/catalogi/:id/news', {id: '@catagoriesId'},{
return $resource('http://localhost:8081/api/catalogi/:id/news', {id: '@catagoriesId'},{
'get': {
method: 'GET',
isArray: true
......
angular.module("myApp").controller('MyHomeController', function ($scope,$http, $state,News, $window,$stateParams,Catagories,LatestNews) {
$scope.catagories = Catagories.query();
$scope.currentPage = 1
,$scope.numPerPage = 6
,$scope.maxSize = 5;
$scope.catagoriDetail = Catagories.get({}, {myCatagoriesId: $stateParams.catagoriId}).$promise.then(
function (value) {
$scope.todos = value.news;
$scope.catagori = value;
$scope.numPages = function () {
return Math.ceil($scope.todos.length / $scope.numPerPage);
};
console.log( $scope.todos.length);
$scope.$watch('currentPage + numPerPage', function () {
var begin = (($scope.currentPage - 1) * $scope.numPerPage)
, end = begin + $scope.numPerPage;
$scope.myNews = $scope.todos.slice(begin, end);
});
},
function (error) {
console.log()
}
);
$scope.newsById = News.get({}, {myNewsId: $stateParams.Id1});
$scope.show = function(id){
$scope.newestNews = LatestNews.get({}, {CatagoriesId: id});
};
$scope.catagoriById = Catagories.get({}, {myCatagoriesId: $stateParams.myCatagoriId});
//Delete News
$scope.deleteNews = function(newsId) {
if (confirm("Delete?")) {
$http({
method: 'DELETE',
url: 'http://localhost:8080/api/HR/news/' + newsId,
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("delete OK");
$state.reload();
}, function (data, status) {
$state.reload();
});
}
};
//Edit news
$scope.newsEditById = News.get({}, {myNewsId: $stateParams.myNewsEditId});
$scope.editNews = function(newsEditById) {
if(confirm("Update?")) {
$http({
method: 'PUT',
url: 'http://localhost:8081/api/HR/news/' + newsEditById.id,
data: angular.toJson(newsEditById),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriEditId});
}, function (data, status) {
console.log(status);
});
}
};
//Add News
$scope.createNews = function(newsAdd) {
if(confirm("Add?")) {
$http({
method: 'POST',
url: 'http://localhost:8081/api/HR/'+ $stateParams.employeeId+'/catalogies/' + $stateParams.myCatagoriAddId+'/news',
data: angular.toJson(newsAdd),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriAddId});
}, function (data, status) {
console.log(status);
});
}
};
});
\ No newline at end of file
angular.module("myApp").controller('homeController', function ($scope,$http, $state,News, $window,$stateParams,Catagories,LatestNews) {
$scope.catagories = Catagories.query();
$scope.currentPage = 1
,$scope.numPerPage = 6
,$scope.maxSize = 5;
$scope.catagoriDetail = Catagories.get({}, {myCatagoriesId: $stateParams.catagoriId}).$promise.then(
function (value) {
$scope.todos = value.news;
$scope.catagori = value;
$scope.numPages = function () {
return Math.ceil($scope.todos.length / $scope.numPerPage);
};
console.log( $scope.todos.length);
$scope.$watch('currentPage + numPerPage', function () {
var begin = (($scope.currentPage - 1) * $scope.numPerPage)
, end = begin + $scope.numPerPage;
$scope.myNews = $scope.todos.slice(begin, end);
});
},
function (error) {
console.log()
}
);
$scope.newsById = News.get({}, {myNewsId: $stateParams.Id1});
$scope.show = function(id){
$scope.newestNews = LatestNews.get({}, {CatagoriesId: id});
};
$scope.catagoriById = Catagories.get({}, {myCatagoriesId: $stateParams.myCatagoriId});
//Delete News
$scope.deleteNews = function(newsId) {
if (confirm("Delete?")) {
$http({
method: 'DELETE',
url: 'http://localhost:8080/api/HR/news/' + newsId,
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("delete OK");
$state.reload();
}, function (data, status) {
$state.reload();
});
}
};
//Edit news
$scope.newsEditById = News.get({}, {myNewsId: $stateParams.myNewsEditId});
$scope.editNews = function(newsEditById) {
if(confirm("Update?")) {
$http({
method: 'PUT',
url: 'http://localhost:8080/api/HR/news/' + newsEditById.id,
data: angular.toJson(newsEditById),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriEditId});
}, function (data, status) {
console.log(status);
});
}
};
//Add News
$scope.createNews = function(newsAdd) {
if(confirm("Add?")) {
$http({
method: 'POST',
url: 'http://localhost:8080/api/HR/'+ $stateParams.employeeId+'/catalogies/' + $stateParams.myCatagoriAddId+'/news',
data: angular.toJson(newsAdd),
headers: {
'Content-Type': 'application/json'
}
}).then(function (response) {
console.log("update OK");
$state.go('newsManagement',{myCatagoriId:$stateParams.myCatagoriAddId});
}, function (data, status) {
console.log(status);
});
}
};
});
\ No newline at end of file
......@@ -12,25 +12,25 @@
<tr>
<div ng-if="catagoriById.name == 'Office'">
<a href="#/management/catagori/4" style="float:left"><< Back </a>
<a href="#/management/catagori/5" style="float:left"><< Back </a>
</div>
<div ng-if="catagoriById.name == 'Outdoor Activiy'">
<div ng-if="catagoriById.name == 'Outdoor Activity'">
<a href="#/management/catagori/1" style="float:left"><< Back </a>
</div>
<div ng-if="catagoriById.name == 'Projects'">
<a href="#/management/catagori/2" style="float:left"><< Back</a>
</div>
<div ng-if="catagoriById.name == 'Recruitments'">
<a href="#/management/catagori/3" style="float:left"><< Back </a>
<a href="#/management/catagori/4" style="float:left"><< Back </a>
</div>
<div ng-if="catagoriById.name == 'Office'">
<a href="#/management/catagori/2" style="float:right">Next >> </a>
</div>
<div ng-if="catagoriById.name == 'Outdoor Activiy'">
<a href="#/management/catagori/3" style="float:right">Next >></a>
<div ng-if="catagoriById.name == 'Outdoor Activity'">
<a href="#/management/catagori/4" style="float:right">Next >></a>
</div>
<div ng-if="catagoriById.name == 'Projects'">
<a href="#/management/catagori/4" style="float:right">Next >></a>
<a href="#/management/catagori/5" style="float:right">Next >></a>
</div>
<div ng-if="catagoriById.name == 'Recruitments'">
<a href="#/management/catagori/1" style="float:right">Next >></a>
......
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