init
This commit is contained in:
39
apps/admin/model/content/CompanyModel.php
Normal file
39
apps/admin/model/content/CompanyModel.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2017年3月24日
|
||||
* 公司信息模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class CompanyModel extends Model
|
||||
{
|
||||
|
||||
// 获取公司信息
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_company')->where("acode='" . session('acode') . "'")->find();
|
||||
}
|
||||
|
||||
// 检查公司信息
|
||||
public function checkCompany()
|
||||
{
|
||||
return parent::table('ay_company')->where("acode='" . session('acode') . "'")->find();
|
||||
}
|
||||
|
||||
// 增加公司信息
|
||||
public function addCompany($data)
|
||||
{
|
||||
return parent::table('ay_company')->insert($data);
|
||||
}
|
||||
|
||||
// 修改公司信息
|
||||
public function modCompany($data)
|
||||
{
|
||||
return parent::table('ay_company')->where("acode='" . session('acode') . "'")->update($data);
|
||||
}
|
||||
}
|
||||
332
apps/admin/model/content/ContentModel.php
Normal file
332
apps/admin/model/content/ContentModel.php
Normal file
@@ -0,0 +1,332 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2017年12月15日
|
||||
* 列表文章模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class ContentModel extends Model
|
||||
{
|
||||
|
||||
protected $scodes = array();
|
||||
|
||||
// 获取文章列表
|
||||
public function getList($mcode)
|
||||
{
|
||||
$field = array(
|
||||
'a.id',
|
||||
'b.name as sortname',
|
||||
'a.scode',
|
||||
'c.name as subsortname',
|
||||
'a.subscode',
|
||||
'a.title',
|
||||
'a.subtitle',
|
||||
'a.date',
|
||||
'a.sorting',
|
||||
'a.status',
|
||||
'a.istop',
|
||||
'a.isrecommend',
|
||||
'a.isheadline',
|
||||
'a.visits',
|
||||
'a.ico',
|
||||
'a.pics',
|
||||
'a.filename',
|
||||
'a.outlink',
|
||||
'd.urlname',
|
||||
'b.filename as sortfilename'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_content_sort c',
|
||||
'a.subscode=c.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model d',
|
||||
'b.mcode=d.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->field($field)
|
||||
->where("b.mcode='$mcode'")
|
||||
->where('d.type=2 OR d.type is null ')
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->order('a.sorting ASC,a.id DESC')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找指定分类及子类文章
|
||||
public function findContent($mcode, $scode, $keyword)
|
||||
{
|
||||
$fields = array(
|
||||
'a.id',
|
||||
'b.name as sortname',
|
||||
'a.scode',
|
||||
'c.name as subsortname',
|
||||
'a.subscode',
|
||||
'a.title',
|
||||
'a.subtitle',
|
||||
'a.date',
|
||||
'a.sorting',
|
||||
'a.status',
|
||||
'a.istop',
|
||||
'a.isrecommend',
|
||||
'a.isheadline',
|
||||
'a.visits',
|
||||
'a.ico',
|
||||
'a.pics',
|
||||
'a.filename',
|
||||
'a.outlink',
|
||||
'd.urlname',
|
||||
'b.filename as sortfilename'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_content_sort c',
|
||||
'a.subscode=c.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model d',
|
||||
'b.mcode=d.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
$this->scodes = array(); // 先清空
|
||||
$scodes = $this->getSubScodes($scode);
|
||||
return parent::table('ay_content a')->field($fields)
|
||||
->where("b.mcode='$mcode'")
|
||||
->where('d.type=2 OR d.type is null ')
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->in('a.scode', $scodes)
|
||||
->like('a.title', $keyword)
|
||||
->join($join)
|
||||
->order('a.sorting ASC,a.id DESC')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 在全部栏目查找文章
|
||||
public function findContentAll($mcode, $keyword)
|
||||
{
|
||||
$fields = array(
|
||||
'a.id',
|
||||
'b.name as sortname',
|
||||
'a.scode',
|
||||
'c.name as subsortname',
|
||||
'a.subscode',
|
||||
'a.title',
|
||||
'a.subtitle',
|
||||
'a.date',
|
||||
'a.sorting',
|
||||
'a.status',
|
||||
'a.istop',
|
||||
'a.isrecommend',
|
||||
'a.isheadline',
|
||||
'a.visits',
|
||||
'a.ico',
|
||||
'a.pics',
|
||||
'a.filename',
|
||||
'a.outlink',
|
||||
'd.urlname',
|
||||
'b.filename as sortfilename'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_content_sort c',
|
||||
'a.subscode=c.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model d',
|
||||
'b.mcode=d.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->field($fields)
|
||||
->where("b.mcode='$mcode'")
|
||||
->where('d.type=2 OR d.type is null ')
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->like('a.title', $keyword)
|
||||
->join($join)
|
||||
->order('a.sorting ASC,a.id DESC')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取子栏目
|
||||
public function getSubScodes($scode)
|
||||
{
|
||||
if (! $scode) {
|
||||
return;
|
||||
}
|
||||
$this->scodes[] = $scode;
|
||||
$subs = parent::table('ay_content_sort')->where("pcode='$scode'")->column('scode');
|
||||
if ($subs) {
|
||||
foreach ($subs as $value) {
|
||||
$this->getSubScodes($value);
|
||||
}
|
||||
}
|
||||
return $this->scodes;
|
||||
}
|
||||
|
||||
// 检查文章
|
||||
public function checkContent($where)
|
||||
{
|
||||
return parent::table('ay_content')->field('id')
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取文章详情
|
||||
public function getContent($id)
|
||||
{
|
||||
$field = array(
|
||||
'a.*',
|
||||
'b.name as sortname',
|
||||
'c.name as subsortname',
|
||||
'd.*'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_content_sort c',
|
||||
'a.subscode=c.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_content_ext d',
|
||||
'a.id=d.contentid',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->field($field)
|
||||
->where("a.id=$id")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 添加文章
|
||||
public function addContent(array $data)
|
||||
{
|
||||
return parent::table('ay_content')->autoTime()->insertGetId($data);
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
public function delContent($id)
|
||||
{
|
||||
return parent::table('ay_content')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
public function delContentList($ids)
|
||||
{
|
||||
return parent::table('ay_content')->where("acode='" . session('acode') . "'")->delete($ids);
|
||||
}
|
||||
|
||||
// 修改文章
|
||||
public function modContent($id, $data)
|
||||
{
|
||||
return parent::table('ay_content')->autoTime()
|
||||
->in('id', $id)
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 复制内容到指定栏目
|
||||
public function copyContent($ids, $scode)
|
||||
{
|
||||
// 查找出要复制的主内容
|
||||
$data = parent::table('ay_content')->in('id', $ids)->select(1);
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
// 查找扩展内容
|
||||
$extdata = parent::table('ay_content_ext')->where('contentid=' . $value['id'])->find(1);
|
||||
|
||||
// 去除主键并修改栏目
|
||||
unset($value['id']);
|
||||
$value['scode'] = $scode;
|
||||
|
||||
// 插入主内容
|
||||
$id = parent::table('ay_content')->insertGetId($value);
|
||||
|
||||
// 插入扩展内容
|
||||
if ($id && $extdata) {
|
||||
unset($extdata['extid']);
|
||||
$extdata['contentid'] = $id;
|
||||
$result = parent::table('ay_content_ext')->insert($extdata);
|
||||
} else {
|
||||
$result = $id;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 查找文章扩展内容
|
||||
public function findContentExt($id)
|
||||
{
|
||||
return parent::table('ay_content_ext')->where("contentid=$id")->find();
|
||||
}
|
||||
|
||||
// 添加文章扩展内容
|
||||
public function addContentExt(array $data)
|
||||
{
|
||||
return parent::table('ay_content_ext')->insert($data);
|
||||
}
|
||||
|
||||
// 修改文章扩展内容
|
||||
public function modContentExt($id, $data)
|
||||
{
|
||||
return parent::table('ay_content_ext')->where("contentid=$id")->update($data);
|
||||
}
|
||||
|
||||
// 删除文章扩展内容
|
||||
public function delContentExt($id)
|
||||
{
|
||||
return parent::table('ay_content_ext')->where("contentid=$id")->delete();
|
||||
}
|
||||
|
||||
// 删除文章扩展内容
|
||||
public function delContentExtList($ids)
|
||||
{
|
||||
return parent::table('ay_content_ext')->delete($ids, 'contentid');
|
||||
}
|
||||
|
||||
// 检查自定义URL名称
|
||||
public function checkFilename($filename, $where = array())
|
||||
{
|
||||
return parent::table('ay_content')->field('id')
|
||||
->where("filename='$filename'")
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
}
|
||||
261
apps/admin/model/content/ContentSortModel.php
Normal file
261
apps/admin/model/content/ContentSortModel.php
Normal file
@@ -0,0 +1,261 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2017年12月26日
|
||||
* 内容栏目模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class ContentSortModel extends Model
|
||||
{
|
||||
|
||||
// 存储分类及子编码
|
||||
protected $scodes = array();
|
||||
|
||||
// 获取内容栏目列表
|
||||
public function getList()
|
||||
{
|
||||
$field = array(
|
||||
'a.*',
|
||||
'b.type',
|
||||
'b.urlname'
|
||||
);
|
||||
$join = array(
|
||||
'ay_model b',
|
||||
'a.mcode=b.mcode',
|
||||
'LEFT'
|
||||
);
|
||||
$result = parent::table('ay_content_sort a')->field($field)
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->order('a.pcode,a.sorting,a.id')
|
||||
->select();
|
||||
$tree = get_tree($result, 0, 'scode', 'pcode');
|
||||
return $tree;
|
||||
}
|
||||
|
||||
// 获取内容栏目选择列表
|
||||
public function getSelect()
|
||||
{
|
||||
$result = parent::table('ay_content_sort')->field('pcode,scode,name')
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->order('pcode,sorting,id')
|
||||
->select();
|
||||
$tree = get_tree($result, 0, 'scode', 'pcode');
|
||||
return $tree;
|
||||
}
|
||||
|
||||
// 获取单页内容栏目选择列表
|
||||
public function getSingleSelect()
|
||||
{
|
||||
$field = array(
|
||||
'a.pcode',
|
||||
'a.scode',
|
||||
'a.name',
|
||||
'a.outlink'
|
||||
);
|
||||
$join = array(
|
||||
'ay_model b',
|
||||
'a.mcode=b.mcode',
|
||||
'LEFT'
|
||||
);
|
||||
$result = parent::table('ay_content_sort a')->field($field)
|
||||
->where('b.type=1')
|
||||
->where("a.outlink=''")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->notIn('a.scode', 'select scode from ay_content')
|
||||
->join($join)
|
||||
->order('a.pcode,a.sorting,a.id')
|
||||
->select();
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 获取列表内容栏目选择列表
|
||||
public function getListSelect($mcode)
|
||||
{
|
||||
$field = array(
|
||||
'a.pcode',
|
||||
'a.scode',
|
||||
'a.name',
|
||||
'a.outlink'
|
||||
);
|
||||
$join = array(
|
||||
'ay_model b',
|
||||
'a.mcode=b.mcode',
|
||||
'LEFT'
|
||||
);
|
||||
$result = parent::table('ay_content_sort a')->field($field)
|
||||
->where('b.type=2')
|
||||
->where("a.outlink=''")
|
||||
->where("a.mcode='$mcode'")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->order('a.pcode,a.sorting,a.id')
|
||||
->select();
|
||||
$tree = get_tree($result, 0, 'scode', 'pcode');
|
||||
// 对于父栏目非列表的栏目进行追加到后面
|
||||
foreach ($result as $value) {
|
||||
if ($value->pcode != 0 && result_value_search($value->pcode, $result, 'scode') === false) {
|
||||
$value->son = get_tree($result, $value->scode, 'scode', 'pcode');
|
||||
$tree[] = $value;
|
||||
}
|
||||
}
|
||||
return $tree;
|
||||
}
|
||||
|
||||
// 检查内容栏目
|
||||
public function checkSort($where)
|
||||
{
|
||||
return parent::table('ay_content_sort')->field('id')
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取内容栏目详情
|
||||
public function getSort($scode)
|
||||
{
|
||||
$field = array(
|
||||
'a.*',
|
||||
'b.type'
|
||||
);
|
||||
$join = array(
|
||||
'ay_model b',
|
||||
'a.mcode=b.mcode',
|
||||
'LEFT'
|
||||
);
|
||||
return parent::table('ay_content_sort a')->field($field)
|
||||
->where("a.scode='$scode'")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取最后一个code
|
||||
public function getLastCode()
|
||||
{
|
||||
return parent::table('ay_content_sort')->order('id DESC')->value('scode');
|
||||
}
|
||||
|
||||
// 添加内容栏目
|
||||
public function addSort(array $data)
|
||||
{
|
||||
return parent::table('ay_content_sort')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除内容栏目及内容
|
||||
public function delSort($scode)
|
||||
{
|
||||
$this->scodes = array(); // 先清空
|
||||
$scodes = $this->getSubScodes($scode); // 获取全部子类
|
||||
$this->delContent($scodes);
|
||||
return parent::table('ay_content_sort')->in('scode', $scodes)
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 批量删除栏目及内容
|
||||
public function delSortList($scodes)
|
||||
{
|
||||
$this->scodes = array(); // 先清空
|
||||
foreach ($scodes as $value) {
|
||||
$allscode = $this->getSubScodes($value); // 获取全部子类
|
||||
}
|
||||
$this->delContent($allscode);
|
||||
return parent::table('ay_content_sort')->in('scode', $allscode)
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改内容栏目资料
|
||||
public function modSort($scode, $data, $modsub = false)
|
||||
{
|
||||
if ($modsub) {
|
||||
// 同步修改子栏目模型及模板
|
||||
$scodes = $this->getSubScodes($scode);
|
||||
$subdata = array(
|
||||
'mcode' => $data['mcode'],
|
||||
'listtpl' => $data['listtpl'],
|
||||
'contenttpl' => $data['contenttpl']
|
||||
);
|
||||
parent::table('ay_content_sort')->in('scode', $scodes)
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($subdata);
|
||||
}
|
||||
$result = parent::table('ay_content_sort')->autoTime()
|
||||
->where("scode='$scode'")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 修改内容栏目排序
|
||||
public function modSortSorting($id, $data)
|
||||
{
|
||||
$result = parent::table('ay_content_sort')->autoTime()
|
||||
->where("id='$id'")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 查找指定单页内容
|
||||
public function findContent($scode)
|
||||
{
|
||||
return parent::table('ay_content')->where("scode='$scode'")->find();
|
||||
}
|
||||
|
||||
// 添加单篇文章
|
||||
public function addSingle(array $data)
|
||||
{
|
||||
return parent::table('ay_content')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除指定栏目文章
|
||||
public function delContent($scodes)
|
||||
{
|
||||
return parent::table('ay_content')->in('scode', $scodes)->delete();
|
||||
}
|
||||
|
||||
// 分类子类集
|
||||
private function getSubScodes($scode)
|
||||
{
|
||||
if (! $scode) {
|
||||
return;
|
||||
}
|
||||
$this->scodes[] = $scode;
|
||||
$subs = parent::table('ay_content_sort')->where("pcode='$scode'")->column('scode');
|
||||
if ($subs) {
|
||||
foreach ($subs as $value) {
|
||||
$this->getSubScodes($value);
|
||||
}
|
||||
}
|
||||
return $this->scodes;
|
||||
}
|
||||
|
||||
// 检查自定义URL名称
|
||||
public function checkFilename($filename, $where = array())
|
||||
{
|
||||
return parent::table('ay_content_sort')->field('id')
|
||||
->where("filename='$filename'")
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 检查URL名字冲突
|
||||
public function checkUrlname($filename)
|
||||
{
|
||||
return parent::table('ay_model')->field('id')
|
||||
->where("urlname='$filename'")
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取当前主题
|
||||
public function getTheme()
|
||||
{
|
||||
return parent::table('ay_site')->where("acode='" . session('acode') . "'")->value('theme');
|
||||
}
|
||||
}
|
||||
87
apps/admin/model/content/ExtFieldModel.php
Normal file
87
apps/admin/model/content/ExtFieldModel.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2018年4月7日
|
||||
* 扩展字段模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class ExtFieldModel extends Model
|
||||
{
|
||||
|
||||
// 获取扩展字段列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_extfield')->order('mcode asc,sorting asc,id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找扩展字段
|
||||
public function findExtField($field, $keyword)
|
||||
{
|
||||
return parent::table('ay_extfield')->like($field, $keyword)
|
||||
->order('mcode asc,sorting asc,id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 检查扩展字段
|
||||
public function checkExtField($name)
|
||||
{
|
||||
return parent::table('ay_extfield')->where("name='$name'")->find();
|
||||
}
|
||||
|
||||
// 获取模型字段
|
||||
public function getModelField($mcode)
|
||||
{
|
||||
return parent::table('ay_extfield')->where("mcode='$mcode'")
|
||||
->order('sorting asc,id asc')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取扩展字段详情
|
||||
public function getExtField($id)
|
||||
{
|
||||
return parent::table('ay_extfield')->where("id=$id")->find();
|
||||
}
|
||||
|
||||
// 获取扩展字段名称
|
||||
public function getExtFieldName($id)
|
||||
{
|
||||
return parent::table('ay_extfield')->where("id=$id")->value('name');
|
||||
}
|
||||
|
||||
// 添加扩展字段
|
||||
public function addExtField(array $data)
|
||||
{
|
||||
return parent::table('ay_extfield')->insert($data);
|
||||
}
|
||||
|
||||
// 删除扩展字段
|
||||
public function delExtField($id)
|
||||
{
|
||||
return parent::table('ay_extfield')->where("id=$id")->delete();
|
||||
}
|
||||
|
||||
// 修改扩展字段
|
||||
public function modExtField($id, $data)
|
||||
{
|
||||
return parent::table('ay_extfield')->where("id=$id")->update($data);
|
||||
}
|
||||
|
||||
// 判断字段是否存在
|
||||
public function isExistField($field)
|
||||
{
|
||||
$fields = parent::tableFields('ay_content_ext');
|
||||
if (in_array($field, $fields)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
238
apps/admin/model/content/FormModel.php
Normal file
238
apps/admin/model/content/FormModel.php
Normal file
@@ -0,0 +1,238 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2018年5月28日
|
||||
* 自定义表单模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class FormModel extends Model
|
||||
{
|
||||
|
||||
// 获取自定义表单列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_form')->page()->select();
|
||||
}
|
||||
|
||||
// 查找自定义表单
|
||||
public function findForm($field, $keyword)
|
||||
{
|
||||
return parent::table('ay_form')->like($field, $keyword)
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取最后一个code
|
||||
public function getLastCode()
|
||||
{
|
||||
return parent::table('ay_form')->order('id DESC')->value('fcode');
|
||||
}
|
||||
|
||||
// 获取自定义表单详情
|
||||
public function getForm($id)
|
||||
{
|
||||
return parent::table('ay_form')->where("id=$id")->find();
|
||||
}
|
||||
|
||||
// 获取自定义表单详情
|
||||
public function getFormByCode($fcode)
|
||||
{
|
||||
return parent::table('ay_form')->where("fcode='$fcode'")->find();
|
||||
}
|
||||
|
||||
// 获取自定义表单表
|
||||
public function getFormTable($id)
|
||||
{
|
||||
return parent::table('ay_form')->where("id=$id")->value('table_name');
|
||||
}
|
||||
|
||||
// 获取自定义表单表
|
||||
public function getFormCode($id)
|
||||
{
|
||||
return parent::table('ay_form')->where("id=$id")->value('fcode');
|
||||
}
|
||||
|
||||
// 获取自定义表单表
|
||||
public function getFormTableByCode($fcode)
|
||||
{
|
||||
return parent::table('ay_form')->where("fcode='$fcode'")->value('table_name');
|
||||
}
|
||||
|
||||
// 添加自定义表单
|
||||
public function addForm(array $data)
|
||||
{
|
||||
return parent::table('ay_form')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除自定义表单
|
||||
public function delForm($id)
|
||||
{
|
||||
$form = parent::table('ay_form')->field('fcode,form_name')
|
||||
->where("id=$id")
|
||||
->find();
|
||||
|
||||
// 删除可能存在的菜单
|
||||
if (! ! $rs = parent::table('ay_menu')->like('url', '/Form/index/fcode/' . $form->fcode . '/action/showdata')->find()) {
|
||||
parent::table('ay_menu')->where("mcode='" . $rs->mcode . "'")->delete();
|
||||
$menu = session('menu_tree');
|
||||
foreach ($menu as $key => $value) {
|
||||
if (! ! $delkey = result_value_search($rs->mcode, $menu[$key]->son, 'mcode')) {
|
||||
unset($menu[$key]->son[$delkey]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$result = parent::table('ay_form')->where("id=$id")->delete(); // 删除表单
|
||||
return $result;
|
||||
}
|
||||
|
||||
// 修改自定义表单
|
||||
public function modForm($id, $data)
|
||||
{
|
||||
return parent::table('ay_form')->where("id=$id")
|
||||
->autoTime()
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 获取表单字段
|
||||
public function getFormFieldByCode($fcode)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("fcode='$fcode'")
|
||||
->order('sorting ASC,id ASC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取字段详情
|
||||
public function getFormField($id)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("id=$id")->find();
|
||||
}
|
||||
|
||||
// 检查表单字段
|
||||
public function checkFormField($fcode, $name)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("fcode='$fcode' AND name='$name'")->find();
|
||||
}
|
||||
|
||||
// 获取表单字段名称
|
||||
public function getFormFieldName($id)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("id=$id")->value('name');
|
||||
}
|
||||
|
||||
// 新增表单字段
|
||||
public function addFormField(array $data)
|
||||
{
|
||||
return parent::table('ay_form_field')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除表单字段
|
||||
public function delFormField($id)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("id=$id")->delete();
|
||||
}
|
||||
|
||||
// 删除表单字段
|
||||
public function delFormFieldByCode($fcode)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("fcode='$fcode'")->delete();
|
||||
}
|
||||
|
||||
// 修改表单字段
|
||||
public function modFormField($id, $data)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("id=$id")
|
||||
->autoTime()
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 判断字段是否存在
|
||||
public function isExistField($table, $field)
|
||||
{
|
||||
$fields = parent::tableFields($table);
|
||||
if (in_array($field, $fields)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 获取表单数据
|
||||
public function getFormData($table, $page = true)
|
||||
{
|
||||
return parent::table($table)->page($page)
|
||||
->order('id DESC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 删除自定义表单数据
|
||||
public function delFormData($table, $id)
|
||||
{
|
||||
return parent::table($table)->where("id=$id")->delete();
|
||||
}
|
||||
|
||||
// 清空自定义表单数据
|
||||
public function clearFormData($table)
|
||||
{
|
||||
return parent::table($table)->delete();
|
||||
}
|
||||
|
||||
// 增加表单数据查看到菜单
|
||||
public function addFormMenu($id)
|
||||
{
|
||||
$form = parent::table('ay_form')->field('fcode,form_name')
|
||||
->where("id=$id")
|
||||
->find();
|
||||
|
||||
$menus = session('menu_tree');
|
||||
|
||||
// 判断是否已经在菜单中
|
||||
if (! ! $menu = parent::table('ay_menu')->like('url', '/Form/index/fcode/' . $form->fcode . '/action/showdata')->find()) {
|
||||
if ($form->form_name != $menu->name) {
|
||||
// 更新缓存菜单
|
||||
parent::table('ay_menu')->where('mcode="' . $menu->mcode . '"')->update('name="' . $form->form_name . '"');
|
||||
foreach ($menus as $key => $value) {
|
||||
if ($value->mcode == 'M157') {
|
||||
if (($skey = result_value_search($menu->mcode, $menus[$key]->son, 'mcode')) !== false) {
|
||||
$menus[$key]->son[$skey]->name = $form->form_name;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 构建数据
|
||||
$lastmcode = parent::table('ay_menu')->order('mcode DESC')->value('mcode');
|
||||
$mcode = get_auto_code($lastmcode);
|
||||
$data = array(
|
||||
'mcode' => $mcode,
|
||||
'pcode' => 'M157',
|
||||
'name' => $form->form_name,
|
||||
'url' => '/Form/index/fcode/' . $form->fcode . '/action/showdata',
|
||||
'sorting' => 599,
|
||||
'status' => 1,
|
||||
'shortcut' => 0,
|
||||
'ico' => 'fa-plus-square-o',
|
||||
'create_user' => session('username'),
|
||||
'update_user' => session('username')
|
||||
);
|
||||
|
||||
// 加入菜单
|
||||
foreach ($menus as $key => $value) {
|
||||
if ($value->mcode == 'M157') {
|
||||
// 未在缓存菜单中才执行添加
|
||||
if (result_value_search($mcode, $menus[$key]->son, 'mcode') === false) {
|
||||
$menus[$key]->son[] = array_to_object($data);
|
||||
return parent::table('ay_menu')->autoTime()->insert($data); // 插入到数据库
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
70
apps/admin/model/content/LabelModel.php
Normal file
70
apps/admin/model/content/LabelModel.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2018年03月23日
|
||||
* 自定义标签模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class LabelModel extends Model
|
||||
{
|
||||
|
||||
// 获取自定义标签列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_label')->select();
|
||||
}
|
||||
|
||||
// 检查自定义标签
|
||||
public function checkLabel($where)
|
||||
{
|
||||
return parent::table('ay_label')->field('id')
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取自定义标签详情
|
||||
public function getLabel($id)
|
||||
{
|
||||
return parent::table('ay_label')->where("id=$id")->find();
|
||||
}
|
||||
|
||||
// 添加自定义标签
|
||||
public function addLabel(array $data)
|
||||
{
|
||||
return parent::table('ay_label')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除自定义标签
|
||||
public function delLabel($id)
|
||||
{
|
||||
return parent::table('ay_label')->where("id='$id'")->delete();
|
||||
}
|
||||
|
||||
// 修改自定义标签
|
||||
public function modLabel($id, $data)
|
||||
{
|
||||
return parent::table('ay_label')->where("id=$id")
|
||||
->autoTime()
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 修改自定义标签值
|
||||
public function modValue($name, $value)
|
||||
{
|
||||
return parent::table('ay_label')->where("name='$name'")
|
||||
->autoTime()
|
||||
->update("value='$value'");
|
||||
}
|
||||
|
||||
// 获取配置参数
|
||||
public function getValue()
|
||||
{
|
||||
return parent::table('ay_label')->column('value', 'name');
|
||||
}
|
||||
}
|
||||
|
||||
80
apps/admin/model/content/LinkModel.php
Normal file
80
apps/admin/model/content/LinkModel.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2018年3月1日
|
||||
* 友情链接模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class LinkModel extends Model
|
||||
{
|
||||
|
||||
// 获取友情链接列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_link')->where("acode='" . session('acode') . "'")
|
||||
->order('gid asc,sorting asc,id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找友情链接
|
||||
public function findLink($field, $keyword)
|
||||
{
|
||||
return parent::table('ay_link')->where("acode='" . session('acode') . "'")
|
||||
->like($field, $keyword)
|
||||
->order('gid asc,sorting asc,id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取友情链接详情
|
||||
public function getLink($id)
|
||||
{
|
||||
return parent::table('ay_link')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取分组
|
||||
public function getGid()
|
||||
{
|
||||
return parent::table('ay_link')->distinct()
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->order('gid')
|
||||
->column('gid');
|
||||
}
|
||||
|
||||
// 获取最大分组值
|
||||
public function getMaxGid()
|
||||
{
|
||||
return parent::table('ay_link')->max('gid');
|
||||
}
|
||||
|
||||
// 添加友情链接
|
||||
public function addLink(array $data)
|
||||
{
|
||||
return parent::table('ay_link')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除友情链接
|
||||
public function delLink($id)
|
||||
{
|
||||
return parent::table('ay_link')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改友情链接
|
||||
public function modLink($id, $data)
|
||||
{
|
||||
return parent::table('ay_link')->autoTime()
|
||||
->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
}
|
||||
}
|
||||
99
apps/admin/model/content/MessageModel.php
Normal file
99
apps/admin/model/content/MessageModel.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2017年3月29日
|
||||
* 留言模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class MessageModel extends Model
|
||||
{
|
||||
|
||||
// 获取列表
|
||||
public function getList($page = true)
|
||||
{
|
||||
$field = array(
|
||||
'a.*',
|
||||
'b.username',
|
||||
'b.nickname',
|
||||
'b.headpic'
|
||||
);
|
||||
$join = array(
|
||||
'ay_member b',
|
||||
'a.uid=b.id',
|
||||
'LEFT'
|
||||
);
|
||||
return parent::table('ay_message a')->field($field)
|
||||
->join($join)
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->order('a.id DESC')
|
||||
->decode(false)
|
||||
->page($page)
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取详情
|
||||
public function getMessage($id)
|
||||
{
|
||||
$field = array(
|
||||
'a.*',
|
||||
'b.username',
|
||||
'b.nickname',
|
||||
'b.headpic'
|
||||
);
|
||||
$join = array(
|
||||
'ay_member b',
|
||||
'a.uid=b.id',
|
||||
'LEFT'
|
||||
);
|
||||
return parent::table('ay_message a')->field($field)
|
||||
->join($join)
|
||||
->where("a.id=$id")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->find();
|
||||
}
|
||||
|
||||
// 删除留言
|
||||
public function delMessage($id)
|
||||
{
|
||||
return parent::table('ay_message')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改留言
|
||||
public function modMessage($id, $data)
|
||||
{
|
||||
return parent::table('ay_message')->autoTime()
|
||||
->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 获取表单字段
|
||||
public function getFormFieldByCode($fcode)
|
||||
{
|
||||
return parent::table('ay_form_field')->where("fcode='$fcode'")
|
||||
->order('sorting ASC,id ASC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取留言数量
|
||||
public function getCount()
|
||||
{
|
||||
$rs = parent::table('ay_message')->field('count(*) as count')
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->find();
|
||||
return $rs->count ?: 0;
|
||||
}
|
||||
|
||||
// 删除全部
|
||||
public function clearMessage()
|
||||
{
|
||||
return parent::table('ay_message')->delete();
|
||||
}
|
||||
}
|
||||
140
apps/admin/model/content/ModelModel.php
Normal file
140
apps/admin/model/content/ModelModel.php
Normal file
@@ -0,0 +1,140 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2018年3月25日
|
||||
* 内容模型模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class ModelModel extends Model
|
||||
{
|
||||
|
||||
// 获取内容模型列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_model')->order('id ASC')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取模型名称
|
||||
public function getName($mcode)
|
||||
{
|
||||
return parent::table('ay_model')->where("mcode='$mcode'")->value('name');
|
||||
}
|
||||
|
||||
// 获取内容模型选择
|
||||
public function getSelectAll()
|
||||
{
|
||||
return parent::table('ay_model')->field('mcode,name,type,listtpl,contenttpl')
|
||||
->order('id ASC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取内容模型选择
|
||||
public function getModelMenu()
|
||||
{
|
||||
return parent::table('ay_model')->field('mcode,name,type')
|
||||
->where('status=1')
|
||||
->order('id ASC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取模型内容数量
|
||||
public function getModelCount($mcode)
|
||||
{
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model d',
|
||||
'b.mcode=d.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->field('count(*) as count')
|
||||
->where("b.mcode='$mcode'")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取内容模型选择
|
||||
public function getSelect()
|
||||
{
|
||||
return parent::table('ay_model')->field('mcode,name,type,listtpl,contenttpl')
|
||||
->where('status=1')
|
||||
->order('id ASC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找内容模型
|
||||
public function findModel($field, $keyword)
|
||||
{
|
||||
return parent::table('ay_model')->like($field, $keyword)
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取最后一个code
|
||||
public function getLastCode()
|
||||
{
|
||||
return parent::table('ay_model')->order('id DESC')->value('mcode');
|
||||
}
|
||||
|
||||
// 获取内容模型详情
|
||||
public function getModel($id)
|
||||
{
|
||||
return parent::table('ay_model')->where("id=$id")->find();
|
||||
}
|
||||
|
||||
// 添加内容模型
|
||||
public function addModel(array $data)
|
||||
{
|
||||
return parent::table('ay_model')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除内容模型
|
||||
public function delModel($id)
|
||||
{
|
||||
$model = parent::table('ay_model')->where('id=' . $id)->find();
|
||||
if (parent::table('ay_content_sort')->where("mcode='$model->mcode'")->find()) {
|
||||
alert_back('模型下面有栏目,不允许直接删除!');
|
||||
}
|
||||
return parent::table('ay_model')->where("id=$id")
|
||||
->where("issystem=0")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改内容模型
|
||||
public function modModel($id, $data)
|
||||
{
|
||||
return parent::table('ay_model')->autoTime()
|
||||
->where("id=$id")
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 检查URL名字冲突
|
||||
public function checkUrlname($urlname, $type, $where = array())
|
||||
{
|
||||
return parent::table('ay_model')->field('id')
|
||||
->where("urlname='$urlname' AND type<>$type")
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 检查栏目名字冲突
|
||||
public function checkSortFilename($urlname)
|
||||
{
|
||||
return parent::table('ay_content_sort')->field('id')
|
||||
->where("filename='$urlname'")
|
||||
->find();
|
||||
}
|
||||
}
|
||||
196
apps/admin/model/content/SingleModel.php
Normal file
196
apps/admin/model/content/SingleModel.php
Normal file
@@ -0,0 +1,196 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2017年12月15日
|
||||
* 单页文章模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class SingleModel extends Model
|
||||
{
|
||||
|
||||
// 获取文章列表
|
||||
public function getList($mcode)
|
||||
{
|
||||
$field = array(
|
||||
'a.id',
|
||||
'a.scode',
|
||||
'b.name as sortname',
|
||||
'a.title',
|
||||
'a.date',
|
||||
'a.status',
|
||||
'a.visits',
|
||||
'b.mcode',
|
||||
'a.ico',
|
||||
'a.pics',
|
||||
'a.outlink',
|
||||
'b.filename',
|
||||
'c.urlname'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model c',
|
||||
'b.mcode=c.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->distinct()
|
||||
->field($field)
|
||||
->where("b.mcode='$mcode'")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->where('c.type=1')
|
||||
->join($join)
|
||||
->where('a.id IN(SELECT MAX(d.id) FROM ay_content d WHERE d.scode=a.scode)')
|
||||
->order('a.id DESC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找文章
|
||||
public function findSingle($mcode, $field, $keyword)
|
||||
{
|
||||
$fields = array(
|
||||
'a.id',
|
||||
'a.scode',
|
||||
'b.name as sortname',
|
||||
'a.title',
|
||||
'a.date',
|
||||
'a.status',
|
||||
'a.visits',
|
||||
'b.mcode',
|
||||
'a.ico',
|
||||
'a.pics',
|
||||
'a.outlink',
|
||||
'b.filename',
|
||||
'c.urlname'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model c',
|
||||
'b.mcode=c.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->distinct()
|
||||
->field($fields)
|
||||
->where("b.mcode='$mcode'")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->where('c.type=1')
|
||||
->like($field, $keyword)
|
||||
->join($join)
|
||||
->group('b.name')
|
||||
->order('a.id DESC')
|
||||
->select();
|
||||
}
|
||||
|
||||
// 检查文章
|
||||
public function checkSingle($where)
|
||||
{
|
||||
return parent::table('ay_content')->field('id')
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取文章详情
|
||||
public function getSingle($id)
|
||||
{
|
||||
$field = array(
|
||||
'a.*',
|
||||
'b.name as sortname',
|
||||
'c.*',
|
||||
'b.filename',
|
||||
'd.urlname'
|
||||
);
|
||||
$join = array(
|
||||
array(
|
||||
'ay_content_sort b',
|
||||
'a.scode=b.scode',
|
||||
'LEFT'
|
||||
|
||||
),
|
||||
array(
|
||||
'ay_content_ext c',
|
||||
'a.id=c.contentid',
|
||||
'LEFT'
|
||||
),
|
||||
array(
|
||||
'ay_model d',
|
||||
'b.mcode=d.mcode',
|
||||
'LEFT'
|
||||
)
|
||||
);
|
||||
return parent::table('ay_content a')->field($field)
|
||||
->where("a.id=$id")
|
||||
->where("a.acode='" . session('acode') . "'")
|
||||
->join($join)
|
||||
->find();
|
||||
}
|
||||
|
||||
// 添加文章
|
||||
public function addSingle(array $data)
|
||||
{
|
||||
return parent::table('ay_content')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除文章
|
||||
public function delSingle($id)
|
||||
{
|
||||
return parent::table('ay_content')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改文章
|
||||
public function modSingle($id, $data)
|
||||
{
|
||||
return parent::table('ay_content')->autoTime()
|
||||
->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
}
|
||||
|
||||
// 查找文章扩展内容
|
||||
public function findContentExt($id)
|
||||
{
|
||||
return parent::table('ay_content_ext')->where("contentid=$id")->find();
|
||||
}
|
||||
|
||||
// 添加文章扩展内容
|
||||
public function addContentExt(array $data)
|
||||
{
|
||||
return parent::table('ay_content_ext')->insert($data);
|
||||
}
|
||||
|
||||
// 修改文章扩展内容
|
||||
public function modContentExt($id, $data)
|
||||
{
|
||||
return parent::table('ay_content_ext')->where("contentid=$id")->update($data);
|
||||
}
|
||||
|
||||
// 删除文章扩展内容
|
||||
public function delContentExt($id)
|
||||
{
|
||||
return parent::table('ay_content_ext')->where("contentid=$id")->delete();
|
||||
}
|
||||
|
||||
// 检查自定义URL名称
|
||||
public function checkFilename($where)
|
||||
{
|
||||
return parent::table('ay_content')->field('id')
|
||||
->where($where)
|
||||
->find();
|
||||
}
|
||||
}
|
||||
45
apps/admin/model/content/SiteModel.php
Normal file
45
apps/admin/model/content/SiteModel.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2017年3月24日
|
||||
* 站点配置模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class SiteModel extends Model
|
||||
{
|
||||
|
||||
// 获取系统配置信息
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_site')->where("acode='" . session('acode') . "'")->find();
|
||||
}
|
||||
|
||||
// 检查系统配置信息
|
||||
public function checkSite()
|
||||
{
|
||||
return parent::table('ay_site')->where("acode='" . session('acode') . "'")->find();
|
||||
}
|
||||
|
||||
// 增加系统配置信息
|
||||
public function addSite($data)
|
||||
{
|
||||
return parent::table('ay_site')->insert($data);
|
||||
}
|
||||
|
||||
// 修改系统配置信息
|
||||
public function modSite($data)
|
||||
{
|
||||
return parent::table('ay_site')->where("acode='" . session('acode') . "'")->update($data);
|
||||
}
|
||||
|
||||
// 系统数据库版本
|
||||
public function getMysql()
|
||||
{
|
||||
return parent::one('SELECT VERSION()', MYSQLI_NUM);
|
||||
}
|
||||
}
|
||||
80
apps/admin/model/content/SlideModel.php
Normal file
80
apps/admin/model/content/SlideModel.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2018年3月1日
|
||||
* 轮播图模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class SlideModel extends Model
|
||||
{
|
||||
|
||||
// 获取轮播图列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_slide')->where("acode='" . session('acode') . "'")
|
||||
->order('gid asc,sorting asc,id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找轮播图
|
||||
public function findSlide($field, $keyword)
|
||||
{
|
||||
return parent::table('ay_slide')->where("acode='" . session('acode') . "'")
|
||||
->like($field, $keyword)
|
||||
->order('gid asc,sorting asc,id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取轮播图详情
|
||||
public function getSlide($id)
|
||||
{
|
||||
return parent::table('ay_slide')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->find();
|
||||
}
|
||||
|
||||
// 获取分组
|
||||
public function getGid()
|
||||
{
|
||||
return parent::table('ay_slide')->distinct()
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->order('gid')
|
||||
->column('gid');
|
||||
}
|
||||
|
||||
// 获取最大分组值
|
||||
public function getMaxGid()
|
||||
{
|
||||
return parent::table('ay_slide')->max('gid');
|
||||
}
|
||||
|
||||
// 添加轮播图
|
||||
public function addSlide(array $data)
|
||||
{
|
||||
return parent::table('ay_slide')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除轮播图
|
||||
public function delSlide($id)
|
||||
{
|
||||
return parent::table('ay_slide')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改轮播图
|
||||
public function modSlide($id, $data)
|
||||
{
|
||||
return parent::table('ay_slide')->autoTime()
|
||||
->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
}
|
||||
}
|
||||
65
apps/admin/model/content/TagsModel.php
Normal file
65
apps/admin/model/content/TagsModel.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright (C)2016-2099 Hnaoyun Inc.
|
||||
* @author XingMeng
|
||||
* @email hnxsh@foxmail.com
|
||||
* @date 2019年07月12日
|
||||
* 内链链接模型类
|
||||
*/
|
||||
namespace app\admin\model\content;
|
||||
|
||||
use core\basic\Model;
|
||||
|
||||
class TagsModel extends Model
|
||||
{
|
||||
|
||||
// 获取文章内链列表
|
||||
public function getList()
|
||||
{
|
||||
return parent::table('ay_tags')->where("acode='" . session('acode') . "'")
|
||||
->order('id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 查找文章内链
|
||||
public function findTags($field, $keyword)
|
||||
{
|
||||
return parent::table('ay_tags')->where("acode='" . session('acode') . "'")
|
||||
->like($field, $keyword)
|
||||
->order('id asc')
|
||||
->page()
|
||||
->select();
|
||||
}
|
||||
|
||||
// 获取文章内链详情
|
||||
public function getTags($id)
|
||||
{
|
||||
return parent::table('ay_tags')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->find();
|
||||
}
|
||||
|
||||
// 添加文章内链
|
||||
public function addTags(array $data)
|
||||
{
|
||||
return parent::table('ay_tags')->autoTime()->insert($data);
|
||||
}
|
||||
|
||||
// 删除文章内链
|
||||
public function delTags($id)
|
||||
{
|
||||
return parent::table('ay_tags')->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->delete();
|
||||
}
|
||||
|
||||
// 修改文章内链
|
||||
public function modTags($id, $data)
|
||||
{
|
||||
return parent::table('ay_tags')->autoTime()
|
||||
->where("id=$id")
|
||||
->where("acode='" . session('acode') . "'")
|
||||
->update($data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user