依据需求更改

master
rong.liu 2 years ago
parent 1b58f64ce0
commit 452488703f
  1. 47
      src/main/java/com/huoran/iasf/controller/SysColumnController.java
  2. 35
      src/main/java/com/huoran/iasf/controller/SysTemplateController.java
  3. 5
      src/main/java/com/huoran/iasf/entity/SysTemplateStyle.java
  4. 3
      src/main/java/com/huoran/iasf/mapper/SysColumnMapper.java
  5. 4
      src/main/java/com/huoran/iasf/mapper/SysContentMapper.java
  6. 63
      src/main/java/com/huoran/iasf/mapper/xml/SysColumnMapper.xml
  7. 88
      src/main/java/com/huoran/iasf/mapper/xml/SysContentMapper.xml
  8. 3
      src/main/java/com/huoran/iasf/service/SysColumnService.java
  9. 2
      src/main/java/com/huoran/iasf/service/SysTemplateStyleService.java
  10. 5
      src/main/java/com/huoran/iasf/service/impl/SysColumnServiceImpl.java
  11. 8
      src/main/java/com/huoran/iasf/service/impl/SysContentServiceImpl.java
  12. 6
      src/main/java/com/huoran/iasf/vo/req/PageContentReqVO.java
  13. 8
      src/main/java/com/huoran/iasf/vo/resp/PageContentRespVO.java
  14. 2
      src/test/java/com/company/project/CodeGenerator.java

@ -26,6 +26,7 @@ import com.huoran.iasf.service.SysColumnService;
import javax.validation.Valid;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
@ -70,6 +71,10 @@ public class SysColumnController {
@PostMapping("/save")
@ApiOperation(value = "新增", response = SysColumn.class)
public R save(@RequestBody @Valid SysColumn sysColumn) {
QueryWrapper<SysColumn> queryWrapper = new QueryWrapper<SysColumn>();
queryWrapper.eq("father_id", sysColumn.getFatherId());
Integer count = service.count(queryWrapper);
sysColumn.setSort(count+1);
boolean addState = service.save(sysColumn);
return addState ? R.success(sysColumn.getId()) : R.fail("新增失败");
}
@ -87,7 +92,7 @@ public class SysColumnController {
boolean delState = service.removeById(id);
QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>();
queryWrapper.in("column_id",id);
queryWrapper.in("column_id", id);
//删除栏目后删除栏目下的文章
List<SysContent> contentId = contentService.list(queryWrapper);
contentService.removeByIds(contentId);
@ -100,7 +105,7 @@ public class SysColumnController {
public R batchDeletion(@ApiParam(name = "ids", value = "主键", required = true) @RequestParam List<Integer> ids) {
boolean delState = service.removeByIds(ids);
QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>();
queryWrapper.in("column_id",ids);
queryWrapper.in("column_id", ids);
//删除栏目后删除栏目下的文章
contentService.remove(queryWrapper);
return delState ? R.success() : R.fail("删除失败");
@ -135,5 +140,43 @@ public class SysColumnController {
return R.success();
}
@ApiOperation("获取一级下的子级栏目(包含自己)")
@PostMapping("/getsTheSubColumn")
public R getsTheSubColumn(Integer id) {
//1 创建list集合,用于封装所有删除菜单id值
List<Integer> idList = new ArrayList<>();
//2 向idList集合设置删除菜单id
this.selectCategoryChildById(id + "", idList);//找到当前菜单的子菜单 把结果id封装到idlist里面去
//把当前id封装到list里面
idList.add(id);//现在把当前id封装进去 之前都是子菜单的id
String str = "";
for (Integer idstr : idList) {
str += idstr + ",";
}
String ids = str.substring(0, str.length() - 1);
return service.getsTheSubColumn(id, ids);
}
public void selectCategoryChildById(String id, List<Integer> idList) {
//查询菜单里面子菜单id
QueryWrapper<SysColumn> wrapper = new QueryWrapper<SysColumn>();
wrapper.eq("father_id", id);
wrapper.eq("deleted", Constant.DATA_NOT_DELETED);
wrapper.select("id");//我们只想查询id 所以只需要查询指定列的值
List<SysColumn> childIdList = service.list(wrapper);//当前菜单的所有子菜单
//把childIdList里面菜单id值获取出来,封装idList里面,做递归查询
childIdList.stream().forEach(item -> {//遍历集合得到每一个对象item
//封装idList里面
idList.add(item.getId());
//递归查询
this.selectCategoryChildById(item.getId() + "", idList);
});
}
}

@ -3,6 +3,8 @@ package com.huoran.iasf.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.huoran.iasf.common.utils.Constant;
import com.huoran.iasf.entity.SysTemplateStyle;
import com.huoran.iasf.entity.SysTemplateStyleConfiguration;
import com.huoran.iasf.service.SysTemplateStyleConfigurationService;
import com.huoran.iasf.service.SysTemplateStyleService;
import io.swagger.annotations.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -41,12 +43,13 @@ public class SysTemplateController {
@Autowired
public SysTemplateStyleService styleService;
@Autowired
public SysTemplateStyleConfigurationService templateStyleConfigurationService;
@PostMapping("/listOfColumnTemplates")
@ApiOperation(value = "获取文章模板列表、详情样式", response = SysTemplate.class)
public R listOfColumnTemplates() {
List<SysTemplate> list = templateService.list(new QueryWrapper<SysTemplate>().eq("type",1));
List<SysTemplate> list = templateService.list(new QueryWrapper<SysTemplate>().eq("type", 1));
return R.success(list);
}
@ -54,7 +57,7 @@ public class SysTemplateController {
@PostMapping("/longPageListStyle")
@ApiOperation(value = "长页列表样式", response = SysTemplate.class)
public R longPageListStyle() {
List<SysTemplateStyle> list = styleService.list(new QueryWrapper<SysTemplateStyle>().eq("template_id",9));
List<SysTemplateStyle> list = styleService.list(new QueryWrapper<SysTemplateStyle>().eq("is_long_page", 1));
return R.success(list);
}
@ -62,28 +65,28 @@ public class SysTemplateController {
@ApiOperation(value = "根据模板id获取样式", response = SysTemplateStyle.class)
public R theTemplateIdGetsTheStyle(@ApiParam(name = "templateId", value = "模板id", required = true) @RequestParam Integer templateId) {
QueryWrapper<SysTemplateStyle> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("template_id",templateId);
/*QueryWrapper<SysTemplateStyle> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("type", Constant.LIST_TEMPLATE_TYPES);
queryWrapper.eq("is_long_page", 0);
List<SysTemplateStyle> listingTemplateTypes = styleService.list(queryWrapper);
QueryWrapper<SysTemplateStyle> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("template_id",templateId);
queryWrapper1.eq("type", Constant.DETAILS_TEMPLATE_TYPE);
List<SysTemplateStyle> detailsTypeOfTheTemplate = styleService.list(queryWrapper1);
List<SysTemplateStyle> detailsTypeOfTheTemplate = styleService.list(queryWrapper1);*/
List<SysTemplateStyle> listingTemplateTypes = templateStyleConfigurationService.getsTheStyleUnderTheTemplate(templateId, 0);
List<SysTemplateStyle> detailsTypeOfTheTemplate = templateStyleConfigurationService.getsTheStyleUnderTheTemplate(templateId, 1);
Map<String,Object> map = new HashMap<>();
map.put("listingTemplateTypes",listingTemplateTypes);//列表样式
map.put("detailsTypeOfTheTemplate",detailsTypeOfTheTemplate);//详情样式
Map<String, Object> map = new HashMap<>();
map.put("listingTemplateTypes", listingTemplateTypes);//列表样式
map.put("detailsTypeOfTheTemplate", detailsTypeOfTheTemplate);//详情样式
return R.success(map);
}
@PostMapping("/fullDetailsTemplateStyle")
@ApiOperation(value = "全部详情模板样式", response = SysTemplateStyle.class)
public R fullDetailsTemplateStyle() {
@ -93,5 +96,13 @@ public class SysTemplateController {
List<SysTemplateStyle> listingTemplateTypes = styleService.list(queryWrapper);
return R.success(listingTemplateTypes);
}
@PostMapping("/individualTemplateDetailsStyle")
@ApiOperation(value = "独立模板详情样式", response = SysTemplate.class)
public R individualTemplateDetailsStyle() {
List<SysTemplateStyle> list = styleService.list(new QueryWrapper<SysTemplateStyle>().eq("type", 1).eq("is_long_page", 0));
return R.success(list);
}
}

@ -35,13 +35,12 @@ public class SysTemplateStyle implements Serializable {
@ApiModelProperty(value = "样式名称")
private String style;
@ApiModelProperty(value = "模板id")
private Integer templateId;
@ApiModelProperty(value = "跳转路径")
private String path;
@ApiModelProperty(value = "是否为长页")
private Integer isLongPage;
}

@ -2,6 +2,7 @@ package com.huoran.iasf.mapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.huoran.iasf.common.utils.R;
import com.huoran.iasf.entity.SysColumn;
import com.huoran.iasf.vo.FatherContentRespVO;
import com.huoran.iasf.vo.req.LongPageColumnReqVO;
@ -32,4 +33,6 @@ public interface SysColumnMapper extends BaseMapper<SysColumn> {
//依据子级查询父级
List<FatherContentRespVO> getParentInformationBasedOnChild(@Param("id")Integer id);
List<SysColumn> getsTheSubColumn(@Param("parentId")Integer parentId ,@Param("ids")String ids);
}

@ -9,6 +9,8 @@ import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @描述文章管理 Mapper 接口
* @作者: Rong
@ -17,4 +19,6 @@ import org.apache.ibatis.annotations.Param;
@Mapper
public interface SysContentMapper extends BaseMapper<SysContent> {
IPage<PageContentRespVO> articlePaginationList(Page<PageContentRespVO> page, @Param("req") PageContentReqVO req);
IPage<PageContentRespVO> getPublishedArticles(Page<PageContentRespVO> page, @Param("req") PageContentReqVO req);
}

@ -49,9 +49,7 @@
<if test="vo.isSort== 1">
ORDER BY
s.father_id,
s.sort ASC,
s.create_time desc
s.sort ASC
</if>
<if test="vo.isSort== 0">
ORDER BY
@ -78,16 +76,13 @@
T2.father_id,
T2.level,
T2.sort
FROM (
SELECT @r AS _id,
FROM (SELECT @r AS _id,
( SELECT @r := father_id FROM sys_column WHERE id = _id ) AS parent_id,
@l := @l + 1 AS lvl
FROM
( SELECT @r := #{id}, @l := 0 ) vars,
sys_column h
( SELECT @r := #{id}, @l := 0 ) vars, sys_column h
WHERE
@r != 0
) T1
@r != 0) T1
JOIN sys_column T2 ON T1._id = T2.id
WHERE
deleted = 1
@ -102,7 +97,36 @@
( SELECT u.username FROM sys_user u WHERE u.id = s.editor_id ) AS editorUser,
( SELECT t.template_type FROM sys_template t WHERE t.id = s.template_id ) AS templateName,
( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS listStyle,
( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id ) AS detailStyle
( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id ) AS detailStyle,
( SELECT sty.path FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS path
FROM
sys_column s
WHERE deleted = 1 and site_id = #{vo.siteId}
and menu_visible = 0
<if test="vo.columnName != '' and vo.columnName!= null">
and column_name LIKE CONCAT('%',#{vo.columnName},'%')
</if>
<if test="vo.isSort== 1">
ORDER BY
s.sort ASC
</if>
<if test="vo.isSort== 0">
ORDER BY
s.create_time asc
</if>
</select>
<!--<select id="filterMenuVisible" resultType="com.huoran.iasf.entity.SysColumn">
SELECT
*,
( SELECT u.username FROM sys_user u WHERE u.id = s.founder_id ) AS creteUser,
( SELECT u.username FROM sys_user u WHERE u.id = s.editor_id ) AS editorUser,
( SELECT t.template_type FROM sys_template t WHERE t.id = s.template_id ) AS templateName,
( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS listStyle,
( SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id ) AS detailStyle,
( SELECT sty.path FROM sys_template_style sty WHERE sty.id = s.list_style_id ) AS path
FROM
sys_column s
WHERE deleted = 1 and site_id = #{vo.siteId}
@ -121,6 +145,25 @@
ORDER BY
s.create_time asc
</if>
</select>-->
<select id="getsTheSubColumn" resultType="com.huoran.iasf.entity.SysColumn">
SELECT *,
(SELECT u.username FROM sys_user u WHERE u.id = s.founder_id) AS creteUser,
(SELECT u.username FROM sys_user u WHERE u.id = s.editor_id) AS editorUser,
(SELECT t.template_type FROM sys_template t WHERE t.id = s.template_id) AS templateName,
(SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.list_style_id) AS listStyle,
(SELECT sty.style FROM sys_template_style sty WHERE sty.id = s.detail_style_id) AS detailStyle,
(SELECT sty.path FROM sys_template_style sty WHERE sty.id = s.list_style_id) AS path
FROM sys_column s
WHERE deleted = 1
AND site_id = 1
<if test="ids != '' and ids!= null">
and FIND_IN_SET(s.id, #{ids})
</if>
ORDER BY
s.create_time asc
</select>
</mapper>

@ -1,50 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.huoran.iasf.mapper.SysContentMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.huoran.iasf.entity.SysContent">
<id column="id" property="id"/>
<result column="title" property="title"/>
<result column="column_id" property="columnId"/>
<result column="title_img" property="titleImg"/>
<result column="banner_img" property="bannerImg"/>
<result column="source" property="source"/>
<result column="release_time" property="releaseTime"/>
<result column="summary" property="summary"/>
<result column="article_template" property="articleTemplate"/>
<result column="main_body" property="mainBody"/>
<result column="author" property="author"/>
<result column="is_release" property="isRelease"/>
<result column="founder_id" property="founderId"/>
<result column="editor_id" property="editorId"/>
<result column="create_time" property="createTime"/>
<result column="update_time" property="updateTime"/>
<result column="total_browsing" property="totalBrowsing"/>
<result column="connection_type" property="connectionType"/>
<result column="link_address" property="linkAddress"/>
<result column="site_selection" property="siteSelection"/>
<result column="is_open" property="isOpen"/>
<result column="deleted" property="deleted"/>
<result column="site_id" property="siteId"/>
<result column="template_status" property="templateStatus"/>
<result column="edit" property="edit"/>
<result column="audit" property="audit"/>
<result column="activity_start_time" property="activityStartTime"/>
<result column="activity_end_time" property="activityEndTime"/>
<result column="lecture_series" property="lectureSeries"/>
<result column="online_location" property="onlineLocation"/>
<result column="offline_location" property="offlineLocation"/>
<result column="keynote_speaker" property="keynoteSpeaker"/>
<result column="event_profile" property="eventProfile"/>
<result column="publication_year" property="publicationYear"/>
<result column="publication_type_id" property="publicationTypeId"/>
<result column="doi" property="doi"/>
<result column="quote" property="quote"/>
<result column="lable_id" property="lableId"/>
<result column="classification_id" property="classificationId"/>
</resultMap>
<select id="articlePaginationList" resultType="com.huoran.iasf.vo.resp.PageContentRespVO">
SELECT c.*,
(SELECT sys_column.column_name FROM sys_column WHERE sys_column.id = c.column_id) AS columnName,
@ -83,5 +39,49 @@
ORDER BY c.create_time desc
</select>
<select id="getPublishedArticles" resultType="com.huoran.iasf.vo.resp.PageContentRespVO">
SELECT
t.*
FROM
(
SELECT
s.*,
( SELECT GROUP_CONCAT( label_name ) FROM sys_content_label l WHERE deleted = 1 AND FIND_IN_SET( l.id, s.lable_id
) ) AS labelName,
( SELECT c.classification_name FROM sys_content_classification c WHERE deleted = 1 AND s.classification_id =
c.id ) AS classificationName
FROM
sys_content s
WHERE
is_disable = 0
AND is_release = 1
) t
WHERE
t.site_id = 1
<if test="req.lableId != null and req.lableId != ''">
AND FIND_IN_SET( #{req.lableId}, t.lable_id )
</if>
<if test="req.classificationId != null">
AND t.classification_id = #{req.classificationId}
</if>
<if test="req.title != null and req.title != ''">
AND title LIKE
CONCAT('%',#{req.title},'%')
</if>
<if test="req.columnIds != null and req.columnIds.size() > 0 ">
and t.column_id in
<foreach item="item" index="index" collection="req.columnIds"
open="(" separator="," close=")">
#{item}
</foreach>
</if>
ORDER BY
t.create_time DESC
</select>
</mapper>

@ -29,4 +29,7 @@ public interface SysColumnService extends IService<SysColumn> {
//长页栏目列表
R longPageColumnList(LongPageColumnReqVO reqVO);
R getsTheSubColumn(Integer parentId,String ids);
}

@ -3,6 +3,8 @@ package com.huoran.iasf.service;
import com.huoran.iasf.entity.SysTemplateStyle;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类

@ -133,6 +133,11 @@ public class SysColumnServiceImpl extends ServiceImpl<SysColumnMapper, SysColumn
return R.success(pageList);
}
@Override
public R getsTheSubColumn(Integer parentId,String ids) {
return R.success(baseMapper.getsTheSubColumn(parentId,ids));
}
public static List<SysColumn> getChildren(Integer id, List<SysColumn> allDept) {
//存放子节点

@ -58,11 +58,11 @@ public class SysContentServiceImpl extends ServiceImpl<SysContentMapper, SysCont
@Override
public R newlyPublishedArticles(PageContentReqVO reqVO) {
QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>();
/* QueryWrapper<SysContent> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("site_id", reqVO.getSiteId());
queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED).orderByDesc("create_time");
Page<SysContent> page = new Page<SysContent>(reqVO.getPageNum(), reqVO.getPageSize());
IPage<SysContent> pageList = baseMapper.selectPage(page, queryWrapper);
queryWrapper.eq("is_release", Constant.ARTICLE_PUBLISHED).orderByDesc("create_time");*/
Page<PageContentRespVO> page = new Page<PageContentRespVO>(reqVO.getPageNum(), reqVO.getPageSize());
IPage<PageContentRespVO> pageList = baseMapper.getPublishedArticles(page,reqVO);
return R.success(pageList);
}

@ -34,5 +34,11 @@ public class PageContentReqVO extends PageReqVO {
@NotNull(message = "站点id不能为空!")
private Integer siteId;
@ApiModelProperty(value = "标签id(逗号隔开)")
private String lableId;
@ApiModelProperty(value = "分类id")
private Integer classificationId;
}

@ -95,4 +95,12 @@ public class PageContentRespVO {
@ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)")
private Integer isDisable;
@ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)")
private String labelName;
@ApiModelProperty(value = "是否禁用(0默认,0启用 1禁用)")
private String classificationName;
}

@ -61,7 +61,7 @@ public class CodeGenerator {
// 5、策略配置
StrategyConfig strategy = new StrategyConfig();
strategy.setInclude("sys_template_style");
strategy.setInclude("sys_template_style_configuration");
strategy.setNaming(NamingStrategy.underline_to_camel);//数据库表映射到实体的命名策略
// strategy.setTablePrefix("sys_"); //生成实体时去掉表前缀

Loading…
Cancel
Save