| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- namespace App\Models;
- use Illuminate\Database\Eloquent\Model;
- use Illuminate\Support\Facades\Redis;
- class SystemStatusInfo extends Model
- {
- protected $primaryKey = 'StatusName'; // Set the primary key
- protected $keyType='string';
- public $incrementing = false; // Disable auto-increment
- public $timestamps = false; // If the table does not have 'created_at' and 'updated_at' columns
- protected $table = 'QPAccountsDB.dbo.SystemStatusInfo'; // 数据表名
- protected $fillable = [
- 'StatusName', 'StatusValue', 'StatusString', 'StatusTip',
- 'StatusDescription'
- ]; // 可批量赋值的属性
- /**
- * @param $StatusName
- * @param $StatusValue
- * @return SystemStatusInfo
- */
- public static function CacheValue($StatusName,$StatusValue=false)
- {
- // $key="SystemStatusInfo_$StatusName";
- // if(Redis::exists($key)){
- // $data=json_decode(Redis::get($key));
- // if(!$data){
- // Redis::del($key);
- // }
- // }
- if(!isset($data)||empty($data)){
- $data = self::query()->where("StatusName", $StatusName)->first();
- // Redis::set($key, json_encode($data));
- // Redis::expire($key, 600);
- }
- if($StatusValue!==false){
- self::query()->where("StatusName", $StatusName)->update(compact("StatusValue"));
- // Redis::del($key);
- }
- return $data;
- }
- /**
- * @param $StatusName
- * @param $StatusValue
- * @return SystemStatusInfo
- */
- public static function OnlyGetCacheValue($StatusName)
- {
- $data=self::CacheValue($StatusName,false);
- return $data->StatusValue;
- }
- public static $KEY_WithDrawSwitch='WithDrawSwitch';
- }
|