diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSCategoryAPI.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSCategoryAPI.java index 0dc2927..173acd5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSCategoryAPI.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSCategoryAPI.java @@ -20,7 +20,7 @@ public class CMSCategoryAPI extends BaseController { private ICmsCategoryService categoryService; /** - * 获取栏目及文章 + * 获取栏目了栏目 */ @GetMapping("/list") public AjaxResult getCategory(CmsCategory category){ @@ -28,7 +28,7 @@ public class CMSCategoryAPI extends BaseController { } /** - * 获取栏目下的子栏目及文章 + * 获取栏目下的子栏目及内容 * @param id 顶层栏目ID */ @GetMapping("/{id}") @@ -37,7 +37,7 @@ public class CMSCategoryAPI extends BaseController { } /** - * 获取某个子栏目的文章 + * 获取某个子栏目的内容 */ @GetMapping("/content/{id}") public AjaxResult getContentById(@PathVariable Long id){ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSContentAPI.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSContentAPI.java index 48ff7be..804da18 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSContentAPI.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/api/CMSContentAPI.java @@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; + @Anonymous @RestController @RequestMapping("/api/content") @@ -19,7 +20,7 @@ public class CMSContentAPI extends BaseController { private ICmsContentService contentService; /** - * 文章详情 + * 内容详情 * @param id * @return */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsContentController.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsContentController.java index 226d916..882a9ae 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsContentController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/CmsContentController.java @@ -28,7 +28,7 @@ import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; /** - * 文章Controller + * 内容Controller * * @author 点亮信息 * @date 2024-07-19 @@ -44,7 +44,7 @@ public class CmsContentController extends BaseController private ICmsCategoryService cmsCategoryService; /** - * 查询文章列表 + * 查询内容列表 */ @PreAuthorize("@ss.hasPermi('cms:content:list')") @GetMapping("/list") @@ -56,20 +56,20 @@ public class CmsContentController extends BaseController } /** - * 导出文章列表 + * 导出内容列表 */ @PreAuthorize("@ss.hasPermi('cms:content:export')") - @Log(title = "文章", businessType = BusinessType.EXPORT) + @Log(title = "内容", businessType = BusinessType.EXPORT) @PostMapping("/export") public void export(HttpServletResponse response, CmsContent cmsContent) { List list = cmsContentService.selectCmsContentList(cmsContent); ExcelUtil util = new ExcelUtil(CmsContent.class); - util.exportExcel(response, list, "文章数据"); + util.exportExcel(response, list, "内容数据"); } /** - * 获取文章详细信息 + * 获取内容详细信息 */ @PreAuthorize("@ss.hasPermi('cms:content:query')") @GetMapping(value = "/{id}") @@ -79,21 +79,22 @@ public class CmsContentController extends BaseController } /** - * 新增文章 + * 新增内容 */ @PreAuthorize("@ss.hasPermi('cms:content:add')") - @Log(title = "文章", businessType = BusinessType.INSERT) + @Log(title = "内容", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody CmsContent cmsContent) { + System.out.println(cmsContent); return toAjax(cmsContentService.insertCmsContent(cmsContent)); } /** - * 修改文章 + * 修改内容 */ @PreAuthorize("@ss.hasPermi('cms:content:edit')") - @Log(title = "文章", businessType = BusinessType.UPDATE) + @Log(title = "内容", businessType = BusinessType.UPDATE) @PutMapping public AjaxResult edit(@RequestBody CmsContent cmsContent) { @@ -101,10 +102,10 @@ public class CmsContentController extends BaseController } /** - * 删除文章 + * 删除内容 */ @PreAuthorize("@ss.hasPermi('cms:content:remove')") - @Log(title = "文章", businessType = BusinessType.DELETE) + @Log(title = "内容", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") public AjaxResult remove(@PathVariable Long[] ids, Principal principal) { @@ -124,7 +125,7 @@ public class CmsContentController extends BaseController /** * 恢复记录 */ - @Log(title = "文章", businessType = BusinessType.DELETE) + @Log(title = "内容", businessType = BusinessType.DELETE) @PutMapping("/{ids}") public AjaxResult recoverContentByIds(@PathVariable Long[] ids, Principal principal) { @@ -132,12 +133,12 @@ public class CmsContentController extends BaseController } /** - * 发布文章,改变文章状态时用 + * 发布内容,改变内容状态时用 * @param ids * @param principal * @return */ - @Log(title = "文章", businessType = BusinessType.UPDATE) + @Log(title = "内容", businessType = BusinessType.UPDATE) @PutMapping("/changeStatus/{ids}") public AjaxResult changeContentByIds(@PathVariable Long[] ids, Principal principal){ return toAjax(cmsContentService.changeContentByIds(ids, principal.getName())); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/UeditorController.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/UeditorController.java index d13bf13..c8b12dc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/UeditorController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/controller/UeditorController.java @@ -9,9 +9,9 @@ import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.file.FileUploadUtils; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.util.ClassUtils; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; @@ -20,7 +20,9 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Anonymous @@ -102,4 +104,41 @@ public class UeditorController { public AjaxResult getLeavesCategoryList(){ return AjaxResult.success(categoryService.getLeavesCategoryList()); } + + /** + * 通用上传请求(多个) + */ +// @PostMapping("/uploads") +// public AjaxResult uploadFiles(List files) throws Exception +// { +// try +// { +// // 上传文件路径 +// String filePath = RuoYiConfig.getUploadPath(); +// List urls = new ArrayList(); +// List fileNames = new ArrayList(); +// List newFileNames = new ArrayList(); +// List originalFilenames = new ArrayList(); +// for (MultipartFile file : files) +// { +// // 上传并返回新文件名称 +// String fileName = FileUploadUtils.upload(filePath, file); +// String url = serverConfig.getUrl() + fileName; +// urls.add(url); +// fileNames.add(fileName); +// newFileNames.add(FileUtils.getName(fileName)); +// originalFilenames.add(file.getOriginalFilename()); +// } +// AjaxResult ajax = AjaxResult.success(); +// ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER)); +// ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER)); +// ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER)); +// ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER)); +// return ajax; +// } +// catch (Exception e) +// { +// return AjaxResult.error(e.getMessage()); +// } +// } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java index f1ed36b..3302287 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/domain/CmsContent.java @@ -1,9 +1,11 @@ package com.ruoyi.cms.domain; import com.alibaba.fastjson2.annotation.JSONField; +import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.ruoyi.system.handler.MysqlTypeHandler; import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -11,9 +13,10 @@ import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.core.domain.BaseEntity; import java.util.Date; +import java.util.List; /** - * 文章对象 cms_content + * 内容对象 cms_content * * @author 点亮信息 * @date 2024-07-19 @@ -42,8 +45,8 @@ public class CmsContent extends BaseEntity @Excel(name = "缩略图") private String contentImg; - /** 文章内容 */ - @Excel(name = "文章内容") + /** 内容 */ + @Excel(name = "内容") private String contentDetail; /** 来源 */ @@ -90,13 +93,15 @@ public class CmsContent extends BaseEntity /** 附件路径 */ @Excel(name = "附件路径") - private String accessoryUrl; + private List accessoryUrl; /** 图片地址 */ - private String imageUrl; + @Excel(name = "图片地址") + private List imageUrl; /** 视频地址 */ - private String videoUrl; + @Excel(name = "视频地址") + private List videoUrl; /** 逻辑删除0未删除1真删除 */ private Integer delFlag; diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/mapper/CmsContentMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/mapper/CmsContentMapper.java index 318dd26..00a3bbe 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/mapper/CmsContentMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/mapper/CmsContentMapper.java @@ -7,7 +7,7 @@ import com.ruoyi.cms.domain.CmsContent; import org.apache.ibatis.annotations.Param; /** - * 文章Mapper接口 + * 内容Mapper接口 * * @author 点亮信息 * @date 2024-07-19 @@ -15,47 +15,47 @@ import org.apache.ibatis.annotations.Param; public interface CmsContentMapper extends BaseMapper { /** - * 查询文章 + * 查询内容 * - * @param id 文章主键 - * @return 文章 + * @param id 内容主键 + * @return 内容 */ public CmsContent selectCmsContentById(Long id); /** - * 查询文章列表 + * 查询内容列表 * - * @param cmsContent 文章 - * @return 文章集合 + * @param cmsContent 内容 + * @return 内容集合 */ public List selectCmsContentList(CmsContent cmsContent); /** - * 新增文章 + * 新增内容 * - * @param cmsContent 文章 + * @param cmsContent 内容 * @return 结果 */ public int insertCmsContent(CmsContent cmsContent); /** - * 修改文章 + * 修改内容 * - * @param cmsContent 文章 + * @param cmsContent 内容 * @return 结果 */ public int updateCmsContent(CmsContent cmsContent); /** - * 删除文章 + * 删除内容 * - * @param id 文章主键 + * @param id 内容主键 * @return 结果 */ public int deleteCmsContentById(Long id); /** - * 批量删除文章 + * 批量删除内容 * * @param ids 需要删除的数据主键集合 * @return 结果 diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsContentService.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsContentService.java index 022c6d5..ab0fe99 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsContentService.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/ICmsContentService.java @@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.ruoyi.cms.domain.CmsContent; /** - * 文章Service接口 + * 内容Service接口 * * @author 点亮信息 * @date 2024-07-19 @@ -14,49 +14,49 @@ import com.ruoyi.cms.domain.CmsContent; public interface ICmsContentService extends IService { /** - * 查询文章 + * 查询内容 * - * @param id 文章主键 - * @return 文章 + * @param id 内容主键 + * @return 内容 */ public CmsContent selectCmsContentById(Long id); /** - * 查询文章列表 + * 查询内容列表 * - * @param cmsContent 文章 - * @return 文章集合 + * @param cmsContent 内容 + * @return 内容集合 */ public List selectCmsContentList(CmsContent cmsContent); /** - * 新增文章 + * 新增内容 * - * @param cmsContent 文章 + * @param cmsContent 内容 * @return 结果 */ public int insertCmsContent(CmsContent cmsContent); /** - * 修改文章 + * 修改内容 * - * @param cmsContent 文章 + * @param cmsContent 内容 * @return 结果 */ public int updateCmsContent(CmsContent cmsContent); /** - * 批量删除文章 + * 批量删除内容 * - * @param ids 需要删除的文章主键集合 + * @param ids 需要删除的内容主键集合 * @return 结果 */ public int deleteCmsContentByIds(Long[] ids, String username); /** - * 删除文章信息 + * 删除内容信息 * - * @param id 文章主键 + * @param id 内容主键 * @return 结果 */ public int deleteCmsContentById(Long id); @@ -67,7 +67,7 @@ public interface ICmsContentService extends IService int recoverContentByIds(Long[] ids, String username); /** - * 发布文章,改变文章状态时用 + * 发布内容,改变内容状态时用 * @param ids * @return */ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java index 5815d23..3136ef3 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsCategoryServiceImpl.java @@ -26,8 +26,6 @@ import com.ruoyi.cms.mapper.CmsCategoryMapper; import com.ruoyi.cms.domain.CmsCategory; import com.ruoyi.cms.service.ICmsCategoryService; -import javax.annotation.Resource; - /** * 栏目Service业务层处理 * @@ -237,13 +235,11 @@ public class CmsCategoryServiceImpl extends ServiceImpl getContentById(Long id) { PageHelper.startPage(1, 10); - List contents = contentMapper.selectList(new QueryWrapper() - .and(item -> { - item.eq("category_id", id) - .eq("status", "1"); - }) - .orderByDesc("create_time") - ); + CmsContent content = new CmsContent(); + content.setCategoryId(id); + content.setStatus("1"); + content.setDelFlag(0); + List contents = contentMapper.selectCmsContentList(content); return new PageInfo(contents); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsContentServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsContentServiceImpl.java index 84128dc..f0484b5 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsContentServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/cms/service/impl/CmsContentServiceImpl.java @@ -15,7 +15,7 @@ import com.ruoyi.cms.domain.CmsContent; import com.ruoyi.cms.service.ICmsContentService; /** - * 文章Service业务层处理 + * 内容Service业务层处理 * * @author 点亮信息 * @date 2024-07-19 @@ -27,10 +27,10 @@ public class CmsContentServiceImpl extends ServiceImpl selectCmsContentList(CmsContent cmsContent) @@ -51,9 +51,9 @@ public class CmsContentServiceImpl extends ServiceImpl - + - - + + @@ -57,6 +57,7 @@ and accessory_url = #{accessoryUrl} and del_flag = #{delFlag} + order by create_time desc, update_time desc @@ -41,7 +41,7 @@ and category_id = #{categoryId} and content_type = #{contentType} - and content_title = #{contentTitle} + and content_title like concat('%', #{contentTitle}, '%') and content_img = #{contentImg} and content_detail = #{contentDetail} and source = #{source} @@ -55,7 +55,9 @@ and offline_date = #{offlineDate} and is_accessory = #{isAccessory} and accessory_url = #{accessoryUrl} + and del_flag = #{delFlag} + order by create_time desc, update_time desc