Skip to content

Commit 85c019a

Browse files
committed
implement home page back-end
1 parent dc44696 commit 85c019a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1140
-65
lines changed

front-end/src/store/getters.js

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,23 @@
1-
// export const user = state => state.user
2-
export const user = state => { return {name: 'James J. Ye'} }
1+
export const user = state => state.user
32

43
export const hasBoards = state => {
5-
// return state.boards.length > 0
6-
return true
4+
return state.boards.length > 0
75
}
86

97
export const personalBoards = state => {
10-
// return state.boards.filter(board => board.teamId === 0)
11-
return [{
12-
id: 1,
13-
name: 'vuejs.spring-boot.mysql',
14-
description: 'An implementation of TaskAgile application with Vue.js, Spring Boot, and MySQL'
15-
}]
8+
return state.boards.filter(board => board.teamId === 0)
169
}
1710

1811
export const teamBoards = state => {
19-
// const teams = []
20-
//
21-
// state.teams.forEach(team => {
22-
// teams.push({
23-
// id: team.id,
24-
// name: team.name,
25-
// boards: state.boards.filter(board => board.teamId === team.id)
26-
// })
27-
// })
28-
//
29-
// return teams
30-
return [{
31-
id: 1,
32-
name: 'Sales & Marketing',
33-
boards: [{
34-
id: 2,
35-
name: '2018 Planning',
36-
description: '2018 sales & marketing planning'
37-
}, {
38-
id: 3,
39-
name: 'Ongoing Campaigns',
40-
description: '2018 ongoing marketing campaigns'
41-
}]
42-
}]
12+
const teams = []
13+
14+
state.teams.forEach(team => {
15+
teams.push({
16+
id: team.id,
17+
name: team.name,
18+
boards: state.boards.filter(board => board.teamId === team.id)
19+
})
20+
})
21+
22+
return teams
4323
}

src/main/java/com/taskagile/config/SecurityConfiguration.java

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.taskagile.config;
22

3+
import com.taskagile.domain.common.security.AccessDeniedHandlerImpl;
34
import com.taskagile.web.apis.authenticate.AuthenticationFilter;
45
import com.taskagile.web.apis.authenticate.SimpleAuthenticationFailureHandler;
56
import com.taskagile.web.apis.authenticate.SimpleAuthenticationSuccessHandler;
@@ -11,6 +12,7 @@
1112
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
1213
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
1314
import org.springframework.security.crypto.password.PasswordEncoder;
15+
import org.springframework.security.web.access.AccessDeniedHandler;
1416
import org.springframework.security.web.authentication.AuthenticationFailureHandler;
1517
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
1618
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
@@ -25,19 +27,21 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
2527
@Override
2628
protected void configure(HttpSecurity http) throws Exception {
2729
http
30+
.exceptionHandling().accessDeniedHandler(accessDeniedHandler())
31+
.and()
2832
.authorizeRequests()
29-
.antMatchers(PUBLIC).permitAll()
30-
.anyRequest().authenticated()
33+
.antMatchers(PUBLIC).permitAll()
34+
.anyRequest().authenticated()
3135
.and()
32-
.addFilterAt(authenticationFilter(), UsernamePasswordAuthenticationFilter.class)
33-
.formLogin()
34-
.loginPage("/login")
36+
.addFilterAt(authenticationFilter(), UsernamePasswordAuthenticationFilter.class)
37+
.formLogin()
38+
.loginPage("/login")
3539
.and()
36-
.logout()
37-
.logoutUrl("/logout")
38-
.logoutSuccessHandler(logoutSuccessHandler())
40+
.logout()
41+
.logoutUrl("/logout")
42+
.logoutSuccessHandler(logoutSuccessHandler())
3943
.and()
40-
.csrf().disable();
44+
.csrf().disable();
4145
}
4246

4347
@Override
@@ -73,4 +77,8 @@ public AuthenticationFailureHandler authenticationFailureHandler() {
7377
public LogoutSuccessHandler logoutSuccessHandler() {
7478
return new SimpleLogoutSuccessHandler();
7579
}
80+
81+
public AccessDeniedHandler accessDeniedHandler() {
82+
return new AccessDeniedHandlerImpl();
83+
}
7684
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package com.taskagile.domain.application;
2+
3+
import com.taskagile.domain.application.commands.CreateBoardCommand;
4+
import com.taskagile.domain.model.board.Board;
5+
import com.taskagile.domain.model.user.UserId;
6+
7+
import java.util.List;
8+
9+
public interface BoardService {
10+
11+
/**
12+
* Find the boards that a user is a member, including those boards
13+
* the user created as well as joined.
14+
*
15+
* @param userId the id of the user
16+
* @return a list of boards or an empty list if none found
17+
*/
18+
List<Board> findBoardsByMembership(UserId userId);
19+
20+
/**
21+
* Create a new board
22+
*
23+
* @param command the command instance
24+
* @return the new board just created
25+
*/
26+
Board createBoard(CreateBoardCommand command);
27+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package com.taskagile.domain.application;
2+
3+
import com.taskagile.domain.application.commands.CreateTeamCommand;
4+
import com.taskagile.domain.model.team.Team;
5+
import com.taskagile.domain.model.user.UserId;
6+
7+
import java.util.List;
8+
9+
public interface TeamService {
10+
11+
/**
12+
* Find the teams that created by a user
13+
*
14+
* @param userId the id of the user
15+
* @return a list of teams or an empty list if none found
16+
*/
17+
List<Team> findTeamsByUserId(UserId userId);
18+
19+
/**
20+
* Create a new team
21+
*
22+
* @param command the command instance
23+
* @return the newly created team
24+
*/
25+
Team createTeam(CreateTeamCommand command);
26+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.taskagile.domain.application.commands;
2+
3+
import com.taskagile.domain.model.team.TeamId;
4+
import com.taskagile.domain.model.user.UserId;
5+
6+
public class CreateBoardCommand {
7+
8+
private UserId userId;
9+
private String name;
10+
private String description;
11+
private TeamId teamId;
12+
13+
public CreateBoardCommand(UserId userId, String name, String description, TeamId teamId) {
14+
this.userId = userId;
15+
this.name = name;
16+
this.description = description;
17+
this.teamId = teamId;
18+
}
19+
20+
public UserId getUserId() {
21+
return userId;
22+
}
23+
24+
public String getName() {
25+
return name;
26+
}
27+
28+
public String getDescription() {
29+
return description;
30+
}
31+
32+
public TeamId getTeamId() {
33+
return teamId;
34+
}
35+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.taskagile.domain.application.commands;
2+
3+
import com.taskagile.domain.model.user.UserId;
4+
5+
public class CreateTeamCommand {
6+
7+
private UserId userId;
8+
private String name;
9+
10+
public CreateTeamCommand(UserId userId, String name) {
11+
this.userId = userId;
12+
this.name = name;
13+
}
14+
15+
public UserId getUserId() {
16+
return userId;
17+
}
18+
19+
public String getName() {
20+
return name;
21+
}
22+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.taskagile.domain.application.impl;
2+
3+
import com.taskagile.domain.application.BoardService;
4+
import com.taskagile.domain.application.commands.CreateBoardCommand;
5+
import com.taskagile.domain.common.event.DomainEventPublisher;
6+
import com.taskagile.domain.model.board.Board;
7+
import com.taskagile.domain.model.board.BoardManagement;
8+
import com.taskagile.domain.model.board.BoardRepository;
9+
import com.taskagile.domain.model.board.events.BoardCreatedEvent;
10+
import com.taskagile.domain.model.user.UserId;
11+
import org.springframework.stereotype.Service;
12+
13+
import javax.transaction.Transactional;
14+
import java.util.List;
15+
16+
@Service
17+
@Transactional
18+
public class BoardServiceImpl implements BoardService {
19+
20+
private BoardRepository boardRepository;
21+
private BoardManagement boardManagement;
22+
private DomainEventPublisher domainEventPublisher;
23+
24+
public BoardServiceImpl(BoardRepository boardRepository,
25+
BoardManagement boardManagement,
26+
DomainEventPublisher domainEventPublisher) {
27+
this.boardRepository = boardRepository;
28+
this.boardManagement = boardManagement;
29+
this.domainEventPublisher = domainEventPublisher;
30+
}
31+
32+
@Override
33+
public List<Board> findBoardsByMembership(UserId userId) {
34+
return boardRepository.findBoardsByMembership(userId);
35+
}
36+
37+
@Override
38+
public Board createBoard(CreateBoardCommand command) {
39+
Board board = boardManagement.createBoard(command.getUserId(), command.getName(),
40+
command.getDescription(), command.getTeamId());
41+
domainEventPublisher.publish(new BoardCreatedEvent(this, board));
42+
return board;
43+
}
44+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.taskagile.domain.application.impl;
2+
3+
import com.taskagile.domain.application.TeamService;
4+
import com.taskagile.domain.application.commands.CreateTeamCommand;
5+
import com.taskagile.domain.common.event.DomainEventPublisher;
6+
import com.taskagile.domain.model.team.Team;
7+
import com.taskagile.domain.model.team.TeamRepository;
8+
import com.taskagile.domain.model.team.events.TeamCreatedEvent;
9+
import com.taskagile.domain.model.user.UserId;
10+
import org.springframework.stereotype.Service;
11+
12+
import javax.transaction.Transactional;
13+
import java.util.List;
14+
15+
@Service
16+
@Transactional
17+
public class TeamServiceImpl implements TeamService {
18+
19+
private TeamRepository teamRepository;
20+
private DomainEventPublisher domainEventPublisher;
21+
22+
public TeamServiceImpl(TeamRepository teamRepository, DomainEventPublisher domainEventPublisher) {
23+
this.teamRepository = teamRepository;
24+
this.domainEventPublisher = domainEventPublisher;
25+
}
26+
27+
@Override
28+
public List<Team> findTeamsByUserId(UserId userId) {
29+
return teamRepository.findTeamsByUserId(userId);
30+
}
31+
32+
@Override
33+
public Team createTeam(CreateTeamCommand command) {
34+
Team team = Team.create(command.getName(), command.getUserId());
35+
teamRepository.save(team);
36+
domainEventPublisher.publish(new TeamCreatedEvent(this, team));
37+
return team;
38+
}
39+
}

src/main/java/com/taskagile/domain/application/impl/UserServiceImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void register(RegistrationCommand command) throws RegistrationException {
6161
command.getPassword());
6262

6363
sendWelcomeMessage(newUser);
64-
domainEventPublisher.publish(new UserRegisteredEvent(newUser));
64+
domainEventPublisher.publish(new UserRegisteredEvent(this, newUser));
6565
}
6666

6767
private void sendWelcomeMessage(User user) {
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.taskagile.domain.common.model;
2+
3+
import java.io.Serializable;
4+
5+
public abstract class AbstractBaseId implements Serializable {
6+
7+
private static final long serialVersionUID = 3435210296634626689L;
8+
9+
private long id;
10+
11+
public AbstractBaseId(long id) {
12+
this.id = id;
13+
}
14+
15+
public long value() {
16+
return id;
17+
}
18+
19+
public boolean isValid() {
20+
return id > 0;
21+
}
22+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy