Cloud.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <?php
  2. namespace app\admin\controller;
  3. use app\BaseController;
  4. use think\App;
  5. use think\console\command\Make;
  6. use think\facade\Db;
  7. class Cloud extends BaseController
  8. {
  9. public $post = "";
  10. public function __construct(App $app)
  11. {
  12. parent::__construct($app);
  13. $this->post = $this->request->post();
  14. }
  15. public function upload(){
  16. $token = isset($this->post['token']) ? trim($this->post['token']) : "";
  17. if($token==""){
  18. return error_show(101,'token不能为空');
  19. }
  20. $effect = VerifyTokens($token);
  21. if(!empty($effect)&& $effect['code']!=0){
  22. return error_show($effect['code'],$effect['message']);
  23. }
  24. $files = $this->request->file('image');
  25. $list="";
  26. if($files!=""){
  27. $list = UploadImg($files);
  28. }
  29. if(is_array($list) &&!empty($list)){
  30. return app_show(0,"上传成功",$list);
  31. }else{
  32. return app_show(1005,"上传失败".$list);
  33. }
  34. }
  35. public function create(){
  36. $token= isset($this->post['token'])&& $this->post['token'] !==""? trim($this->post['token']) :"";
  37. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
  38. if($bugNo==""){
  39. return error_show(1002,"参数bugNo不能为空");
  40. }
  41. $str=Db::name('note')->where(['bugNo'=>$bugNo])->find();
  42. if(empty($str)){
  43. return error_show(1002,"未找到数据");
  44. }
  45. $talk_note = isset($this->post['talk_note']) && $this->post['talk_note'] !=="" ? trim($this->post['talk_note']) :"";
  46. if($talk_note==""){
  47. return error_show(1002,"参数talk_note不能为空");
  48. }
  49. // $is_edit = isset($this->post['is_edit']) && $this->post['is_edit'] !=="" ? intval($this->post['is_edit']) :"";
  50. // if ($is_edit==""){
  51. // return error_show(1002,"参数is_edit不能为空");
  52. // }
  53. $apply_id =verifyToken($token);
  54. if(empty($apply_id)||$apply_id['code']!=0){
  55. return error_show(1002,"申请人数据不存在");
  56. }
  57. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  58. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  59. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"1";
  60. $data = [
  61. "talk_name"=>$ri,
  62. "talk_id"=>$rm,
  63. "talk_note"=>$talk_note,
  64. "bugNo"=>$bugNo,
  65. "status"=>$status,
  66. "is_del"=>0,
  67. // "is_edit"=>$is_edit,
  68. "addtime"=>date("Y-m-d H:i:s"),
  69. "updatetime"=>date("Y-m-d H:i:s")
  70. ];
  71. $datainfo = Db::name('talk')->insert($data);
  72. if($datainfo){
  73. return error_show(0,"添加成功");
  74. }else{
  75. return error_show(1002,"添加失败");
  76. }
  77. }
  78. public function list(){
  79. $token= isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
  80. // var_dump($this->post);
  81. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
  82. if($id==""){
  83. return error_show(1002,"参数id不能为空");
  84. }
  85. $str=Db::name('note')->where(['id'=>$id])->find();
  86. if(empty($str)){
  87. return error_show(1002,"未找到数据");
  88. }
  89. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
  90. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
  91. $where =[['is_del','=',0],['bugNo',"=",$str['bugNo']]];
  92. $talk_id = isset($this->post['talk_id']) && $this->post['talk_id']!==""? intval($this->post['talk_id']):"";
  93. if($talk_id!==""){
  94. $where[]=['talk_id','=',$talk_id];
  95. }
  96. $talk_name = isset($this->post['talk_name']) && $this->post['talk_name']!==""? intval($this->post['talk_name']):"";
  97. if($talk_name!==""){
  98. $where[]=["talk_name","like","%$talk_name%"];
  99. }
  100. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo']!==""? trim($this->post['bugNo']):"";
  101. if($bugNo!==""){
  102. $where[]=["bugNo","like","%$bugNo%"];
  103. }
  104. $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
  105. if($start!==""){
  106. $where[]=['addtime',">=",$start];
  107. }
  108. $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
  109. if($end!==""){
  110. $where[]=['addtime',"<=",$end];
  111. }
  112. $count = Db::name('talk')->where($where)->count();
  113. $total = ceil($count/$size);
  114. $page = $page>$total ? $total:$page;
  115. $list = Db::name('talk')->where($where)->page($page,$size)->order("addtime desc")->select();
  116. $apply_id =verifyToken($token);
  117. // var_dump($apply_id);
  118. if(empty($apply_id)||$apply_id['code']!=0){
  119. return error_show(1002,"申请人数据不存在");
  120. }
  121. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  122. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  123. $data =[];
  124. foreach ($list as $value){
  125. $value['is_edit']=$value['talk_id'] !=$rm ?"1":"0";
  126. $data[]=$value;
  127. }
  128. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  129. }
  130. public function edit(){
  131. $token = isset($this->post['token']) && $this->post['token'] !==""? trim($this->post['token']):"";
  132. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
  133. if($id==""){
  134. return error_show(1002,"参数id 不能为空");
  135. }
  136. $info = Db::name("talk")->where(["id"=>$id,"is_del"=>0])->find();
  137. if(empty($info)){
  138. return error_show(1002,'未找到数据');
  139. }
  140. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
  141. if($bugNo==""){
  142. return error_show(1002,"参数bugNo不能为空");
  143. }
  144. $talk_note = isset($this->post['talk_note']) && $this->post['talk_note'] !=="" ? trim($this->post['talk_note']) :"";
  145. if($talk_note==""){
  146. return error_show(1002,"参数talk_note不能为空");
  147. }
  148. $apply_id =verifyToken($token);
  149. if(empty($apply_id)||$apply_id['code']!=0){
  150. return error_show(1002,"申请人数据不存在");
  151. }
  152. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  153. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  154. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
  155. $data = [
  156. "id"=>$id,
  157. "talk_name"=>$ri,
  158. "talk_id"=>$rm,
  159. "talk_note"=>$talk_note,
  160. "bugNo"=>$bugNo,
  161. "status"=>$status,
  162. "is_del"=>0,
  163. "updatetime"=>date("Y-m-d H:i:s")
  164. ];
  165. $datainfo = Db::name('talk')->where($info)->save($data);
  166. if($datainfo){
  167. return error_show(0,"更新成功");
  168. }else{
  169. return error_show(1002,"更新失败");
  170. }
  171. }
  172. public function del(){
  173. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
  174. if($id==""){
  175. return error_show(1002,"参数不能为空");
  176. }
  177. $info=Db::name('talk')->where(['id'=>$id,'is_del'=>0])->find();
  178. if(empty($info)){
  179. return error_show(1002,"未找到数据");
  180. }
  181. $str['is_del']=1;
  182. $str['updatetime']=date("Y-m-d H:i:s");
  183. $info=Db::name('talk')->where($info)->save($str);
  184. return $info ? app_show(0,"删除成功") :error_show(1002,"删除失败");
  185. }
  186. }