package com.zcloud.modules.feedback.controller;

import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.middleware.MiddlewareBean;
import com.zcloud.common.utils.*;
import com.zcloud.modules.custormerInfo.dao.BusCustomerInfoDao;
import com.zcloud.modules.feedback.entity.BusFeedbackEntity;
import com.zcloud.modules.feedback.service.BusFeedbackService;
import com.zcloud.modules.sys.controller.AbstractController;
import com.zcloud.modules.sys.dao.SysUserDao;
import com.zcloud.modules.sys.dao.SysUserRoleDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author wangpeng
 * @Desc 意见反馈表(BusFeedback)表控制层
 * @Date 2024-03-30 15:19:58
 */
@Api(tags = "意见反馈表")
@RestController
@RequestMapping("/busFeedback")
public class BusFeedbackController extends AbstractController {

    @Autowired
    private BusFeedbackService busFeedbackService;

    @ApiOperation("意见反馈表-新增数据")
    @SysLog("意见反馈表-新增数据")
    @PostMapping("/save")
    @ResponseBody
    public R insert(@RequestPart BusFeedbackEntity entity) {
        entity.setCreator(getUserId());
        entity.setOperator(getUserId());
        busFeedbackService.save(entity);

        return R.ok();
    }

    @ApiOperation("意见反馈表-编辑数据")
    @SysLog("意见反馈表-编辑数据")
    @PostMapping("/update")
    public R update(@RequestBody BusFeedbackEntity param) {
        param.setOperator(getUserId());
        busFeedbackService.updateById(param);

        return R.ok();
    }


    @ApiOperation("意见反馈表-删除数据")
    @SysLog("意见反馈表-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusFeedbackEntity param) {
        busFeedbackService.delete(param.getFeedbackId(),getUserId());
        return R.ok();
    }


    @ApiOperation("意见反馈表-分页查询")
    @SysLog("意见反馈表-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) throws JsonProcessingException {
      PageUtils page = busFeedbackService.listPage(params);
      return R.ok().put("page", page);
    }


    @ApiOperation("意见反馈表-根据ID查详情")
    @SysLog("意见反馈表-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusFeedbackEntity param) {
        BusFeedbackEntity busFeedback = busFeedbackService.getById(param.getFeedbackId());
        return R.ok().put("busFeedback", busFeedback);
    }

    @ApiOperation("意见反馈表-根据ID查详情")
    @SysLog("意见反馈表-根据ID查详情")
    @PostMapping("/replyInfo")
    public R replyInfo(@RequestBody BusFeedbackEntity param) {
        BusFeedbackEntity busFeedback = busFeedbackService.replyInfo(param.getFeedbackId());
        return R.ok().put("busFeedback", busFeedback);
    }

}
