From 1dceadba4c53f26ab1bf829cb5717e3cfa9a3478 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子Li <15040126243@163.com> Date: 星期六, 28 五月 2022 23:47:16 +0800 Subject: [PATCH] update 用户头像上传限制只能为图片格式 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java | 80 ++++++++++++++++++++-------------------- 1 files changed, 40 insertions(+), 40 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index 4f4eb4f..7e08698 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -4,13 +4,17 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.core.controller.BaseController; -import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.core.domain.PageQuery; import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.system.domain.SysPost; import com.ruoyi.system.service.ISysPostService; -import org.springframework.beans.factory.annotation.Autowired; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.RequiredArgsConstructor; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; @@ -20,59 +24,58 @@ /** * 宀椾綅淇℃伅鎿嶄綔澶勭悊 * - * @author ruoyi + * @author Lion Li */ +@Validated +@Api(value = "宀椾綅淇℃伅鎺у埗鍣�", tags = {"宀椾綅淇℃伅绠$悊"}) +@RequiredArgsConstructor @RestController @RequestMapping("/system/post") -public class SysPostController extends BaseController -{ - @Autowired - private ISysPostService postService; +public class SysPostController extends BaseController { + + private final ISysPostService postService; /** * 鑾峰彇宀椾綅鍒楄〃 */ + @ApiOperation("鑾峰彇宀椾綅鍒楄〃") @SaCheckPermission("system:post:list") @GetMapping("/list") - public TableDataInfo list(SysPost post) - { - return postService.selectPagePostList(post); + public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) { + return postService.selectPagePostList(post, pageQuery); } + @ApiOperation("瀵煎嚭宀椾綅鍒楄〃") @Log(title = "宀椾綅绠$悊", businessType = BusinessType.EXPORT) @SaCheckPermission("system:post:export") - @GetMapping("/export") - public void export(SysPost post, HttpServletResponse response) - { + @PostMapping("/export") + public void export(SysPost post, HttpServletResponse response) { List<SysPost> list = postService.selectPostList(post); - ExcelUtil.exportExcel(list, "宀椾綅鏁版嵁", SysPost.class, response); + ExcelUtil.exportExcel(list, "宀椾綅鏁版嵁", SysPost.class, response); } /** * 鏍规嵁宀椾綅缂栧彿鑾峰彇璇︾粏淇℃伅 */ + @ApiOperation("鏍规嵁宀椾綅缂栧彿鑾峰彇璇︾粏淇℃伅") @SaCheckPermission("system:post:query") @GetMapping(value = "/{postId}") - public AjaxResult getInfo(@PathVariable Long postId) - { - return AjaxResult.success(postService.selectPostById(postId)); + public R<SysPost> getInfo(@ApiParam("宀椾綅ID") @PathVariable Long postId) { + return R.ok(postService.selectPostById(postId)); } /** * 鏂板宀椾綅 */ + @ApiOperation("鏂板宀椾綅") @SaCheckPermission("system:post:add") @Log(title = "宀椾綅绠$悊", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@Validated @RequestBody SysPost post) - { - if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) - { - return AjaxResult.error("鏂板宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶅悕绉板凡瀛樺湪"); - } - else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) - { - return AjaxResult.error("鏂板宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶇紪鐮佸凡瀛樺湪"); + public R<Void> add(@Validated @RequestBody SysPost post) { + if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { + return R.fail("鏂板宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶅悕绉板凡瀛樺湪"); + } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { + return R.fail("鏂板宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶇紪鐮佸凡瀛樺湪"); } return toAjax(postService.insertPost(post)); } @@ -80,18 +83,15 @@ /** * 淇敼宀椾綅 */ + @ApiOperation("淇敼宀椾綅") @SaCheckPermission("system:post:edit") @Log(title = "宀椾綅绠$悊", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@Validated @RequestBody SysPost post) - { - if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) - { - return AjaxResult.error("淇敼宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶅悕绉板凡瀛樺湪"); - } - else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) - { - return AjaxResult.error("淇敼宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶇紪鐮佸凡瀛樺湪"); + public R<Void> edit(@Validated @RequestBody SysPost post) { + if (UserConstants.NOT_UNIQUE.equals(postService.checkPostNameUnique(post))) { + return R.fail("淇敼宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶅悕绉板凡瀛樺湪"); + } else if (UserConstants.NOT_UNIQUE.equals(postService.checkPostCodeUnique(post))) { + return R.fail("淇敼宀椾綅'" + post.getPostName() + "'澶辫触锛屽矖浣嶇紪鐮佸凡瀛樺湪"); } return toAjax(postService.updatePost(post)); } @@ -99,21 +99,21 @@ /** * 鍒犻櫎宀椾綅 */ + @ApiOperation("鍒犻櫎宀椾綅") @SaCheckPermission("system:post:remove") @Log(title = "宀椾綅绠$悊", businessType = BusinessType.DELETE) @DeleteMapping("/{postIds}") - public AjaxResult remove(@PathVariable Long[] postIds) - { + public R<Void> remove(@ApiParam("宀椾綅ID涓�") @PathVariable Long[] postIds) { return toAjax(postService.deletePostByIds(postIds)); } /** * 鑾峰彇宀椾綅閫夋嫨妗嗗垪琛� */ + @ApiOperation("鑾峰彇宀椾綅閫夋嫨妗嗗垪琛�") @GetMapping("/optionselect") - public AjaxResult optionselect() - { + public R<List<SysPost>> optionselect() { List<SysPost> posts = postService.selectPostAll(); - return AjaxResult.success(posts); + return R.ok(posts); } } -- Gitblit v1.9.3