|
|
@ -16,8 +16,10 @@ import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
import org.jeecg.modules.demo.cms.entity.CmsArticle; |
|
|
|
import org.jeecg.modules.demo.cms.entity.CmsArticle; |
|
|
|
import org.jeecg.modules.demo.cms.entity.CmsColumn; |
|
|
|
import org.jeecg.modules.demo.cms.entity.CmsColumn; |
|
|
|
|
|
|
|
import org.jeecg.modules.demo.cms.entity.Subweside; |
|
|
|
import org.jeecg.modules.demo.cms.service.ICmsArticleService; |
|
|
|
import org.jeecg.modules.demo.cms.service.ICmsArticleService; |
|
|
|
import org.jeecg.modules.demo.cms.service.ICmsColumnService; |
|
|
|
import org.jeecg.modules.demo.cms.service.ICmsColumnService; |
|
|
|
|
|
|
|
import org.jeecg.modules.demo.cms.service.ISubwesideService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.util.ObjectUtils; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
@ -27,6 +29,8 @@ import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @Description: 文章 |
|
|
|
* @Description: 文章 |
|
|
@ -44,6 +48,9 @@ public class CmsArticleController extends JeecgController<CmsArticle, ICmsArticl |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ICmsColumnService cmsColumnService; |
|
|
|
private ICmsColumnService cmsColumnService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private ISubwesideService subwesideService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 分页列表查询 |
|
|
|
* 分页列表查询 |
|
|
|
* |
|
|
|
* |
|
|
@ -85,6 +92,18 @@ public class CmsArticleController extends JeecgController<CmsArticle, ICmsArticl |
|
|
|
cmsArticle.setPublishTime(new Date()); |
|
|
|
cmsArticle.setPublishTime(new Date()); |
|
|
|
cmsArticle.setStatus("1"); |
|
|
|
cmsArticle.setStatus("1"); |
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
QueryWrapper<Subweside> subwesideQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
subwesideQueryWrapper.in("id", principal.getId()); |
|
|
|
|
|
|
|
List<Subweside> subwesideList = subwesideService.list(subwesideQueryWrapper); |
|
|
|
|
|
|
|
if (!subwesideList.isEmpty()) { |
|
|
|
|
|
|
|
List<String> subnames = subwesideList.stream() |
|
|
|
|
|
|
|
.map(Subweside::getSubname) // 将每个Subweside对象映射到其subname字段
|
|
|
|
|
|
|
|
.collect(Collectors.toList()); // 收集结果到List<String>
|
|
|
|
|
|
|
|
String joinedString = String.join(", ", subnames); |
|
|
|
|
|
|
|
cmsArticle.setSource("来自子站:"+joinedString); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
cmsArticle.setSource("来自子站管理员"); |
|
|
|
|
|
|
|
} |
|
|
|
cmsArticleService.save(cmsArticle); |
|
|
|
cmsArticleService.save(cmsArticle); |
|
|
|
return Result.OK("添加成功!"); |
|
|
|
return Result.OK("添加成功!"); |
|
|
|
} |
|
|
|
} |
|
|
@ -111,10 +130,23 @@ public class CmsArticleController extends JeecgController<CmsArticle, ICmsArticl |
|
|
|
// @RequiresPermissions("cms:cms_article:edit")
|
|
|
|
// @RequiresPermissions("cms:cms_article:edit")
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
|
|
|
public Result<String> edit(@RequestBody CmsArticle cmsArticle) { |
|
|
|
public Result<String> edit(@RequestBody CmsArticle cmsArticle) { |
|
|
|
|
|
|
|
LoginUser principal = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
CmsColumn cmsColumn = cmsColumnService.getById(cmsArticle.getColumnId()); |
|
|
|
CmsColumn cmsColumn = cmsColumnService.getById(cmsArticle.getColumnId()); |
|
|
|
if (!ObjectUtils.isEmpty(cmsColumn)) { |
|
|
|
if (!ObjectUtils.isEmpty(cmsColumn)) { |
|
|
|
cmsArticle.setColumnName(cmsColumn.getName()); |
|
|
|
cmsArticle.setColumnName(cmsColumn.getName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
QueryWrapper<Subweside> subwesideQueryWrapper = new QueryWrapper<>(); |
|
|
|
|
|
|
|
subwesideQueryWrapper.in("id", principal.getId()); |
|
|
|
|
|
|
|
List<Subweside> subwesideList = subwesideService.list(subwesideQueryWrapper); |
|
|
|
|
|
|
|
if (!subwesideList.isEmpty()) { |
|
|
|
|
|
|
|
List<String> subnames = subwesideList.stream() |
|
|
|
|
|
|
|
.map(Subweside::getSubname) // 将每个Subweside对象映射到其subname字段
|
|
|
|
|
|
|
|
.collect(Collectors.toList()); // 收集结果到List<String>
|
|
|
|
|
|
|
|
String joinedString = String.join(", ", subnames); |
|
|
|
|
|
|
|
cmsArticle.setSource("来自子站:"+joinedString); |
|
|
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
cmsArticle.setSource("管理员"); |
|
|
|
|
|
|
|
} |
|
|
|
cmsArticleService.updateById(cmsArticle); |
|
|
|
cmsArticleService.updateById(cmsArticle); |
|
|
|
return Result.OK("编辑成功!"); |
|
|
|
return Result.OK("编辑成功!"); |
|
|
|
} |
|
|
|
} |
|
|
|