diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index cec5006e..512e2b22 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -23,7 +23,7 @@ import com.ruoyi.framework.config.ServerConfig; /** * 通用请求处理 - * + * * @author ruoyi */ @RestController @@ -39,7 +39,7 @@ public class CommonController /** * 通用下载请求 - * + * * @param fileName 文件名称 * @param delete 是否删除 */ @@ -84,7 +84,7 @@ public class CommonController String url = serverConfig.getUrl() + fileName; AjaxResult ajax = AjaxResult.success(); ajax.put("url", url); - ajax.put("fileName", fileName); + ajax.put("fileName", url); ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("originalFilename", file.getOriginalFilename()); return ajax; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/CmsArticleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/CmsArticleController.java index 9ddb9cbb..490763a5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/CmsArticleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/CmsArticleController.java @@ -33,8 +33,7 @@ import com.ruoyi.common.core.page.TableDataInfo; */ @RestController @RequestMapping("/system/article") -public class CmsArticleController extends BaseController -{ +public class CmsArticleController extends BaseController { @Autowired private ICmsArticleService cmsArticleService; @@ -46,15 +45,14 @@ public class CmsArticleController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:article:list')") @GetMapping("/list") - public TableDataInfo list(CmsArticle cmsArticle) - { + public TableDataInfo list(CmsArticle cmsArticle) { startPage(); List list = cmsArticleService.selectCmsArticleList(cmsArticle); - for (int i = 0;i list = cmsArticleService.selectCmsArticleList(cmsArticle); ExcelUtil util = new ExcelUtil(CmsArticle.class); util.exportExcel(response, list, "文章管理数据"); @@ -79,8 +76,7 @@ public class CmsArticleController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:article:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return success(cmsArticleService.selectCmsArticleById(id)); } @@ -90,9 +86,14 @@ public class CmsArticleController extends BaseController @PreAuthorize("@ss.hasPermi('system:article:add')") @Log(title = "文章管理", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody CmsArticle cmsArticle) - { + public AjaxResult add(@RequestBody CmsArticle cmsArticle) { String content = new String(Base64.decode(cmsArticle.getContent())); + if (content.contains("/dev-api")) { + content = content.replace("/dev-api", ""); + } + if (content.contains("/prod-api")) { + content = content.replace("/prod-api", ""); + } cmsArticle.setContent(content); return toAjax(cmsArticleService.insertCmsArticle(cmsArticle)); } @@ -103,9 +104,14 @@ public class CmsArticleController extends BaseController @PreAuthorize("@ss.hasPermi('system:article:edit')") @Log(title = "文章管理", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody CmsArticle cmsArticle) - { + public AjaxResult edit(@RequestBody CmsArticle cmsArticle) { String content = new String(Base64.decode(cmsArticle.getContent())); + if (content.contains("/dev-api")) { + content = content.replace("/dev-api", ""); + } + if (content.contains("/prod-api")) { + content = content.replace("/prod-api", ""); + } cmsArticle.setContent(content); return toAjax(cmsArticleService.updateCmsArticle(cmsArticle)); } @@ -115,9 +121,8 @@ public class CmsArticleController extends BaseController */ @PreAuthorize("@ss.hasPermi('system:article:remove')") @Log(title = "文章管理", businessType = BusinessType.DELETE) - @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + @DeleteMapping("/{ids}") + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(cmsArticleService.deleteCmsArticleByIds(ids)); } }