From 68985c22a03d280a96e89f4d0e67f144259fab92 Mon Sep 17 00:00:00 2001 From: 安瑾然 <107107765@qq.com> Date: 星期三, 13 七月 2022 11:54:54 +0800 Subject: [PATCH] commit --- src/main/java/com/example/jz/controller/CommonQuestionController.java | 73 ++++++++++++++++++++++++++++-------- 1 files changed, 57 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/example/jz/controller/CommonQuestionController.java b/src/main/java/com/example/jz/controller/CommonQuestionController.java index c99d745..3fecef8 100644 --- a/src/main/java/com/example/jz/controller/CommonQuestionController.java +++ b/src/main/java/com/example/jz/controller/CommonQuestionController.java @@ -1,18 +1,20 @@ package com.example.jz.controller; - import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.api.ApiController; import com.baomidou.mybatisplus.extension.api.R; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.example.jz.modle.PageParam; import com.example.jz.modle.entity.CommonQuestion; import com.example.jz.service.CommonQuestionService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.io.Serializable; -import java.util.List; +import java.util.Date; /** * 甯歌闂琛�(CommonQuestion)琛ㄦ帶鍒跺眰 @@ -22,6 +24,7 @@ */ @RestController @RequestMapping("commonQuestion") +@Api(tags = "甯歌闂琛�(CommonQuestion)琛ㄦ帴鍙�") public class CommonQuestionController extends ApiController { /** * 鏈嶅姟瀵硅薄 @@ -32,13 +35,14 @@ /** * 鍒嗛〉鏌ヨ鎵�鏈夋暟鎹� * - * @param page 鍒嗛〉瀵硅薄 + * @param page 鍒嗛〉瀵硅薄 * @param commonQuestion 鏌ヨ瀹炰綋 * @return 鎵�鏈夋暟鎹� */ @GetMapping - public R selectAll(Page<CommonQuestion> page, CommonQuestion commonQuestion) { - return success(this.commonQuestionService.page(page, new QueryWrapper<>(commonQuestion))); + @ApiOperation("鍒嗛〉鏌ヨ鎵�鏈夋暟鎹�") + public R<IPage<CommonQuestion>> selectAll(PageParam<CommonQuestion> page, CommonQuestion commonQuestion) { + return R.ok(commonQuestionService.page(page, new QueryWrapper<>(commonQuestion))); } /** @@ -48,8 +52,9 @@ * @return 鍗曟潯鏁版嵁 */ @GetMapping("{id}") - public R selectOne(@PathVariable Serializable id) { - return success(this.commonQuestionService.getById(id)); + @ApiOperation(value = "閫氳繃涓婚敭鏌ヨ鍗曟潯鏁版嵁", notes = "閫氳繃涓婚敭鏌ヨ鍗曟潯鏁版嵁") + public R<CommonQuestion> selectOne(@PathVariable Serializable id) { + return R.ok(commonQuestionService.getById(id)); } /** @@ -59,8 +64,11 @@ * @return 鏂板缁撴灉 */ @PostMapping - public R insert(@RequestBody CommonQuestion commonQuestion) { - return success(this.commonQuestionService.save(commonQuestion)); + @ApiOperation(value = "鏂板鏁版嵁", notes = "鏂板鏁版嵁") + public R<Boolean> insert(@RequestBody CommonQuestion commonQuestion) { + commonQuestion.setStatus(0); + commonQuestion.setCtime(new Date()); + return R.ok(commonQuestionService.save(commonQuestion)); } /** @@ -70,19 +78,52 @@ * @return 淇敼缁撴灉 */ @PutMapping - public R update(@RequestBody CommonQuestion commonQuestion) { - return success(this.commonQuestionService.updateById(commonQuestion)); + @ApiOperation(value = "淇敼鏁版嵁", notes = "淇敼鏁版嵁") + public R<Boolean> update(@RequestBody CommonQuestion commonQuestion) { + if (commonQuestion.getId() == 1) { + commonQuestion.setReleaseTime(new Date()); + } + return R.ok(commonQuestionService.updateById(commonQuestion)); } /** * 鍒犻櫎鏁版嵁 * - * @param idList 涓婚敭缁撳悎 + * @param id 涓婚敭 * @return 鍒犻櫎缁撴灉 */ @DeleteMapping - public R delete(@RequestParam("idList") List<Long> idList) { - return success(this.commonQuestionService.removeByIds(idList)); + @ApiOperation(value = "鍒犻櫎鏁版嵁", notes = "鍒犻櫎鏁版嵁") + public R<Boolean> delete(@RequestParam("id") Serializable id) { + return R.ok(commonQuestionService.removeById(id)); + } + + /** + * 鍙戝竷 + * + * @param id 涓婚敭 + * @return 鍙戝竷缁撴灉 + */ + @ApiOperation(value = "鍙戝竷", notes = "鍙戝竷") + @GetMapping("release/{id}") + public R<Boolean> release(@PathVariable Serializable id) { + CommonQuestion commonQuestion = commonQuestionService.getById(id); + commonQuestion.setReleaseTime(new Date()); + commonQuestion.setStatus(1); + return R.ok(commonQuestionService.updateById(commonQuestion)); + } + + /** + * 涓嬫灦 + * + * @param id 涓婚敭 + * @return 鍙戝竷缁撴灉 + */ + @ApiOperation(value = "涓嬫灦", notes = "涓嬫灦") + @GetMapping("offline/{id}") + public R<Boolean> offline(@PathVariable Serializable id) { + CommonQuestion commonQuestion = commonQuestionService.getById(id); + commonQuestion.setStatus(2); + return R.ok(commonQuestionService.updateById(commonQuestion)); } } - -- Gitblit v1.8.0