Cloud.php 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  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. if($token==""){
  38. return error_show(101,'token不能为空');
  39. }
  40. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
  41. if($bugNo==""){
  42. return error_show(1002,"参数bugNo不能为空");
  43. }
  44. $str=Db::name('note')->where(['bugNo'=>$bugNo])->find();
  45. if(empty($str)){
  46. return error_show(1002,"未找到数据");
  47. }
  48. $talk_note = isset($this->post['talk_note']) && $this->post['talk_note'] !=="" ? trim($this->post['talk_note']) :"";
  49. if($talk_note==""){
  50. return error_show(1002,"参数talk_note不能为空");
  51. }
  52. // $is_edit = isset($this->post['is_edit']) && $this->post['is_edit'] !=="" ? intval($this->post['is_edit']) :"";
  53. // if ($is_edit==""){
  54. // return error_show(1002,"参数is_edit不能为空");
  55. // }
  56. $apply_id =VerifyTokens($token);
  57. if(empty($apply_id)||$apply_id['code']!=0){
  58. return error_show(1002,"申请人数据不存在");
  59. }
  60. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  61. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  62. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"1";
  63. $data = [
  64. "talk_name"=>$ri,
  65. "talk_id"=>$rm,
  66. "talk_note"=>$talk_note,
  67. "bugNo"=>$bugNo,
  68. "status"=>$status,
  69. "is_del"=>0,
  70. // "is_edit"=>$is_edit,
  71. "addtime"=>date("Y-m-d H:i:s"),
  72. "updatetime"=>date("Y-m-d H:i:s")
  73. ];
  74. $datainfo = Db::name('talk')->insert($data);
  75. if($datainfo){
  76. return error_show(0,"添加成功");
  77. }else{
  78. return error_show(1002,"添加失败");
  79. }
  80. }
  81. public function list(){
  82. $token= isset($this->post['token']) && $this->post['token'] !=="" ? trim($this->post['token']) :"";
  83. if($token==""){
  84. return error_show(101,'token不能为空');
  85. }
  86. // var_dump($this->post);
  87. $id = isset($this->post['id']) && $this->post['id'] !=="" ? intval($this->post['id']):"";
  88. if($id==""){
  89. return error_show(1002,"参数id不能为空");
  90. }
  91. $str=Db::name('note')->where(['id'=>$id])->find();
  92. if(empty($str)){
  93. return error_show(1002,"未找到数据");
  94. }
  95. $page = isset($this->post['page']) && $this->post['page'] !=="" ? intval($this->post['page']) :"1";
  96. $size = isset($this->post['size']) && $this->post['size'] !=="" ? intval($this->post['size']) :"10";
  97. $where =[['is_del','=',0],['bugNo',"=",$str['bugNo']]];
  98. $talk_id = isset($this->post['talk_id']) && $this->post['talk_id']!==""? intval($this->post['talk_id']):"";
  99. if($talk_id!==""){
  100. $where[]=['talk_id','=',$talk_id];
  101. }
  102. $talk_name = isset($this->post['talk_name']) && $this->post['talk_name']!==""? intval($this->post['talk_name']):"";
  103. if($talk_name!==""){
  104. $where[]=["talk_name","like","%$talk_name%"];
  105. }
  106. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo']!==""? trim($this->post['bugNo']):"";
  107. if($bugNo!==""){
  108. $where[]=["bugNo","like","%$bugNo%"];
  109. }
  110. $start = isset($this->post['start']) && $this->post['start']!=="" ? $this->post['start']:"";
  111. if($start!==""){
  112. $where[]=['addtime',">=",$start];
  113. }
  114. $end = isset($this->post['end']) && $this->post['end']!=="" ? $this->post['end']:"";
  115. if($end!==""){
  116. $where[]=['addtime',"<=",$end];
  117. }
  118. $count = Db::name('talk')->where($where)->count();
  119. $total = ceil($count/$size);
  120. $page = $page>$total ? $total:$page;
  121. $list = Db::name('talk')->where($where)->page($page,$size)->order("addtime desc")->select();
  122. $apply_id =VerifyTokens($token);
  123. // var_dump($apply_id);
  124. if(empty($apply_id)||$apply_id['code']!=0){
  125. return error_show(1002,"申请人数据不存在");
  126. }
  127. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  128. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  129. $data =[];
  130. foreach ($list as $value){
  131. $value['is_edit']=$value['talk_id'] !=$rm ?"1":"0";
  132. $data[]=$value;
  133. }
  134. return app_show(0,"获取成功",['list'=>$data,"count"=>$count]);
  135. }
  136. public function edit(){
  137. $token = isset($this->post['token']) && $this->post['token'] !==""? trim($this->post['token']):"";
  138. if($token==""){
  139. return error_show(101,'token不能为空');
  140. }
  141. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']):"";
  142. if($id==""){
  143. return error_show(1002,"参数id 不能为空");
  144. }
  145. $info = Db::name("talk")->where(["id"=>$id,"is_del"=>0])->find();
  146. if(empty($info)){
  147. return error_show(1002,'未找到数据');
  148. }
  149. $bugNo = isset($this->post['bugNo']) && $this->post['bugNo'] !=="" ? trim($this->post['bugNo']) :"";
  150. if($bugNo==""){
  151. return error_show(1002,"参数bugNo不能为空");
  152. }
  153. $talk_note = isset($this->post['talk_note']) && $this->post['talk_note'] !=="" ? trim($this->post['talk_note']) :"";
  154. if($talk_note==""){
  155. return error_show(1002,"参数talk_note不能为空");
  156. }
  157. $apply_id =VerifyTokens($token);
  158. if(empty($apply_id)||$apply_id['code']!=0){
  159. return error_show(1002,"申请人数据不存在");
  160. }
  161. $rm= isset($apply_id["data"]['id']) ? $apply_id["data"]['id'] : "";
  162. $ri= isset($apply_id["data"]['nickname']) ? $apply_id["data"]['nickname'] : "";
  163. $status = isset($this->post['status']) && $this->post['status'] !=="" ? intval($this->post['status']) :"";
  164. $data = [
  165. "id"=>$id,
  166. "talk_name"=>$ri,
  167. "talk_id"=>$rm,
  168. "talk_note"=>$talk_note,
  169. "bugNo"=>$bugNo,
  170. "status"=>$status,
  171. "is_del"=>0,
  172. "updatetime"=>date("Y-m-d H:i:s")
  173. ];
  174. $datainfo = Db::name('talk')->where($info)->save($data);
  175. if($datainfo){
  176. return error_show(0,"更新成功");
  177. }else{
  178. return error_show(1002,"更新失败");
  179. }
  180. }
  181. public function del(){
  182. $id = isset($this->post['id']) && $this->post['id'] !==""? intval($this->post['id']) :"";
  183. if($id==""){
  184. return error_show(1002,"参数不能为空");
  185. }
  186. $info=Db::name('talk')->where(['id'=>$id,'is_del'=>0])->find();
  187. if(empty($info)){
  188. return error_show(1002,"未找到数据");
  189. }
  190. $str['is_del']=1;
  191. $str['updatetime']=date("Y-m-d H:i:s");
  192. $info=Db::name('talk')->where($info)->save($str);
  193. return $info ? app_show(0,"删除成功") :error_show(1002,"删除失败");
  194. }
  195. }