Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ca2e14a6f5
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,3 +10,4 @@
|
||||
/public/backup/*
|
||||
/public/static/home/dev
|
||||
/public/static/home/oa
|
||||
/config/database.php
|
||||
|
34
app/admin/validate/party/Article.php
Normal file
34
app/admin/validate/party/Article.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Article extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'title' => 'require|max:100',
|
||||
'content' => 'require',
|
||||
'category_id' => 'require',
|
||||
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'title' => '请填写标题',
|
||||
'content' => '请填写内容',
|
||||
'category_id' => '请填写分类',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => ['title','content'],
|
||||
'edit' => ['title','content'],
|
||||
];
|
||||
|
||||
}
|
37
app/admin/validate/party/Branch.php
Normal file
37
app/admin/validate/party/Branch.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Branch extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'user_id' => 'require',
|
||||
'phone' => 'require',
|
||||
'two_user_id' => 'require',
|
||||
'two_phone' => 'require',
|
||||
'company'=>'require',
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'user_id' => '书记不能为空',
|
||||
'phone' => '手机不能为空',
|
||||
'two_user_id' => '副书记不能为空',
|
||||
'two_phone' => '副书记手机不能为空',
|
||||
'company'=>'单位不能为空',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
37
app/admin/validate/party/BranchPayList.php
Normal file
37
app/admin/validate/party/BranchPayList.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class BranchPayList extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'branch_id'=>'require',
|
||||
'start_time'=>'require',
|
||||
'end_time'=>'require',
|
||||
// 'pay'=>'require',
|
||||
// 'no_pay'=>'require'
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'branch_id'=>'党组织未选择',
|
||||
'start_time'=>'请选择开始时间',
|
||||
'end_time'=>'请选择结束时间',
|
||||
'pay'=>'应收金额不能为空',
|
||||
'no_pay'=>'未收金额不能为空',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
35
app/admin/validate/party/BranchPayUser.php
Normal file
35
app/admin/validate/party/BranchPayUser.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class BranchPayUser extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'user_id'=> 'require',
|
||||
'start_time'=>'require',
|
||||
'count'=>'require',
|
||||
'pay'=>'require',
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'user_id'=> '请填写用户',
|
||||
'start_time'=>'请填写时间',
|
||||
'count'=>'请填写需要缴纳几个月',
|
||||
'pay'=>'请填写金额',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
65
app/admin/validate/party/Info.php
Normal file
65
app/admin/validate/party/Info.php
Normal file
@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Info extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'user_id'=>'require',
|
||||
// 'title'=>'require',
|
||||
// 'picture'=>'require',
|
||||
// 'groups'=>'require',
|
||||
// 'nation'=>'require',
|
||||
'politics'=>'require',
|
||||
// 'phone'=>'require',
|
||||
// 'marriage'=>'require',
|
||||
// 'idcard'=>'require',
|
||||
// 'gender'=>'require',
|
||||
// 'age'=>'require',
|
||||
'company'=>'require',
|
||||
'department'=>'require',
|
||||
'post'=>'require',
|
||||
'party_branch'=>'require',
|
||||
'branch_add_time'=>'require',
|
||||
'branch_type'=>'require',
|
||||
'referrer'=>'require',
|
||||
'branch_pay'=>'require',
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'user_id'=>'请选择用户',
|
||||
'title'=>'请填写姓名',
|
||||
'picture'=>'请填写头像',
|
||||
'groups'=>'请填写社区或者村组',
|
||||
'nation'=>'请填写民族',
|
||||
'politics'=>'请填写政治面貌',
|
||||
'phone'=>'请填写手机号',
|
||||
'marriage'=>'请填写婚姻状况',
|
||||
'idcard'=>'请填写身份证',
|
||||
'gender'=>'请填写性别',
|
||||
'age'=>'请填写年龄',
|
||||
'company'=>'请填写所属单位',
|
||||
'department'=>'请填写所属部门',
|
||||
'post'=>'请填写职务',
|
||||
'party_branch'=>'请填写党支部',
|
||||
'branch_add_time'=>'请填写加入时间',
|
||||
'branch_type'=>'请填写在籍状态',
|
||||
'referrer'=>'请填写介绍人',
|
||||
'branch_pay'=>'请填写党费',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
35
app/admin/validate/party/Vote.php
Normal file
35
app/admin/validate/party/Vote.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class Vote extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'title'=>'require',
|
||||
'start_time'=>'require',
|
||||
'end_time'=>'require',
|
||||
'content'=>'require',
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'title'=>'请填写标题',
|
||||
'start_time'=>'请填写开始时间',
|
||||
'end_time'=>'请填写结束时间',
|
||||
'content'=>'请填写内容',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => [],
|
||||
'edit' => [],
|
||||
];
|
||||
|
||||
}
|
33
app/admin/validate/party/VoteComment.php
Normal file
33
app/admin/validate/party/VoteComment.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace app\admin\validate\party;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class VoteComment extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'vote_id' => 'require',
|
||||
'content' => 'require',
|
||||
'type' => 'require',
|
||||
];
|
||||
/**
|
||||
* 提示消息
|
||||
*/
|
||||
protected $message = [
|
||||
'vote_id' => '没有内容id',
|
||||
'content' => '请填写内容',
|
||||
'type' => '没有type字段',
|
||||
];
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => ['vote_id','content','type'],
|
||||
'edit' => ['vote_id','content','type'],
|
||||
];
|
||||
|
||||
}
|
@ -537,7 +537,7 @@ class Article extends BaseController
|
||||
public function edit($id)
|
||||
{
|
||||
$model =Db::table('fa_article');
|
||||
$find = $model->where('id', $id)->find()->toArray();
|
||||
$find = $model->where('id', $id)->find();
|
||||
if ($find && $find['is_vote'] == 1) {
|
||||
$data = Db::table('fa_article_vote_side_tables')->where('article_id', $find['id'])->find();
|
||||
$find['extend']['vote'] = $data;
|
||||
|
@ -6,7 +6,6 @@ use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use fast\Random;
|
||||
use think\exception\ValidateException;
|
||||
use app\common\model\User;
|
||||
|
||||
@ -772,7 +771,7 @@ class Maintainentry extends BaseController
|
||||
$data['user_id'] = $user_id;
|
||||
|
||||
$data['createtime'] = time();
|
||||
$res = Db::table('fa_szxc_information_planting')->create($data);
|
||||
$res = Db::table('fa_szxc_information_planting')->insert($data);
|
||||
if ($res) {
|
||||
$this->apiSuccess('保存成功', null, 1);
|
||||
} else {
|
||||
@ -1232,7 +1231,7 @@ class Maintainentry extends BaseController
|
||||
$mobile = $post['phone'];
|
||||
$ip = request()->ip();
|
||||
$time = time();
|
||||
$salt = Random::alnum(); //随机字符串
|
||||
$salt = set_salt(); //随机字符串
|
||||
// 注册用户
|
||||
$params = [
|
||||
'username' => $mobile,
|
||||
@ -1527,7 +1526,7 @@ class Maintainentry extends BaseController
|
||||
$mobile = $post['phone'];
|
||||
$ip = request()->ip();
|
||||
$time = time();
|
||||
$salt = Random::alnum(); //随机字符串
|
||||
$salt = set_salt(); //随机字符串
|
||||
// 注册用户
|
||||
$params = [
|
||||
'username' => $mobile,
|
||||
|
@ -2,35 +2,22 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use think\Exception;
|
||||
use think\facade\Cache;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
use think\exception\ValidateException;
|
||||
use app\common\model\User;
|
||||
use app\common\model\PersonalNews;
|
||||
use app\common\model\PersonalComment;
|
||||
use app\common\model\UserAddress;
|
||||
use app\admin\model\InformationUsermsg;
|
||||
use app\admin\model\Article;
|
||||
//use think\middleware\Throttle;
|
||||
|
||||
/**
|
||||
* 数据大屏接口.
|
||||
*/
|
||||
class Statistics extends Api
|
||||
class Statistics extends BaseController
|
||||
{
|
||||
//如果$noNeedLogin为空表示所有接口都需要登录才能请求
|
||||
//如果$noNeedRight为空表示所有接口都需要验证权限才能请求
|
||||
//如果接口已经设置无需登录,那也就无需鉴权了
|
||||
//
|
||||
// 无需登录的接口,*表示全部
|
||||
protected $noNeedLogin = ['*'];
|
||||
// 无需鉴权的接口,*表示全部
|
||||
protected $noNeedRight = ['*'];
|
||||
// protected $middleware = [
|
||||
// Throttle::class
|
||||
// ];
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
|
||||
//人口构成(80岁以上、61-80岁、36-60岁、18-35岁、0-17岁)
|
||||
public function get_people($area_id=0,$street_id=0,$village_id=0){
|
||||
@ -45,15 +32,15 @@ class Statistics extends Api
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 80岁以上
|
||||
$num1 = InformationUsermsg::where($where)->whereAge('>', 80)->count();
|
||||
$num1 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count();
|
||||
//61-80岁
|
||||
$num2 = InformationUsermsg::where($where)->whereAge('<=', 80)->whereAge('>', 60)->count();
|
||||
$num2 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 80)->whereAge('>', 60)->count();
|
||||
//36-60岁
|
||||
$num3 = InformationUsermsg::where($where)->whereAge('<=', 60)->whereAge('>=', 36)->count();
|
||||
$num3 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 60)->whereAge('>=', 36)->count();
|
||||
//18-35岁
|
||||
$num4 = InformationUsermsg::where($where)->whereAge('<', 36)->whereAge('>', 17)->count();
|
||||
$num4 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 36)->whereAge('>', 17)->count();
|
||||
//0-17岁
|
||||
$num5 = InformationUsermsg::where($where)->whereAge('<', 18)->count();
|
||||
$num5 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 18)->count();
|
||||
$return = [
|
||||
['value'=>$num1,'name'=>'80岁以上'],
|
||||
['value'=>$num2,'name'=>'61-80岁'],
|
||||
@ -61,7 +48,7 @@ class Statistics extends Api
|
||||
['value'=>$num4,'name'=>'18-35岁'],
|
||||
['value'=>$num5,'name'=>'0-17岁']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//人群关爱(特困人员、高龄老人、低保人员、空巢老人、残疾人员、留守儿童)
|
||||
@ -77,27 +64,27 @@ class Statistics extends Api
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 特困人员
|
||||
$num1 = InformationUsermsg::where($where)->whereAge('>', 80)->count();
|
||||
$num1 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count();
|
||||
//高龄老人
|
||||
$num2 = InformationUsermsg::where($where)->whereAge('>', 80)->count();
|
||||
$num2 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('>', 80)->count();
|
||||
//空巢老人
|
||||
$num4 = InformationUsermsg::where($where)->whereAge('<=', 80)->whereAge('>', 60)->count();
|
||||
$num4 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<=', 80)->whereAge('>', 60)->count();
|
||||
//留守儿童
|
||||
$num6 = InformationUsermsg::where($where)->whereAge('<', 18)->count();
|
||||
$num6 = Db::table('fa_szxc_information_usermsg')->where($where)->whereAge('<', 18)->count();
|
||||
|
||||
foreach ($where as $key =>$value){
|
||||
$where[$key][0] = 'm.'.$value[0];
|
||||
}
|
||||
//低保人员
|
||||
$num3 = Db::name('szxc_information_usermsg')
|
||||
$num3 = Db::table('fa_szxc_information_usermsg')
|
||||
->alias('m')
|
||||
->where($where)
|
||||
->join('szxc_information_insurance i','m.user_id=i.user_id and i.insurance_type!=219')->count();
|
||||
->join('fa_szxc_information_insurance i','m.user_id=i.user_id and i.insurance_type!=219')->count();
|
||||
//残疾人员
|
||||
$num5 = Db::name('szxc_information_usermsg')
|
||||
$num5 = Db::table('fa_szxc_information_usermsg')
|
||||
->alias('m')
|
||||
->where($where)
|
||||
->join('szxc_information_insurance i','m.user_id=i.user_id and i.whether_disabled!=112')->count();
|
||||
->join('fa_szxc_information_insurance i','m.user_id=i.user_id and i.whether_disabled!=112')->count();
|
||||
$return = [
|
||||
['value'=>$num1,'name'=>'特困人员'],
|
||||
['value'=>$num2,'name'=>'高龄老人'],
|
||||
@ -106,7 +93,7 @@ class Statistics extends Api
|
||||
['value'=>$num5,'name'=>'低保人员'],
|
||||
['value'=>$num6,'name'=>'残疾人员']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//事项办理(待办事项、延期待办、总计办理、办理结率)
|
||||
@ -121,13 +108,13 @@ class Statistics extends Api
|
||||
if ($village_id){
|
||||
$where[] = ['village', '=', $village_id];
|
||||
}
|
||||
$model = new Article();
|
||||
|
||||
// 待办事项
|
||||
$shuqiu = $model->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','>', date('Y-m-d h:i:s'))->count();
|
||||
$shuqiu = Db::table('fa_article')->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','>', date('Y-m-d h:i:s'))->count();
|
||||
// 延期待办
|
||||
$time = $model->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','<=', date('Y-m-d h:i:s'))->count();
|
||||
$time = Db::table('fa_article')->where('is_solve', 0)->where($where)->where('category_id', 'in',[165,150,149,148,147])->whereTime('end_time','<=', date('Y-m-d h:i:s'))->count();
|
||||
// 总计办理
|
||||
$is_solve = $model->where('is_solve', 1)->where($where)->count();
|
||||
$is_solve = Db::table('fa_article')->where('is_solve', 1)->where($where)->count();
|
||||
if($is_solve){
|
||||
// 办理结率
|
||||
$num4 = ($is_solve-$shuqiu-$time)/$is_solve;
|
||||
@ -142,7 +129,7 @@ class Statistics extends Api
|
||||
['value'=>$is_solve,'name'=>'总计办理'],
|
||||
['value'=>$num4,'name'=>'办理结率']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//资产情况(总耕地面积、人均耕地面积、退林还耕面积、种植物种类、养殖物种类)
|
||||
@ -161,9 +148,9 @@ class Statistics extends Api
|
||||
$map[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 总耕地面积
|
||||
$num1 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where($where)->sum('land_area');
|
||||
$num1 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where($where)->sum('land_area');
|
||||
//人均耕地面积
|
||||
$all = InformationUsermsg::where($map)->whereStatus('=', 1)->count();
|
||||
$all = Db::table('fa_szxc_information_usermsg')->where($map)->whereStatus('=', 1)->count();
|
||||
if($all){
|
||||
$num2 = $num1/$all;
|
||||
}else{
|
||||
@ -173,7 +160,7 @@ class Statistics extends Api
|
||||
//退林还耕面积
|
||||
$num3 = $num1*0.3;
|
||||
//种植物种类
|
||||
$num4 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where($where)->column('crops_msg');
|
||||
$num4 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where($where)->column('crops_msg');
|
||||
$a = 0;
|
||||
foreach ($num4 as $k=>$v){
|
||||
$v = json_decode($v,true);
|
||||
@ -192,7 +179,7 @@ class Statistics extends Api
|
||||
['value'=>$num4,'name'=>'种植物种类'],
|
||||
['value'=>$num5,'name'=>'养殖物种类']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//消费数据(农资消费总计、食品消费总计、衣着消费总计、居住消费总计、生活用品及服务总计、交通通信总计、教育文化娱乐总计、医疗服务总计)
|
||||
@ -233,7 +220,7 @@ class Statistics extends Api
|
||||
['value'=>$num7,'name'=>'教育文化娱乐总计'],
|
||||
['value'=>$num8,'name'=>'医疗服务总计']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//收入构成(工资性收入、生产经营性收入、财产性收入、保险性收入)
|
||||
@ -263,7 +250,7 @@ class Statistics extends Api
|
||||
['value'=>$num3,'name'=>'财产性收入'],
|
||||
['value'=>$num4,'name'=>'保险性收入']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
|
||||
@ -286,19 +273,19 @@ class Statistics extends Api
|
||||
$where[] = ['b.village_id', '=', $village_id];
|
||||
}
|
||||
// 总耕地面积
|
||||
$num1 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',70)->where($where)->sum('land_area');
|
||||
$num1 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',70)->where($where)->sum('land_area');
|
||||
//园地
|
||||
$num2 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',69)->where($where)->sum('land_area');
|
||||
$num2 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',69)->where($where)->sum('land_area');
|
||||
//林地
|
||||
$num3 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',214)->where($where)->sum('land_area');
|
||||
$num3 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',214)->where($where)->sum('land_area');
|
||||
//牧草地
|
||||
$num4 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',215)->where($where)->sum('land_area');
|
||||
$num4 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',215)->where($where)->sum('land_area');
|
||||
//养殖
|
||||
$num5 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',216)->where($where)->sum('land_area');
|
||||
$num5 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',216)->where($where)->sum('land_area');
|
||||
//坑塘
|
||||
$num6 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',217)->where($where)->sum('land_area');
|
||||
$num6 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',217)->where($where)->sum('land_area');
|
||||
//农田水利设施用地
|
||||
$num7 = Db::name('szxc_information_planting')->alias('a')->join('szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',218)->where($where)->sum('land_area');
|
||||
$num7 = Db::table('fa_szxc_information_planting')->alias('a')->join('fa_szxc_information_usermsg b','a.user_id = b.user_id')->where('nature_of_land',218)->where($where)->sum('land_area');
|
||||
$return = [
|
||||
['value'=>$num1,'name'=>'耕地面积'],
|
||||
['value'=>$num2,'name'=>'园地'],
|
||||
@ -308,7 +295,7 @@ class Statistics extends Api
|
||||
['value'=>$num6,'name'=>'坑塘'],
|
||||
['value'=>$num7,'name'=>'农田水利设施用地']
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//文化程度(
|
||||
@ -330,17 +317,17 @@ class Statistics extends Api
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 文盲及半文盲
|
||||
$num1 = Db::name('szxc_information_usermsg')->where('education',71)->where($where)->count();
|
||||
$num1 = Db::table('fa_szxc_information_usermsg')->where('education',71)->where($where)->count();
|
||||
//小学
|
||||
$num2 = Db::name('szxc_information_usermsg')->where('education',72)->where($where)->count();
|
||||
$num2 = Db::table('fa_szxc_information_usermsg')->where('education',72)->where($where)->count();
|
||||
//初中
|
||||
$num3 = Db::name('szxc_information_usermsg')->where('education',73)->where($where)->count();
|
||||
$num3 = Db::table('fa_szxc_information_usermsg')->where('education',73)->where($where)->count();
|
||||
//高中/技校/中专
|
||||
$num4 = Db::name('szxc_information_usermsg')->where('education',74)->where($where)->count();
|
||||
$num4 = Db::table('fa_szxc_information_usermsg')->where('education',74)->where($where)->count();
|
||||
//大学专科及以上
|
||||
$num5 = Db::name('szxc_information_usermsg')->where('education',75)->where($where)->count();
|
||||
$num5 = Db::table('fa_szxc_information_usermsg')->where('education',75)->where($where)->count();
|
||||
//不详
|
||||
$num6 = Db::name('szxc_information_usermsg')->where('education',76)->where($where)->count();
|
||||
$num6 = Db::table('fa_szxc_information_usermsg')->where('education',76)->where($where)->count();
|
||||
|
||||
$return = [
|
||||
['value'=>$num1,'name'=>'文盲及半文盲'],
|
||||
@ -350,7 +337,7 @@ class Statistics extends Api
|
||||
['value'=>$num5,'name'=>'大学专科及以上'],
|
||||
['value'=>$num6,'name'=>'不详'],
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//政治面貌(
|
||||
@ -370,13 +357,13 @@ class Statistics extends Api
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 群众
|
||||
$num1 = Db::name('szxc_information_usermsg')->where('political_outlook',2)->where($where)->count();
|
||||
$num1 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',2)->where($where)->count();
|
||||
//团员
|
||||
$num2 = Db::name('szxc_information_usermsg')->where('political_outlook',3)->where($where)->count();
|
||||
$num2 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',3)->where($where)->count();
|
||||
//党员
|
||||
$num3 = Db::name('szxc_information_usermsg')->where('political_outlook',4)->where($where)->count();
|
||||
$num3 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',4)->where($where)->count();
|
||||
//预备役
|
||||
$num4 = Db::name('szxc_information_usermsg')->where('political_outlook',177)->where($where)->count();
|
||||
$num4 = Db::table('fa_szxc_information_usermsg')->where('political_outlook',177)->where($where)->count();
|
||||
|
||||
$return = [
|
||||
['value'=>$num1,'name'=>'群众'],
|
||||
@ -384,12 +371,13 @@ class Statistics extends Api
|
||||
['value'=>$num3,'name'=>'党员'],
|
||||
['value'=>$num4,'name'=>'预备役'],
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//优秀村民
|
||||
public function get_num8($area_id=0,$street_id=0,$village_id=0){
|
||||
$where[] = ['user_id','in','1,3,5'];
|
||||
public function get_num8($area_id=0,$street_id=0,$village_id=0,$page=1,$limit=10){
|
||||
// $where[] = ['user_id','in','1,3,5'];
|
||||
$where = [];
|
||||
if ($area_id){
|
||||
$where[] = ['area_id', '=', $area_id];
|
||||
}
|
||||
@ -400,9 +388,10 @@ class Statistics extends Api
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 群众
|
||||
$return = Db::name('szxc_information_usermsg')
|
||||
$return = Db::table('fa_szxc_information_usermsg')
|
||||
->field('name,age,address_name as address,gender')
|
||||
->where($where)
|
||||
->page($page,$limit)
|
||||
->withAttr('gender', function ($value, $data) {
|
||||
if($value == 1){
|
||||
return '男';
|
||||
@ -413,7 +402,7 @@ class Statistics extends Api
|
||||
}
|
||||
})
|
||||
->select();
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
|
||||
@ -440,7 +429,7 @@ class Statistics extends Api
|
||||
['value'=>20,'name'=>'其他']]
|
||||
]
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//农业结构
|
||||
@ -463,7 +452,105 @@ class Statistics extends Api
|
||||
['value'=>102,'name'=>'土豆'],
|
||||
['value'=>24,'name'=>'山药'],
|
||||
];
|
||||
$this->success('获取成功',$return);
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//村名数量 男 女 已婚 未婚 技能培训次数 农业指导次数 政策指导次数 求职人数 土地总面积 荒地总面积 养殖面积 种植面积
|
||||
public function get_num11()
|
||||
{
|
||||
// $return = "{villagernum:1000,mannum:600,wumannum:400,married:600,unmarried:400,skillnum:20,policynum:20,agriculture:20,Jobnum:105,landsum:800,wasteland:100,breeding:200,planting500}";
|
||||
$return = [
|
||||
'villagernum' => 1000,
|
||||
'mannum' => 600,
|
||||
'wumannum' => 400,
|
||||
'married' => 600,
|
||||
'unmarried' => 400,
|
||||
'skillnum' => 20,
|
||||
'policynum' => 20,
|
||||
'agriculture' => 20,
|
||||
'Jobnum' => 105,
|
||||
'landsum' => 800,
|
||||
'wasteland' => 100,
|
||||
'breeding' => 200,
|
||||
'planting' => 500
|
||||
];
|
||||
$this->apiSuccess('获取成功', $return);
|
||||
}
|
||||
|
||||
|
||||
//优秀工作人员
|
||||
public function get_num12($area_id=0,$street_id=0,$village_id=0,$page=1,$limit=10){
|
||||
$where[] = ['user_id','in','77,78,79'];
|
||||
// $where = [];
|
||||
// if ($area_id){
|
||||
// $where[] = ['area_id', '=', $area_id];
|
||||
// }
|
||||
// if ($street_id){
|
||||
// $where[] = ['street_id', '=', $street_id];
|
||||
// }
|
||||
// if ($village_id){
|
||||
// $where[] = ['village_id', '=', $village_id];
|
||||
// }
|
||||
// 群众
|
||||
$return = Db::table('fa_szxc_information_usermsg')
|
||||
->field('name,phone as telephone')
|
||||
->where($where)
|
||||
->page($page,$limit)
|
||||
->select()->toArray();
|
||||
foreach ($return as $k=>$v){
|
||||
$return[$k]['pic'] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230118/a32db5b98f8cf2aa8d1fa07dce0ca9a3.png";
|
||||
}
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
//职业
|
||||
// 国家机关、党群组织、企业、事业单位负责人
|
||||
// 专业技术人员
|
||||
// 办事人员和有关人员
|
||||
// 社会生产服务和生活服务人员
|
||||
// 农、林、牧、渔业生产及辅助人员
|
||||
// 生产、运输设备操作人员及有关人员
|
||||
// 军人
|
||||
// 不便分类的其他从业人员
|
||||
public function get_num13($area_id=0,$street_id=0,$village_id=0){
|
||||
$where = [];
|
||||
if ($area_id){
|
||||
$where[] = ['area_id', '=', $area_id];
|
||||
}
|
||||
if ($street_id){
|
||||
$where[] = ['street_id', '=', $street_id];
|
||||
}
|
||||
if ($village_id){
|
||||
$where[] = ['village_id', '=', $village_id];
|
||||
}
|
||||
// 国家机关、党群组织、企业、事业单位负责人
|
||||
$num1 = 1358;
|
||||
// 专业技术人员
|
||||
$num2 = 2578;
|
||||
// 办事人员和有关人员
|
||||
$num3 = 3684;
|
||||
// 社会生产服务和生活服务人员
|
||||
$num4 = 8524;
|
||||
// 农、林、牧、渔业生产及辅助人员
|
||||
$num5 = 9687;
|
||||
// 生产、运输设备操作人员及有关人员
|
||||
$num6 = 1458;
|
||||
// 军人
|
||||
$num7 = 998;
|
||||
// 不便分类的其他从业人员
|
||||
$num8 = 8745;
|
||||
|
||||
$return = [
|
||||
['value'=>$num1,'name'=>'国家机关、党群组织、企业、事业单位负责人'],
|
||||
['value'=>$num2,'name'=>'专业技术人员'],
|
||||
['value'=>$num3,'name'=>'办事人员和有关人员'],
|
||||
['value'=>$num4,'name'=>'社会生产服务和生活服务人员'],
|
||||
['value'=>$num5,'name'=>'农、林、牧、渔业生产及辅助人员'],
|
||||
['value'=>$num6,'name'=>'生产、运输设备操作人员及有关人员'],
|
||||
['value'=>$num7,'name'=>'军人'],
|
||||
['value'=>$num8,'name'=>'不便分类的其他从业人员']
|
||||
];
|
||||
$this->apiSuccess('获取成功',$return);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use fast\Random;
|
||||
use app\common\controller\Api;
|
||||
|
||||
/**
|
||||
@ -32,7 +31,7 @@ class Token extends Api
|
||||
$token = $this->auth->getToken();
|
||||
\app\common\library\Token::delete($token);
|
||||
//创建新Token
|
||||
$token = Random::uuid();
|
||||
$token = make_token();
|
||||
\app\common\library\Token::set($token, $this->auth->id, 2592000);
|
||||
$tokenInfo = \app\common\library\Token::get($token);
|
||||
$this->success('', ['token' => $tokenInfo['token'], 'expires_in' => $tokenInfo['expires_in']]);
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use fast\Random;
|
||||
use Firebase\JWT\JWT;
|
||||
use think\facade\Validate;
|
||||
use think\facade\Config;
|
||||
@ -31,7 +30,8 @@ class User extends BaseController
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$this->apiSuccess('', ['nickname' => $this->auth->nickname,'avatar'=>$this->auth->avatar]);
|
||||
$user = Db::table('fa_user')->where('id',JWT_UID)->find();
|
||||
$this->apiSuccess('', ['nickname' => $user['nickname'],'avatar'=>$user['avatar']]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -4,9 +4,9 @@ namespace app\api\controller;
|
||||
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use Firebase\JWT\JWT;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
use fast\Random;
|
||||
use think\exception\ValidateException;
|
||||
use think\facade\Request;
|
||||
|
||||
@ -190,7 +190,7 @@ class Userinfo extends BaseController
|
||||
// $ret = $this->auth->login($user['username'], '');
|
||||
// if ($ret) {
|
||||
//创建新Token
|
||||
$token = Random::uuid();
|
||||
$token = $this->getToken($user['id']);
|
||||
\app\common\library\Token::set($token, $user['id'], 2592000);
|
||||
$tokenInfo = \app\common\library\Token::get($token);
|
||||
$Userinfo = $user;
|
||||
@ -224,6 +224,27 @@ class Userinfo extends BaseController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $user_id
|
||||
* @return string
|
||||
*/
|
||||
public function getToken($user_id){
|
||||
$time = time(); //当前时间
|
||||
$conf = $this->jwt_conf;
|
||||
$token = [
|
||||
'iss' => $conf['iss'], //签发者 可选
|
||||
'aud' => $conf['aud'], //接收该JWT的一方,可选
|
||||
'iat' => $time, //签发时间
|
||||
'nbf' => $time-1 , //(Not Before):某个时间点后才能访问,比如设置time+30,表示当前时间30秒后才能使用
|
||||
'exp' => $time+$conf['exptime'], //过期时间,这里设置2个小时
|
||||
'data' => [
|
||||
//自定义信息,不要定义敏感信息
|
||||
'userid' =>$user_id,
|
||||
]
|
||||
];
|
||||
return JWT::encode($token, $conf['secrect'], 'HS256'); //输出Token 默认'HS256'
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 根据身份证号码获取性别
|
||||
|
@ -319,6 +319,7 @@ class Village extends BaseController
|
||||
}
|
||||
$this->apiSuccess('获取成功', $news);
|
||||
} else {
|
||||
$news['id'] = $address['village_id'];
|
||||
$news['title'] = $address_name;
|
||||
$news['address'] = $address_name;
|
||||
$news['images'] = ["https://lihai001.oss-cn-chengdu.aliyuncs.com/uploads/20230115/4dc84e69408fef859e8553a5c7091197.jpg"];
|
||||
|
@ -1,18 +1,24 @@
|
||||
<?php
|
||||
namespace app\api\controller\party;
|
||||
use app\common\controller\Api;
|
||||
use app\admin\model\party\Article as ArticleModel;
|
||||
use app\admin\validate\party\Article as ArticleValdate;
|
||||
use think\facade\Cache;
|
||||
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
|
||||
|
||||
/**
|
||||
* 党群文章
|
||||
*/
|
||||
class Article extends Api{
|
||||
protected $noNeedLogin = ['index','details'];
|
||||
protected $noNeedRight = ['*'];
|
||||
class Article extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => ['index','hot_list','getArticleList','details','indexs'] ]
|
||||
];
|
||||
|
||||
public function index($search='',$category_id=1,$page=1) {
|
||||
$order = $this->request->request('order', 1);
|
||||
@ -22,14 +28,13 @@ class Article extends Api{
|
||||
}else{
|
||||
$orders='asc';
|
||||
}
|
||||
$model = new ArticleModel();
|
||||
$where=[
|
||||
['status','=', 1],
|
||||
['category_id','=', $category_id]
|
||||
];
|
||||
//根据个人村id进行查询
|
||||
if ($this->auth->id) {
|
||||
$find = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->find();
|
||||
if (JWT_UID) {
|
||||
$find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
|
||||
if ($find) {
|
||||
if ($find['auth_range']==1){
|
||||
$where[] = ['village', '=', $find['village_id']];
|
||||
@ -40,19 +45,18 @@ class Article extends Api{
|
||||
}
|
||||
}
|
||||
}
|
||||
$count=$model->where($where)->count();
|
||||
$month_count=$model->where($where)->whereMonth('view_time')->count();
|
||||
$count=Db::table('fa_szxc_party_article')->where($where)->count();
|
||||
$month_count=Db::table('fa_szxc_party_article')->where($where)->whereMonth('view_time')->count();
|
||||
if ($search!=''){
|
||||
$where[]=['title','like','%'.$search.'%'];
|
||||
}
|
||||
$select=$model->with('user')->where($where)->page($page)->limit(20)
|
||||
$select=Db::table('fa_szxc_party_article')->with('user')->where($where)->page($page)->limit(20)
|
||||
->field('id,title,user_id,view,view_time,image')->order('id',$orders)->select();
|
||||
return $this->success('ok',['list'=>$select,'count'=>['count'=>$count,'month_count'=>$month_count]]);
|
||||
return $this->apiSuccess('ok',['list'=>$select,'count'=>['count'=>$count,'month_count'=>$month_count]]);
|
||||
}
|
||||
public function details($id)
|
||||
{
|
||||
$model = new ArticleModel();
|
||||
$find=$model->where('id',$id)->find();
|
||||
$find=Db::table('fa_szxc_party_article')->where('id',$id)->find();
|
||||
if ($find){
|
||||
// 增加阅读数
|
||||
// $ip = 'party_article-details-'.$this->request->ip().'-'.$id;
|
||||
@ -60,23 +64,22 @@ class Article extends Api{
|
||||
// if(empty($ip_cache)){
|
||||
// Cache::set($ip,$id,3600*24);
|
||||
$map[] =['id','=', $id];
|
||||
Db::name('szxc_party_article')->where($map)->inc('view','1')->update();
|
||||
Db::table('fa_szxc_party_article')->where($map)->inc('view','1')->update();
|
||||
// }
|
||||
}
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
}
|
||||
public function add(){
|
||||
|
||||
}
|
||||
public function post(){
|
||||
$input=$this->request->post();
|
||||
$valdate = new ArticleValdate();
|
||||
$res=$valdate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($valdate->getError());
|
||||
}
|
||||
$model = new ArticleModel();
|
||||
$useraddress = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->where('status', 1)->find();
|
||||
$input=get_params();
|
||||
// $valdate = new ArticleValdate();
|
||||
// $res=$valdate->check($input);
|
||||
// if (!$res){
|
||||
// return $this->apiError($valdate->getError());
|
||||
// }
|
||||
$useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->where('status', 1)->find();
|
||||
if ($useraddress) {
|
||||
$input['county'] = $useraddress['area_id'];
|
||||
$input['township'] = $useraddress['street_id'];
|
||||
@ -84,43 +87,40 @@ class Article extends Api{
|
||||
}
|
||||
$input['add_time'] = date('Y-m-d H:i:s');
|
||||
$input['view_time'] = date('Y-m-d H:i:s');
|
||||
$input['user_id'] = $this->auth->id;
|
||||
$res=$model->save($input);
|
||||
$input['user_id'] = JWT_UID;
|
||||
$res=Db::table('fa_szxc_party_article')->save($input);
|
||||
if ($res){
|
||||
return $this->success('添加成功');
|
||||
return $this->apiSuccess('添加成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit($id){
|
||||
$model = new ArticleModel();
|
||||
$find=$model->where('id',$id)->find();
|
||||
return $this->success('ok',$find);
|
||||
$find=Db::table('fa_szxc_party_article')->where('id',$id)->find();
|
||||
return $this->apiSuccess('ok',$find);
|
||||
|
||||
}
|
||||
public function put($id){
|
||||
$input=$this->request->post();
|
||||
$valdate = new ArticleValdate();
|
||||
$res=$valdate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($valdate->getError());
|
||||
}
|
||||
$model = new ArticleModel();
|
||||
$input['user_id'] = $this->auth->id;
|
||||
$res=$model->where('id',$id)->update($input);
|
||||
$input=get_params();
|
||||
// $valdate = new ArticleValdate();
|
||||
// $res=$valdate->check($input);
|
||||
// if (!$res){
|
||||
// return $this->apiError($valdate->getError());
|
||||
// }
|
||||
$input['user_id'] = JWT_UID;
|
||||
$res=Db::table('fa_szxc_party_article')->where('id',$id)->update($input);
|
||||
if ($res){
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
public function delete($id){
|
||||
$model = new ArticleModel();
|
||||
$res=$model->where('id',$id)->update(['status'=>0]);
|
||||
$res=Db::table('fa_szxc_party_article')->where('id',$id)->update(['status'=>0]);
|
||||
if ($res){
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,28 @@
|
||||
<?php
|
||||
namespace app\api\controller\party;
|
||||
use app\admin\model\User;
|
||||
use app\common\controller\Api;
|
||||
use app\admin\model\party\Branch as BranchModel;
|
||||
|
||||
use app\admin\validate\party\Branch as BranchValdate;
|
||||
use think\App;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 党支部
|
||||
*/
|
||||
class Branch extends Api{
|
||||
class Branch extends BaseController{
|
||||
|
||||
protected $noNeedRight = ['*'];
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new BranchModel();
|
||||
$this->model = Db::table('fa_szxc_party_branch');
|
||||
$this->validate = new BranchValdate();
|
||||
}
|
||||
|
||||
@ -25,8 +31,8 @@ class Branch extends Api{
|
||||
['status','=', 1],
|
||||
];
|
||||
//根据个人村id进行查询
|
||||
if ($this->auth->id) {
|
||||
$find = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->find();
|
||||
if (JWT_UID) {
|
||||
$find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
|
||||
if ($find) {
|
||||
if ($find['auth_range']==1){
|
||||
$where[] = ['village', '=', $find['village_id']];
|
||||
@ -37,23 +43,23 @@ class Branch extends Api{
|
||||
}
|
||||
}
|
||||
}
|
||||
$select=Db::name('szxc_party_branch')->where($where)
|
||||
$select=Db::table('fa_szxc_party_branch')->where($where)
|
||||
->withAttr('nickname',function ($value, $data){
|
||||
$find= Db::name('user')->where('id',$data['user_id'])->field('nickname')->find();
|
||||
$find= Db::table('fa_user')->where('id',$data['user_id'])->field('nickname')->find();
|
||||
return $find?$find['nickname']:'';
|
||||
})
|
||||
->withAttr('two_nickname',function ($value, $data){
|
||||
$find= Db::name('user')->where('id',$data['two_user_id'])->field('nickname')->find();
|
||||
$find= Db::table('fa_user')->where('id',$data['two_user_id'])->field('nickname')->find();
|
||||
return $find?$find['nickname']:'';
|
||||
})
|
||||
->withAttr('count',function ($value, $data){
|
||||
$find= Db::name('szxc_party_info')->where('party_branch',$data['id'])->where('branch_type',1)->count();
|
||||
$find= Db::table('fa_szxc_party_info')->where('party_branch',$data['id'])->where('branch_type',1)->count();
|
||||
return $find;
|
||||
})
|
||||
->page($page)->limit(20)->select();
|
||||
$branch_count=Db::name('szxc_party_branch')->where('status', 1)->count();
|
||||
$info_count=Db::name('szxc_party_info')->where('status', 1)->where('branch_type',1)->count();
|
||||
$info_count_two=Db::name('szxc_party_info')->where('status', 1)->where('branch_type',2)->count();
|
||||
$branch_count=Db::table('fa_szxc_party_branch')->where('status', 1)->count();
|
||||
$info_count=Db::table('fa_szxc_party_info')->where('status', 1)->where('branch_type',1)->count();
|
||||
$info_count_two=Db::table('fa_szxc_party_info')->where('status', 1)->where('branch_type',2)->count();
|
||||
$data=[
|
||||
'page'=>$page,
|
||||
'branch_count'=>$branch_count,//支部总数
|
||||
@ -61,7 +67,7 @@ class Branch extends Api{
|
||||
'info_count_two'=>$info_count_two,//预备役总数
|
||||
'list' =>$select//党支部列表
|
||||
];
|
||||
return $this->success('ok',$data);
|
||||
return $this->apiSuccess('ok',$data);
|
||||
}
|
||||
/** 党员信息
|
||||
* @param $search
|
||||
@ -73,33 +79,33 @@ class Branch extends Api{
|
||||
['user_id','=',$id],
|
||||
];
|
||||
|
||||
$user_info=Db::name('szxc_information_usermsg')->where($where)
|
||||
$user_info=Db::table('fa_szxc_information_usermsg')->where($where)
|
||||
->withAttr('category_info',function ($value, $data){
|
||||
$find=Db::name('category')->where('id',$data['marital_status'])->find();
|
||||
$nation=Db::name('category')->where('id',$data['nation'])->find();
|
||||
$find=Db::table('fa_category')->where('id',$data['marital_status'])->find();
|
||||
$nation=Db::table('fa_category')->where('id',$data['nation'])->find();
|
||||
$datas['marital']=$find['name'];
|
||||
$datas['nation']=$nation['name'];
|
||||
return $datas;
|
||||
})
|
||||
->withAttr('branch_info',function ($value, $data){
|
||||
$find=Db::name('szxc_party_branch')->where('id',$data['branch_id'])
|
||||
$find=Db::table('fa_szxc_party_branch')->where('id',$data['branch_id'])
|
||||
->withAttr('user_nickname',function ($value, $data){
|
||||
$find=Db::name('szxc_information_usermsg')->where('user_id',$data['user_id'])->field('name')->find();
|
||||
$find=Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->field('name')->find();
|
||||
return $find?$find['name']:'';
|
||||
})
|
||||
->withAttr('two_user_nickname',function ($value, $data){
|
||||
$find=Db::name('szxc_information_usermsg')->where('user_id',$data['two_user_id'])->field('name')->find();
|
||||
$find=Db::table('fa_szxc_information_usermsg')->where('user_id',$data['two_user_id'])->field('name')->find();
|
||||
return $find?$find['name']:'';
|
||||
})
|
||||
->find();
|
||||
return $find;
|
||||
})
|
||||
->withAttr('branch_user_info',function ($value, $data){
|
||||
$find=Db::name('szxc_party_info')->where('user_id',$data['user_id'])->find();
|
||||
$find=Db::table('fa_szxc_party_info')->where('user_id',$data['user_id'])->find();
|
||||
return $find;
|
||||
})
|
||||
->find();
|
||||
return $this->success('ok',$user_info);
|
||||
return $this->apiSuccess('ok',$user_info);
|
||||
}
|
||||
public function info_save($id,$branch_id) {
|
||||
// $where=[
|
||||
@ -107,18 +113,18 @@ class Branch extends Api{
|
||||
// ['user_id','=',$id],
|
||||
// ['branch_id','=',$id],
|
||||
// ];
|
||||
$input=$this->request->post();
|
||||
$input=get_params();
|
||||
|
||||
$find=Db::name('szxc_party_info')->where('user_id',$id)->find();
|
||||
$find=Db::table('fa_szxc_party_info')->where('user_id',$id)->find();
|
||||
if ($find){
|
||||
Db::name('szxc_party_info')->where('user_id',$id)->update($input);
|
||||
return $this->success('ok','修改成功');
|
||||
Db::table('fa_szxc_party_info')->where('user_id',$id)->update($input);
|
||||
return $this->apiSuccess('ok','修改成功');
|
||||
|
||||
}else{
|
||||
$input['party_branch']=$branch_id;
|
||||
$input['user_id']=$id;
|
||||
Db::name('szxc_party_info')->insert($input);
|
||||
return $this->success('ok','添加成功');
|
||||
Db::table('fa_szxc_party_info')->insert($input);
|
||||
return $this->apiSuccess('ok','添加成功');
|
||||
|
||||
};
|
||||
}
|
||||
@ -134,16 +140,16 @@ class Branch extends Api{
|
||||
if ($search!=''){
|
||||
$where[]=['title','like','%'.$search.'%'];
|
||||
}
|
||||
$branch=Db::name('szxc_party_branch')->where('id',$id)->find();
|
||||
$branch=Db::table('fa_szxc_party_branch')->where('id',$id)->find();
|
||||
|
||||
$select = Db::name('szxc_party_info')->withAttr('user_info', function ($value, $data) {
|
||||
$find = Db::name('user')->where('id', $data['user_id'])->field('nickname,mobile,avatar')->find();
|
||||
$select = Db::table('fa_szxc_party_info')->withAttr('user_info', function ($value, $data) {
|
||||
$find = Db::table('fa_user')->where('id', $data['user_id'])->field('nickname,mobile,avatar')->find();
|
||||
return $find;
|
||||
})
|
||||
->where($where)->page($page)->limit(20)->select();
|
||||
|
||||
$info_count=Db::name('szxc_party_info')->where('status', 1)->where('branch_type',1)->count();
|
||||
$info_count_two=Db::name('szxc_party_info')->where('status', 1)->where('branch_type',2)->count();
|
||||
$info_count=Db::table('fa_szxc_party_info')->where('status', 1)->where('branch_type',1)->count();
|
||||
$info_count_two=Db::table('fa_szxc_party_info')->where('status', 1)->where('branch_type',2)->count();
|
||||
$data=[
|
||||
'page'=>$page,
|
||||
'branch'=>$branch,
|
||||
@ -151,56 +157,56 @@ class Branch extends Api{
|
||||
'info_count_two'=>$info_count_two,//预备役总数
|
||||
'list' =>$select//党员列表
|
||||
];
|
||||
return $this->success('ok',$data);
|
||||
return $this->apiSuccess('ok',$data);
|
||||
}
|
||||
public function add(){
|
||||
|
||||
}
|
||||
public function post(){
|
||||
$input=$this->request->post();
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$res=$this->model->save($input);
|
||||
if ($res){
|
||||
return $this->success('添加成功');
|
||||
return $this->apiSuccess('添加成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit($id){
|
||||
$find=Db::name('szxc_party_branch')->where('id',$id)->where('status', 1)
|
||||
$find=Db::table('fa_szxc_party_branch')->where('id',$id)->where('status', 1)
|
||||
->withAttr('nickname',function ($value, $data){
|
||||
$find= Db::name('user')->where('id',$data['user_id'])->field('nickname')->find();
|
||||
$find= Db::table('fa_user')->where('id',$data['user_id'])->field('nickname')->find();
|
||||
return $find?$find['nickname']:'';
|
||||
})
|
||||
->withAttr('two_nickname',function ($value, $data){
|
||||
$find= Db::name('user')->where('id',$data['two_user_id'])->field('nickname')->find();
|
||||
$find= Db::table('fa_user')->where('id',$data['two_user_id'])->field('nickname')->find();
|
||||
return $find?$find['nickname']:'';
|
||||
})->find();
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
|
||||
}
|
||||
public function put($id){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();;
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$res=$this->model->where('id',$id)->update($input);
|
||||
if ($res){
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
public function delete($id){
|
||||
$res=$this->model->where('id',$id)->update(['status'=>0]);
|
||||
if ($res){
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,22 +2,28 @@
|
||||
|
||||
namespace app\api\controller\party;
|
||||
|
||||
use app\common\controller\Api;
|
||||
use app\admin\model\party\BranchPayList as BranchPayListModel;
|
||||
use app\admin\validate\party\BranchPayList as BranchPayListValdate;
|
||||
use think\App;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 党费列表
|
||||
*/
|
||||
class BranchPayList extends Api
|
||||
class BranchPayList extends BaseController
|
||||
{
|
||||
protected $noNeedRight = ['*'];
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new BranchPayListModel();
|
||||
$this->model = Db::table('fa_szxc_party_branch_pay_list');
|
||||
$this->validate = new BranchPayListValdate();
|
||||
}
|
||||
|
||||
@ -32,30 +38,30 @@ class BranchPayList extends Api
|
||||
*/
|
||||
public function index($search = '', $page = 1)
|
||||
{
|
||||
$select = Db::name('szxc_party_branch')->where('status', 1)
|
||||
$select = Db::table('fa_szxc_party_branch')->where('status', 1)
|
||||
->withAttr('pay_info', function ($data, $value) {
|
||||
$find = Db::name('szxc_party_branch_pay_list')->where('branch_id',$value['id'])->where('status', 1)->field('pay,no_pay')->find();
|
||||
$find = Db::table('fa_szxc_party_branch_pay_list')->where('branch_id',$value['id'])->where('status', 1)->field('pay,no_pay')->find();
|
||||
return $find;
|
||||
})->withAttr('nickname', function ($datas, $value) {
|
||||
$finds = Db::name('user')->where('id', $value['user_id'])->field('nickname')->find();
|
||||
$finds = Db::table('fa_user')->where('id', $value['user_id'])->field('nickname')->find();
|
||||
return $finds?$finds['nickname']:'';
|
||||
})
|
||||
->withAttr('two_nickname', function ($datas, $value) {
|
||||
$finds = Db::name('user')->where('id', $value['two_user_id'])->field('nickname')->find();
|
||||
$finds = Db::table('fa_user')->where('id', $value['two_user_id'])->field('nickname')->find();
|
||||
return $finds?$finds['nickname']:'';
|
||||
})
|
||||
->page($page)->limit(20)->select();
|
||||
$branch_count = $this->model->where('status', 1)->count();
|
||||
$branch_pay_count = $this->model->where('status', 1)->sum('pay');
|
||||
$branch_no_pay_count = $this->model->where('status', 1)->sum('no_pay');
|
||||
return $this->success('ok', ['list' => $select,
|
||||
return $this->apiSuccess('ok', ['list' => $select,
|
||||
'branch' => ['branch_count' => $branch_count, 'branch_pay_count' => $branch_pay_count, 'branch_no_pay_count' => $branch_no_pay_count]]);
|
||||
}
|
||||
|
||||
public function branch_pay_list($id,$page=1){
|
||||
$select = $this->model->where('branch_id',$id)->where('status', 1)->page($page)->select();
|
||||
$count = $this->model->where('branch_id',$id)->where('status', 1)->count();
|
||||
return $this->success('ok', ['list' => $select, 'count' =>$count]);
|
||||
return $this->apiSuccess('ok', ['list' => $select, 'count' =>$count]);
|
||||
|
||||
}
|
||||
|
||||
@ -66,41 +72,41 @@ class BranchPayList extends Api
|
||||
|
||||
public function post()
|
||||
{
|
||||
$input = $this->request->post();
|
||||
$input = get_params();
|
||||
$res = $this->validate->check($input);
|
||||
if (!$res) {
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$input['pay'] = 0;
|
||||
$input['no_pay'] = 0;
|
||||
$input['status'] = 0;
|
||||
$res = BranchPayListModel::create($input);
|
||||
$res = Db::table('fa_szxc_party_branch_pay_list')->insert($input);
|
||||
if ($res) {
|
||||
return $this->success('添加成功', ['id' => $res->id]);
|
||||
return $this->apiSuccess('添加成功', ['id' => $res->id]);
|
||||
} else {
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
$find = $this->model->with('branch')->where('id', $id)->find();
|
||||
return $this->success('ok', $find);
|
||||
return $this->apiSuccess('ok', $find);
|
||||
|
||||
}
|
||||
|
||||
public function put($id)
|
||||
{
|
||||
$input = $this->request->post();;
|
||||
$input = get_params();;
|
||||
$res = $this->validate->check($input);
|
||||
if (!$res) {
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$res = $this->model->where('id', $id)->update($input);
|
||||
if ($res) {
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
} else {
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,9 +114,9 @@ class BranchPayList extends Api
|
||||
{
|
||||
$res = $this->model->where('id', $id)->update(['status' => 0]);
|
||||
if ($res) {
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
} else {
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +1,39 @@
|
||||
<?php
|
||||
namespace app\api\controller\party;
|
||||
use app\common\controller\Api;
|
||||
use app\admin\model\party\BranchPayUser as BranchPayUsertModel;
|
||||
|
||||
use app\admin\validate\party\BranchPayUser as BranchPayUserValdate;
|
||||
use app\admin\model\party\BranchPayList;
|
||||
use think\App;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 党支部
|
||||
*/
|
||||
class BranchPayUser extends Api{
|
||||
class BranchPayUser extends BaseController{
|
||||
|
||||
protected $noNeedRight = ['*'];
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new BranchPayUsertModel();
|
||||
$this->model = Db::table('fa_szxc_party_branch_pay_user');
|
||||
$this->validate = new BranchPayUserValdate();
|
||||
}
|
||||
public function index($id,$page=1,$search='',$type=0) {
|
||||
$find=BranchPayList::where('id',$id)->find();
|
||||
$find=Db::table('fa_szxc_party_branch_pay_list')->where('id',$id)->find();
|
||||
if (!$find) return $this->edit('清单数据不存在');
|
||||
$where=[
|
||||
['branch_id','=',$find['branch_id']],
|
||||
['status','=', 1]
|
||||
];
|
||||
if ($search!=''){
|
||||
$userall=Db::name('user')->where('nickname','like', $search . '%')->field('id')->select();
|
||||
$userall=Db::table('fa_user')->where('nickname','like', $search . '%')->field('id')->select();
|
||||
if ($userall){
|
||||
$ids=[];
|
||||
foreach ($userall as $user){
|
||||
@ -35,39 +41,39 @@ class BranchPayUser extends Api{
|
||||
}
|
||||
$where[]=['user_id','in',implode(',',$ids)];
|
||||
}else{
|
||||
return $this->error('查询内容不存在');
|
||||
return $this->apiError('查询内容不存在');
|
||||
}
|
||||
|
||||
}
|
||||
if ($type>0){
|
||||
$where[]=['is_pay','=',$type];
|
||||
}
|
||||
$select=Db::name('szxc_party_branch_pay_user')->where($where)
|
||||
$select=Db::table('fa_szxc_party_branch_pay_user')->where($where)
|
||||
->withAttr('user',function ($value, $data){
|
||||
$user = Db::name('user')->where('id',$data['user_id'])->field('nickname,avatar')->find();
|
||||
$user = Db::table('fa_user')->where('id',$data['user_id'])->field('nickname,avatar')->find();
|
||||
return $user;
|
||||
|
||||
})
|
||||
->page($page)->limit(20)->select();
|
||||
$count=Db::name('szxc_party_info')->where('party_branch',$id)->count();
|
||||
$count=Db::table('fa_szxc_party_info')->where('party_branch',$id)->count();
|
||||
|
||||
$data['info']=$find;
|
||||
$data['list']=$select;
|
||||
$data['count']=$count;
|
||||
return $this->success('ok',$data);
|
||||
return $this->apiSuccess('ok',$data);
|
||||
}
|
||||
|
||||
public function add($id,$page=1){
|
||||
$find=BranchPayList::where('id',$id)->find();
|
||||
$find=Db::table('fa_szxc_party_branch_pay_list')->where('id',$id)->find();
|
||||
$strtotime1=strtotime($find['start_time']);
|
||||
$strtotime2=strtotime($find['end_time']);
|
||||
$m=date('m',$strtotime1);
|
||||
$ms=date('m',$strtotime2);
|
||||
$m_count=$ms-$m;
|
||||
if (!$find) return $this->edit('清单数据不存在');
|
||||
$select=Db::name('szxc_party_info')->where('party_branch',$find['branch_id'])
|
||||
$select=Db::table('fa_szxc_party_info')->where('party_branch',$find['branch_id'])
|
||||
->withAttr('user_info',function($data,$value){
|
||||
$user = Db::name('user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$user = Db::table('fa_user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
return $user;
|
||||
})->field('id,user_id,branch_pay')
|
||||
->select();
|
||||
@ -76,52 +82,52 @@ class BranchPayUser extends Api{
|
||||
$data_list[$key]['month_pay_count']= $value['branch_pay']*$m_count;
|
||||
$data_list[$key]['month_count']=$m_count;
|
||||
}
|
||||
$count=Db::name('szxc_party_info')->where('party_branch',$find['branch_id'])->count();
|
||||
$count=Db::table('fa_szxc_party_info')->where('party_branch',$find['branch_id'])->count();
|
||||
$data['info']=$find;
|
||||
$data['list']=$data_list;
|
||||
$data['count']=$count;
|
||||
return $this->success('ok',$data);
|
||||
return $this->apiSuccess('ok',$data);
|
||||
|
||||
}
|
||||
public function post(){
|
||||
$input=$this->request->post();
|
||||
$input=get_params();
|
||||
foreach ($input as $k=>$v){
|
||||
$res=$this->validate->check($v);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
}
|
||||
$res=$this->model->saveAll($input);
|
||||
if ($res){
|
||||
return $this->success('添加成功');
|
||||
return $this->apiSuccess('添加成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit($id){
|
||||
$find=$this->model->where('id',$id)->find();
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
|
||||
}
|
||||
public function put($id){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();;
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$res=$this->model->where('id',$id)->update($input);
|
||||
if ($res){
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
public function delete($id){
|
||||
$res=$this->model->where('id',$id)->update(['status'=>0]);
|
||||
if ($res){
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +1,27 @@
|
||||
<?php
|
||||
namespace app\api\controller\party;
|
||||
use app\common\controller\Api;
|
||||
use app\admin\model\party\Info as InfoModel;
|
||||
|
||||
use app\admin\validate\party\Info as InfoValdate;
|
||||
use think\App;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 党员维护
|
||||
*/
|
||||
class Info extends Api{
|
||||
// protected $noNeedLogin = ['index'];
|
||||
protected $noNeedLogin = ['*'];
|
||||
class Info extends BaseController{
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new InfoModel();
|
||||
$this->model = Db::table('fa_szxc_party_info');
|
||||
$this->validate = new InfoValdate();
|
||||
}
|
||||
public function index($search='',$page=1,$type=0,$branch_id=0) {
|
||||
@ -23,7 +29,7 @@ class Info extends Api{
|
||||
['status','=', 1]
|
||||
];
|
||||
if ($search!=''){
|
||||
$userall=Db::name('user')->where('nickname','like', $search . '%')->field('id')->select();
|
||||
$userall=Db::table('fa_user')->where('nickname','like', $search . '%')->field('id')->select();
|
||||
if ($userall){
|
||||
$ids=[];
|
||||
foreach ($userall as $user){
|
||||
@ -31,7 +37,7 @@ class Info extends Api{
|
||||
}
|
||||
$where[]=['user_id','in',implode(',',$ids)];
|
||||
}else{
|
||||
return $this->error('查询内容不存在');
|
||||
return $this->apiError('查询内容不存在');
|
||||
}
|
||||
}
|
||||
if ($type>0){
|
||||
@ -40,65 +46,65 @@ class Info extends Api{
|
||||
if ($branch_id!=0){
|
||||
$where[]=['party_branch','=',$branch_id];
|
||||
}
|
||||
$select=Db::name('szxc_party_info')->where($where)
|
||||
$select=Db::table('fa_szxc_party_info')->where($where)
|
||||
->withAttr('user_info',function ($value, $data){
|
||||
$user = Db::name('user')->where('id',$data['user_id'])->field('nickname,avatar,mobile')->find();
|
||||
$usermsg = Db::name('szxc_information_usermsg')->where('user_id',$data['user_id'])->field('idcard')->find();
|
||||
$user = Db::table('fa_user')->where('id',$data['user_id'])->field('nickname,avatar,mobile')->find();
|
||||
$usermsg = Db::table('fa_szxc_information_usermsg')->where('user_id',$data['user_id'])->field('idcard')->find();
|
||||
$user['idcard'] =$usermsg?$usermsg['idcard']:'';
|
||||
return $user;
|
||||
})
|
||||
->withAttr('branch',function ($value, $data){
|
||||
$find = Db::name('szxc_party_branch')->where('id',$data['party_branch'])->field('company')->find();
|
||||
$find = Db::table('fa_szxc_party_branch')->where('id',$data['party_branch'])->field('company')->find();
|
||||
return $find['company'];
|
||||
})
|
||||
->page($page)->limit(20)->select();
|
||||
return $this->success('ok',$select);
|
||||
return $this->apiSuccess('ok',$select);
|
||||
}
|
||||
|
||||
public function add($user_id){
|
||||
$user = Db::name('user')->where('id',$user_id)->field('nickname,avatar,mobile,gender')->find();
|
||||
$usermsg = Db::name('szxc_information_usermsg')->where('user_id',$user_id)->field('idcard,age,political_outlook,marriage')->find();
|
||||
return $this->success('ok',['userinfo'=>array_merge($user,$usermsg)]);
|
||||
$user = Db::table('fa_user')->where('id',$user_id)->field('nickname,avatar,mobile,gender')->find();
|
||||
$usermsg = Db::table('fa_szxc_information_usermsg')->where('user_id',$user_id)->field('idcard,age,political_outlook,marriage')->find();
|
||||
return $this->apiSuccess('ok',['userinfo'=>array_merge($user,$usermsg)]);
|
||||
|
||||
}
|
||||
public function post(){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$res=$this->model->save($input);
|
||||
if ($res){
|
||||
return $this->success('添加成功');
|
||||
return $this->apiSuccess('添加成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit($id){
|
||||
$find=$this->model->where('id',$id)->find();
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
|
||||
}
|
||||
public function put($id){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$input['user_id'] = 1;
|
||||
$res=$this->model->where('id',$id)->update($input);
|
||||
if ($res){
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
public function delete($id){
|
||||
$res=$this->model->where('id',$id)->update(['status'=>0]);
|
||||
if ($res){
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,28 @@
|
||||
<?php
|
||||
namespace app\api\controller\party;
|
||||
use app\common\controller\Api;
|
||||
|
||||
use app\admin\model\party\Vote as VoteModel;
|
||||
use app\admin\validate\party\Vote as VoteValdate;
|
||||
use think\facade\Cache;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
use think\App;
|
||||
|
||||
/**
|
||||
* 党员维护
|
||||
*/
|
||||
class Vote extends Api{
|
||||
// protected $noNeedLogin = ['index'];
|
||||
protected $noNeedRight = ['*'];
|
||||
class Vote extends BaseController{
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new VoteModel();
|
||||
$this->model = Db::table('fa_szxc_party_vote');
|
||||
$this->validate = new VoteValdate();
|
||||
}
|
||||
public function index($search='',$page=1,$type=0,$screen=1) {
|
||||
@ -24,8 +30,8 @@ class Vote extends Api{
|
||||
['status','=', 1]
|
||||
];
|
||||
//根据个人村id进行查询
|
||||
if ($this->auth->id) {
|
||||
$find = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->find();
|
||||
if (JWT_UID) {
|
||||
$find = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->find();
|
||||
if ($find) {
|
||||
if ($find['auth_range']==1){
|
||||
$where[] = ['village', '=', $find['village_id']];
|
||||
@ -36,8 +42,8 @@ class Vote extends Api{
|
||||
}
|
||||
}
|
||||
}
|
||||
$count=Db::name('szxc_party_vote')->where($where)->count();
|
||||
$month_count=Db::name('szxc_party_vote')->where($where)->whereMonth('start_time')->count();
|
||||
$count=Db::table('fa_szxc_party_vote')->where($where)->count();
|
||||
$month_count=Db::table('fa_szxc_party_vote')->where($where)->whereMonth('start_time')->count();
|
||||
|
||||
if ($search!=''){
|
||||
$where[]=['title','like',$search.'%'];
|
||||
@ -48,7 +54,7 @@ class Vote extends Api{
|
||||
if ($screen==3){
|
||||
$where[]=['end_time','<=',date('Y-m-d')];
|
||||
}
|
||||
$select=Db::name('szxc_party_vote')->where($where)->page($page)->limit(20)
|
||||
$select=Db::table('fa_szxc_party_vote')->where($where)->page($page)->limit(20)
|
||||
->withAttr('percentage',function ($data,$value){
|
||||
$count=$value['agree']+$value['opposition']+$value['other'];
|
||||
$find['agree_percentage']=0;
|
||||
@ -64,11 +70,11 @@ class Vote extends Api{
|
||||
return $find;
|
||||
})
|
||||
->withAttr('nickname',function($value,$data){
|
||||
$find=Db::name('user')->where('id',$data['user_id'])->field('nickname')->find();
|
||||
$find=Db::table('fa_user')->where('id',$data['user_id'])->field('nickname')->find();
|
||||
return $find['nickname'];
|
||||
})->order('id DESC')
|
||||
->field('id,title,image,user_id,view,start_time,end_time,agree,opposition,other')->select();
|
||||
return $this->success('ok',['list'=>$select,'count'=>['count'=>$count,'month_count'=>$month_count]]);
|
||||
return $this->apiSuccess('ok',['list'=>$select,'count'=>['count'=>$count,'month_count'=>$month_count]]);
|
||||
}
|
||||
public function details($id)
|
||||
{
|
||||
@ -80,7 +86,7 @@ class Vote extends Api{
|
||||
// if(empty($ip_cache)){
|
||||
// Cache::set($ip,$id,3600*24);
|
||||
$map[] =['id','=', $id];
|
||||
Db::name('szxc_party_vote')->where($map)->inc('view','1')->update();
|
||||
Db::table('fa_szxc_party_vote')->where($map)->inc('view','1')->update();
|
||||
// }
|
||||
$count=$find['agree']+$find['opposition']+$find['other'];
|
||||
$find['agree_percentage']=0;
|
||||
@ -94,44 +100,44 @@ class Vote extends Api{
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
}
|
||||
public function add(){
|
||||
|
||||
}
|
||||
public function post(){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$useraddress = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->where('status', 1)->find();
|
||||
$useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->where('status', 1)->find();
|
||||
if ($useraddress) {
|
||||
$input['county'] = $useraddress['area_id'];
|
||||
$input['township'] = $useraddress['street_id'];
|
||||
$input['village'] = $useraddress['village_id'];
|
||||
}
|
||||
$input['user_id']=$this->auth->id;
|
||||
$input['user_id']=JWT_UID;
|
||||
$input['add_time']=date('Y-m-d H:i:s');
|
||||
$res=$this->model->save($input);
|
||||
if ($res){
|
||||
return $this->success('添加成功');
|
||||
return $this->apiSuccess('添加成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit($id){
|
||||
$find=$this->model->where('id',$id)->find();
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
|
||||
}
|
||||
public function put($id){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$useraddress = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->where('status', 1)->find();
|
||||
$useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->where('status', 1)->find();
|
||||
if ($useraddress) {
|
||||
$input['county'] = $useraddress['area_id'];
|
||||
$input['township'] = $useraddress['street_id'];
|
||||
@ -139,17 +145,17 @@ class Vote extends Api{
|
||||
}
|
||||
$res=$this->model->where('id',$id)->update($input);
|
||||
if ($res){
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
public function delete($id){
|
||||
$res=$this->model->where('id',$id)->update(['status'=>0]);
|
||||
if ($res){
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,27 +1,34 @@
|
||||
<?php
|
||||
namespace app\api\controller\party;
|
||||
use app\common\controller\Api;
|
||||
use app\admin\model\party\VoteComment as VoteCommentModel;
|
||||
|
||||
use app\admin\validate\party\VoteComment as VoteCommentValdate;
|
||||
use think\App;
|
||||
use app\api\BaseController;
|
||||
use app\api\middleware\Auth;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 党员维护
|
||||
*/
|
||||
class VoteComment extends Api{
|
||||
// protected $noNeedLogin = ['index'];
|
||||
protected $noNeedRight = ['*'];
|
||||
class VoteComment extends BaseController{
|
||||
/**
|
||||
* 控制器中间件 [不需要鉴权]
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
Auth::class => ['except' => [] ]
|
||||
];
|
||||
|
||||
public function __construct(App $app)
|
||||
{
|
||||
parent::__construct($app);
|
||||
$this->model = new VoteCommentModel();
|
||||
$this->model = Db::table('fa_szxc_party_vote_comment');
|
||||
$this->validate = new VoteCommentValdate();
|
||||
}
|
||||
public function index($search='',$vote_id=1,$page=1) {
|
||||
$select=Db::name('szxc_party_vote_comment')
|
||||
$select=Db::table('fa_szxc_party_vote_comment')
|
||||
->withAttr('user_info',function ($data,$value){
|
||||
$find=Db::name('user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$find=Db::table('fa_user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$data = $find;
|
||||
$data['user_type_info']='党员';
|
||||
return $data;
|
||||
@ -35,9 +42,9 @@ class VoteComment extends Api{
|
||||
return $find;
|
||||
})
|
||||
->where('vote_id', $vote_id)->where('status', 1)->where('type',1)->page($page)->limit(20)->select();
|
||||
$select_type2=Db::name('szxc_party_vote_comment')
|
||||
$select_type2=Db::table('fa_szxc_party_vote_comment')
|
||||
->withAttr('user_info',function ($data,$value){
|
||||
$find=Db::name('user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$find=Db::table('fa_user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$data = $find;
|
||||
$data['user_type_info']='党员';
|
||||
return $data;
|
||||
@ -51,9 +58,9 @@ class VoteComment extends Api{
|
||||
return $find;
|
||||
})
|
||||
->where('vote_id', $vote_id)->where('status', 1)->where('type',2)->page($page)->limit(20)->select();
|
||||
$select_type3=Db::name('szxc_party_vote_comment')
|
||||
$select_type3=Db::table('fa_szxc_party_vote_comment')
|
||||
->withAttr('user_info',function ($data,$value){
|
||||
$find=Db::name('user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$find=Db::table('fa_user')->where('id',$value['user_id'])->field('nickname,avatar')->find();
|
||||
$data = $find;
|
||||
$data['user_type_info']='党员';
|
||||
return $data;
|
||||
@ -67,19 +74,19 @@ class VoteComment extends Api{
|
||||
return $find;
|
||||
})
|
||||
->where('vote_id', $vote_id)->where('status', 1)->where('type',3)->page($page)->limit(20)->select();
|
||||
return $this->success('ok',['list1'=>$select,'list2'=>$select_type2,'list3'=>$select_type3]);
|
||||
return $this->apiSuccess('ok',['list1'=>$select,'list2'=>$select_type2,'list3'=>$select_type3]);
|
||||
}
|
||||
|
||||
public function add(){
|
||||
|
||||
}
|
||||
public function post(){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$useraddress = Db::name('szxc_information_useraddress')->where('user_id', $this->auth->id)->where('status', 1)->find();
|
||||
$useraddress = Db::table('fa_szxc_information_useraddress')->where('user_id', JWT_UID)->where('status', 1)->find();
|
||||
|
||||
if ($useraddress) {
|
||||
$input['county'] = $useraddress['area_id'];
|
||||
@ -91,36 +98,36 @@ class VoteComment extends Api{
|
||||
$input['add_time']=date('Y-m-d H:i:s');
|
||||
$res=$this->model->save($input);
|
||||
if ($res){
|
||||
return $this->success('评论成功');
|
||||
return $this->apiSuccess('评论成功');
|
||||
}else{
|
||||
return $this->error('添加失败');
|
||||
return $this->apiError('添加失败');
|
||||
}
|
||||
}
|
||||
public function edit($id){
|
||||
$find=$this->model->with('user')->where('id',$id)->find();
|
||||
return $this->success('ok',$find);
|
||||
return $this->apiSuccess('ok',$find);
|
||||
|
||||
}
|
||||
public function put($id){
|
||||
$input=$this->request->post();;
|
||||
$input=get_params();
|
||||
$res=$this->validate->check($input);
|
||||
if (!$res){
|
||||
return $this->error($this->validate->getError());
|
||||
return $this->apiError($this->validate->getError());
|
||||
}
|
||||
$input['user_id'] = 1;
|
||||
$res=$this->model->where('id',$id)->update($input);
|
||||
if ($res){
|
||||
return $this->success('修改成功');
|
||||
return $this->apiSuccess('修改成功');
|
||||
}else{
|
||||
return $this->error('修改失败');
|
||||
return $this->apiError('修改失败');
|
||||
}
|
||||
}
|
||||
public function delete($id){
|
||||
$res=$this->model->where('id',$id)->update(['status'=>0]);
|
||||
if ($res){
|
||||
return $this->success('删除成功');
|
||||
return $this->apiSuccess('删除成功');
|
||||
}else{
|
||||
return $this->error('删除失败');
|
||||
return $this->apiError('删除失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,9 +82,9 @@ class Maintainentry extends Validate
|
||||
* 验证场景.
|
||||
*/
|
||||
protected $scene = [
|
||||
'add' => ['name', 'gender_id', 'age', 'phone','idcard', 'marriage_id', 'zzmm_id', 'nation_id'],
|
||||
'add' => ['name', 'gender_id', 'age', 'phone','idcard', 'marriage_id', 'nation_id'],
|
||||
'myadd' => ['name', 'gender_id', 'age', 'phone','idcard', 'marriage_id', 'zzmm_id', 'nation_id'],
|
||||
'edit' => ['name', 'gender', 'age', 'phone','idcard', 'marriage_id', 'zzmm_id', 'nation_id'],
|
||||
'edit' => ['name', 'gender', 'age', 'phone','idcard', 'marriage_id', 'nation_id'],
|
||||
'insurancemsg' => ['endowment_insurance_status_id', 'insurance_type_id', 'disability_type_id','ny_insurance_id','sy_insurance_id'],
|
||||
];
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user