479 lines
15 KiB
PHP
479 lines
15 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 = '';
|
||
protected $sys_scient_obj = '';
|
||
protected $sys_book_obj = '';
|
||
protected $sys_not_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');
|
||
$this->sys_scient_obj = Db::name('system_scient');
|
||
$this->sys_book_obj = Db::name('system_books');
|
||
$this->sys_not_obj = Db::name('system_notices');
|
||
}
|
||
|
||
/**
|
||
* @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!']);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 图片上传
|
||
* @description 图片上传
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/up_file
|
||
* @method POST
|
||
*
|
||
* @param name:name type:string require:1 default:system desc:文件域名称
|
||
*
|
||
* @return upurl:图片地址
|
||
*/
|
||
public function up_file() {
|
||
$file = request()->file('system');
|
||
if ($file) {
|
||
$info = $file->move(ROOT_PATH . 'public' . DS . 'system');
|
||
if ($info) {
|
||
return json(['code'=>0 , 'msg'=>'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||
}
|
||
}
|
||
}
|
||
|
||
/**
|
||
* @title 增加scient
|
||
* @description 增加scient
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/addScient
|
||
* @method POST
|
||
*
|
||
* @param name:name type:string require:1 desc:名字
|
||
* @param name:intro type:string require:1 desc:简介
|
||
* @param name:icon type:string require:1 desc:头像
|
||
*/
|
||
public function addScient(){
|
||
$data = $this->request->post();
|
||
$insert['name'] = $data['name'];
|
||
$insert['intro'] = $data['intro'];
|
||
$insert['icon'] = $data['icon'];
|
||
$this->sys_scient_obj->insert($insert);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 删除scient
|
||
* @description 删除scient
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/delScient
|
||
* @method POST
|
||
*
|
||
* @param name:system_scient_id type:int require:1 desc:主键id
|
||
*/
|
||
public function delScient(){
|
||
$data = $this->request->post();
|
||
$this->sys_scient_obj->where('system_scient_id',$data['system_scient_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 编辑scient
|
||
* @description 编辑scient
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/editScient
|
||
* @method POST
|
||
*
|
||
* @param name:system_scient_id type:int require:1 desc:主键id
|
||
* @param name:name type:string require:1 desc:名字
|
||
* @param name:intro type:string require:1 desc:简介
|
||
* @param name:icon type:string require:1 desc:头像
|
||
*/
|
||
public function editScient(){
|
||
$data = $this->request->post();
|
||
$update['name'] = $data['name'];
|
||
$update['intro'] = $data['intro'];
|
||
$update['icon'] = $data['icon'];
|
||
$this->sys_scient_obj->where('system_scient_id',$data['system_scient_id'])->update($update);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 获取scient
|
||
* @description 获取scient
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/getScient
|
||
* @method POST
|
||
*
|
||
* @return scients:array#
|
||
*/
|
||
public function getScient(){
|
||
$list = $this->sys_scient_obj->where('state',0)->select();
|
||
|
||
$re['scients'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title 增加book
|
||
* @description 增加book
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/addBook
|
||
* @method POST
|
||
*
|
||
* @param name:title type:string require:1 desc:标题
|
||
* @param name:language type:string require:1 desc:语言
|
||
* @param name:author type:string require:1 desc:作者
|
||
* @param name:isbn type:string require:1
|
||
* @param name:price type:string require:1
|
||
* @param name:pdf type:string require:1 desc:pdf地址
|
||
* @param name:phone type:string require:1
|
||
* @param name:icon type:string require:1 desc:书皮图片
|
||
* @param name:sale_icon type:string require:1 desc:销售二维码
|
||
* @param name:sale_url type:string require:1 desc:销售链接
|
||
*
|
||
*/
|
||
public function addBook(){
|
||
$data = $this->request->post();
|
||
$insert['title'] = $data['title'];
|
||
$insert['language'] = $data['language'];
|
||
$insert['author'] = $data['author'];
|
||
$insert['isbn'] = $data['isbn'];
|
||
$insert['price'] = $data['price'];
|
||
$insert['pdf'] = $data['pdf'];
|
||
$insert['phone'] = $data['phone'];
|
||
$insert['icon'] = $data['icon'];
|
||
$insert['sale_icon'] = $data['sale_icon'];
|
||
$insert['sale_url'] = $data['sale_url'];
|
||
$this->sys_book_obj->insert($insert);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 删除book
|
||
* @description 删除book
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/delBook
|
||
* @method POST
|
||
*
|
||
* @param name:system_book_id type:int require:1 desc:主键
|
||
*
|
||
*/
|
||
public function delBook(){
|
||
$data = $this->request->post();
|
||
$this->sys_book_obj->where('system_book_id',$data['system_book_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 编辑book
|
||
* @description 编辑book
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/editBook
|
||
* @method POST
|
||
*
|
||
* $param name:system_book_id type:int require:1 desc:主键
|
||
* @param name:title type:string require:1 desc:标题
|
||
* @param name:language type:string require:1 desc:语言
|
||
* @param name:author type:string require:1 desc:作者
|
||
* @param name:isbn type:string require:1
|
||
* @param name:pdf type:string require:1 desc:pdf地址
|
||
* @param name:price type:string require:1
|
||
* @param name:phone type:string require:1
|
||
* @param name:icon type:string require:1 desc:书皮图片
|
||
* @param name:sale_icon type:string require:1 desc:销售二维码
|
||
* @param name:sale_url type:string require:1 desc:销售链接
|
||
*
|
||
*/
|
||
public function editBook(){
|
||
$data = $this->request->post();
|
||
$upload['title'] = $data['title'];
|
||
$upload['language'] = $data['language'];
|
||
$upload['author'] = $data['author'];
|
||
$upload['isbn'] = $data['isbn'];
|
||
$upload['pdf'] = $data['pdf'];
|
||
$upload['price'] = $data['price'];
|
||
$upload['phone'] = $data['phone'];
|
||
$upload['icon'] = $data['icon'];
|
||
$upload['sale_icon'] = $data['sale_icon'];
|
||
$upload['sale_url'] = $data['sale_url'];
|
||
$this->sys_book_obj->where('system_book_id',$data['system_book_id'])->update($upload);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 获取book
|
||
* @description 获取book
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/getBooks
|
||
* @method POST
|
||
*
|
||
* @return books:array#
|
||
*/
|
||
public function getBooks(){
|
||
$list = $this->sys_book_obj->where('state',0)->select();
|
||
$re['books'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title 增加出版集团消息
|
||
* @description 增加出版集团消息
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/addNotices
|
||
* @method POST
|
||
*
|
||
* @param name:title type:string require:1 desc:消息标题
|
||
* @param name:content type:string require:1 desc:内容
|
||
* @param name:ctime type:string require:1 desc:时间
|
||
*/
|
||
public function addNotices(){
|
||
$data = $this->request->post();
|
||
$insert['title'] = $data['title'];
|
||
$insert['content'] = $data['content'];
|
||
$insert['ctime'] = $data['ctime']==''?time():strtotime($data['ctime']);
|
||
$this->sys_not_obj->insert($insert);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 删除出版集团消息
|
||
* @description 删除出版集团消息
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/delNotices
|
||
* @method POST
|
||
*
|
||
* @param name:system_notices_id type:int require:1 desc:消息id
|
||
*/
|
||
public function delNotices(){
|
||
$data = $this->request->post();
|
||
$this->sys_not_obj->where('system_notices_id',$data['system_notices_id'])->update(['state'=>1]);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 编辑出版集团消息
|
||
* @description 编辑出版集团消息
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/editNotices
|
||
* @method POST
|
||
*
|
||
* @param name:system_notices_id type:int require:1 desc:消息标题
|
||
* @param name:title type:string require:1 desc:消息标题
|
||
* @param name:content type:string require:1 desc:内容
|
||
*/
|
||
public function editNotices(){
|
||
$data = $this->request->post();
|
||
$update['title'] = $data['title'];
|
||
$update['content'] = $data['content'];
|
||
$this->sys_not_obj->where('system_notices_id',$data['system_notices_id'])->update($update);
|
||
return jsonSuccess([]);
|
||
}
|
||
|
||
/**
|
||
* @title 获取出版集团消息
|
||
* @description 获取出版集团消息
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/getNotices
|
||
* @method POST
|
||
*
|
||
* @return notices:消息array#
|
||
*/
|
||
public function getNotices(){
|
||
$data = $this->request->post();
|
||
$list = $this->sys_not_obj->where('state',0)->select();
|
||
$re['notices'] = $list;
|
||
return jsonSuccess($re);
|
||
}
|
||
|
||
/**
|
||
* @title pdf上传
|
||
* @description pdf上传
|
||
* @author wangjinlei
|
||
* @url /master/Mysystem/up_pdf_file
|
||
* @method POST
|
||
*
|
||
* @param name:name type:string require:1 default:bookpdf desc:文件域名称
|
||
*
|
||
* @return upurl:图片地址
|
||
*/
|
||
public function up_pdf_file() {
|
||
$file = request()->file('bookpdf');
|
||
if ($file) {
|
||
$info = $file->move(ROOT_PATH . 'public' . DS . 'bookpdf');
|
||
if ($info) {
|
||
return json(['code'=>0 , 'msg'=>'success', 'upurl' => str_replace("\\", "/", $info->getSaveName())]);
|
||
} else {
|
||
return json(['code' => 1, 'msg' => $file->getError()]);
|
||
}
|
||
}
|
||
}
|
||
}
|