Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import org.springframework.stereotype.Service;

@Service
public class COmmonUtilService {
public class CommonUtilService {

public static String standardUpperCase (String givenString){

Expand Down
14 changes: 0 additions & 14 deletions src/main/java/com/interview/exercise/Package.java

This file was deleted.

30 changes: 0 additions & 30 deletions src/main/java/com/interview/exercise/entities/AppUser.java

This file was deleted.

20 changes: 0 additions & 20 deletions src/main/java/com/interview/exercise/entities/AppUserMapper.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

28 changes: 0 additions & 28 deletions src/main/java/com/interview/exercise/entities/Role.java

This file was deleted.

10 changes: 10 additions & 0 deletions src/main/java/com/interview/exercise/entities/courier/Courier.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.interview.exercise.entities.courier;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
public class Courier {
@Id
int courierId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package com.interview.exercise.entities.courier;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;

@RestController
@RequestMapping("/courier")
public class CourierController {
@Autowired
CourierService service;

@GetMapping("/all")
public ArrayList<CourierDto> getAllCouriers() {
return service.getAllCouriers();
}

@GetMapping("/all/{name}")
public ArrayList<CourierDto> getAllCouriersByName(@RequestParam("name") String name) {
return service.getAllCouriersByName(name);
}

@PostMapping("")
public CourierDto createCourier(CourierDto courier) {
return service.createCourier(courier);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.interview.exercise.entities.courier;

public class CourierDto {
private int courierId;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.interview.exercise.entities.courier;

import org.springframework.stereotype.Service;

import java.util.ArrayList;

@Service
class CourierService {
public ArrayList<CourierDto> getAllCouriers() {
return null;
}

public CourierDto createCourier(CourierDto courier) {
return null;
}

public ArrayList<CourierDto> getAllCouriersByName(String name) {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.interview.exercise.entities;
package com.interview.exercise.entities.invoice;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class FaktraController {
public class InvoiceController {

@Autowired
private FakturaSerwis fakturaSerwis;
private InvoiceService invoiceService;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.interview.exercise.entities.invoice;


import org.springframework.stereotype.Component;

@Component
public class InvoiceService {
}
18 changes: 18 additions & 0 deletions src/main/java/com/interview/exercise/entities/pack/Package.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.interview.exercise.entities.pack;

import com.interview.exercise.entities.user.User;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToMany;

@Entity
public class Package {

@Id
private int id;

@ManyToMany
private User packageUserToDeliveryFrom;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.interview.exercise.entities.pack;

import com.interview.exercise.entities.user.User;
import com.interview.exercise.entities.user.UserRepository;
import com.interview.exercise.entities.user.UserDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/paczki")

public class PackageController {

@Autowired
UserRepository appUserRepository;


@GetMapping("/all")
public List<Package> getAllPackagesInSystem(List<UserDto> consideredUsers) {

int helper = 0;

List<User> allUsers = new ArrayList<User>();
List <String> userSurnames = new ArrayList<>();
for (UserDto myUser :consideredUsers) {

System.out.println(myUser.getName());

userSurnames.add( consideredUsers.get(helper).getSurname());

helper++;


allUsers = appUserRepository.findAllByLastName(userSurnames);
}

List<Package> paczki = new ArrayList<>();

for (User user: allUsers) {
List<Package> packages = user.getPackages();
paczki.addAll(packages);
}

return paczki;
}

}
43 changes: 43 additions & 0 deletions src/main/java/com/interview/exercise/entities/role/Role.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.interview.exercise.entities.role;

import com.fasterxml.jackson.annotation.JsonBackReference;
import com.interview.exercise.entities.user.User;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.OneToOne;

@Entity
@Data
public class Role implements RoleMapper {

@Id
@GeneratedValue
private Double id;
private String name;
private String surname;
public String roleType;
public String upperName;

@JsonBackReference
@OneToOne
public User user;


@Override
public Role roleDtoToRole(RoleDto roleDto) {
Role role = new Role();
role.setName(roleDto.getName());
role.setSurname(roleDto.getSurname());
role.setUser(new User().userDtoToUser(roleDto.getUser()));
return role;

}

@Override
public String nameToUpper(RoleDto roleDto) {
return RoleMapper.super.nameToUpper(roleDto);
}
}
Loading