no message
This commit is contained in:
parent
de4e5f1e89
commit
4e2b123106
@ -26,6 +26,7 @@ class Dog extends Mod\Base {
|
|||||||
private $aMsg = [];
|
private $aMsg = [];
|
||||||
public $aSelectField = [];
|
public $aSelectField = [];
|
||||||
public $aHideField = [];
|
public $aHideField = [];
|
||||||
|
public $aJsonField = [];
|
||||||
|
|
||||||
public function __construct($oModelSelf = false)
|
public function __construct($oModelSelf = false)
|
||||||
{
|
{
|
||||||
@ -52,6 +53,11 @@ class Dog extends Mod\Base {
|
|||||||
$this->iStrMaxLen = $iStrMaxLen;
|
$this->iStrMaxLen = $iStrMaxLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function _setJsonField($aJsonField)
|
||||||
|
{
|
||||||
|
$this->aJsonField = $aJsonField;
|
||||||
|
}
|
||||||
|
|
||||||
// 隐藏某些字段[id,name]
|
// 隐藏某些字段[id,name]
|
||||||
public function _setHideField($aHideField = [])
|
public function _setHideField($aHideField = [])
|
||||||
{
|
{
|
||||||
@ -70,7 +76,6 @@ class Dog extends Mod\Base {
|
|||||||
$this->iStrMaxLen = ModelDogOption::_hit($this->sDogName, "str_len_max");
|
$this->iStrMaxLen = ModelDogOption::_hit($this->sDogName, "str_len_max");
|
||||||
|
|
||||||
if (!$this->iStrMaxLen) {
|
if (!$this->iStrMaxLen) {
|
||||||
// throw new \Exception("需要设置dog的option的str_len_max");
|
|
||||||
$this->iStrMaxLen = 60;
|
$this->iStrMaxLen = 60;
|
||||||
$this->aMsg["警告882"] = "需要设置dog的option的str_len_max,临时设为60。";
|
$this->aMsg["警告882"] = "需要设置dog的option的str_len_max,临时设为60。";
|
||||||
}
|
}
|
||||||
@ -205,14 +210,14 @@ class Dog extends Mod\Base {
|
|||||||
//// option 系列 end
|
//// option 系列 end
|
||||||
|
|
||||||
//// 辅助系列
|
//// 辅助系列
|
||||||
private function filterList($oSelfList)
|
// private function filterList($oSelfList)
|
||||||
{
|
// {
|
||||||
foreach ($oSelfList as &$oSelfListRow) {
|
// foreach ($oSelfList as &$oSelfListRow) {
|
||||||
$oSelfListRow = $this->filterRow($oSelfListRow);
|
// $oSelfListRow = $this->filterRow($oSelfListRow);
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return $oSelfList;
|
// return $oSelfList;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private function meToStr_list($oMe)
|
private function meToStr_list($oMe)
|
||||||
{
|
{
|
||||||
@ -277,15 +282,19 @@ class Dog extends Mod\Base {
|
|||||||
}
|
}
|
||||||
//// me系列 end
|
//// me系列 end
|
||||||
|
|
||||||
private function filterRow($oSelfRow)
|
// private function filterRow($oSelfRow)
|
||||||
{
|
// {
|
||||||
|
//
|
||||||
foreach ($this->aStrField as $v) {
|
// foreach ($this->aStrField as $v) {
|
||||||
$oSelfRow->{$v} = $this->subStr($oSelfRow->{$v});
|
// $oSelfRow->{$v} = $this->subStr($oSelfRow->{$v});
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
return $oSelfRow;
|
// foreach ($this->aJsonField as $v) {
|
||||||
}
|
// $oSelfRow->{$v} = json_decode($oSelfRow->{$v});
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return $oSelfRow;
|
||||||
|
// }
|
||||||
|
|
||||||
private function subStr($input) {
|
private function subStr($input) {
|
||||||
|
|
||||||
@ -435,7 +444,7 @@ class Dog extends Mod\Base {
|
|||||||
public function find($aParam)
|
public function find($aParam)
|
||||||
{
|
{
|
||||||
$sField = $aParam["aOption"][1] ?? $this->sPrimaryKey;
|
$sField = $aParam["aOption"][1] ?? $this->sPrimaryKey;
|
||||||
$sValue = $aParam["aArg"][1] ?? false;
|
$sValue = $aParam["aArg"][1] ?? "_all";
|
||||||
$iPage = $aParam["aOption"][2] ?? 1;
|
$iPage = $aParam["aOption"][2] ?? 1;
|
||||||
$isLike = $aParam["is_like"] ?? false;
|
$isLike = $aParam["is_like"] ?? false;
|
||||||
$sHitField = $aParam["sHitField"] ?? false;
|
$sHitField = $aParam["sHitField"] ?? false;
|
||||||
@ -467,11 +476,19 @@ class Dog extends Mod\Base {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// hit必然单体
|
// hit必然单体
|
||||||
if ($sHitField) {
|
// if ($sHitField) {
|
||||||
return $oSelf->items()[0]->$sHitField;
|
// return $oSelf->items()[0]->$sHitField;
|
||||||
}
|
// }
|
||||||
|
|
||||||
$aData = $this->toDataList($oSelf);
|
$aData = $this->toDataList($oSelf);
|
||||||
|
|
||||||
|
if ($sHitField) {
|
||||||
|
if (in_array($sHitField, $this->aStrField)) {
|
||||||
|
$aData = $oSelf->items()[0]->$sHitField;
|
||||||
|
} else {
|
||||||
|
$aData = $aData[0][$sHitField];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $this->toJson($aData);
|
return $this->toJson($aData);
|
||||||
}
|
}
|
||||||
@ -596,6 +613,10 @@ class Dog extends Mod\Base {
|
|||||||
foreach ($this->aStrField as $sStrField) {
|
foreach ($this->aStrField as $sStrField) {
|
||||||
$aData[$sStrField] = $this->subStr($aData[$sStrField]);
|
$aData[$sStrField] = $this->subStr($aData[$sStrField]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->aJsonField as $sJsonField) {
|
||||||
|
$aData[$sJsonField] = json_decode($aData[$sJsonField]);
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->aOutFormat as $sFormatField => $sFormatType) {
|
foreach ($this->aOutFormat as $sFormatField => $sFormatType) {
|
||||||
if ($sFormatType == "date") {
|
if ($sFormatType == "date") {
|
||||||
@ -627,7 +648,81 @@ class Dog extends Mod\Base {
|
|||||||
return $this->set($aParam);
|
return $this->set($aParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonAdd($aParam)
|
public function arrUnset($aParam)
|
||||||
|
{
|
||||||
|
$aParam["sCmd"] = "unset";
|
||||||
|
return $this->arrSet($aParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function arrSet($aParam)
|
||||||
|
{
|
||||||
|
$sWhereValue = $aParam["aOption"][1] ?? '';
|
||||||
|
$sUpdField = $aParam["aOption"][2] ?? '';
|
||||||
|
$sUpdKey = $aParam["aOption"][3] ?? '';
|
||||||
|
$sUpdValue = $aParam["aArg"][1] ?? '';
|
||||||
|
$sCmd = $aParam["sCmd"] ?? 'set';
|
||||||
|
|
||||||
|
if ($sUpdValue == "?") {
|
||||||
|
return "#arrSet__[sWhereValue]__[sUpdField]__[?sUpdKey] [?sUpdValue]";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$sWhereValue) {
|
||||||
|
return "需要whereValue";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$sUpdField) {
|
||||||
|
return "需要sWhereValue";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$sUpdKey) {
|
||||||
|
// return "需要sUpdKey";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$sUpdValue) {
|
||||||
|
if ($sCmd == "set") {
|
||||||
|
return "需要sUpdValue";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$oModelSelf = $this->oModelSelf->where($this->sPrimaryKey, $sWhereValue)->first();
|
||||||
|
|
||||||
|
if (!$oModelSelf) {
|
||||||
|
return "没找到";
|
||||||
|
}
|
||||||
|
|
||||||
|
$sArr = $oModelSelf->$sUpdField ?? "[]";
|
||||||
|
$aArr = json_decode($sArr, true);
|
||||||
|
$aArrNew = $aArr;
|
||||||
|
|
||||||
|
if ($sCmd == "set") {
|
||||||
|
if ($sUpdKey) {
|
||||||
|
$aArrNew[$sUpdKey] = $sUpdValue;
|
||||||
|
} else {
|
||||||
|
$aArrNew[] = $sUpdValue;
|
||||||
|
}
|
||||||
|
} else if ($sCmd == "unset") {
|
||||||
|
if (!$sUpdKey) {
|
||||||
|
return "需要sUpdKey";
|
||||||
|
}
|
||||||
|
if (isset($aArrNew[$sUpdKey])) {
|
||||||
|
unset($aArrNew[$sUpdKey]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sArrNew = json_encode($aArrNew);
|
||||||
|
$oModelSelf->$sUpdField = $sArrNew ?? "[]";
|
||||||
|
$r = $oModelSelf->save();
|
||||||
|
|
||||||
|
if (!$r) {
|
||||||
|
return "save失败?";
|
||||||
|
}
|
||||||
|
|
||||||
|
$a = json_decode($oModelSelf->$sUpdField);
|
||||||
|
|
||||||
|
return $this->toJson($a);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function schemaAdd($aParam)
|
||||||
{
|
{
|
||||||
if (($aParam["aArg"][1] ?? false) == "?") {
|
if (($aParam["aArg"][1] ?? false) == "?") {
|
||||||
return "#jsonAdd {json}";
|
return "#jsonAdd {json}";
|
||||||
@ -654,7 +749,7 @@ class Dog extends Mod\Base {
|
|||||||
return $this->find($aParam);
|
return $this->find($aParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonSet($aParam)
|
public function schemaSet($aParam)
|
||||||
{
|
{
|
||||||
$sWhereValue = $aParam["aOption"][1] ?? false;
|
$sWhereValue = $aParam["aOption"][1] ?? false;
|
||||||
$aJson = $aParam["aArg"] ?? false;
|
$aJson = $aParam["aArg"] ?? false;
|
||||||
@ -682,7 +777,7 @@ class Dog extends Mod\Base {
|
|||||||
|
|
||||||
foreach ($aJson as $k => $v) {
|
foreach ($aJson as $k => $v) {
|
||||||
$v = $this->inFormat($k, $v);
|
$v = $this->inFormat($k, $v);
|
||||||
$oModelSelf->$k = $v;
|
$oModelSelf->$k = $v;
|
||||||
}
|
}
|
||||||
|
|
||||||
$oModelSelf->save();
|
$oModelSelf->save();
|
||||||
@ -693,7 +788,7 @@ class Dog extends Mod\Base {
|
|||||||
return $this->find($aParam);
|
return $this->find($aParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function jsonGet($aParam)
|
public function schemaGet($aParam)
|
||||||
{
|
{
|
||||||
$sWhereValue = $aParam["aArg"][1] ?? false;
|
$sWhereValue = $aParam["aArg"][1] ?? false;
|
||||||
$sWhereField = $aParam["aOption"][1] ?? $this->sPrimaryKey;
|
$sWhereField = $aParam["aOption"][1] ?? $this->sPrimaryKey;
|
||||||
|
|||||||
@ -16,9 +16,12 @@ class Node extends Base {
|
|||||||
$this->oDog->_setDogName("node"); // 必须,me用,正常就是类名,只不过后期没准改名,所以就这里写死
|
$this->oDog->_setDogName("node"); // 必须,me用,正常就是类名,只不过后期没准改名,所以就这里写死
|
||||||
// $this->oDog->_setPrimaryKey("code"); // 可选,默认id
|
// $this->oDog->_setPrimaryKey("code"); // 可选,默认id
|
||||||
// $this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
|
// $this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
|
||||||
|
$this->oDog->_setJsonField(["custom_config", "dynamic_rate_config"]);
|
||||||
|
$this->oDog->_setHideFile(["gfw_block", "dynamic_rate_type", "dynamic_rate_config", "password", "online_user_date_last"]);
|
||||||
$this->oDog->_setOutFormat([
|
$this->oDog->_setOutFormat([
|
||||||
// "create_time" => "date",
|
"node_heartbeat" => "date",
|
||||||
// "update_time" => "date",
|
"node_bandwidth_limit" => "gb",
|
||||||
|
"node_bandwidth" => "node_bandwidth"
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user