Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/main/java/io/khasang/pm/config/AppConfig.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
package io.khasang.pm.config;

import io.khasang.pm.dao.CatDao;
import io.khasang.pm.dao.DocumentDao;
import io.khasang.pm.dao.EmployeeDao;
import io.khasang.pm.dao.ProjectDao;
import io.khasang.pm.dao.DocumentDao;
import io.khasang.pm.dao.RoleDao;
import io.khasang.pm.dao.impl.CatDaoImpl;
import io.khasang.pm.dao.impl.DocumentDaoImpl;
import io.khasang.pm.dao.impl.EmployeeDaoImpl;
import io.khasang.pm.dao.impl.ProjectDaoImpl;
import io.khasang.pm.dao.impl.DocumentDaoImpl;
import io.khasang.pm.dao.impl.RoleDaoImpl;
import io.khasang.pm.entity.Cat;
import io.khasang.pm.entity.Employee;
import io.khasang.pm.entity.Project;
import io.khasang.pm.entity.Document;
import io.khasang.pm.entity.Role;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
Expand All @@ -34,9 +37,14 @@ public DocumentDao documentDao(){
return new DocumentDaoImpl(Document.class);
}

@Bean
public RoleDao roleDao() {
return new RoleDaoImpl(Role.class);
}

@Bean
public EmployeeDao employeeDao(){
return new EmployeeDaoImpl(Employee.class);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ public void setDataSource(DataSource dataSource) {
public void setEnvironment(Environment environment) {
this.environment = environment;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ private PasswordEncoder passwordEncoder() {
public void setUserDetailsService(UserDetailsService userDetailsService) {
this.userDetailsService = userDetailsService;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
import org.springframework.security.web.context.AbstractSecurityWebApplicationInitializer;

public class SecurityInit extends AbstractSecurityWebApplicationInitializer {
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this class here?

}
7 changes: 6 additions & 1 deletion src/main/java/io/khasang/pm/controller/AppController.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@ public String getProjectPage() {
return "project";
}

@RequestMapping("/")
@RequestMapping("/getCat")
Copy link
Collaborator

Choose a reason for hiding this comment

The 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
localhost:8080/getRole

solid -

public String getHelloPage() {
return "cat";
}

@RequestMapping("/")
public String getRolePage() {
return "role";
}

@RequestMapping("/doc")
public String workWithDoc() {
return "doc";
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/khasang/pm/controller/CatController.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public List<Cat> getAll(){
public void setCatService(CatService catService) {
this.catService = catService;
}
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/khasang/pm/controller/Rabbit.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ public void cleanUp() {
public void init() {
System.err.println("Rabbit is coming...");
}
}
}
39 changes: 39 additions & 0 deletions src/main/java/io/khasang/pm/controller/RoleController.java
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
Copy link
Collaborator

Choose a reason for hiding this comment

The 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")
Copy link
Collaborator

Choose a reason for hiding this comment

The 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;
}
}
6 changes: 6 additions & 0 deletions src/main/java/io/khasang/pm/dao/RoleDao.java
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> {
}
10 changes: 10 additions & 0 deletions src/main/java/io/khasang/pm/dao/impl/RoleDaoImpl.java
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);
}
}
37 changes: 37 additions & 0 deletions src/main/java/io/khasang/pm/entity/Login.java
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;
}
}
51 changes: 51 additions & 0 deletions src/main/java/io/khasang/pm/entity/Role.java
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;
}
}
13 changes: 13 additions & 0 deletions src/main/java/io/khasang/pm/service/RoleService.java
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);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add java doc


Role getById(long id);

List<Role> getAll();
}
34 changes: 34 additions & 0 deletions src/main/java/io/khasang/pm/service/impl/RoleServiceImpl.java
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;
}
}
2 changes: 1 addition & 1 deletion src/main/resources/hibernate.properties
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never do this!

hibernate.hbm2ddl.auto=create
Loading