package com.zhujizheng.IHome.feedback.controller; import com.zhujizheng.IHome.feedback.dto.PYPushFeedBackDTO; import com.zhujizheng.IHome.feedback.service.PYFeedBackService; import com.zhujizheng.IHome.feedback.vo.PYFeedBackUpdateVO; import com.zhujizheng.IHome.feedback.vo.PYFeedBackVO; import com.zhujizheng.IHome.generator.dao.PYFeedBack; import com.zhujizheng.IHome.util.response.ResponseResult; import com.zhujizheng.IHome.util.response.RestResultGenerator; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import java.util.List; /** * Created with IntelliJ IDEA *

* Author: yons * Date: 2019/04/17 * Time: 01:43 * Description: * Copyright © 2019年 com.zhujizheng. All rights reserved. */ @Api("反馈意见") @RestController @RequestMapping("/feedback") public class PYFeedBackController { @Autowired private PYFeedBackService feedBackService; @ApiOperation("上传反馈意见") @ApiImplicitParam(name = "feedbackDTO", value = "反馈意见的数据", required = true, dataType = "PYFeedBackDTO") @PostMapping("/push") public ResponseResult pushFeedback(@Validated @RequestBody PYPushFeedBackDTO feedBackDTO) { System.out.println("dto = " + feedBackDTO); int result = feedBackService.pushFeedBack(feedBackDTO); if (result == 0) { return RestResultGenerator.genErrorResult("反馈失败"); } else { return RestResultGenerator.genResult("反馈成功"); } } @ApiOperation("获取反馈意见") @ApiImplicitParams({ @ApiImplicitParam(name = "feedbackTime", value = "反馈时间", paramType = "path", required = true, dataType = "long"), @ApiImplicitParam(name = "statusUpdateTime", value = "反状态更新时间", paramType = "path", required = true, dataType = "long"), @ApiImplicitParam(name = "status", value = "状态", paramType = "path", required = true, dataType = "int") }) @GetMapping("/pull/{feedbackTime}/{statusUpdateTime}/{status}") public ResponseResult getFeedbacks(@PathVariable long feedbackTime, @PathVariable long statusUpdateTime, @PathVariable int status) { List voList = feedBackService.pullFeedBackVO(feedbackTime, statusUpdateTime, status); if (voList == null) { return RestResultGenerator.genErrorResult("获取用户反馈信息失败"); } return RestResultGenerator.genResult(voList, "获取用户反馈信息成功"); } @ApiOperation("获取反馈意见条数") @ApiImplicitParam(name = "status", value = "状态", paramType = "path", required = true, dataType = "int") @GetMapping("/pull/num/{status}") public ResponseResult getUndealNum(@PathVariable int status) { List voList = feedBackService.pullNumFeedBackVO(status); if (voList == null) { return RestResultGenerator.genErrorResult("获取反馈意见条数失败"); } return RestResultGenerator.genResult(voList.size(), "获取反馈意见条数成功"); } @ApiOperation("删除反馈意见") @ApiImplicitParam(name = "qaId", value = "反馈id", paramType = "path", required = true, dataType = "int") @GetMapping("delete/{qaId}") public ResponseResult deleteFeedbackByQaId(@PathVariable int qaId) { int result = feedBackService.deleteFeedbackByQaId(qaId); if (result == 0) { return RestResultGenerator.genErrorResult("删除反馈意见失败"); } return RestResultGenerator.genResult(qaId, "删除反馈意见成功"); } @ApiOperation("更新反馈意见的状态") @ApiImplicitParams({ @ApiImplicitParam(name = "qaId", value = "反馈id", paramType = "path", required = true, dataType = "int"), @ApiImplicitParam(name = "status", value = "状态", paramType = "path", required = true, dataType = "int") }) @GetMapping("update/{qaId}/{status}") public ResponseResult updateFeedback(@PathVariable int qaId, @PathVariable int status) { int result = feedBackService.updateFeedback(qaId, status); if (result == 0) { return RestResultGenerator.genErrorResult("更新反馈意见的状态失败"); } PYFeedBackUpdateVO vo = new PYFeedBackUpdateVO(); vo.setQaId(qaId); vo.setStatus(status); return RestResultGenerator.genResult(vo, "更新成功"); } }