123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <?php
- namespace app\bug\controller;
- use app\bug\model\Talk;
- use think\App;
- use think\facade\Validate;
- class Cloud extends Base
- {
- public function __construct(App $app)
- {
- parent::__construct($app);
- $this->model = new \app\bug\model\Note();
- }
- /** 图片上传
- * @return \think\Response|\think\response\Json|void
- * @throws \think\Exception
- */
- public function upload(){
- $files = $this->request->file('image');
- $list=[];
- if($files!=""){
- $list = UploadImg($files);
- }
- if(is_array($list) &&!empty($list)){
- return success("上传成功",$list);
- }
- return error("上传失败");
- }
- /**问题反馈工单下评论添加
- */
- public function create(){
- $param = $this->request->param(["bugNo"=>'',"talk_note"=>"","status"=>1],"post","trim");
- $valid = Validate::rule([
- "bugNo|工单编号"=>"require|max:255",
- "talk_note|评论内容"=>"require"
- ]);
- if($valid->check($param)==false) return error($valid->getError());
- $str=$this->model->where(["bugNo"=>$param['bugNo']])->findOrEmpty();
- if($str->isEmpty())return error("未找到数据");
- $data = [
- "talk_name"=>$this->uname,
- "talk_id"=>$this->uid,
- "talk_note"=>$param['talk_note'],
- "bugNo"=>$param['bugNo'],
- "status"=>$param['status'],
- ];
- $talk=Talk::create($data);
- if($talk->id>0)event('wx_push',['type'=>'talk','data'=>$talk->toArray()]);
- return success("添加成功");
-
- }
- /** 工单下评论列表
- * @return \think\Response|\think\response\Json
- * @throws \think\db\exception\DbException
- */
- public function list(){
- $param = $this->request->param(['id'=>'','page'=>1,'size'=>10,"talk_id"=>"","talk_name"=>'',"bugNo"=>'',"start"=>'',"end"=>''],
- 'post','trim');
- $where=[["is_del","=",0]];
- if($param['id']>0){
- $bugNo = $this->model->where(["id"=>$param['id']])->value("bugNo",'');
- if($bugNo!=''){
- $where[]=[['bugNo',"=",$bugNo]];
- }
- }
- $param['talk_id']!==''?? $where[]=['talk_id','=',$param['talk_id']];
- $param['talk_name']!==''?? $where[]=['talk_name',"like","%{$param['talk_name']}%"];
- $param['bugNo']!==''?? $where[]=['bugNo','like',"%{$param['bugNo']}%"];
- $param['start']!==''?? $where[]=['addtime','>=',startTime($param['start'])];
- $param['end']!==''?? $where[]=['addtime','<=',endTime($param['end'])];
- $list= Talk::where($where)->order("id desc")->paginate(["list_rows"=>$param['size'],"page"=>$param['page']]);
- foreach ($list->items() as &$value){
- $value['is_edit']=$value['talk_id'] !=$this->uid ?"1":"0";
- }
- return success("获取成功",['list'=>$list->items(),"count"=>$list->total()]);
- }
- /**工单下评论编辑
- **/
- public function edit(){
- $param = $this->request->param(['id'=>'','talk_note'=>'','status'=>1],
- 'post','trim');
- $valid = Validate::rule([
- 'id|主键id'=>'require|number|gt:0',
- 'talk_note|评论内容'=>'require'
- ]);
- if($valid->check($param)==false) return error($valid->getError());
-
- $info = Talk::where(["id"=>$param['id'],"is_del"=>0])->findOrEmpty();
- if($info->isEmpty())return error("未找到数据");
- $info->talk_name = $this->uname;
- $info->talk_id = $this->uid;
- $info->talk_note = $param['talk_note'];
- $info->status = $param['status'];
- $datainfo = $info->save();
- if($datainfo==false)return error('更新失败');
- return success("更新成功");
- }
- /**工单下评论删除
- **/
- public function del(){
- $id = $this->request->post('id/d');
- $info = Talk::where(['id'=>$id,'is_del'=>0])->findOrEmpty();
- if($info->isEmpty())return error('未找到数据');
- $info->is_del=1;
- $datainfo = $info->save();
- if($datainfo==false)return error('删除失败');
- return success('删除成功');
- }
- }
|