From dd25573ebce3450d90d0012a30b12a5185bc7310 Mon Sep 17 00:00:00 2001 From: 疯狂的狮子li <15040126243@163.com> Date: 星期五, 08 七月 2022 15:49:15 +0800 Subject: [PATCH] update 使用 @param 注释替换 @Parameter 注解 fix 修复 token 无法传递 与 无法持久化问题 --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java | 247 +++++++++++++++++++++++-------------------------- 1 files changed, 117 insertions(+), 130 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 67d76ee..5feaa6c 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 @@ -1,130 +1,117 @@ -package com.ruoyi.web.controller.system; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -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.page.TableDataInfo; -import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.system.domain.SysPost; -import com.ruoyi.system.service.ISysPostService; - -/** - * 宀椾綅淇℃伅鎿嶄綔澶勭悊 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/system/post") -public class SysPostController extends BaseController -{ - @Autowired - private ISysPostService postService; - - /** - * 鑾峰彇宀椾綅鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('system:post:list')") - @GetMapping("/list") - public TableDataInfo list(SysPost post) - { - startPage(); - List<SysPost> list = postService.selectPostList(post); - return getDataTable(list); - } - - @Log(title = "宀椾綅绠$悊", businessType = BusinessType.EXPORT) - @PreAuthorize("@ss.hasPermi('system:post:export')") - @GetMapping("/export") - public AjaxResult export(SysPost post) - { - List<SysPost> list = postService.selectPostList(post); - ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class); - return util.exportExcel(list, "宀椾綅鏁版嵁"); - } - - /** - * 鏍规嵁宀椾綅缂栧彿鑾峰彇璇︾粏淇℃伅 - */ - @PreAuthorize("@ss.hasPermi('system:post:query')") - @GetMapping(value = "/{postId}") - public AjaxResult getInfo(@PathVariable Long postId) - { - return AjaxResult.success(postService.selectPostById(postId)); - } - - /** - * 鏂板宀椾綅 - */ - @PreAuthorize("@ss.hasPermi('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() + "'澶辫触锛屽矖浣嶇紪鐮佸凡瀛樺湪"); - } - post.setCreateBy(SecurityUtils.getUsername()); - return toAjax(postService.insertPost(post)); - } - - /** - * 淇敼宀椾綅 - */ - @PreAuthorize("@ss.hasPermi('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() + "'澶辫触锛屽矖浣嶇紪鐮佸凡瀛樺湪"); - } - post.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(postService.updatePost(post)); - } - - /** - * 鍒犻櫎宀椾綅 - */ - @PreAuthorize("@ss.hasPermi('system:post:remove')") - @Log(title = "宀椾綅绠$悊", businessType = BusinessType.DELETE) - @DeleteMapping("/{postIds}") - public AjaxResult remove(@PathVariable Long[] postIds) - { - return toAjax(postService.deletePostByIds(postIds)); - } - - /** - * 鑾峰彇宀椾綅閫夋嫨妗嗗垪琛� - */ - @GetMapping("/optionselect") - public AjaxResult optionselect() - { - List<SysPost> posts = postService.selectPostAll(); - return AjaxResult.success(posts); - } -} +package com.ruoyi.web.controller.system; + +import cn.dev33.satoken.annotation.SaCheckPermission; +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.PageQuery; +import com.ruoyi.common.core.domain.R; +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 io.swagger.v3.oas.annotations.tags.Tag; +import lombok.RequiredArgsConstructor; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + +/** + * 宀椾綅淇℃伅鎿嶄綔澶勭悊 + * + * @author Lion Li + */ +@Validated +@Tag(name ="宀椾綅淇℃伅鎺у埗鍣�", description = "宀椾綅淇℃伅绠$悊") +@RequiredArgsConstructor +@RestController +@RequestMapping("/system/post") +public class SysPostController extends BaseController { + + private final ISysPostService postService; + + /** + * 鑾峰彇宀椾綅鍒楄〃 + */ + @SaCheckPermission("system:post:list") + @GetMapping("/list") + public TableDataInfo<SysPost> list(SysPost post, PageQuery pageQuery) { + return postService.selectPagePostList(post, pageQuery); + } + + /** + * 瀵煎嚭宀椾綅鍒楄〃 + */ + @Log(title = "宀椾綅绠$悊", businessType = BusinessType.EXPORT) + @SaCheckPermission("system:post:export") + @PostMapping("/export") + public void export(SysPost post, HttpServletResponse response) { + List<SysPost> list = postService.selectPostList(post); + ExcelUtil.exportExcel(list, "宀椾綅鏁版嵁", SysPost.class, response); + } + + /** + * 鏍规嵁宀椾綅缂栧彿鑾峰彇璇︾粏淇℃伅 + * + * @param postId 宀椾綅ID + */ + @SaCheckPermission("system:post:query") + @GetMapping(value = "/{postId}") + public R<SysPost> getInfo(@PathVariable Long postId) { + return R.ok(postService.selectPostById(postId)); + } + + /** + * 鏂板宀椾綅 + */ + @SaCheckPermission("system:post:add") + @Log(title = "宀椾綅绠$悊", businessType = BusinessType.INSERT) + @PostMapping + 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)); + } + + /** + * 淇敼宀椾綅 + */ + @SaCheckPermission("system:post:edit") + @Log(title = "宀椾綅绠$悊", businessType = BusinessType.UPDATE) + @PutMapping + 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)); + } + + /** + * 鍒犻櫎宀椾綅 + * + * @param postIds 宀椾綅ID涓� + */ + @SaCheckPermission("system:post:remove") + @Log(title = "宀椾綅绠$悊", businessType = BusinessType.DELETE) + @DeleteMapping("/{postIds}") + public R<Void> remove(@PathVariable Long[] postIds) { + return toAjax(postService.deletePostByIds(postIds)); + } + + /** + * 鑾峰彇宀椾綅閫夋嫨妗嗗垪琛� + */ + @GetMapping("/optionselect") + public R<List<SysPost>> optionselect() { + List<SysPost> posts = postService.selectPostAll(); + return R.ok(posts); + } +} -- Gitblit v1.9.3