|
@@ -0,0 +1,107 @@
|
|
|
+package com.xiaoan.web.backend;
|
|
|
+
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
+import com.xiaoan.common.constant.MsgCode;
|
|
|
+import com.xiaoan.common.model.PageDto;
|
|
|
+import com.xiaoan.common.util.ResultJson;
|
|
|
+import com.xiaoan.domain.backend.IssueEntity;
|
|
|
+import com.xiaoan.domain.dto.request.IssueRequest;
|
|
|
+import com.xiaoan.domain.dto.response.IssueResponse;
|
|
|
+import com.xiaoan.domain.dto.response.LogResponse;
|
|
|
+import com.xiaoan.service.backend.IssueService;
|
|
|
+import com.xiaoan.service.backend.LogService;
|
|
|
+import com.xiaoan.web.aop.WebControllerLog;
|
|
|
+import com.xiaoan.web.shiro.JWTUtil;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by owen on 2020/2/18 0018 12:17
|
|
|
+ */
|
|
|
+@Api(tags = "IssueController", description = "后台问题反馈")
|
|
|
+@RestController
|
|
|
+@RequestMapping("api/manage/issue")
|
|
|
+@Transactional
|
|
|
+public class IssueController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IssueService issueService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @WebControllerLog(description = "问题反馈-问题搜索/列表")
|
|
|
+ @ApiOperation("搜索/列表共用")
|
|
|
+ @PostMapping("search")
|
|
|
+ public ResultJson search(@RequestBody PageDto param){
|
|
|
+
|
|
|
+ PageHelper.startPage(param.getPageNum(), param.getPageSize());
|
|
|
+ List<IssueResponse> list = null;
|
|
|
+ List userRole = JWTUtil.getUserRole(getToken());
|
|
|
+ if (userRole.contains("admin")) {
|
|
|
+ list = issueService.search(param.getItemName());
|
|
|
+ } else {
|
|
|
+ Long userId = JWTUtil.getUserId(getToken());
|
|
|
+ list = issueService.search(param.getItemName(), userId);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ PageInfo<IssueResponse> pageInfo = new PageInfo<>(list);
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @WebControllerLog(description = "问题反馈-提交问题")
|
|
|
+ @ApiOperation("提交问题")
|
|
|
+ @PostMapping("save")
|
|
|
+ public ResultJson save(@RequestBody IssueRequest param){
|
|
|
+ IssueEntity issueEntity = new IssueEntity();
|
|
|
+ BeanUtils.copyProperties(param, issueEntity);
|
|
|
+ Long userId = JWTUtil.getUserId(getToken());
|
|
|
+ issueEntity.setUserId(userId);
|
|
|
+ issueService.save(issueEntity);
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
|
|
|
+ }
|
|
|
+
|
|
|
+ @WebControllerLog(description = "问题反馈-回复问题")
|
|
|
+ @ApiOperation("回复问题")
|
|
|
+ @PostMapping("edit/{id}/{item}")
|
|
|
+ public ResultJson edit(@PathVariable Long id, @PathVariable String item){
|
|
|
+
|
|
|
+ IssueEntity entity = issueService.findById(id);
|
|
|
+ if (entity == null) {
|
|
|
+ return new ResultJson(MsgCode.FAILURE_CODE_3001, MsgCode.FAILURE_MSG_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ entity.setReply(item);
|
|
|
+ entity.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ issueService.update(entity);
|
|
|
+
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
|
|
|
+ }
|
|
|
+
|
|
|
+ @WebControllerLog(description = "问题反馈-删除问题")
|
|
|
+ @ApiOperation("删除问题")
|
|
|
+ @PostMapping("delete/{id}")
|
|
|
+ public ResultJson save(@PathVariable Long id){
|
|
|
+ issueService.deleteById(id);
|
|
|
+ return new ResultJson(MsgCode.SUCCESS_CODE, MsgCode.SUCCESS_MSG);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|