Skip to content

Commit

Permalink
Merge pull request #20 from coalingot/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
oat431 authored Feb 8, 2022
2 parents 355578c + c8df854 commit 9682fe3
Show file tree
Hide file tree
Showing 61 changed files with 2,100 additions and 2 deletions.
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: '3.8'
services:
db:
image: mysql
command: --default-authentication-plugin=mysql_native_password
ports:
- 3306:3306
environment:
MYSQL_ROOT_PASSWORD: password
phpmyadmin:
image: phpmyadmin
restart: always
ports:
- 9000:80
environment:
PMA_HOST: db
MYSQL_ROOT_PASSWORD: password
75 changes: 74 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,67 @@
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.4.2.Final</version>
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>1.4.2.Final</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.mobile</groupId>
<artifactId>spring-mobile-device</artifactId>
<version>2.0.0.M3</version>
</dependency>

<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-storage</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>public report</id>
<name>Maven Center</name>
<url>https://repo.maven.apache.org/maven2/</url>
</repository>
<repository>
<id>graphql date repo</id>
<name>repo for date of graph ql</name>
<url>https://dl.bintray.com/donbeave/maven/</url>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
<repository>
<id>spring-snapshots</id>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>

</repositories>
<build>
<plugins>
<plugin>
Expand All @@ -66,7 +125,21 @@
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
</plugins>
</build>

<pluginRepositories>
<pluginRepository>
<id>repository.spring.release</id>
<name>Spring GA Repository</name>
<url>https://repo.spring.io/plugins-release/</url>
</pluginRepository>
</pluginRepositories>
</project>
15 changes: 15 additions & 0 deletions src/main/java/se/project/coalingot/CoalingotApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,27 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootApplication
public class CoalingotApplication {

public static void main(String[] args) {
SpringApplication.run(CoalingotApplication.class, args);
}
@Bean
public WebMvcConfigurer corsConfigurer(){
return new WebMvcConfigurer() {
@Override
public void addCorsMappings(CorsRegistry registry){
registry.addMapping("/**")
.allowedOrigins("http://localhost:3000")
.allowedOrigins("https://firebase.hosting.app.somehting")
.exposedHeaders("x-total-count");
}
};
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package se.project.coalingot.auction.controller;

import org.springframework.stereotype.Controller;

@Controller
public class AuctionController {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package se.project.coalingot.auction.dao;

public interface AuctionDao {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package se.project.coalingot.auction.dao;

import org.springframework.stereotype.Repository;

@Repository
public class AuctionDaoImpl implements AuctionDao{
}
24 changes: 24 additions & 0 deletions src/main/java/se/project/coalingot/auction/dto/AuctionDto.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package se.project.coalingot.auction.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import se.project.coalingot.item.dto.ItemAuctionDto;

import java.util.Date;
import java.util.List;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AuctionDto {
Long auctionId;
ItemAuctionDto auctionItem;
Double highestPrice;
Boolean status;
Date startDate;
Date endDate;
List<AuctionHistoryDto> histories;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package se.project.coalingot.auction.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import se.project.coalingot.auctionuser.dto.AuctionUserPaticipantDto;
import se.project.coalingot.item.dto.ItemAuctionDto;
import se.project.coalingot.item.dto.ItemDto;
import se.project.coalingot.item.dto.ItemHistoryDto;

import java.util.Date;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AuctionHistoryDto {
AuctionUserPaticipantDto auctionUser;
Double submitPrice;
Date submitAt;
ItemHistoryDto auctionItem;
}
35 changes: 35 additions & 0 deletions src/main/java/se/project/coalingot/auction/entity/Auction.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package se.project.coalingot.auction.entity;

import lombok.*;
import se.project.coalingot.item.entity.Item;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Builder
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class Auction {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@EqualsAndHashCode.Exclude
Long auctionId;

@OneToOne
Item auctionItem;

@OneToMany(mappedBy = "auctionEvent")
List<AuctionHistory> histories = new ArrayList<>();

Double highestPrice;

Boolean status;

Date startDate;

Date endDate;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package se.project.coalingot.auction.entity;

import lombok.*;
import se.project.coalingot.auctionuser.entity.AuctionUser;
import se.project.coalingot.item.entity.Item;

import javax.persistence.*;
import java.util.Date;

@Data
@Builder
@Entity
@AllArgsConstructor
@NoArgsConstructor
public class AuctionHistory {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@EqualsAndHashCode.Exclude
Long auctionHistoryId;

@ManyToOne
AuctionUser auctionUser;

@ManyToOne
Auction auctionEvent;

Double submitPrice;

Date submitAt;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package se.project.coalingot.auction.entity;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class AuctionRequest {
Long auctionId;
Long userId;
Double submitPrice;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package se.project.coalingot.auction.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import se.project.coalingot.auction.entity.AuctionHistory;

public interface AuctionHistoryRepository extends JpaRepository<AuctionHistory, Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package se.project.coalingot.auction.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import se.project.coalingot.auction.entity.Auction;

public interface AuctionRepository extends JpaRepository<Auction,Long> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package se.project.coalingot.auction.service;

public interface AuctionService {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package se.project.coalingot.auction.service;

import org.springframework.stereotype.Service;

@Service
public class AuctionServiceImpl implements AuctionService{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package se.project.coalingot.auctionuser.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import se.project.coalingot.auction.entity.Auction;
import se.project.coalingot.auction.entity.AuctionRequest;
import se.project.coalingot.auction.repository.AuctionRepository;
import se.project.coalingot.auctionuser.entity.AuctionUser;
import se.project.coalingot.auctionuser.service.AuctionUserService;
import se.project.coalingot.util.AuctionMapper;

import java.util.List;

@Controller
public class AuctionUserController {
@Autowired
AuctionUserService auctionUserService;

// will change later
@Autowired
AuctionRepository auctionRepository;

@PostMapping("/submit-price")
public ResponseEntity<?> submitPrice(
@RequestBody AuctionRequest auctionRequest
) {
auctionUserService.submitPrice(
auctionRequest.getAuctionId(),
auctionRequest.getUserId(),
auctionRequest.getSubmitPrice()
);
return ResponseEntity.ok("You has been submitted the price.");
}

@GetMapping("/see-all-auction")
public ResponseEntity<?> seeAuction(){
List<Auction> output = auctionRepository.findAll();
return ResponseEntity.ok(AuctionMapper.INSTANCE.seeAuction(output));
}

@GetMapping("auctionList/{auctionUserID}")
public ResponseEntity<?> getAuctionThatSubmit(
@PathVariable("auctionUserID") Long auctionID
) {
AuctionUser output = auctionUserService.getAuctionUser(auctionID);
return ResponseEntity.ok(AuctionMapper.INSTANCE.getAuctionUserDto(output));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package se.project.coalingot.auctionuser.dao;

import se.project.coalingot.auctionuser.entity.AuctionUser;

public interface AuctionUserDao {
void submitPrice(Long auctionId,Long userId,Double price);
AuctionUser getAuctionUser(Long auctionUserID);
}
Loading

0 comments on commit 9682fe3

Please sign in to comment.