2024.5.15 纪念馆新后台

This commit is contained in:
libao 2024-05-15 10:23:04 +08:00
parent bdc336f8f9
commit 10b079283c
2 changed files with 26 additions and 21 deletions

View File

@ -23,7 +23,7 @@ import com.ruoyi.framework.config.ServerConfig;
/** /**
* 通用请求处理 * 通用请求处理
* *
* @author ruoyi * @author ruoyi
*/ */
@RestController @RestController
@ -39,7 +39,7 @@ public class CommonController
/** /**
* 通用下载请求 * 通用下载请求
* *
* @param fileName 文件名称 * @param fileName 文件名称
* @param delete 是否删除 * @param delete 是否删除
*/ */
@ -84,7 +84,7 @@ public class CommonController
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("url", url); ajax.put("url", url);
ajax.put("fileName", fileName); ajax.put("fileName", url);
ajax.put("newFileName", FileUtils.getName(fileName)); ajax.put("newFileName", FileUtils.getName(fileName));
ajax.put("originalFilename", file.getOriginalFilename()); ajax.put("originalFilename", file.getOriginalFilename());
return ajax; return ajax;

View File

@ -33,8 +33,7 @@ import com.ruoyi.common.core.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/system/article") @RequestMapping("/system/article")
public class CmsArticleController extends BaseController public class CmsArticleController extends BaseController {
{
@Autowired @Autowired
private ICmsArticleService cmsArticleService; private ICmsArticleService cmsArticleService;
@ -46,15 +45,14 @@ public class CmsArticleController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:article:list')") @PreAuthorize("@ss.hasPermi('system:article:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(CmsArticle cmsArticle) public TableDataInfo list(CmsArticle cmsArticle) {
{
startPage(); startPage();
List<CmsArticle> list = cmsArticleService.selectCmsArticleList(cmsArticle); List<CmsArticle> list = cmsArticleService.selectCmsArticleList(cmsArticle);
for (int i = 0;i<list.size();i++){ for (int i = 0; i < list.size(); i++) {
CmsCategory category = categoryService.selectCmsCategoryByCategoryId(Long.valueOf(list.get(i).getCategoryId())); CmsCategory category = categoryService.selectCmsCategoryByCategoryId(Long.valueOf(list.get(i).getCategoryId()));
if(category != null){ if (category != null) {
list.get(i).setCategoryName(category.getCategoryName()); list.get(i).setCategoryName(category.getCategoryName());
}else { } else {
list.get(i).setCategoryName(null); list.get(i).setCategoryName(null);
} }
} }
@ -67,8 +65,7 @@ public class CmsArticleController extends BaseController
@PreAuthorize("@ss.hasPermi('system:article:export')") @PreAuthorize("@ss.hasPermi('system:article:export')")
@Log(title = "文章管理", businessType = BusinessType.EXPORT) @Log(title = "文章管理", businessType = BusinessType.EXPORT)
@PostMapping("/export") @PostMapping("/export")
public void export(HttpServletResponse response, CmsArticle cmsArticle) public void export(HttpServletResponse response, CmsArticle cmsArticle) {
{
List<CmsArticle> list = cmsArticleService.selectCmsArticleList(cmsArticle); List<CmsArticle> list = cmsArticleService.selectCmsArticleList(cmsArticle);
ExcelUtil<CmsArticle> util = new ExcelUtil<CmsArticle>(CmsArticle.class); ExcelUtil<CmsArticle> util = new ExcelUtil<CmsArticle>(CmsArticle.class);
util.exportExcel(response, list, "文章管理数据"); util.exportExcel(response, list, "文章管理数据");
@ -79,8 +76,7 @@ public class CmsArticleController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:article:query')") @PreAuthorize("@ss.hasPermi('system:article:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id) {
{
return success(cmsArticleService.selectCmsArticleById(id)); return success(cmsArticleService.selectCmsArticleById(id));
} }
@ -90,9 +86,14 @@ public class CmsArticleController extends BaseController
@PreAuthorize("@ss.hasPermi('system:article:add')") @PreAuthorize("@ss.hasPermi('system:article:add')")
@Log(title = "文章管理", businessType = BusinessType.INSERT) @Log(title = "文章管理", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody CmsArticle cmsArticle) public AjaxResult add(@RequestBody CmsArticle cmsArticle) {
{
String content = new String(Base64.decode(cmsArticle.getContent())); 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); cmsArticle.setContent(content);
return toAjax(cmsArticleService.insertCmsArticle(cmsArticle)); return toAjax(cmsArticleService.insertCmsArticle(cmsArticle));
} }
@ -103,9 +104,14 @@ public class CmsArticleController extends BaseController
@PreAuthorize("@ss.hasPermi('system:article:edit')") @PreAuthorize("@ss.hasPermi('system:article:edit')")
@Log(title = "文章管理", businessType = BusinessType.UPDATE) @Log(title = "文章管理", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody CmsArticle cmsArticle) public AjaxResult edit(@RequestBody CmsArticle cmsArticle) {
{
String content = new String(Base64.decode(cmsArticle.getContent())); 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); cmsArticle.setContent(content);
return toAjax(cmsArticleService.updateCmsArticle(cmsArticle)); return toAjax(cmsArticleService.updateCmsArticle(cmsArticle));
} }
@ -115,9 +121,8 @@ public class CmsArticleController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('system:article:remove')") @PreAuthorize("@ss.hasPermi('system:article:remove')")
@Log(title = "文章管理", businessType = BusinessType.DELETE) @Log(title = "文章管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids) {
{
return toAjax(cmsArticleService.deleteCmsArticleByIds(ids)); return toAjax(cmsArticleService.deleteCmsArticleByIds(ids));
} }
} }