...
 
Commits (2)
cache:
key: "$CI_COMMIT_REF_NAME"
paths:
- .maven/
stages:
- build
- test
- analyze
- package
- release
- deploy
before_script:
- export MAVEN_USER_HOME=`pwd`/.maven
- ./mvnw com.github.eirslett:frontend-maven-plugin:install-node-and-npm -DnodeVersion=v10.13.0 -DnpmVersion=6.4.1 -Dmaven.repo.local=$MAVEN_USER_HOME
- ./mvnw com.github.eirslett:frontend-maven-plugin:npm -Dmaven.repo.local=$MAVEN_USER_HOME
maven-compile:
stage: build
script:
- ./mvnw compile -Dmaven.repo.local=$MAVEN_USER_HOME
artifacts:
paths:
- target/classes/
- target/generated-sources/
expire_in: 1 day
maven-test:
stage: test
script:
- ./mvnw test -Dmaven.repo.local=$MAVEN_USER_HOME
artifacts:
reports:
junit: target/surefire-reports/TEST-*.xml
paths:
- target/test-results
expire_in: 1 day
frontend-test:
stage: test
script:
- ./mvnw com.github.eirslett:frontend-maven-plugin:npm -Dfrontend.npm.arguments='test -- -u' -Dmaven.repo.local=$MAVEN_USER_HOME
artifacts:
reports:
junit: target/test-results/jest/TESTS-*.xml
paths:
- target/test-results
expire_in: 1 day
maven-package:
stage: package
script:
- ./mvnw verify -Pprod -DskipTests -Dmaven.repo.local=$MAVEN_USER_HOME
artifacts:
paths:
- target/*.war
expire_in: 1 day
# Uncomment the following line to use gitlabs container registry. You need to adapt the REGISTRY_URL in case you are not using gitlab.com
#docker-push:
# image: docker:latest
# services:
# - docker:dind
# variables:
# REGISTRY_URL: registry.gitlab.com
# DOCKER_HOST: tcp://docker:2375
# DOCKER_DRIVER: overlay2
# IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
# stage: release
# dependencies:
# - maven-package
# before_script:
# - docker info
# - cp target/*.war src/main/docker
# script:
# - docker login -u "gitlab-ci-token" -p "$CI_BUILD_TOKEN" $REGISTRY_URL
# - docker build -f src/main/docker/Dockerfile -t $IMAGE_TAG src/main/docker
# - docker push $IMAGE_TAG
{
"name": "Campaign",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
},
{
"fieldName": "state",
"fieldType": "State",
"fieldValues": "STARTED,FINISHED,COMING_SOON"
}
],
"relationships": [
{
"relationshipType": "one-to-many",
"relationshipName": "offer",
"otherEntityName": "offer",
"otherEntityRelationshipName": "campaign"
},
{
"relationshipType": "many-to-one",
"relationshipName": "user",
"otherEntityName": "user",
"otherEntityField": "id"
},
{
"relationshipType": "one-to-one",
"relationshipName": "analysis",
"otherEntityName": "campaignAnalysis",
"ownerSide": false,
"otherEntityRelationshipName": "campaignAnalysis"
}
],
"changelogDate": "20190124134238",
"entityTableName": "campaign",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
\ No newline at end of file
{
"name": "CampaignAnalysis",
"fields": [
{
"fieldName": "views",
"fieldType": "Integer"
},
{
"fieldName": "shares",
"fieldType": "Integer"
},
{
"fieldName": "likes",
"fieldType": "Integer"
},
{
"fieldName": "orders",
"fieldType": "Integer"
}
],
"relationships": [
{
"relationshipType": "one-to-one",
"relationshipName": "campaign",
"otherEntityName": "campaign",
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "analysis"
}
],
"changelogDate": "20190124134241",
"entityTableName": "campaign_analysis",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
\ No newline at end of file
{
"name": "Offer",
"fields": [
{
"fieldName": "promotionCode",
"fieldType": "String"
},
{
"fieldName": "hashtag",
"fieldType": "String"
},
{
"fieldName": "name",
"fieldType": "String"
}
],
"relationships": [
{
"relationshipType": "one-to-one",
"relationshipName": "product",
"otherEntityName": "product",
"otherEntityField": "id",
"ownerSide": true,
"otherEntityRelationshipName": "offer"
},
{
"relationshipType": "many-to-one",
"relationshipName": "brand",
"otherEntityName": "user",
"otherEntityField": "id"
},
{
"relationshipType": "many-to-one",
"relationshipName": "campaign",
"otherEntityName": "campaign",
"otherEntityField": "id"
}
],
"changelogDate": "20190124134239",
"entityTableName": "offer",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
\ No newline at end of file
{
"name": "Product",
"fields": [
{
"fieldName": "name",
"fieldType": "String"
},
{
"fieldName": "category",
"fieldType": "String"
},
{
"fieldName": "type",
"fieldType": "String"
},
{
"fieldName": "price",
"fieldType": "String"
},
{
"fieldName": "description",
"fieldType": "String"
},
{
"fieldName": "image",
"fieldType": "byte[]",
"fieldTypeBlobContent": "any"
}
],
"relationships": [
{
"relationshipType": "many-to-one",
"relationshipName": "brand",
"otherEntityName": "user",
"otherEntityField": "id"
}
],
"changelogDate": "20190124134240",
"entityTableName": "product",
"dto": "no",
"pagination": "no",
"service": "no",
"jpaMetamodelFiltering": false,
"fluentMethods": true,
"clientRootFolder": "",
"applications": "*"
}
\ No newline at end of file
......@@ -33,6 +33,8 @@
"nativeLanguage": "en",
"languages": [
"en"
]
],
"herokuAppName": "cooptippon",
"herokuDeployType": "git"
}
}
\ No newline at end of file
web: java $JAVA_OPTS -Xmx256m -jar target/*.war --spring.profiles.active=prod,heroku,no-liquibase --server.port=$PORT
release: cp -R src/main/resources/config config && ./mvnw liquibase:update -Pheroku
entity Campaign {
name String,
state State
}
enum State{
STARTED, FINISHED, COMING_SOON
}
entity Offer {
promotionCode String
hashtag String
name String
}
entity Product {
name String
category String
type String
price String
description String
image Blob
}
entity CampaignAnalysis {
views Integer
shares Integer
likes Integer
orders Integer
}
relationship OneToOne {
CampaignAnalysis to Campaign{analysis}
}
relationship OneToOne {
Offer{product} to Product
}
relationship OneToMany {
Campaign{offer} to Offer{campaign}
}
relationship ManyToOne {
Campaign to User
}
relationship ManyToOne {
Product{brand} to User
}
relationship ManyToOne {
Offer{brand} to User
}
......@@ -352,6 +352,14 @@
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-data</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-localconfig-connector</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-heroku-connector</artifactId>
</dependency>
<!-- jhipster-needle-maven-add-dependency -->
</dependencies>
......@@ -1100,6 +1108,59 @@
</dependency>
</dependencies>
</profile>
<profile>
<id>heroku</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<configuration combine.self="override">
<changeLogFile>src/main/resources/config/liquibase/master.xml</changeLogFile>
<diffChangeLogFile>src/main/resources/config/liquibase/changelog/${maven.build.timestamp}_changelog.xml</diffChangeLogFile>
<driver></driver>
<url>${env.JDBC_DATABASE_URL}</url>
<defaultSchemaName></defaultSchemaName>
<username>${env.JDBC_DATABASE_USERNAME}</username>
<password>${env.JDBC_DATABASE_PASSWORD}</password>
<referenceUrl>hibernate:spring:com.mycompany.myapp.domain?dialect=org.hibernate.dialect.MySQL5InnoDBDialect&amp;hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy&amp;hibernate.implicit_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringImplicitNamingStrategy</referenceUrl>
<verbose>true</verbose>
<logging>debug</logging>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>${maven-clean-plugin.version}</version>
<executions>
<execution>
<id>clean-artifacts</id>
<phase>install</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target</directory>
<excludes>
<exclude>*.war</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
<fileset>
<directory>node_modules</directory>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<!-- jhipster-needle-maven-add-profile -->
</profiles>
</project>
......@@ -38,6 +38,11 @@ public class CacheConfiguration {
cm.createCache(com.mycompany.myapp.domain.User.class.getName(), jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.Authority.class.getName(), jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.User.class.getName() + ".authorities", jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.Campaign.class.getName(), jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.Campaign.class.getName() + ".offers", jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.Offer.class.getName(), jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.Product.class.getName(), jcacheConfiguration);
cm.createCache(com.mycompany.myapp.domain.CampaignAnalysis.class.getName(), jcacheConfiguration);
// jhipster-needle-ehcache-add-entry
};
}
......
package com.mycompany.myapp.domain;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import java.util.Objects;
import com.mycompany.myapp.domain.enumeration.State;
/**
* A Campaign.
*/
@Entity
@Table(name = "campaign")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Campaign implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name")
private String name;
@Enumerated(EnumType.STRING)
@Column(name = "state")
private State state;
@OneToMany(mappedBy = "campaign")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
private Set<Offer> offers = new HashSet<>();
@ManyToOne
@JsonIgnoreProperties("")
private User user;
@OneToOne(mappedBy = "campaignAnalysis")
@JsonIgnore
private CampaignAnalysis analysis;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public Campaign name(String name) {
this.name = name;
return this;
}
public void setName(String name) {
this.name = name;
}
public State getState() {
return state;
}
public Campaign state(State state) {
this.state = state;
return this;
}
public void setState(State state) {
this.state = state;
}
public Set<Offer> getOffers() {
return offers;
}
public Campaign offers(Set<Offer> offers) {
this.offers = offers;
return this;
}
public Campaign addOffer(Offer offer) {
this.offers.add(offer);
offer.setCampaign(this);
return this;
}
public Campaign removeOffer(Offer offer) {
this.offers.remove(offer);
offer.setCampaign(null);
return this;
}
public void setOffers(Set<Offer> offers) {
this.offers = offers;
}
public User getUser() {
return user;
}
public Campaign user(User user) {
this.user = user;
return this;
}
public void setUser(User user) {
this.user = user;
}
public CampaignAnalysis getAnalysis() {
return analysis;
}
public Campaign analysis(CampaignAnalysis campaignAnalysis) {
this.analysis = campaignAnalysis;
return this;
}
public void setAnalysis(CampaignAnalysis campaignAnalysis) {
this.analysis = campaignAnalysis;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Campaign campaign = (Campaign) o;
if (campaign.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), campaign.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Campaign{" +
"id=" + getId() +
", name='" + getName() + "'" +
", state='" + getState() + "'" +
"}";
}
}
package com.mycompany.myapp.domain;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A CampaignAnalysis.
*/
@Entity
@Table(name = "campaign_analysis")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class CampaignAnalysis implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "views")
private Integer views;
@Column(name = "shares")
private Integer shares;
@Column(name = "likes")
private Integer likes;
@Column(name = "orders")
private Integer orders;
@OneToOne @JoinColumn(unique = true)
private Campaign campaign;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public Integer getViews() {
return views;
}
public CampaignAnalysis views(Integer views) {
this.views = views;
return this;
}
public void setViews(Integer views) {
this.views = views;
}
public Integer getShares() {
return shares;
}
public CampaignAnalysis shares(Integer shares) {
this.shares = shares;
return this;
}
public void setShares(Integer shares) {
this.shares = shares;
}
public Integer getLikes() {
return likes;
}
public CampaignAnalysis likes(Integer likes) {
this.likes = likes;
return this;
}
public void setLikes(Integer likes) {
this.likes = likes;
}
public Integer getOrders() {
return orders;
}
public CampaignAnalysis orders(Integer orders) {
this.orders = orders;
return this;
}
public void setOrders(Integer orders) {
this.orders = orders;
}
public Campaign getCampaign() {
return campaign;
}
public CampaignAnalysis campaign(Campaign campaign) {
this.campaign = campaign;
return this;
}
public void setCampaign(Campaign campaign) {
this.campaign = campaign;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CampaignAnalysis campaignAnalysis = (CampaignAnalysis) o;
if (campaignAnalysis.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), campaignAnalysis.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "CampaignAnalysis{" +
"id=" + getId() +
", views=" + getViews() +
", shares=" + getShares() +
", likes=" + getLikes() +
", orders=" + getOrders() +
"}";
}
}
package com.mycompany.myapp.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A Offer.
*/
@Entity
@Table(name = "offer")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Offer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "promotion_code")
private String promotionCode;
@Column(name = "hashtag")
private String hashtag;
@Column(name = "name")
private String name;
@OneToOne @JoinColumn(unique = true)
private Product product;
@ManyToOne
@JsonIgnoreProperties("")
private User brand;
@ManyToOne
@JsonIgnoreProperties("offers")
private Campaign campaign;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getPromotionCode() {
return promotionCode;
}
public Offer promotionCode(String promotionCode) {
this.promotionCode = promotionCode;
return this;
}
public void setPromotionCode(String promotionCode) {
this.promotionCode = promotionCode;
}
public String getHashtag() {
return hashtag;
}
public Offer hashtag(String hashtag) {
this.hashtag = hashtag;
return this;
}
public void setHashtag(String hashtag) {
this.hashtag = hashtag;
}
public String getName() {
return name;
}
public Offer name(String name) {
this.name = name;
return this;
}
public void setName(String name) {
this.name = name;
}
public Product getProduct() {
return product;
}
public Offer product(Product product) {
this.product = product;
return this;
}
public void setProduct(Product product) {
this.product = product;
}
public User getBrand() {
return brand;
}
public Offer brand(User user) {
this.brand = user;
return this;
}
public void setBrand(User user) {
this.brand = user;
}
public Campaign getCampaign() {
return campaign;
}
public Offer campaign(Campaign campaign) {
this.campaign = campaign;
return this;
}
public void setCampaign(Campaign campaign) {
this.campaign = campaign;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Offer offer = (Offer) o;
if (offer.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), offer.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Offer{" +
"id=" + getId() +
", promotionCode='" + getPromotionCode() + "'" +
", hashtag='" + getHashtag() + "'" +
", name='" + getName() + "'" +
"}";
}
}
package com.mycompany.myapp.domain;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;
/**
* A Product.
*/
@Entity
@Table(name = "product")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class Product implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "name")
private String name;
@Column(name = "category")
private String category;
@Column(name = "jhi_type")
private String type;
@Column(name = "price")
private String price;
@Column(name = "description")
private String description;
@Lob
@Column(name = "image")
private byte[] image;
@Column(name = "image_content_type")
private String imageContentType;
@ManyToOne
@JsonIgnoreProperties("")
private User brand;
// jhipster-needle-entity-add-field - JHipster will add fields here, do not remove
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public Product name(String name) {
this.name = name;
return this;
}
public void setName(String name) {
this.name = name;
}
public String getCategory() {
return category;
}
public Product category(String category) {
this.category = category;
return this;
}
public void setCategory(String category) {
this.category = category;
}
public String getType() {
return type;
}
public Product type(String type) {
this.type = type;
return this;
}
public void setType(String type) {
this.type = type;
}
public String getPrice() {
return price;
}
public Product price(String price) {
this.price = price;
return this;
}
public void setPrice(String price) {
this.price = price;
}
public String getDescription() {
return description;
}
public Product description(String description) {
this.description = description;
return this;
}
public void setDescription(String description) {
this.description = description;
}
public byte[] getImage() {
return image;
}
public Product image(byte[] image) {
this.image = image;
return this;
}
public void setImage(byte[] image) {
this.image = image;
}
public String getImageContentType() {
return imageContentType;
}
public Product imageContentType(String imageContentType) {
this.imageContentType = imageContentType;
return this;
}
public void setImageContentType(String imageContentType) {
this.imageContentType = imageContentType;
}
public User getBrand() {
return brand;
}
public Product brand(User user) {
this.brand = user;
return this;
}
public void setBrand(User user) {
this.brand = user;
}
// jhipster-needle-entity-add-getters-setters - JHipster will add getters and setters here, do not remove
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Product product = (Product) o;
if (product.getId() == null || getId() == null) {
return false;
}
return Objects.equals(getId(), product.getId());
}
@Override
public int hashCode() {
return Objects.hashCode(getId());
}
@Override
public String toString() {
return "Product{" +
"id=" + getId() +
", name='" + getName() + "'" +
", category='" + getCategory() + "'" +
", type='" + getType() + "'" +
", price='" + getPrice() + "'" +
", description='" + getDescription() + "'" +
", image='" + getImage() + "'" +
", imageContentType='" + getImageContentType() + "'" +
"}";
}
}
package com.mycompany.myapp.domain.enumeration;
/**
* The State enumeration.
*/
public enum State {
STARTED, FINISHED, COMING_SOON
}
package com.mycompany.myapp.repository;
import com.mycompany.myapp.domain.CampaignAnalysis;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
/**
* Spring Data repository for the CampaignAnalysis entity.
*/
@SuppressWarnings("unused")
@Repository
public interface CampaignAnalysisRepository extends JpaRepository<CampaignAnalysis, Long> {
}
package com.mycompany.myapp.repository;
import com.mycompany.myapp.domain.Campaign;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Spring Data repository for the Campaign entity.
*/
@SuppressWarnings("unused")
@Repository
public interface CampaignRepository extends JpaRepository<Campaign, Long> {
@Query("select campaign from Campaign campaign where campaign.user.login = ?#{principal.username}")
List<Campaign> findByUserIsCurrentUser();
}
package com.mycompany.myapp.repository;
import com.mycompany.myapp.domain.Offer;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Spring Data repository for the Offer entity.
*/
@SuppressWarnings("unused")
@Repository
public interface OfferRepository extends JpaRepository<Offer, Long> {
@Query("select offer from Offer offer where offer.brand.login = ?#{principal.username}")
List<Offer> findByBrandIsCurrentUser();
}
package com.mycompany.myapp.repository;
import com.mycompany.myapp.domain.Product;
import org.springframework.data.jpa.repository.*;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Spring Data repository for the Product entity.
*/
@SuppressWarnings("unused")
@Repository
public interface ProductRepository extends JpaRepository<Product, Long> {
@Query("select product from Product product where product.brand.login = ?#{principal.username}")
List<Product> findByBrandIsCurrentUser();
}
package com.mycompany.myapp.web.rest;
import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.CampaignAnalysis;
import com.mycompany.myapp.repository.CampaignAnalysisRepository;
import com.mycompany.myapp.web.rest.errors.BadRequestAlertException;
import com.mycompany.myapp.web.rest.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing CampaignAnalysis.
*/
@RestController
@RequestMapping("/api")
public class CampaignAnalysisResource {
private final Logger log = LoggerFactory.getLogger(CampaignAnalysisResource.class);
private static final String ENTITY_NAME = "campaignAnalysis";
private final CampaignAnalysisRepository campaignAnalysisRepository;
public CampaignAnalysisResource(CampaignAnalysisRepository campaignAnalysisRepository) {
this.campaignAnalysisRepository = campaignAnalysisRepository;
}
/**
* POST /campaign-analyses : Create a new campaignAnalysis.
*
* @param campaignAnalysis the campaignAnalysis to create
* @return the ResponseEntity with status 201 (Created) and with body the new campaignAnalysis, or with status 400 (Bad Request) if the campaignAnalysis has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/campaign-analyses")
@Timed
public ResponseEntity<CampaignAnalysis> createCampaignAnalysis(@RequestBody CampaignAnalysis campaignAnalysis) throws URISyntaxException {
log.debug("REST request to save CampaignAnalysis : {}", campaignAnalysis);
if (campaignAnalysis.getId() != null) {
throw new BadRequestAlertException("A new campaignAnalysis cannot already have an ID", ENTITY_NAME, "idexists");
}
CampaignAnalysis result = campaignAnalysisRepository.save(campaignAnalysis);
return ResponseEntity.created(new URI("/api/campaign-analyses/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /campaign-analyses : Updates an existing campaignAnalysis.
*
* @param campaignAnalysis the campaignAnalysis to update
* @return the ResponseEntity with status 200 (OK) and with body the updated campaignAnalysis,
* or with status 400 (Bad Request) if the campaignAnalysis is not valid,
* or with status 500 (Internal Server Error) if the campaignAnalysis couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/campaign-analyses")
@Timed
public ResponseEntity<CampaignAnalysis> updateCampaignAnalysis(@RequestBody CampaignAnalysis campaignAnalysis) throws URISyntaxException {
log.debug("REST request to update CampaignAnalysis : {}", campaignAnalysis);
if (campaignAnalysis.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
CampaignAnalysis result = campaignAnalysisRepository.save(campaignAnalysis);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, campaignAnalysis.getId().toString()))
.body(result);
}
/**
* GET /campaign-analyses : get all the campaignAnalyses.
*
* @return the ResponseEntity with status 200 (OK) and the list of campaignAnalyses in body
*/
@GetMapping("/campaign-analyses")
@Timed
public List<CampaignAnalysis> getAllCampaignAnalyses() {
log.debug("REST request to get all CampaignAnalyses");
return campaignAnalysisRepository.findAll();
}
/**
* GET /campaign-analyses/:id : get the "id" campaignAnalysis.
*
* @param id the id of the campaignAnalysis to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the campaignAnalysis, or with status 404 (Not Found)
*/
@GetMapping("/campaign-analyses/{id}")
@Timed
public ResponseEntity<CampaignAnalysis> getCampaignAnalysis(@PathVariable Long id) {
log.debug("REST request to get CampaignAnalysis : {}", id);
Optional<CampaignAnalysis> campaignAnalysis = campaignAnalysisRepository.findById(id);
return ResponseUtil.wrapOrNotFound(campaignAnalysis);
}
/**
* DELETE /campaign-analyses/:id : delete the "id" campaignAnalysis.
*
* @param id the id of the campaignAnalysis to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/campaign-analyses/{id}")
@Timed
public ResponseEntity<Void> deleteCampaignAnalysis(@PathVariable Long id) {
log.debug("REST request to delete CampaignAnalysis : {}", id);
campaignAnalysisRepository.deleteById(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}
package com.mycompany.myapp.web.rest;
import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Campaign;
import com.mycompany.myapp.repository.CampaignRepository;
import com.mycompany.myapp.web.rest.errors.BadRequestAlertException;
import com.mycompany.myapp.web.rest.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.StreamSupport;
/**
* REST controller for managing Campaign.
*/
@RestController
@RequestMapping("/api")
public class CampaignResource {
private final Logger log = LoggerFactory.getLogger(CampaignResource.class);
private static final String ENTITY_NAME = "campaign";
private final CampaignRepository campaignRepository;
public CampaignResource(CampaignRepository campaignRepository) {
this.campaignRepository = campaignRepository;
}
/**
* POST /campaigns : Create a new campaign.
*
* @param campaign the campaign to create
* @return the ResponseEntity with status 201 (Created) and with body the new campaign, or with status 400 (Bad Request) if the campaign has already an ID
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PostMapping("/campaigns")
@Timed
public ResponseEntity<Campaign> createCampaign(@RequestBody Campaign campaign) throws URISyntaxException {
log.debug("REST request to save Campaign : {}", campaign);
if (campaign.getId() != null) {
throw new BadRequestAlertException("A new campaign cannot already have an ID", ENTITY_NAME, "idexists");
}
Campaign result = campaignRepository.save(campaign);
return ResponseEntity.created(new URI("/api/campaigns/" + result.getId()))
.headers(HeaderUtil.createEntityCreationAlert(ENTITY_NAME, result.getId().toString()))
.body(result);
}
/**
* PUT /campaigns : Updates an existing campaign.
*
* @param campaign the campaign to update
* @return the ResponseEntity with status 200 (OK) and with body the updated campaign,
* or with status 400 (Bad Request) if the campaign is not valid,
* or with status 500 (Internal Server Error) if the campaign couldn't be updated
* @throws URISyntaxException if the Location URI syntax is incorrect
*/
@PutMapping("/campaigns")
@Timed
public ResponseEntity<Campaign> updateCampaign(@RequestBody Campaign campaign) throws URISyntaxException {
log.debug("REST request to update Campaign : {}", campaign);
if (campaign.getId() == null) {
throw new BadRequestAlertException("Invalid id", ENTITY_NAME, "idnull");
}
Campaign result = campaignRepository.save(campaign);
return ResponseEntity.ok()
.headers(HeaderUtil.createEntityUpdateAlert(ENTITY_NAME, campaign.getId().toString()))
.body(result);
}
/**
* GET /campaigns : get all the campaigns.
*
* @param filter the filter of the request
* @return the ResponseEntity with status 200 (OK) and the list of campaigns in body
*/
@GetMapping("/campaigns")
@Timed
public List<Campaign> getAllCampaigns(@RequestParam(required = false) String filter) {
if ("analysis-is-null".equals(filter)) {
log.debug("REST request to get all Campaigns where analysis is null");
return StreamSupport
.stream(campaignRepository.findAll().spliterator(), false)
.filter(campaign -> campaign.getAnalysis() == null)
.collect(Collectors.toList());
}
log.debug("REST request to get all Campaigns");
return campaignRepository.findAll();
}
/**
* GET /campaigns/:id : get the "id" campaign.
*
* @param id the id of the campaign to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the campaign, or with status 404 (Not Found)
*/
@GetMapping("/campaigns/{id}")
@Timed
public ResponseEntity<Campaign> getCampaign(@PathVariable Long id) {
log.debug("REST request to get Campaign : {}", id);
Optional<Campaign> campaign = campaignRepository.findById(id);
return ResponseUtil.wrapOrNotFound(campaign);
}
/**
* DELETE /campaigns/:id : delete the "id" campaign.
*
* @param id the id of the campaign to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/campaigns/{id}")
@Timed
public ResponseEntity<Void> deleteCampaign(@PathVariable Long id) {
log.debug("REST request to delete Campaign : {}", id);
campaignRepository.deleteById(id);
return ResponseEntity.ok().headers(HeaderUtil.createEntityDeletionAlert(ENTITY_NAME, id.toString())).build();
}
}
package com.mycompany.myapp.web.rest;
import com.codahale.metrics.annotation.Timed;
import com.mycompany.myapp.domain.Offer;
import com.mycompany.myapp.repository.OfferRepository;
import com.mycompany.myapp.web.rest.errors.BadRequestAlertException;
import com.mycompany.myapp.web.rest.util.HeaderUtil;
import io.github.jhipster.web.util.ResponseUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Optional;
/**
* REST controller for managing Offer.
*/
@RestController
@RequestMapping("/api")
public class OfferResource {
private final Logger log = LoggerFactory.getLogger(OfferResource.class);
private static final String ENTITY_NAME = "offer";
private final OfferRepository offerRepository;
public OfferResource(OfferRepository offerRepository) {
this.offerRepository = offerRepository;
}
/**
* POST /offers : Create a new offer.
*
* @param offer the offer to create
* @return the ResponseEntity with status 201 (Created) and with body the new offer, or with status 400 (Bad Request) if the offer has already an ID