185 lines
5.6 KiB
PHP
185 lines
5.6 KiB
PHP
<?php
|
||
namespace app\master\controller;
|
||
|
||
use think\Controller;
|
||
use think\Db;
|
||
|
||
/**
|
||
* @title 系统接口
|
||
* @description 系统相关操作
|
||
* @group 系统相关
|
||
*/
|
||
class Mysystem extends Controller {
|
||
//put your code here
|
||
protected $admin_obj = '';
|
||
protected $sys_obj = '';
|
||
protected $sys_abs_obj = '';
|
||
|
||
public function __construct(\think\Request $request = null) {
|
||
parent::__construct($request);
|
||
$this->admin_obj = Db::name('admin');
|
||
$this->sys_obj = Db::name('system');
|
||
$this->sys_abs_obj = Db::name('system_abstracting');
|
||
}
|
||
|
||
/**
|
||
* @title 获取系统基本信息
|
||
* @description 获取系统基本信息
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/getSysBase
|
||
* @method POST
|
||
*
|
||
* @return account:copyright
|
||
* @return phone:email
|
||
* @return realname:website
|
||
*/
|
||
public function getSysBase(){
|
||
$res = $this->sys_obj->where('system_id = 1')->find();
|
||
return json(['code'=>0,'msg'=>'success','data'=>$res]);
|
||
}
|
||
|
||
/**
|
||
* @title 编辑系统基本信息
|
||
* @description 编辑系统基本信息
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/editSysBase
|
||
* @method POST
|
||
*
|
||
*
|
||
* @param name:copyright type:string require:1
|
||
* @param name:email type:string require:1
|
||
* @param name:website type:string require:1
|
||
*
|
||
*/
|
||
public function editSysBase(){
|
||
$data = $this->request->post();
|
||
$this->sys_obj->where('system_id = 1')->update(['copyright'=>$data['copyright'],'email'=>$data['email'],'website'=>$data['website']]);
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}
|
||
|
||
/**
|
||
* @title 获取abs列表
|
||
* @description 获取abs列表
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/getAbsList
|
||
* @method POST
|
||
*
|
||
*
|
||
* @param name:pageIndex type:int require:1 desc:当前页码数
|
||
* @param name:pageSize type:int require:1 desc:单页数据条数
|
||
*
|
||
* @return count:总数据数
|
||
* @return abslist:数据@
|
||
* @abslist title:标题 url:地址 sort:权重 is_show:是否显示(1显示0不显示)
|
||
*
|
||
*/
|
||
public function getAbsList(){
|
||
$data = $this->request->post();
|
||
$limit_start = ($data['pageIndex'] - 1) * $data['pageSize'];
|
||
$res = $this->sys_abs_obj
|
||
->order('sort desc')
|
||
->limit($limit_start,$data['pageSize'])
|
||
->select();
|
||
$count = $this->sys_abs_obj->count();
|
||
return json(['code'=>0,'msg'=>'success','data'=>['count'=>$count,'abslist'=>$res]]);
|
||
}
|
||
|
||
/**
|
||
* @title 增加abs
|
||
* @description 增加abs
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/addAbs
|
||
* @method POST
|
||
*
|
||
*
|
||
* @param name:title type:int require:1 desc:标题
|
||
* @param name:url type:string require:1 desc:地址
|
||
* @param name:sort type:int require:1 default:0 desc:权重
|
||
* @param name:is_show type:int require:1 default:1 desc:是否显示(1yes0no)
|
||
*
|
||
*
|
||
*/
|
||
public function addAbs(){
|
||
$data = $this->request->post();
|
||
$add_data['title'] = $data['title'];
|
||
$add_data['url'] = $data['url'];
|
||
$add_data['sort'] = $data['sort']?$data['sort']:0;
|
||
$add_data['is_show'] = $data['is_show'];
|
||
$res = $this->sys_abs_obj->insert($add_data);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'system error!']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 获取abs详情
|
||
* @description 获取abs详情
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/getAbsDetail
|
||
* @method POST
|
||
*
|
||
*
|
||
* @param name:system_abstracting_id type:int require:1 desc:id主键
|
||
*
|
||
* @return system_abstracting_id:主键
|
||
* @return title:标题
|
||
* @return url:地址
|
||
* @return sort:权重
|
||
* @return is_show:是否显示(1显示2不显示)
|
||
*
|
||
*/
|
||
public function getAbsDetail(){
|
||
$data = $this->request->post();
|
||
$res = $this->sys_abs_obj->where('system_abstracting_id',$data['system_abstracting_id'])->find();
|
||
return json(['code'=>0,'msg'=>'success','data'=>$res]);
|
||
}
|
||
|
||
|
||
/**
|
||
* @title 更改abs详情
|
||
* @description 更改abs详情
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/editAbs
|
||
* @method POST
|
||
*
|
||
*
|
||
* @param name:system_abstracting_id type:int require:1 desc:id主键
|
||
* @param name:title type:int require:1 desc:标题
|
||
* @param name:url type:string require:1 desc:地址
|
||
* @param name:sort type:int require:1 default:0 desc:权重
|
||
*/
|
||
public function editAbs(){
|
||
$data = $this->request->post();
|
||
$res = $this->sys_abs_obj->update($data);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'system error!']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 更改abs显示状态
|
||
* @description 更改abs显示状态
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/changeShow
|
||
* @method POST
|
||
*
|
||
*
|
||
* @param name:system_abstracting_id type:int require:1 desc:id主键
|
||
* @param name:is_show type:int require:1 desc:id主键
|
||
*/
|
||
public function changeShow(){
|
||
$data = $this->request->post();
|
||
$res = $this->sys_abs_obj->where('system_abstracting_id',$data['system_abstracting_id'])->update(['is_show'=>$data['is_show']]);
|
||
if($res){
|
||
return json(['code'=>0,'msg'=>'success']);
|
||
}else{
|
||
return json(['code'=>1,'msg'=>'system error!']);
|
||
}
|
||
}
|
||
|
||
}
|