Compare commits
No commits in common. "2c5368c621b8ee95c338e6fbe70c74bdfde3e2f3" and "7c40ea6f9795486b08dadcebfbe437fbd118015e" have entirely different histories.
2c5368c621
...
7c40ea6f97
9 changed files with 7 additions and 36 deletions
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
find_package(Boost 1.62 COMPONENTS date_time REQUIRED)
|
find_package(Boost 1.62 REQUIRED)
|
||||||
find_package(SQLite3 REQUIRED)
|
find_package(SQLite3 REQUIRED)
|
||||||
|
|
||||||
#set(CORE_HEADERS
|
#set(CORE_HEADERS
|
||||||
|
@ -13,9 +13,8 @@ set(CORE_SOURCES
|
||||||
entity.cpp
|
entity.cpp
|
||||||
seller.cpp
|
seller.cpp
|
||||||
article.cpp
|
article.cpp
|
||||||
sale.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(core STATIC ${CORE_SOURCES})
|
add_library(core STATIC ${CORE_SOURCES})
|
||||||
target_link_libraries(core Boost::boost Boost::date_time)
|
target_link_libraries(core Boost::boost)
|
||||||
target_link_libraries(core sqlite3)
|
target_link_libraries(core sqlite3)
|
|
@ -16,6 +16,4 @@ bool Article::isSold() { return salePtr_ ? true : false; }
|
||||||
|
|
||||||
std::string Article::getDescription() { return description_; }
|
std::string Article::getDescription() { return description_; }
|
||||||
|
|
||||||
Seller* Article::getSeller() { return sellerPtr_.get(); }
|
Seller* Article::getSeller() { return sellerPtr_.get(); }
|
||||||
|
|
||||||
int Article::getPrice() { return price_; }
|
|
|
@ -9,7 +9,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class Seller;
|
class Seller;
|
||||||
class Sale;
|
|
||||||
|
|
||||||
class Article : public Entity
|
class Article : public Entity
|
||||||
{
|
{
|
||||||
|
@ -25,7 +24,6 @@ class Article : public Entity
|
||||||
|
|
||||||
std::string getDescription();
|
std::string getDescription();
|
||||||
Seller* getSeller();
|
Seller* getSeller();
|
||||||
int getPrice();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<Seller> sellerPtr_{};
|
std::shared_ptr<Seller> sellerPtr_{};
|
||||||
|
|
|
@ -184,7 +184,7 @@ unsigned int Database::storeSellers(std::vector<Seller>& sellers)
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
throw std::runtime_error(errMsg);
|
throw std::runtime_error(errMsg);
|
||||||
}
|
}
|
||||||
seller.setState(Seller::State::OK);
|
seller.setState(Seller::State::CLEAN);
|
||||||
++count;
|
++count;
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class Entity
|
class Entity
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum class State { NEW, UPDATE, DELETE, OK };
|
enum class State { NEW, UPDATED, CLEAN };
|
||||||
|
|
||||||
virtual ~Entity() = 0;
|
virtual ~Entity() = 0;
|
||||||
const boost::uuids::uuid& getUuid() const { return uuid_; };
|
const boost::uuids::uuid& getUuid() const { return uuid_; };
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
#include "sale.h"
|
|
||||||
|
|
||||||
#include <numeric>
|
|
||||||
|
|
||||||
int Sale::sumInCents()
|
|
||||||
{
|
|
||||||
int test = std::accumulate(articles_.begin(), articles_.end(), 0,
|
|
||||||
[](int a, Article* b) { return a + b->getPrice(); });
|
|
||||||
return test;
|
|
||||||
}
|
|
|
@ -1,21 +1,8 @@
|
||||||
#ifndef SALE_H
|
#ifndef SALE_H
|
||||||
#define SALE_H
|
#define SALE_H
|
||||||
|
|
||||||
#include "article.h"
|
class Sale : public Entity {
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#include <boost/date_time.hpp>
|
|
||||||
|
|
||||||
class Article;
|
|
||||||
|
|
||||||
class Sale : public Entity
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
int sumInCents();
|
|
||||||
private:
|
|
||||||
boost::posix_time::ptime systemTime_{boost::posix_time::second_clock::local_time()};
|
|
||||||
std::vector<Article*> articles_{};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -51,6 +51,6 @@ BOOST_AUTO_TEST_CASE(seller_states)
|
||||||
std::cout << "Anzahl sellers: " << sellers.size() << "\n";
|
std::cout << "Anzahl sellers: " << sellers.size() << "\n";
|
||||||
BOOST_TEST((sellers.at(0).getState() == Entity::State::NEW));
|
BOOST_TEST((sellers.at(0).getState() == Entity::State::NEW));
|
||||||
BOOST_TEST(db.storeSellers(sellers) == 1);
|
BOOST_TEST(db.storeSellers(sellers) == 1);
|
||||||
BOOST_TEST((sellers.at(0).getState() == Entity::State::OK));
|
BOOST_TEST((sellers.at(0).getState() == Entity::State::CLEAN));
|
||||||
BOOST_TEST(db.storeSellers(sellers) == 0);
|
BOOST_TEST(db.storeSellers(sellers) == 0);
|
||||||
}
|
}
|
|
@ -35,5 +35,4 @@ BOOST_AUTO_TEST_CASE(with_article) {
|
||||||
article->setDescription("Test article");
|
article->setDescription("Test article");
|
||||||
seller.addArticle(article);
|
seller.addArticle(article);
|
||||||
BOOST_TEST(seller.getArticles().at(0)->getDescription() == "Test article");
|
BOOST_TEST(seller.getArticles().at(0)->getDescription() == "Test article");
|
||||||
BOOST_TEST(seller.soldArticles() == 0);
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue