| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
- declare (strict_types = 1);
- namespace app\model\api;
- use library\basic\BaseModel;
- use library\traits\JwtAuthModelTrait;
- use library\traits\ModelTrait;
- use think\Model;
- /**
- * @mixin \think\Model
- */
- class Sys extends Model
- {
- use ModelTrait;
- use JwtAuthModelTrait;
- /**
- * 保存数据
- * @param $save
- */
- public function saveSys($save) {
- $this->where('id',1)->save($save);
- }
- /**
- * 微信配置信息
- * @param type $data
- */
- public function saveWxConfig($data){
- $save=[
- "appid" => empty($data["appid"])?"":$data["appid"],
- "secret" => empty($data["secret"])?"":$data["secret"],
- "mchid" => empty($data["mchid"])?"":$data["mchid"],
- "apiv2key" => empty($data["apiv2key"])?"":$data["apiv2key"],
- "apiclient_key" => empty($data["apiclient_key"])?"":$data["apiclient_key"],
- "apiclient_cert" => empty($data["apiclient_cert"])?"":$data["apiclient_cert"],
- "notify_url" => empty($data["notify_url"])?"":$data["notify_url"],
- ];
- $this->where("id",1)->update(["wxconfig"=> serialize($save)]);
- }
- /**
- * 分享配置信息
- * @param type $data
- */
- public function saveShareConfig($data){
- $save=[
- "img" => empty($data["img"]) ?"":$data["img"],
- "title" => empty($data["title"])?"":$data["title"],
- "query" => empty($data["query"])?"":$data["query"],
- ];
- $this->where("id",1)->update(["shareconfig"=> serialize($save)]);
- }
- /**
- * 获取配置详情
- * @return type
- */
- public function getDataInfo($code=""){
- $sys = (new SysModel)->where("id", 1)->find();
- $data = $sys->toArray();
- //微信配置
- if(empty($data["wxconfig"])){
- $data["wxconfig"]=[
- "appid"=>"",
- "secret"=>"",
- "mchid"=>"",
- "apiv2key"=>"",
- "apiclient_key"=>"",
- "apiclient_cert"=>"",
- "notify_url"=>""
- ];
- }else{
- $data["wxconfig"] = unserialize($data["wxconfig"]);
- }
- //分享配置
- if(empty($data["shareconfig"])){
- $data["shareconfig"]=[
- "img"=>"",
- "title"=>"",
- "query"=>"",
- ];
- }else{
- $data["shareconfig"] = unserialize($data["wxconfig"]);
- }
- if($code=="weixin"){
- return $data["wxconfig"];
- }
- if($code=="share"){
- return $data["shareconfig"];
- }
- return $data;
- }
- }
|