-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
170 additions
and
29 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright(C) 2021 hikyuu.org | ||
* | ||
* Create on: 2021-04-12 | ||
* Author: fasiondog | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <string> | ||
#include <boost/uuid/uuid.hpp> | ||
#include <boost/uuid/uuid_generators.hpp> | ||
#include <boost/uuid/uuid_io.hpp> | ||
|
||
namespace hku { | ||
|
||
inline std::string UUID() { | ||
static auto rgen = boost::uuids::random_generator(); | ||
return boost::uuids::to_string(rgen()); | ||
} | ||
|
||
} // namespace hku |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright(C) 2021 hikyuu.org | ||
* | ||
* Create on: 2021-04-13 | ||
* Author: fasiondog | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace hku { | ||
|
||
enum TradeErrorCode { TD_ACCOUNT_REPETITION = 20000 }; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ | |
#pragma once | ||
|
||
#include "http/HttpHandle.h" | ||
#include "RestErrorCode.h" | ||
|
||
namespace hku { | ||
|
||
|
43 changes: 43 additions & 0 deletions
43
hikyuu_cpp/hikyuu_server/service/trade/TradeAccountHandle.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright(C) 2021 hikyuu.org | ||
* | ||
* Create on: 2021-04-12 | ||
* Author: fasiondog | ||
*/ | ||
|
||
#include "common/uuid.h" | ||
#include "TradeAccountHandle.h" | ||
#include "TradeService.h" | ||
|
||
namespace hku { | ||
|
||
void AddTradeAccountHandle::run() { | ||
json req = getReqJson(); | ||
HTTP_VALID_CHECK(req.contains("name"), HttpErrorCode::MISS_PARAMETER, | ||
R"(Missing param "name")"); | ||
HTTP_VALID_CHECK(req.contains("type"), HttpErrorCode::MISS_PARAMETER, | ||
R"(Missing param "type")"); | ||
TradeAccountModel account; | ||
std::string name = req["name"].get<std::string>(); | ||
account.setName(name); | ||
account.setType(req["type"].get<std::string>()); | ||
account.setAccount(UUID()); | ||
auto con = TradeService::getDBConnect(); | ||
{ | ||
TransAction trans(con); | ||
HTTP_VALID_CHECK(!TradeAccountModel::isExistName(con, name), | ||
TradeErrorCode::TD_ACCOUNT_REPETITION, "Name repetition"); | ||
con->save(account, false); | ||
} | ||
json res; | ||
to_json(res, account); | ||
setResData(res); | ||
} | ||
|
||
void GetTradeAccountHandle::run() {} | ||
|
||
void ModTradeAccountHandle::run() {} | ||
|
||
void DelTradeAccountHandle::run() {} | ||
|
||
} // namespace hku |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.