Skip to content

Commit

Permalink
Merge pull request #7 from kucharzyk/dev
Browse files Browse the repository at this point in the history
version 1.8.0
  • Loading branch information
kucharzyk committed Jun 30, 2016
2 parents edd60d7 + 202bc7e commit eefb716
Show file tree
Hide file tree
Showing 105 changed files with 1,533 additions and 769 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -10,6 +10,7 @@ shardis-api/target/
shardis-ui/target/

### node
npm-debug.log
shardis-ui/etc/
shardis-ui/node/
shardis-ui/node_modules/
Expand Down
18 changes: 17 additions & 1 deletion CHANGELOG.md
@@ -1,4 +1,20 @@
## Changelog
## CHANGELOG:

### 1.8.0 (30.06.2016)
* Better directory structure for angular components
* Dependency updates
* Updated Angular to rc.2
* Migrate awesome-ts-loader to ts-loader due to problems with karma
* Migrate to router 3
* Lazy routes with modified version of AngularClass webpack resolver
* Updated Angular to rc.3
* Added 404 page
* Much cleaner webpack configuration
* Role based visibility of menu items
* CRUD example for authenticated users
* Route access for selected roles (guards)
* Switched to new Angular Forms
* Updated angular2-material to 2.0.0-alpha.6

### 1.7.0 (08.06.2016)
* Added npm-check-updates as dev dependency
Expand Down
50 changes: 33 additions & 17 deletions README.md
@@ -1,16 +1,22 @@
# Spring Boot Angular 2 starter
# SPRING BOOT ANGULAR 2 STARTER

## PROJECT DESCRIPTION:

This sample project demonstrates how to integrate Spring Boot application with Angular 2.
It could be used as base for your future Angular2 Java projects.
Node and npm are installed as part of maven build. Also webpack build and karma tests runs with maven.
It also uses Spring Cloud microservices and Spring Security with Oauth2 JWT tokens.

Originally based on great [AngularClass](https://github.com/AngularClass) webpack starter

## FEATURES:
* Build and testing process integrated with maven
* Spring cloud microservices with Zull and Eureka
* Spring security Oauth2 integration
* Spring Boot application in development mode use resources from webpack dev server
* scss support
* Angular material
* font-awesome

* Scss support
* Angular material integration
* Font-awesome integration
* Lazy loaded routes

## PRODUCTION USAGE:

Expand All @@ -29,28 +35,28 @@ Then build and run discovery server:
```
cd shardis-discovery/
mvn clean package
java -jar ./target/shardis-discovery-1.7.0.jar
java -jar ./target/shardis-discovery-1.8.0.jar
```

Then build and run api server:
```
cd shardis-api/
mvn clean package
java -jar ./target/shardis-api-1.7.0.jar
java -jar ./target/shardis-api-1.8.0.jar
```

Then build and run auth server:
```
cd shardis-auth/
mvn clean package
java -jar ./target/shardis-auth-1.7.0.jar
java -jar ./target/shardis-auth-1.8.0.jar
```

Then build and run ui server:
```
cd shardis-api/
mvn clean package
java -jar ./target/shardis-ui-1.7.0.jar
java -jar ./target/shardis-ui-1.8.0.jar
```


Expand Down Expand Up @@ -112,7 +118,23 @@ cd shardis-ui
npm run e2e
```

## Changelog
## CHANGELOG:

### 1.8.0 (30.06.2016)
* Better directory structure for angular components
* Dependency updates
* Updated Angular to rc.2
* Migrate awesome-ts-loader to ts-loader due to problems with karma
* Migrate to router 3
* Lazy routes with modified version of AngularClass webpack resolver
* Updated Angular to rc.3
* Added 404 page
* Much cleaner webpack configuration
* Role based visibility of menu items
* CRUD example for authenticated users
* Route access for selected roles (guards)
* Switched to new Angular Forms
* Updated angular2-material to 2.0.0-alpha.6

### 1.7.0 (08.06.2016)
* Added npm-check-updates as dev dependency
Expand Down Expand Up @@ -141,10 +163,4 @@ npm run e2e
* Fixed webpack validator custom schema config
* Some fixes from AngularClass starter

### 1.5.0 (13.05.2016)
* Updated Spring Boot to 1.3.4
* Updated Spring Boot to 1.3.5
* Added Spring IO Platform dependency
* Various bugfixes

[show full changelog](CHANGELOG.md)
6 changes: 3 additions & 3 deletions pom.xml
Expand Up @@ -5,16 +5,16 @@

<groupId>com.shardis</groupId>
<artifactId>shardis</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<packaging>pom</packaging>

<name>shardis</name>
<description>shardis</description>

<modules>
<module>shardis-parent</module>
<module>shardis-parent</module>
<module>shardis-common</module>
<module>shardis-discovery</module>
<module>shardis-discovery</module>
<module>shardis-auth</module>
<module>shardis-ui</module>
<module>shardis-api</module>
Expand Down
5 changes: 3 additions & 2 deletions shardis-api/pom.xml
Expand Up @@ -3,8 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.shardis</groupId>
<artifactId>shardis-api</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<packaging>jar</packaging>

<name>shardis-api</name>
Expand All @@ -13,7 +14,7 @@
<parent>
<groupId>com.shardis</groupId>
<artifactId>shardis-parent</artifactId>
<version>1.7.0</version>
<version>1.8.0</version>
<relativePath/>
</parent>

Expand Down
Expand Up @@ -4,6 +4,7 @@
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;

/**
Expand Down
19 changes: 19 additions & 0 deletions shardis-api/src/main/java/com/shardis/api/config/JpaConfig.java
@@ -0,0 +1,19 @@
package com.shardis.api.config;

import com.shardis.api.domain.user.User;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.domain.AuditorAware;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;

/**
* Created by Tomasz Kucharzyk
*/
@Configuration
@EnableJpaAuditing(auditorAwareRef = "auditorProvider")
public class JpaConfig {
@Bean(name = "auditorProvider" )
public AuditorAware<User> auditorProvider() {
return () -> null;
}
}
@@ -0,0 +1,61 @@
package com.shardis.api.controllers.rest;


import com.google.common.collect.Lists;
import com.shardis.api.domain.blog.BlogPost;
import com.shardis.api.domain.blog.BlogPostRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.PostConstruct;
import java.util.List;

/**
* Created by Tomasz Kucharzyk
*/

@Transactional
@RestController
@RequestMapping("/posts")
@PreAuthorize(value = "hasRole('ROLE_USER')")
@Slf4j
public class BlogPostRestController {

@Autowired
private BlogPostRepository blogPostRepository;

@PostConstruct
public void fillData() {
List<BlogPost> posts = this.getPosts();
if (posts.isEmpty()) {
for (int i = 1; i <= 10; i++) {
BlogPost post = new BlogPost("Sample blog post title #" + i, "Sample blog post content #" + i);
blogPostRepository.save(post);
log.warn(post.toString());
}
}
}

@RequestMapping(value = "/", method = RequestMethod.GET)
public List<BlogPost> getPosts() {
return Lists.newArrayList(blogPostRepository.findAll());
}

@RequestMapping(value = "/", method = RequestMethod.POST)
public BlogPost savePost(@RequestBody BlogPost blogPost) {
return blogPostRepository.save(blogPost);
}

@RequestMapping(value = "/{postId}", method = RequestMethod.DELETE)
public BlogPost deletePost(@PathVariable("postId") Long postId) {
BlogPost blogPost = blogPostRepository.findOne(postId);
if (blogPost != null) {
blogPostRepository.delete(blogPost);
}
return blogPost;
}

}
@@ -0,0 +1,46 @@
package com.shardis.api.domain.base;

import com.shardis.api.domain.user.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.envers.Audited;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import javax.persistence.EntityListeners;
import javax.persistence.ManyToOne;
import javax.persistence.MappedSuperclass;
import javax.persistence.Version;
import java.time.LocalDateTime;

/**
* Created by Tomasz Kucharzyk
*/
@Audited
@Data
@EqualsAndHashCode(callSuper = true)
@EntityListeners(AuditingEntityListener.class)
@MappedSuperclass
public class AuditedEntity extends BaseEntity {

@CreatedDate
protected LocalDateTime createdDate;

@CreatedBy
@ManyToOne
protected User createdBy;

@LastModifiedDate
protected LocalDateTime updatedDate;

@LastModifiedBy
@ManyToOne
protected User updatedBy;

@Version
protected Long version;

}
@@ -0,0 +1,21 @@
package com.shardis.api.domain.base;

import lombok.Data;

import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;

/**
* Created by Tomasz Kucharzyk
*/
@Data
@MappedSuperclass
public class BaseEntity {

@Id
@GeneratedValue(strategy = GenerationType.AUTO)
protected Long id;

}
@@ -0,0 +1,44 @@
package com.shardis.api.domain.blog;

import com.shardis.api.domain.base.AuditedEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.persistence.Entity;
import javax.persistence.Table;

/**
* Created by Tomasz Kucharzyk
*/

@Entity
@Table(name = "BLOG_POST")
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
public class BlogPost extends AuditedEntity {


private String title;
private String content;

public BlogPost(String title, String content) {
this.title = title;
this.content = content;
}

@Override
public String toString() {
return "BlogPost{" +
"id=" + id +
", createdDate=" + createdDate +
", createdBy=" + createdBy +
", updatedDate=" + updatedDate +
", updatedBy=" + updatedBy +
", version=" + version +
", title='" + title + '\'' +
", content='" + content + '\'' +
'}';
}
}
@@ -0,0 +1,11 @@
package com.shardis.api.domain.blog;

import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;

/**
* Created by Tomasz Kucharzyk
*/
@Repository
public interface BlogPostRepository extends CrudRepository<BlogPost, Long> {
}

0 comments on commit eefb716

Please sign in to comment.