-
Notifications
You must be signed in to change notification settings - Fork 1
Task #2 (based on actually development branch) #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,11 +30,16 @@ public String getProjectPage() { | |
| return "project"; | ||
| } | ||
|
|
||
| @RequestMapping("/") | ||
| @RequestMapping("/getCat") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is not your functional - shoudn't change localhost:8080/ - for cat - localhost:8080/getCat solid - |
||
| public String getHelloPage() { | ||
| return "cat"; | ||
| } | ||
|
|
||
| @RequestMapping("/") | ||
| public String getRolePage() { | ||
| return "role"; | ||
| } | ||
|
|
||
| @RequestMapping("/doc") | ||
| public String workWithDoc() { | ||
| return "doc"; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,4 +43,4 @@ public void cleanUp() { | |
| public void init() { | ||
| System.err.println("Rabbit is coming..."); | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| package io.khasang.pm.controller; | ||
|
|
||
| import io.khasang.pm.entity.Role; | ||
| import io.khasang.pm.service.RoleService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Controller; | ||
| import org.springframework.web.bind.annotation.*; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Controller | ||
| @RequestMapping("/role") | ||
| // localhost:8080/role | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove |
||
| public class RoleController { | ||
| private RoleService roleService; | ||
|
|
||
| @RequestMapping(value = "/add", method = RequestMethod.POST, produces = "application/json;charset=utf-8") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add please update, delete |
||
| @ResponseBody | ||
| public Role addRole(@RequestBody Role role){ | ||
| return roleService.add(role); | ||
| } | ||
|
|
||
| @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) | ||
| @ResponseBody | ||
| public Role getById(@PathVariable("id") long id) { | ||
| return roleService.getById(id); | ||
| } | ||
|
|
||
| @RequestMapping(value = "/all", method = RequestMethod.GET) | ||
| @ResponseBody | ||
| public List<Role> getAll(){ | ||
| return roleService.getAll(); | ||
| } | ||
|
|
||
| @Autowired | ||
| public void setRoleService(RoleService roleService){ | ||
| this.roleService = roleService; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| package io.khasang.pm.dao; | ||
|
|
||
| import io.khasang.pm.entity.Role; | ||
|
|
||
| public interface RoleDao extends BasicDao<Role> { | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| package io.khasang.pm.dao.impl; | ||
|
|
||
| import io.khasang.pm.dao.RoleDao; | ||
| import io.khasang.pm.entity.Role; | ||
|
|
||
| public class RoleDaoImpl extends BasicDaoImpl<Role> implements RoleDao { | ||
| public RoleDaoImpl(Class<Role> entityClass) { | ||
| super(entityClass); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package io.khasang.pm.entity; | ||
|
|
||
| import javax.persistence.*; | ||
|
|
||
| @Entity | ||
| @Table(name = "login") | ||
| public class Login { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.AUTO) | ||
| private Long id; | ||
| private String name; | ||
| private String description; | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(Long id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| this.description = description; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package io.khasang.pm.entity; | ||
|
|
||
| import javax.persistence.*; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
|
|
||
| @Entity | ||
| @Table(name = "roles") | ||
| public class Role { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.AUTO) | ||
| private long id; | ||
|
|
||
| private String name; | ||
| private String description; | ||
|
|
||
| public List<Login> getLogin() { | ||
| return login; | ||
| } | ||
|
|
||
| public void setLogin(List<Login> login) { | ||
| this.login = login; | ||
| } | ||
|
|
||
| @OneToMany(cascade = CascadeType.ALL, orphanRemoval = true, fetch = FetchType.EAGER) | ||
| private List<Login> login = new ArrayList<>(); | ||
|
|
||
| public long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(long id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public void setDescription(String description) { | ||
| this.description = description; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| package io.khasang.pm.service; | ||
|
|
||
| import io.khasang.pm.entity.Role; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public interface RoleService { | ||
| Role add(Role role); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. add java doc |
||
|
|
||
| Role getById(long id); | ||
|
|
||
| List<Role> getAll(); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package io.khasang.pm.service.impl; | ||
|
|
||
| import io.khasang.pm.dao.RoleDao; | ||
| import io.khasang.pm.entity.Role; | ||
| import io.khasang.pm.service.RoleService; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @Service("roleService") | ||
| public class RoleServiceImpl implements RoleService { | ||
| private RoleDao roleDao; | ||
|
|
||
| @Override | ||
| public Role add(Role role) { | ||
| return roleDao.add(role); | ||
| } | ||
|
|
||
| @Override | ||
| public Role getById(long id) { | ||
| return roleDao.getById(id); | ||
| } | ||
|
|
||
| @Override | ||
| public List<Role> getAll() { | ||
| return roleDao.getAll(); | ||
| } | ||
|
|
||
| @Autowired | ||
| public void setRoleDao (RoleDao roleDao){ | ||
| this.roleDao = roleDao; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect | ||
| hibernate.show_sql=true | ||
| hibernate.format_sql=true | ||
| hibernate.hbm2ddl.auto=update | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. never do this! |
||
| hibernate.hbm2ddl.auto=create | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this class here?