no message

This commit is contained in:
hellcat 2025-07-18 19:27:04 +08:00
parent 1321df5a62
commit c70f29ad2d
2 changed files with 34 additions and 11 deletions

View File

@ -18,11 +18,12 @@ class Dog extends Mod\Base {
public $oModelSelf;
public $sPrimaryKey = "id";
public $iStrMaxLen = 50;
public $iStrMaxLen;
public $aStrField = [];
public $aInFormat = [];
public $aOutFormat = [];
public $sDogName;
private $aMsg = [];
public function __construct($oModelSelf = false)
{
@ -37,6 +38,14 @@ class Dog extends Mod\Base {
public function _setStrField($aStrField)
{
$this->iStrMaxLen = ModelDogOption::_hit($this->sDogName, "str_len_max");
if (!$this->iStrMaxLen) {
// throw new \Exception("需要设置dog的option的str_len_max");
$this->iStrMaxLen = 60;
$this->aMsg["警告882"] = "需要设置dog的option的str_len_max临时设为60。";
}
$this->aStrField = $aStrField;
}
@ -261,10 +270,9 @@ class Dog extends Mod\Base {
}
private function subStr($input) {
if (mb_strlen($input, 'UTF-8') > $this->iStrMaxLen) {
if (mb_strlen($input, 'UTF-8') > (int) $this->iStrMaxLen) {
return mb_substr($input, 0, $this->iStrMaxLen, 'UTF-8')."……";
return mb_substr($input, 0, (int) $this->iStrMaxLen, 'UTF-8')."……";
}
@ -383,7 +391,9 @@ class Dog extends Mod\Base {
}
if (!$iLimit) {
throw new \Exception("需要option里的dog_limit");
// throw new \Exception("需要option里的dog_limit");
$iLimit = 30;
$this->aMsg["警告881"] = "需要option里的dog_limit临时设为30。";
}
return $iLimit;
@ -454,28 +464,41 @@ class Dog extends Mod\Base {
if ($iPageTotal > 1) {
if ($iPage) {
$aMsg[""]["页当前"] = $iPage;
$this->aMsg[""]["页当前"] = $iPage;
}
if ($iPageTotal) {
$aMsg[""]["页总数"] = $iPageTotal;
$this->aMsg[""]["页总数"] = $iPageTotal;
}
if ($iPagePer) {
$aMsg[""]["行每页"] = $iPagePer;
$this->aMsg[""]["行每页"] = $iPagePer;
}
if ($iCount) {
$aMsg[""]["行总数"] = $iCount;
$this->aMsg[""]["行总数"] = $iCount;
}
}
$aData = $this->filterDataList($aData);
$aData = $this->dataInsterMsgList($aData, $aMsg);
// $aData = $this->dataInsterMsgList($aData);
return $aData;
}
public function toJson($aData)
{
if ($this->aMsg && !is_string($aData)) {
if (is_object($aData)) {
$aData = $aData->toArray();
}
array_unshift($aData, $this->aMsg);
}
return parent::toJson($aData);
}
private function dataInsterMsgList($aData, $aMsg)
{
if ($aMsg) {

View File

@ -14,9 +14,9 @@ class Blade extends Base {
{
$this->oDog = new Dog(new ModelBlade());
$this->oDog->_setDogName("blade"); // 必须me用正常就是类名只不过后期没准改名所以就这里写死
$this->oDog->_setPrimaryKey("code"); // 可选默认id
$this->oDog->_setStrField(["content"]); // 可选,指定长文本字段
$this->oDog->_setDogName("blade"); // 必须me用正常就是类名只不过后期没准改名所以就这里写死
}