123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- <?php
- namespace app\admin\controller;
- use app\BaseController;
- use think\App;
- use think\console\command\Make;
- use think\facade\Db;
- class Cloud extends BaseController
- {
- public $post = "";
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->post = $this->request->post();
- }
- public function upload(){
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $effect = VerifyTokens($token);
- if(!empty($effect)&& $effect['code']!=0){
- return error_show($effect['code'],$effect['message']);
- }
- $files = $this->request->file('image');
- $list="";
- if($files!=""){
- $list = UploadImg($files);
- }
- if(is_array($list) &&!empty($list)){
- return app_show(0,"上传成功",$list);
- }else{
- return app_show(1005,"上传失败".$list);
- }
- }
- public function create(){
- $token= isset($this->post['token'])&& $this->post['token'] !==""? trim($this->post['token']) :"";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
- if($bugNo==""){
- return error_show(1002,"参数bugNo不能为空");
- }
- $str=Db::name('note')->where(['bugNo'=>$bugNo])->find();
- if(empty($str)){
- return error_show(1002,"未找到数据");
- }
- $talk_note = isset($this->post['talk_note']) && $this->post['talk_note'] !=="" ? trim($this->post['talk_note']) :"";
- if($talk_note==""){
- return error_show(1002,"参数talk_note不能为空");
- }
- // $is_edit = isset($this->post['is_edit']) && $this->post['is_edit'] !=="" ? intval($this->post['is_edit']) :"";
- // if ($is_edit==""){
- // return error_show(1002,"参数is_edit不能为空");
- // }
- $apply_id =VerifyTokens($token);
- if(empty($apply_id)||$apply_id['code']!=0){
- return error_show(1002,"申请人数据不存在");
- }
- $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
- $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
- $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"1";
- $data = [
- "talk_name"=>$ri,
- "talk_id"=>$rm,
- "talk_note"=>$talk_note,
- "bugNo"=>$bugNo,
- "status"=>$status,
- "is_del"=>0,
- // "is_edit"=>$is_edit,
- "addtime"=>date("Y-m-d H:i:s"),
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $datainfo = Db::name('talk')->insert($data);
- if($datainfo){
- return error_show(0,"添加成功");
- }else{
- return error_show(1002,"添加失败");
- }
- }
- public function list(){
- $token= isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- // var_dump($this->post);
- $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
- if($id==""){
- return error_show(1002,"参数id不能为空");
- }
- $str=Db::name('note')->where(['id'=>$id])->find();
- if(empty($str)){
- return error_show(1002,"未找到数据");
- }
- $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
- $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
- $where =[['is_del','=',0],['bugNo',"=",$str['bugNo']]];
- $talk_id = isset($this->post['talk_id']) && $this->post['talk_id']!==""? intval($this->post['talk_id']):"";
- if($talk_id!==""){
- $where[]=['talk_id','=',$talk_id];
- }
- $talk_name = isset($this->post['talk_name']) && $this->post['talk_name']!==""? intval($this->post['talk_name']):"";
- if($talk_name!==""){
- $where[]=["talk_name","like","%$talk_name%"];
- }
- $bugNo = isset($this->post['bugNo']) && $this->post['bugNo']!==""? trim($this->post['bugNo']):"";
- if($bugNo!==""){
- $where[]=["bugNo","like","%$bugNo%"];
- }
- $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
- if($start!==""){
- $where[]=['addtime',">=",$start];
- }
- $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
- if($end!==""){
- $where[]=['addtime',"<=",$end];
- }
- $count = Db::name('talk')->where($where)->count();
- $total = ceil($count/$size);
- $page = $page>$total ? $total:$page;
- $list = Db::name('talk')->where($where)->page($page,$size)->order("addtime desc")->select();
- $apply_id =VerifyTokens($token);
- // var_dump($apply_id);
- if(empty($apply_id)||$apply_id['code']!=0){
- return error_show(1002,"申请人数据不存在");
- }
- $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
- $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
- $data =[];
- foreach ($list as $value){
- $value['is_edit']=$value['talk_id'] !=$rm ?"1":"0";
- $data[]=$value;
- }
- return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
- }
- public function edit(){
- $token = isset($this->post['token']) && $this->post['token'] !==""? trim($this->post['token']):"";
- if($token==""){
- return error_show(101,'token不能为空');
- }
- $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
- if($id==""){
- return error_show(1002,"参数id 不能为空");
- }
- $info = Db::name("talk")->where(["id"=>$id,"is_del"=>0])->find();
- if(empty($info)){
- return error_show(1002,'未找到数据');
- }
- $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
- if($bugNo==""){
- return error_show(1002,"参数bugNo不能为空");
- }
- $talk_note = isset($this->post['talk_note']) && $this->post['talk_note'] !=="" ? trim($this->post['talk_note']) :"";
- if($talk_note==""){
- return error_show(1002,"参数talk_note不能为空");
- }
- $apply_id =VerifyTokens($token);
- if(empty($apply_id)||$apply_id['code']!=0){
- return error_show(1002,"申请人数据不存在");
- }
- $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
- $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
- $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
- $data = [
- "id"=>$id,
- "talk_name"=>$ri,
- "talk_id"=>$rm,
- "talk_note"=>$talk_note,
- "bugNo"=>$bugNo,
- "status"=>$status,
- "is_del"=>0,
- "updatetime"=>date("Y-m-d H:i:s")
- ];
- $datainfo = Db::name('talk')->where($info)->save($data);
- if($datainfo){
- return error_show(0,"更新成功");
- }else{
- return error_show(1002,"更新失败");
- }
- }
- public function del(){
- $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
- if($id==""){
- return error_show(1002,"参数不能为空");
- }
- $info=Db::name('talk')->where(['id'=>$id,'is_del'=>0])->find();
- if(empty($info)){
- return error_show(1002,"未找到数据");
- }
- $str['is_del']=1;
- $str['updatetime']=date("Y-m-d H:i:s");
- $info=Db::name('talk')->where($info)->save($str);
- return $info ? app_show(0,"删除成功") :error_show(1002,"删除失败");
- }
- }
|