mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
add host to group to allow login-server making json-request to community-server in docker environment
This commit is contained in:
parent
419c7012e5
commit
bacc254638
@ -3,6 +3,7 @@ CREATE TABLE `groups` (
|
||||
`alias` varchar(190) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`url` varchar(255) NOT NULL,
|
||||
`host` varchar(255) DEFAULT "/",
|
||||
`home` varchar(255) DEFAULT "/",
|
||||
`description` text,
|
||||
PRIMARY KEY (`id`),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `home`, `description`) VALUES
|
||||
(2, 'docker', 'docker gradido group', 'localhost', '/', 'gradido test group for docker and stage2 with blockchain db');
|
||||
INSERT INTO `groups` (`id`, `alias`, `name`, `url`, `host`, `home`, `description`) VALUES
|
||||
(2, 'docker', 'docker gradido group', 'localhost', 'nginx', '/', 'gradido test group for docker and stage2 with blockchain db');
|
||||
|
||||
|
||||
|
||||
|
||||
@ -17,7 +17,7 @@ namespace controller {
|
||||
|
||||
Poco::AutoPtr<Group> Group::create(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description)
|
||||
{
|
||||
auto db = new model::table::Group(alias, name, url, home, description);
|
||||
auto db = new model::table::Group(alias, name, url,"", home, description);
|
||||
auto group = new Group(db);
|
||||
return Poco::AutoPtr<Group>(group);
|
||||
}
|
||||
@ -94,7 +94,11 @@ namespace controller {
|
||||
}
|
||||
}
|
||||
auto model = getModel();
|
||||
return JsonRequest(model->getUrl(), port);
|
||||
std::string request_url = model->getHost();
|
||||
if ("" == request_url) {
|
||||
request_url = model->getUrl();
|
||||
}
|
||||
return JsonRequest(request_url, port);
|
||||
}
|
||||
|
||||
std::string Group::getHost()
|
||||
|
||||
@ -8,15 +8,16 @@ namespace model {
|
||||
{
|
||||
}
|
||||
|
||||
Group::Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description)
|
||||
: mAlias(alias), mName(name), mUrl(url), mHome(home), mDescription(description)
|
||||
Group::Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& host, const std::string& home, const std::string& description)
|
||||
: mAlias(alias), mName(name), mUrl(url), mHost(host), mHome(home), mDescription(description)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Group::Group(GroupTuple tuple)
|
||||
: ModelBase(tuple.get<0>()),
|
||||
mAlias(tuple.get<1>()), mName(tuple.get<2>()), mUrl(tuple.get<3>()), mHome(tuple.get<4>()), mDescription(tuple.get<5>())
|
||||
mAlias(tuple.get<1>()), mName(tuple.get<2>()), mUrl(tuple.get<3>()),
|
||||
mHost(tuple.get<4>()), mHome(tuple.get<5>()), mDescription(tuple.get<6>())
|
||||
{
|
||||
|
||||
}
|
||||
@ -32,6 +33,7 @@ namespace model {
|
||||
ss << "Alias: " << mAlias << std::endl;
|
||||
ss << "Name: " << mName << std::endl;
|
||||
ss << "Url: " << mUrl << std::endl;
|
||||
ss << "Host: " << mHost << std::endl;
|
||||
ss << "Home: " << mHome << std::endl;
|
||||
ss << "Description:" << mDescription << std::endl;
|
||||
return ss.str();
|
||||
@ -41,9 +43,9 @@ namespace model {
|
||||
{
|
||||
Poco::Data::Statement select(session);
|
||||
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << getTableName()
|
||||
select << "SELECT id, alias, name, url, host, home, description FROM " << getTableName()
|
||||
<< " where " << fieldName << " = ?"
|
||||
, into(mID), into(mAlias), into(mName), into(mUrl), into(mHome), into(mDescription);
|
||||
, into(mID), into(mAlias), into(mName), into(mUrl), into(mHost), into(mHome), into(mDescription);
|
||||
|
||||
return select;
|
||||
}
|
||||
@ -52,7 +54,7 @@ namespace model {
|
||||
{
|
||||
Poco::Data::Statement select(session);
|
||||
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << getTableName();
|
||||
select << "SELECT id, alias, name, url, host, home, description FROM " << getTableName();
|
||||
|
||||
return select;
|
||||
}
|
||||
@ -61,7 +63,7 @@ namespace model {
|
||||
{
|
||||
Poco::Data::Statement select(session);
|
||||
// typedef Poco::Tuple<std::string, std::string, std::string, Poco::Nullable<Poco::Data::BLOB>, int> UserTuple;
|
||||
select << "SELECT id, alias, name, url, home, description FROM " << getTableName()
|
||||
select << "SELECT id, alias, name, url, host, home, description FROM " << getTableName()
|
||||
<< " where " << fieldName << " LIKE ?";
|
||||
|
||||
return select;
|
||||
@ -84,8 +86,8 @@ namespace model {
|
||||
Poco::ScopedLock<Poco::Mutex> _lock(mWorkMutex);
|
||||
|
||||
insert << "INSERT INTO " << getTableName()
|
||||
<< " (alias, name, url, home, description) VALUES(?,?,?,?,?)"
|
||||
, use(mAlias), use(mName), use(mUrl), use(mHome), use(mDescription);
|
||||
<< " (alias, name, url, host, home, description) VALUES(?,?,?,?,?,?)"
|
||||
, use(mAlias), use(mName), use(mUrl), use(mHost), use(mHome), use(mDescription);
|
||||
|
||||
return insert;
|
||||
}
|
||||
|
||||
@ -7,13 +7,13 @@
|
||||
namespace model {
|
||||
namespace table {
|
||||
|
||||
typedef Poco::Tuple<int, std::string, std::string, std::string, std::string, std::string> GroupTuple;
|
||||
typedef Poco::Tuple<int, std::string, std::string, std::string, std::string, std::string, std::string> GroupTuple;
|
||||
|
||||
class Group : public ModelBase
|
||||
{
|
||||
public:
|
||||
Group();
|
||||
Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& home, const std::string& description);
|
||||
Group(const std::string& alias, const std::string& name, const std::string& url, const std::string& host, const std::string& home, const std::string& description);
|
||||
Group(GroupTuple userTuple);
|
||||
~Group();
|
||||
|
||||
@ -25,11 +25,13 @@ namespace model {
|
||||
inline const std::string& getName() const { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mName; }
|
||||
inline const std::string& getDescription() const { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mDescription; }
|
||||
inline const std::string& getUrl() const { std::shared_lock<std::shared_mutex> _lock(mSharedMutex); return mUrl; }
|
||||
inline const std::string& getHost() const { SHARED_LOCK; return mHost; }
|
||||
inline const std::string& getHome() const { SHARED_LOCK; return mHome; }
|
||||
|
||||
inline void setName(const std::string& name) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mName = name; }
|
||||
inline void setDescription(const std::string& desc) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mDescription = desc; }
|
||||
inline void setUrl(const std::string& url) { std::unique_lock<std::shared_mutex> _lock(mSharedMutex); mUrl = url; }
|
||||
inline void setHost(const std::string& host) { UNIQUE_LOCK; mHost = host; }
|
||||
inline void setHome(const std::string& home) { UNIQUE_LOCK; mHome = home; }
|
||||
|
||||
protected:
|
||||
@ -42,6 +44,7 @@ namespace model {
|
||||
std::string mAlias;
|
||||
std::string mName;
|
||||
std::string mUrl;
|
||||
std::string mHost;
|
||||
std::string mHome;
|
||||
std::string mDescription;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user