Skip to content

Commit 8565631

Browse files
committed
minor fixes
1 parent 2e9a276 commit 8565631

File tree

9 files changed

+52
-85
lines changed

9 files changed

+52
-85
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
<optional>true</optional>
4040
</dependency>
4141
<dependency>
42-
<groupId>mysql</groupId>
43-
<artifactId>mysql-connector-java</artifactId>
42+
<groupId>org.postgresql</groupId>
43+
<artifactId>postgresql</artifactId>
4444
<scope>runtime</scope>
4545
</dependency>
4646
<dependency>

react-frontend/.eslintcache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\index.js":"1","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\app\\app.js":"2","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\parts\\header.js":"3","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\parts\\footer.js":"4","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\store.js":"5","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\reducers\\index.js":"6","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\reducers\\error-reducer.js":"7","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\actions\\types.js":"8","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\actions\\employee-actions.js":"9","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\reducers\\employee-reducer.js":"10","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employee-add-component.js":"11","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employee-update-component.js":"12","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employees-list-component.js":"13","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employee-view-component.js":"14","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\parts\\input-form.js":"15"},{"size":159,"mtime":1603024139520,"results":"16","hashOfConfig":"17"},{"size":1357,"mtime":1607354677981,"results":"18","hashOfConfig":"17"},{"size":380,"mtime":1607277075765,"results":"19","hashOfConfig":"17"},{"size":368,"mtime":1607277075779,"results":"20","hashOfConfig":"17"},{"size":704,"mtime":1607285804596,"results":"21","hashOfConfig":"17"},{"size":238,"mtime":1607290290431,"results":"22","hashOfConfig":"17"},{"size":277,"mtime":1610052714666,"results":"23","hashOfConfig":"17"},{"size":194,"mtime":1607294294762,"results":"24","hashOfConfig":"17"},{"size":1704,"mtime":1607341318486,"results":"25","hashOfConfig":"17"},{"size":638,"mtime":1610127149385,"results":"26","hashOfConfig":"17"},{"size":1766,"mtime":1610127266409,"results":"27","hashOfConfig":"17"},{"size":2299,"mtime":1610127300478,"results":"28","hashOfConfig":"17"},{"size":3277,"mtime":1607354678027,"results":"29","hashOfConfig":"17"},{"size":2137,"mtime":1607354678017,"results":"30","hashOfConfig":"17"},{"size":4126,"mtime":1607355107333,"results":"31","hashOfConfig":"17"},{"filePath":"32","messages":"33","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},"hn9ska",{"filePath":"35","messages":"36","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"37","messages":"38","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"39","messages":"40","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"41","messages":"42","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"43","messages":"44","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"45","messages":"46","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":"47","usedDeprecatedRules":"34"},{"filePath":"48","messages":"49","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"50","messages":"51","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"52","messages":"53","errorCount":0,"warningCount":1,"fixableErrorCount":0,"fixableWarningCount":0,"source":null},{"filePath":"54","messages":"55","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"56","messages":"57","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"58","messages":"59","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"60","messages":"61","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},{"filePath":"62","messages":"63","errorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0,"usedDeprecatedRules":"34"},"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\index.js",[],["64","65"],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\app\\app.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\parts\\header.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\parts\\footer.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\store.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\reducers\\index.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\reducers\\error-reducer.js",["66"],"import {GET_ERRORS} from \"../actions/types\";\r\n\r\nconst initialState = {};\r\n\r\nexport default function (state = initialState, action) {\r\n switch (action.type) {\r\n case GET_ERRORS:\r\n return action.payload;\r\n default:\r\n return state;\r\n }\r\n}","C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\actions\\types.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\actions\\employee-actions.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\reducers\\employee-reducer.js",["67"],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employee-add-component.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employee-update-component.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employees-list-component.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\employees-components\\employee-view-component.js",[],"C:\\Users\\merik\\IdeaProjects\\spring-boot-reactjs-crud-app\\react-frontend\\src\\components\\parts\\input-form.js",[],{"ruleId":"68","replacedBy":"69"},{"ruleId":"70","replacedBy":"71"},{"ruleId":"72","severity":1,"message":"73","line":5,"column":1,"nodeType":"74","endLine":13,"endColumn":2},{"ruleId":"72","severity":1,"message":"73","line":8,"column":1,"nodeType":"74","endLine":24,"endColumn":2},"no-native-reassign",["75"],"no-negated-in-lhs",["76"],"import/no-anonymous-default-export","Unexpected default export of anonymous function","ExportDefaultDeclaration","no-global-assign","no-unsafe-negation"]

react-frontend/src/components/employees-components/employee-add-component.js

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@ import {createEmployee} from "../../actions/employee-actions";
66
import InputForm from "../parts/input-form";
77

88
class EmployeeAddComponent extends Component {
9-
constructor(props) {
10-
super(props);
11-
12-
this.state = {
13-
firstName: "",
14-
lastName: "",
15-
city: "",
16-
address: "",
17-
telephone: "",
18-
errors: {}
19-
};
20-
21-
this.createEmployee = this.createEmployee.bind(this);
22-
this.handleInputChange = this.handleInputChange.bind(this);
23-
}
9+
state = {
10+
firstName: "",
11+
lastName: "",
12+
city: "",
13+
address: "",
14+
telephone: "",
15+
errors: {}
16+
};
2417

2518
// static getDerivedStateFromProps(nextProps)
2619
componentWillReceiveProps(nextProps) {
@@ -29,26 +22,19 @@ class EmployeeAddComponent extends Component {
2922
}
3023
}
3124

32-
handleInputChange(event) {
25+
handleInputChange = (event) => {
3326
const {name, value} = event.target;
3427

3528
this.setState({
3629
[name]: value
3730
});
3831
};
3932

40-
createEmployee(event) {
33+
createEmployee = (event) => {
4134
event.preventDefault();
4235

4336
const {firstName, lastName, city, address, telephone} = this.state;
44-
45-
const employee = {
46-
firstName,
47-
lastName,
48-
city,
49-
address,
50-
telephone
51-
};
37+
const employee = {firstName, lastName, city, address, telephone};
5238

5339
this.props.createEmployee(employee, this.props.history);
5440
};
@@ -61,8 +47,7 @@ class EmployeeAddComponent extends Component {
6147
employee={this.state}
6248
errors={this.state.errors}
6349
onSubmitForm={this.createEmployee}
64-
handleInputChange={this.handleInputChange}
65-
/>
50+
handleInputChange={this.handleInputChange}/>
6651
</div>
6752
);
6853
}

react-frontend/src/components/employees-components/employee-update-component.js

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,14 @@ import {updateEmployee, getEmployeeById} from "../../actions/employee-actions";
66
import InputForm from "../parts/input-form";
77

88
class EmployeeUpdateComponent extends Component {
9-
constructor(props) {
10-
super(props);
11-
12-
this.state = {
13-
firstName: "",
14-
lastName: "",
15-
city: "",
16-
address: "",
17-
telephone: "",
18-
errors: {}
19-
};
20-
21-
this.updateEmployee = this.updateEmployee.bind(this);
22-
this.handleInputChange = this.handleInputChange.bind(this);
23-
}
9+
state = {
10+
firstName: "",
11+
lastName: "",
12+
city: "",
13+
address: "",
14+
telephone: "",
15+
errors: {}
16+
};
2417

2518
componentDidMount() {
2619
this.props.getEmployeeById(this.props.match.params.id);
@@ -55,14 +48,7 @@ class EmployeeUpdateComponent extends Component {
5548
event.preventDefault();
5649

5750
const {firstName, lastName, city, address, telephone} = this.state;
58-
59-
const employee = {
60-
firstName,
61-
lastName,
62-
city,
63-
address,
64-
telephone
65-
};
51+
const employee = {firstName, lastName, city, address, telephone};
6652

6753
this.props.updateEmployee(this.props.match.params.id, employee, this.props.history);
6854
};
@@ -75,8 +61,7 @@ class EmployeeUpdateComponent extends Component {
7561
employee={this.state}
7662
errors={this.state.errors}
7763
onSubmitForm={this.updateEmployee}
78-
handleInputChange={this.handleInputChange}
79-
/>
64+
handleInputChange={this.handleInputChange}/>
8065
</div>
8166
);
8267
}

react-frontend/src/reducers/employee-reducer.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,18 @@ const initialState = {
66
};
77

88
export default function (state = initialState, action) {
9-
switch (action.type) {
9+
const {type, payload} = action;
10+
11+
switch (type) {
1012
case GET_EMPLOYEES:
11-
return {
12-
...state,
13-
employees: action.payload
14-
};
13+
return {...state, employees: payload};
14+
1515
case DELETE_EMPLOYEE:
16-
return {
17-
...state,
18-
employees: state.employees.filter((employee) => employee.id !== action.payload)
19-
};
16+
return {...state, employees: state.employees.filter((employee) => employee.id !== payload)};
17+
2018
case GET_EMPLOYEE_BY_ID:
21-
return {
22-
...state,
23-
employee: action.payload
24-
};
19+
return {...state, employee: payload};
20+
2521
default:
2622
return state;
2723
}

src/main/java/com/gmail/merikbest2015/springbootreactjscrudapp/model/Employee.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
package com.gmail.merikbest2015.springbootreactjscrudapp.model;
22

33
import lombok.Data;
4-
import lombok.NoArgsConstructor;
5-
import lombok.RequiredArgsConstructor;
64

75
import javax.persistence.*;
86
import javax.validation.constraints.NotBlank;
97

108
@Entity
119
@Table(name = "employees")
1210
@Data
13-
@NoArgsConstructor
1411
public class Employee {
1512
@Id
16-
@GeneratedValue(strategy = GenerationType.IDENTITY)
13+
@GeneratedValue(strategy = GenerationType.AUTO)
1714
private Long id;
1815
@NotBlank(message = "Empty field!")
1916
@Column(name = "first_name")
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
spring.datasource.url=jdbc:mysql://localhost:3306/employee_management_system
2-
spring.datasource.username=root
1+
spring.datasource.url=jdbc:postgresql://localhost:5432/employee-management-system
2+
spring.datasource.username=postgres
33
spring.datasource.password=root
4-
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
5-
spring.jpa.hibernate.ddl-auto=validate
64
spring.jpa.generate-ddl=false
5+
spring.jpa.show-sql=false
6+
spring.jpa.hibernate.ddl-auto=validate
77
spring.flyway.locations=classpath:/db/migration
Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
CREATE TABLE IF NOT EXISTS employees (
2-
id BIGINT AUTO_INCREMENT PRIMARY KEY,
3-
first_name VARCHAR(100),
4-
last_name VARCHAR(100),
5-
city VARCHAR(100),
6-
address VARCHAR(100),
7-
telephone VARCHAR(100)
1+
create sequence hibernate_sequence start 4 increment 1;
2+
3+
create table employees(
4+
id int8 not null,
5+
address varchar(255),
6+
city varchar(255),
7+
first_name varchar(255),
8+
last_name varchar(255),
9+
telephone varchar(255),
10+
primary key (id)
811
);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
INSERT INTO employees VALUES (1, 'Ivan', 'Ivanov', 'Kiev', 'Khreschatyk 1', '414-00-01');
2-
INSERT INTO employees VALUES (2, 'John', 'Doe', 'New York', 'Wall Street, 2', '777-77-72');
3-
INSERT INTO employees VALUES (3, 'Walter', 'White', 'Albuquerque', 'Negra Arroyo Lane, 308', '777-77-73');
1+
insert into employees (id, first_name, last_name, city, address, telephone) values (1, 'Ivan', 'Ivanov', 'Kiev', 'Khreschatyk 1', '414-00-01');
2+
insert into employees (id, first_name, last_name, city, address, telephone) values (2, 'John', 'Doe', 'New York', 'Wall Street, 2', '777-77-72');
3+
insert into employees (id, first_name, last_name, city, address, telephone) values (3, 'Walter', 'White', 'Albuquerque', 'Negra Arroyo Lane, 308', '777-77-73');

0 commit comments

Comments
 (0)