|
@@ -3,7 +3,7 @@
|
|
|
|
|
|
namespace app\admin\controller;
|
|
|
|
|
|
-use think\App;
|
|
|
+use app\admin\model\WechatUser;use think\App;
|
|
|
use think\facade\Validate;
|
|
|
use think\facade\Db;
|
|
|
class WeChat extends Base {
|
|
@@ -75,4 +75,41 @@ class WeChat extends Base {
|
|
|
}
|
|
|
return app_show(0,"获取成功",$baseconfig);
|
|
|
}
|
|
|
+
|
|
|
+ public function list(){
|
|
|
+ $post =$this->request->only(['mobile'=>'',"nickname"=>"","page"=>1,"size"=>10],'post','trim');
|
|
|
+ $where=[];
|
|
|
+ if($post['mobile']!='')$where[]=["mobile","like","%{$post['mobile']}%"];
|
|
|
+ if($post['nickname']!='')$where[]=["nickname","like","%{$post['nickname']}%"];
|
|
|
+ $list =(new WechatUser())->where($where)->json(['companyArr'])->paginate(["page"=>$post['page'],"list_rows"=>$post['size']]);
|
|
|
+ $this->success("获取成功",["list"=>$list->items(),"count"=>$list->total()]);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function save(){
|
|
|
+ $post =$this->request->only([
|
|
|
+ "id"=>"",
|
|
|
+ 'mobile'=>'',
|
|
|
+ 'nickname'=>'',
|
|
|
+ 'is_show'=>'',
|
|
|
+ 'companyArr'=>[],
|
|
|
+ ],'post','trim');
|
|
|
+ $valid =Validate::rule([
|
|
|
+ "id|主键id"=>"require|number",
|
|
|
+ "mobile|手机号"=>"require|mobile",
|
|
|
+ "nickname|名称"=>"require",
|
|
|
+ "is_show|可查看报表"=>"require",
|
|
|
+ "companyArr|可查看企业"=>"require|array"
|
|
|
+ ]);
|
|
|
+ if($valid->check($post)==false)$this->error($valid->getError());
|
|
|
+ $model = new WechatUser();
|
|
|
+ $info =$model->findOrEmpty($post['id']);
|
|
|
+ if($info->isEmpty())$this->error("未找到用户数据");
|
|
|
+ $info->mobile = $post['mobile'];
|
|
|
+ $info->nickname = $post['nickname'];
|
|
|
+ $info->is_show = $post['is_show'];
|
|
|
+ $info->companyArr = json_encode($post['companyArr'],JSON_UNESCAPED_UNICODE);
|
|
|
+ $info->save();
|
|
|
+ $this->success('更新成功');
|
|
|
+ }
|
|
|
+
|
|
|
}
|