PackagerEntity, -Repository and -Controller
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng.customer;
|
||||
package net.hostsharing.hsadminng.hscustomer;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng.customer;
|
||||
package net.hostsharing.hsadminng.hscustomer;
|
||||
|
||||
import lombok.Getter;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.hostsharing.hsadminng.customer;
|
||||
package net.hostsharing.hsadminng.hscustomer;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
@ -0,0 +1,37 @@
|
||||
package net.hostsharing.hsadminng.hspackage;
|
||||
|
||||
import net.hostsharing.hsadminng.context.Context;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import javax.transaction.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
@Controller
|
||||
public class PackageController {
|
||||
|
||||
@Autowired
|
||||
private Context context;
|
||||
|
||||
@Autowired
|
||||
private PackageRepository packageRepository;
|
||||
|
||||
@ResponseBody
|
||||
@RequestMapping(value = "/api/package", method = RequestMethod.GET)
|
||||
@Transactional
|
||||
public List<PackageEntity> listPackages(
|
||||
@RequestHeader(value = "current-user") String userName,
|
||||
@RequestHeader(value = "assumed-roles", required = false) String assumedRoles
|
||||
) {
|
||||
context.setCurrentUser(userName);
|
||||
if (assumedRoles != null && !assumedRoles.isBlank()) {
|
||||
context.assumeRoles(assumedRoles);
|
||||
}
|
||||
return packageRepository.findAll();
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package net.hostsharing.hsadminng.hspackage;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.hostsharing.hsadminng.hscustomer.CustomerEntity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Table(name = "package_rv")
|
||||
@Getter
|
||||
public class PackageEntity {
|
||||
|
||||
private @Id UUID uuid;
|
||||
|
||||
private String name;
|
||||
|
||||
@ManyToOne(optional = false)
|
||||
@JoinColumn(name = "customeruuid")
|
||||
private CustomerEntity customer;
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package net.hostsharing.hsadminng.hspackage;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface PackageRepository extends JpaRepository<PackageEntity, UUID> {
|
||||
|
||||
}
|
Reference in New Issue
Block a user