139 lines
4.5 KiB
PHP
139 lines
4.5 KiB
PHP
<?php
|
|
/*
|
|
* @Author: mkm
|
|
* @Date: 2023-02-12 10:38:40
|
|
* @LastEditTime: 2023-02-12 11:06:03
|
|
* @LastEditors: your name
|
|
* @Description:
|
|
* @FilePath: \nk-lihaink-cn\app\admin\controller\nk\StreetCulture.php
|
|
* 可以输入预定的版权声明、个性签名、空行等
|
|
*/
|
|
|
|
namespace app\admin\controller\nk;
|
|
|
|
use app\admin\BaseController;
|
|
use think\exception\ValidateException;
|
|
use think\facade\Db;
|
|
use app\admin\controller\nk\Article;
|
|
use think\facade\View;
|
|
|
|
/**
|
|
* 农旅文化
|
|
*
|
|
* @icon fa fa-circle-o
|
|
*/
|
|
class StreetCulture extends BaseController
|
|
{
|
|
|
|
public function __construct()
|
|
{
|
|
$this->adminInfo = get_login_admin();
|
|
$this->url=[
|
|
'/admin/nk.street_culture/index',
|
|
'/admin/nk.street_culture/add',
|
|
'/admin/nk.street_culture/edit',
|
|
'/admin/nk.street_culture/del',
|
|
'/admin/nk.street_culture/read',
|
|
];
|
|
}
|
|
/**
|
|
* 查看
|
|
*/
|
|
public function index()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$params= get_params();
|
|
$where[]= ['status','=',1];
|
|
if (isset($params['keywords']) && !empty($params['keywords'])){
|
|
$where[]=['title','like','%'.$params['keywords'].'%'];
|
|
}
|
|
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
|
|
$www['admin_id'] = $this->adminInfo['id'];
|
|
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
|
|
if ($user_address) {
|
|
if ($user_address['auth_range'] == 1) {
|
|
$where[]= ['county','=',$user_address['area_id']];
|
|
$where[] =['township','=', $user_address['street_id']];
|
|
$where[] =['village','=', $user_address['village_id']];
|
|
} elseif ($user_address['auth_range'] == 2) {
|
|
$where[]= ['county','=',$user_address['area_id']];
|
|
$where[] =['township','=', $user_address['street_id']];
|
|
}
|
|
}
|
|
}
|
|
$map[] = ['category_id','in',[307,308,309,310,311,312]];
|
|
$total = Db::table('fa_article')
|
|
->where($where)
|
|
->where($map)
|
|
->count();
|
|
|
|
$list = Db::table('fa_article')
|
|
->withAttr('nickname',function ($value,$data){
|
|
return Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->value('name');
|
|
})
|
|
->withAttr('area',function ($value,$data){
|
|
return Db::table('fa_geo_area')->where('area_code',$data['county'])->value('area_name');
|
|
})
|
|
->withAttr('street',function ($value,$data){
|
|
return Db::table('fa_geo_street')->where('street_code',$data['township'])->value('street_name');
|
|
})
|
|
->withAttr('village',function ($value,$data){
|
|
return Db::table('fa_geo_village')->where('village_id',$data['village'])->value('village_name');
|
|
})
|
|
->where($where)
|
|
->where($map)
|
|
->page($params['page'])
|
|
->limit($params['limit'])
|
|
->order('id desc')
|
|
->field('id,title,user_id,county,township,village,image,view_time')
|
|
|
|
->select();
|
|
$result = ['total' => $total, 'data' => $list];
|
|
return table_assign(0, '', $result);
|
|
}
|
|
return view('',['url'=>$this->url]);
|
|
}
|
|
/**
|
|
* 添加
|
|
*/
|
|
public function add()
|
|
{
|
|
if (request()->isAjax()) {
|
|
$params= get_params();
|
|
$params['category_id']=$this->category_id;
|
|
(new Article())->add($params);
|
|
}else{
|
|
View::assign('editor', get_system_config('other','editor'));
|
|
View::assign('url', $this->url);
|
|
return view('nk/article/add');
|
|
}
|
|
}
|
|
/**
|
|
* 修改
|
|
*/
|
|
public function edit()
|
|
{
|
|
$params= get_params();
|
|
(new Article())->edit($params);
|
|
return view('nk/article/edit',['url'=>$this->url]);
|
|
}
|
|
/**
|
|
* 查看信息
|
|
*/
|
|
public function read()
|
|
{
|
|
$params = get_params();
|
|
(new Article())->read($params);
|
|
|
|
return view('nk/article/read',['url'=>$this->url]);
|
|
|
|
}
|
|
/**
|
|
* 修改
|
|
*/
|
|
public function del()
|
|
{
|
|
$params= get_params();
|
|
(new Article())->del($params);
|
|
}
|
|
} |