Skip to content

Commit

Permalink
Merge pull request #32 from thde/stuff
Browse files Browse the repository at this point in the history
Stuff
  • Loading branch information
lroellin authored Apr 11, 2017
2 parents 4887c69 + bcf5122 commit e5e74dc
Show file tree
Hide file tree
Showing 9 changed files with 349 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ SET client_min_messages = ERROR;
-- valid values are: 'UTF8', 'LATIN1', 'WIN1252'
\encoding 'UTF8'

\ir drop_tables.sql
-- create tables
\ir tables.sql
\ir create_tables.sql

-- constraints and indexes

Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CREATE TYPE TRANSACTIONTYPE AS ENUM (
'compensation'
);

CREATE TABLE IF NOT EXISTS "group" (
CREATE TABLE "group" (
"id" VARCHAR(50),
"name" VARCHAR(50) NOT NULL,
"currency" VARCHAR(50) NOT NULL,
Expand All @@ -17,7 +17,7 @@ CREATE TABLE IF NOT EXISTS "group" (
PRIMARY KEY ("id")
);

CREATE TABLE IF NOT EXISTS "person" (
CREATE TABLE "person" (
"id" SERIAL,
"name" VARCHAR(50) NOT NULL,
"group" VARCHAR(50) REFERENCES "group" ON DELETE CASCADE,
Expand All @@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS "person" (
PRIMARY KEY ("id")
);

CREATE TABLE IF NOT EXISTS "transaction" (
CREATE TABLE "transaction" (
"id" SERIAL,
"title" VARCHAR(50) NOT NULL,
"amount" INTEGER NOT NULL,
Expand All @@ -37,7 +37,7 @@ CREATE TABLE IF NOT EXISTS "transaction" (
PRIMARY KEY ("id")
);

CREATE TABLE IF NOT EXISTS "profiteer" (
CREATE TABLE "profiteer" (
"person" INTEGER REFERENCES "person" ON DELETE CASCADE,
"transaction" INTEGER REFERENCES "transaction",
"factor" DECIMAL(5) NOT NULL,
Expand Down
8 changes: 8 additions & 0 deletions src/dist/sql/drop_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-- Order is important
DROP TABLE "profiteer";
DROP TABLE "transaction";
DROP TABLE "person";
DROP TABLE "group";

DROP TYPE CURRENCY;
DROP TYPE TRANSACTIONTYPE;
7 changes: 7 additions & 0 deletions src/dist/sql/setup-tables.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -e
set -x

cd "$(dirname "$0")"

psql -U tylr -f 10_runEverytime.sql
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
package io.teiler.server.persistence.repositories;

import java.util.List;

import javax.persistence.EntityManager;
import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.querydsl.jpa.impl.JPAQuery;

import io.teiler.server.dto.Person;
import io.teiler.server.persistence.entities.GroupEntity;
import io.teiler.server.persistence.entities.PersonEntity;
import io.teiler.server.persistence.entities.QPersonEntity;
import java.util.List;
import javax.persistence.EntityManager;
import javax.transaction.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

/**
* Provides database-related operations for Groups.
Expand Down Expand Up @@ -71,6 +67,7 @@ public List<PersonEntity> getPeople(String groupId, long limit) {
return new JPAQuery<PersonEntity>(entityManager).from(QPersonEntity.personEntity)
.where(QPersonEntity.personEntity.groupId.eq(groupId))
.limit(limit)
.orderBy(QPersonEntity.personEntity.id.asc())
.fetch();
}

Expand Down
33 changes: 0 additions & 33 deletions src/main/java/io/teiler/server/util/AuthorizationChecker.java

This file was deleted.

Loading

0 comments on commit e5e74dc

Please sign in to comment.