package com.zcloud.modules.feedback.controller;

import com.zcloud.common.annotation.SysLog;
import com.zcloud.common.utils.DateUtil;
import com.zcloud.common.utils.PageUtils;
import com.zcloud.common.utils.R;
import com.zcloud.common.utils.Tools;
import com.zcloud.modules.feedback.entity.BusFeedbackReplyEntity;
import com.zcloud.modules.feedback.service.BusFeedbackReplyService;
import com.zcloud.modules.sys.controller.AbstractController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import java.util.Date;
import java.util.Map;

/**
 * @Author wangpeng
 * @Desc 意见反馈-回复表(BusFeedbackReply)表控制层
 * @Date 2024-03-30 15:20:00
 */
@Api(tags = "意见反馈-回复表")
@RestController
@RequestMapping("/busFeedbackReply")
public class BusFeedbackReplyController extends AbstractController {

    @Autowired
    private BusFeedbackReplyService busFeedbackReplyService;

    @ApiOperation("意见反馈-回复表-新增数据")
    @SysLog("意见反馈-回复表-新增数据")
    @PostMapping("/save")
    public R insert(@RequestPart(value = "param") BusFeedbackReplyEntity param) throws Exception {
        param.setCreator(getUserId());
		param.setOperator(getUserId());
		param.setIsDelete(0);
		param.setCreateTime(DateUtil.date2Str(new Date()));
		param.setReadTime(DateUtil.date2Str(new Date()));
		param.setOperatTime(DateUtil.date2Str(new Date()));
		param.setFeedbackReplyId(Tools.get32UUID());
        busFeedbackReplyService.saveFeedbackReply(param);

        return R.ok();
    }

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

        return R.ok();
    }

    @ApiOperation("意见反馈-回复表-修改处理状态")
    @SysLog("意见反馈-回复表-修改处理状态")
    @PostMapping("/editStatus")
    public R editStatus(@RequestBody BusFeedbackReplyEntity param) {
        param.setOperator(getUserId());
        busFeedbackReplyService.updateById(param);

        return R.ok();
    }


    @ApiOperation("意见反馈-回复表-删除数据")
    @SysLog("意见反馈-回复表-删除数据")
    @PostMapping("/delete")
    public R delete(@RequestBody BusFeedbackReplyEntity param) {
        busFeedbackReplyService.delete(param.getFeedbackReplyId(),getUserId());
        return R.ok();
    }

    @ApiOperation("意见反馈-回复表-分页查询")
    @SysLog("意见反馈-回复表-分页查询")
    @PostMapping("/listPage")
    public R listPage(@RequestBody Map<String, Object> params) {
        PageUtils page = busFeedbackReplyService.listPage(params);

		return R.ok().put("page", page);
    }


    @ApiOperation("意见反馈-回复表-根据ID查详情")
    @SysLog("意见反馈-回复表-根据ID查详情")
    @PostMapping("/info")
    public R info(@RequestBody BusFeedbackReplyEntity param) {
        BusFeedbackReplyEntity busFeedbackReply = busFeedbackReplyService.getById(param.getFeedbackReplyId());
        return R.ok().put("busFeedbackReply", busFeedbackReply);
    }

}
