This repository has been archived by the owner on May 28, 2021. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add developer crud operations (front-end and back-end)
- Loading branch information
Showing
7 changed files
with
270 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
src/main/java/com/ferdisonmezay/issuetracker/controller/DeveloperController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.ferdisonmezay.issuetracker.controller; | ||
|
||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
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 com.ferdisonmezay.issuetracker.entity.DeveloperEntity; | ||
import com.ferdisonmezay.issuetracker.service.DeveloperService; | ||
|
||
@RestController | ||
@RequestMapping("/developer") | ||
public class DeveloperController { | ||
|
||
@Autowired | ||
private DeveloperService developerService; | ||
|
||
@RequestMapping(value="list", method = RequestMethod.GET) | ||
public List<DeveloperEntity> getDeveloperList() { | ||
return developerService.getDevelopers(); | ||
} | ||
|
||
@RequestMapping(value = "create", method = RequestMethod.POST) | ||
public DeveloperEntity create(@RequestBody String name) { | ||
return developerService.add(name); | ||
} | ||
|
||
@RequestMapping(value = "update/{id}", method = RequestMethod.PUT) | ||
public DeveloperEntity update(@RequestBody DeveloperEntity developer) { | ||
return developerService.update(developer); | ||
} | ||
|
||
@RequestMapping(value = "delete/{id}", method = RequestMethod.DELETE) | ||
public void delete(@PathVariable(value = "id") Integer developerId) { | ||
developerService.delete(developerId); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/ferdisonmezay/issuetracker/dao/DeveloperDao.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.ferdisonmezay.issuetracker.dao; | ||
|
||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
import com.ferdisonmezay.issuetracker.entity.DeveloperEntity; | ||
|
||
@Repository | ||
public interface DeveloperDao extends JpaRepository<DeveloperEntity, Integer> { | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/ferdisonmezay/issuetracker/entity/BaseEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.ferdisonmezay.issuetracker.entity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.GeneratedValue; | ||
import javax.persistence.GenerationType; | ||
import javax.persistence.Id; | ||
import javax.persistence.MappedSuperclass; | ||
|
||
@MappedSuperclass | ||
public class BaseEntity { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
@Column(name="ID") | ||
private Integer id; | ||
|
||
public Integer getId() { return id; } | ||
public void setId(Integer id) { this.id = id; } | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/ferdisonmezay/issuetracker/entity/DeveloperEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.ferdisonmezay.issuetracker.entity; | ||
|
||
import javax.persistence.Column; | ||
import javax.persistence.Entity; | ||
import javax.persistence.Table; | ||
|
||
@Entity | ||
@Table(name="DEVELOPERS") | ||
public class DeveloperEntity extends BaseEntity { | ||
|
||
@Column(name="name") | ||
private String name; | ||
|
||
public DeveloperEntity() {} | ||
public DeveloperEntity(String name) { this.name = name; } | ||
public String getName() { return name; } | ||
public void setName(String name) { this.name = name; } | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/ferdisonmezay/issuetracker/service/DeveloperService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.ferdisonmezay.issuetracker.service; | ||
|
||
import java.util.List; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Service; | ||
import com.ferdisonmezay.issuetracker.dao.DeveloperDao; | ||
import com.ferdisonmezay.issuetracker.entity.DeveloperEntity; | ||
|
||
@Service | ||
public class DeveloperService{ | ||
|
||
@Autowired | ||
private DeveloperDao developerDao; | ||
|
||
public DeveloperEntity add(String name) { | ||
DeveloperEntity developer = new DeveloperEntity(name); | ||
return developerDao.save(developer); | ||
} | ||
|
||
public List<DeveloperEntity> getDevelopers(){ return developerDao.findAll(); } | ||
public DeveloperEntity getById(Integer id) { return developerDao.findOne(id); } | ||
public DeveloperEntity update(DeveloperEntity developer) { return developerDao.save(developer); } | ||
public void delete(Integer developerId) { developerDao.delete(developerId); } | ||
public Long getDeveloperCount() { return developerDao.count(); } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<ol class="breadcrumb"> | ||
<li><a href="#/home"><i class="fa fa-home" aria-hidden="true"></i></a></li> | ||
<li class="active">Developers</li> | ||
</ol> | ||
|
||
<div class="row" data-ng-controller="DevelopersController"> | ||
<div class="col-md-6"> | ||
<h4 class="text-center">Developers</h4> | ||
<div class="white-background" style="padding:15px;"> | ||
<table class="table table-hover table-condensed"> | ||
<thead> | ||
<tr> | ||
<th>#</th> | ||
<th>Name</th> | ||
<th>Actions</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="developer in developers" ng-class="(developer.id == currentDeveloper.id) ? 'warning' : ''"> | ||
<td></td> | ||
<td width="80%"></td> | ||
<td width="5%" style="text-align:center;"> | ||
<a class="btn btn-xs btn-success" ng-click="selectDeveloper(developer)"><i class="fa fa-pencil-square-o "></i></a> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<div class="col-md-1"></div> | ||
<div class="col-md-5"> | ||
<h4 style="color:#B80D57;"></h4> | ||
<div class="white-background" style="padding:20px;"> | ||
<form name="developerForm" ng-submit="submit()" method="POST"> | ||
<div class="row"> | ||
<div class="col-md-12"> | ||
<div class="form-group"> | ||
<label class="control-label" for="name">Name</label> | ||
<input value="" name="name" id="name" type="text" ng-model="name" placeholder="" class="form-control"> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="row"> | ||
<div class="col-md-12 text-right"> | ||
<input class="btn btn-success btn-sm" type="submit" id="submit" value="" /> | ||
<a ng-if="currentDeveloper.id" ng-click="delete(currentDeveloper.id)" class="btn btn-danger btn-sm">Delete</a> | ||
<a ng-if="currentDeveloper.id" ng-click="cancel()" class="btn btn-default btn-sm">Cancel</a> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
</div> | ||
</div> |