提交 2f88b7b1 作者: 925993793@qq.com

自定义专题-部分逻辑调整、bug修改以及研究中心补充接口

上级 9425dabd
package com.zzsn.event.config; package com.zzsn.event.config;
import com.zzsn.event.util.user.AuthUtil; import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserVo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.binding.MapperMethod.ParamMap; import org.apache.ibatis.binding.MapperMethod.ParamMap;
...@@ -101,7 +102,12 @@ public class MybatisInterceptor implements Interceptor { ...@@ -101,7 +102,12 @@ public class MybatisInterceptor implements Interceptor {
} }
private String getLoginUsername() { private String getLoginUsername() {
return AuthUtil.getLoginUser().getUsername(); String username = null;
UserVo loginUser = AuthUtil.getLoginUser();
if(loginUser != null){
username = loginUser.getUsername();
}
return username;
} }
//修改对应字段的值 //修改对应字段的值
......
...@@ -57,8 +57,6 @@ public class SubjectManageController { ...@@ -57,8 +57,6 @@ public class SubjectManageController {
private ISubjectKeywordsMapService subjectKeywordsMapService; private ISubjectKeywordsMapService subjectKeywordsMapService;
@Autowired @Autowired
private IXxlJobInfoService xxlJobInfoService; private IXxlJobInfoService xxlJobInfoService;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Autowired @Autowired
private IInfoSourceService infoSourceService; private IInfoSourceService infoSourceService;
@Autowired @Autowired
...@@ -76,14 +74,17 @@ public class SubjectManageController { ...@@ -76,14 +74,17 @@ public class SubjectManageController {
@Autowired @Autowired
private ISubjectInfoSourceMapService subjectInfoSourceMapService; private ISubjectInfoSourceMapService subjectInfoSourceMapService;
@Autowired @Autowired
private ObsUtil obsUtil;
@Autowired
private SubjectSampleFileService subjectSampleFileService; private SubjectSampleFileService subjectSampleFileService;
@Autowired @Autowired
private SubjectInfoSourceMiddleMapService subjectInfoSourceMiddleMapService; private SubjectInfoSourceMiddleMapService subjectInfoSourceMiddleMapService;
@Autowired @Autowired
private SysDictItemService sysDictItemService; private SysDictItemService sysDictItemService;
@Autowired
private ObsUtil obsUtil;
@Resource
private KafkaTemplate<String, String> kafkaTemplate;
@Value("${hotWords.extractUrl}") @Value("${hotWords.extractUrl}")
private String extractHotWordsUrl; private String extractHotWordsUrl;
...@@ -126,6 +127,8 @@ public class SubjectManageController { ...@@ -126,6 +127,8 @@ public class SubjectManageController {
public Result<?> researchCenterPageList(SubjectCondition subjectCondition, public Result<?> researchCenterPageList(SubjectCondition subjectCondition,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
UserVo loginUser = AuthUtil.getLoginUser();
subjectCondition.setUsername(loginUser.getUsername());
Page<SubjectPage> pageList = subjectService.researchCenterPageList(subjectCondition, pageNo, pageSize); Page<SubjectPage> pageList = subjectService.researchCenterPageList(subjectCondition, pageNo, pageSize);
return Result.OK(pageList); return Result.OK(pageList);
} }
...@@ -206,7 +209,7 @@ public class SubjectManageController { ...@@ -206,7 +209,7 @@ public class SubjectManageController {
try { try {
for (MultipartFile file : files) { for (MultipartFile file : files) {
InputStream inputStream = file.getInputStream(); InputStream inputStream = file.getInputStream();
PutObjectResult putObjectResult = obsUtil.uploadFile("subjectSampleFile", inputStream); PutObjectResult putObjectResult = obsUtil.uploadFile("subjectSampleFile/" + file.getOriginalFilename(), inputStream);
String filePath = putObjectResult.getObjectKey(); String filePath = putObjectResult.getObjectKey();
SubjectSampleFile subjectSampleFile = new SubjectSampleFile(); SubjectSampleFile subjectSampleFile = new SubjectSampleFile();
subjectSampleFile.setSubjectId(subjectId); subjectSampleFile.setSubjectId(subjectId);
...@@ -225,6 +228,19 @@ public class SubjectManageController { ...@@ -225,6 +228,19 @@ public class SubjectManageController {
} }
/** /**
* 获取专题详情(包含样例文章信息)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/8
*/
@GetMapping("/queryInfo")
public Result<?> queryInfo(@RequestParam String subjectId){
SubjectSampleFileInfoVO info = subjectService.queryInfo(subjectId);
return Result.OK(info);
}
/**
* 添加 * 添加
* *
* @param subjectPage * @param subjectPage
......
...@@ -8,6 +8,8 @@ import com.zzsn.event.service.ISubjectTypeMapService; ...@@ -8,6 +8,8 @@ import com.zzsn.event.service.ISubjectTypeMapService;
import com.zzsn.event.service.ISubjectTypeService; import com.zzsn.event.service.ISubjectTypeService;
import com.zzsn.event.util.tree.Node; import com.zzsn.event.util.tree.Node;
import com.zzsn.event.util.tree.TreeUtil; import com.zzsn.event.util.tree.TreeUtil;
import com.zzsn.event.util.user.AuthUtil;
import com.zzsn.event.util.user.UserVo;
import com.zzsn.event.vo.SubjectTreeVO; import com.zzsn.event.vo.SubjectTreeVO;
import com.zzsn.event.vo.SubjectTypeVo; import com.zzsn.event.vo.SubjectTypeVo;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -96,24 +98,6 @@ public class SubjectTypeController { ...@@ -96,24 +98,6 @@ public class SubjectTypeController {
} }
/** /**
* 专题和分类树型结构-研究中心专题页左侧树
*
* @param facePublic 是否公开(1-是;0-否)
* @author lkg
* @date 2025/1/7
*/
@GetMapping("/subjectAndTypeTree")
public Result<?> subjectAndTypeTree(@RequestParam(required = false) Integer facePublic) {
List<SubjectTreeVO> dataList = null;
if (facePublic == null) {
dataList = subjectTypeService.subjectAndTypeTree();
} else if (facePublic == 1) {
dataList = subjectTypeService.subjectsByFacePublic(facePublic);
}
return Result.OK(dataList);
}
/**
* 通过父级id列表查询-专题页左侧异步树 * 通过父级id列表查询-专题页左侧异步树
* *
* @return * @return
...@@ -146,4 +130,36 @@ public class SubjectTypeController { ...@@ -146,4 +130,36 @@ public class SubjectTypeController {
List<SubjectTypeVo> allList = subjectTypeService.eventListByType(parentId); List<SubjectTypeVo> allList = subjectTypeService.eventListByType(parentId);
return Result.OK(allList); return Result.OK(allList);
} }
/**
* 专题和分类树型结构-研究中心专题页左侧树
*
* @param facePublic 是否公开(1-是;0-否)
* @author lkg
* @date 2025/1/7
*/
@GetMapping("/subjectAndTypeTree")
public Result<?> subjectAndTypeTree(@RequestParam(required = false) Integer facePublic) {
List<SubjectTreeVO> dataList = null;
if (facePublic == null) {
dataList = subjectTypeService.subjectAndTypeTree();
} else if (facePublic == 1) {
dataList = subjectTypeService.subjectsByFacePublic(facePublic);
}
return Result.OK(dataList);
}
/**
* 分类列表-树型结构-研究中心
*
* @author lkg
* @date 2024/12/17
*/
@GetMapping("/typeList")
public Result<?> typeTreeList() {
UserVo loginUser = AuthUtil.getLoginUser();
List<Node> nodes = subjectTypeService.researchCenterEnableList(loginUser.getUsername());
List<Node> tree = TreeUtil.tree(nodes, "0");
return Result.OK(tree);
}
} }
...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zzsn.event.entity.Subject; import com.zzsn.event.entity.Subject;
import com.zzsn.event.vo.SubjectCondition; import com.zzsn.event.vo.SubjectCondition;
import com.zzsn.event.vo.SubjectPage; import com.zzsn.event.vo.SubjectPage;
import com.zzsn.event.vo.SubjectSampleFileInfoVO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -38,6 +39,14 @@ public interface SubjectMapper extends BaseMapper<Subject> { ...@@ -38,6 +39,14 @@ public interface SubjectMapper extends BaseMapper<Subject> {
Page<SubjectPage> researchCenterPageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page); Page<SubjectPage> researchCenterPageList(@Param("subjectCondition") SubjectCondition subjectCondition, Page<SubjectPage> page);
/** /**
* 获取专题详情(包含样例文章信息)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/8
*/
SubjectSampleFileInfoVO queryInfo(@Param("subjectId") String subjectId);
/**
* 专题详情 * 专题详情
* *
* @param subjectId 专题id * @param subjectId 专题id
......
...@@ -3,8 +3,9 @@ ...@@ -3,8 +3,9 @@
<mapper namespace="com.zzsn.event.mapper.SubjectMapper"> <mapper namespace="com.zzsn.event.mapper.SubjectMapper">
<select id="pageList" resultType="com.zzsn.event.vo.SubjectPage"> <select id="pageList" resultType="com.zzsn.event.vo.SubjectPage">
SELECT distinct d.*, c.id as subjectTypeId, c.type_name as subjectTypeName, g.id as projectId, g.project_name as SELECT distinct d.*, c.id as subjectTypeId, c.type_name as subjectTypeName, g.id as projectId,
projectName from subject d g.project_name as projectName
from subject d
INNER JOIN subject_type_map b ON b.subject_id = d.id INNER JOIN subject_type_map b ON b.subject_id = d.id
INNER JOIN subject_type c ON b.type_id = c.id INNER JOIN subject_type c ON b.type_id = c.id
LEFT JOIN project_subject_map f ON f.subject_id = d.id LEFT JOIN project_subject_map f ON f.subject_id = d.id
...@@ -79,7 +80,8 @@ ...@@ -79,7 +80,8 @@
d.subject_name, d.subject_name,
d.remark, d.remark,
d.create_time, d.create_time,
d.status c.type_name as subjectTypeName, d.status,
c.type_name as subjectTypeName
from subject d from subject d
LEFT JOIN subject_type_map b ON b.subject_id = d.id LEFT JOIN subject_type_map b ON b.subject_id = d.id
LEFT JOIN subject_type c ON b.type_id = c.id LEFT JOIN subject_type c ON b.type_id = c.id
...@@ -107,4 +109,40 @@ ...@@ -107,4 +109,40 @@
</if> </if>
order by d.create_time desc order by d.create_time desc
</select> </select>
<resultMap id="subjectSampleFileInfoVOMap" type="com.zzsn.event.vo.SubjectSampleFileInfoVO">
<result column="subject_name" property="subjectName"/>
<result column="subjectTypeName" property="subjectTypeName"/>
<result column="remark" property="remark"/>
<result column="data_source" property="dataSource"/>
<result column="time_enable" property="timeEnable"/>
<result column="time_disable" property="timeDisable"/>
<result column="library" property="library"/>
<result column="face_public" property="facePublic"/>
<collection property="sampleFileList" ofType="com.zzsn.event.entity.SubjectSampleFile">
<id column="id" property="id"/>
<result column="file_name" property="fileName"/>
<result column="file_path" property="filePath"/>
</collection>
</resultMap>
<select id="queryInfo" resultMap="subjectSampleFileInfoVOMap">
select s.subject_name,
s.remark,
s.status,
s.time_enable,
s.time_disable,
s.data_source,
s.face_public,
s.library,
c.type_name as subjectTypeName,
f.id,
f.file_name,
f.file_path
from subject s
inner join subject_type_map b ON b.subject_id = s.id
inner join subject_type c ON b.type_id = c.id
left join subject_sample_file f on s.id = f.subject_id
where s.id = #{subjectId}
</select>
</mapper> </mapper>
...@@ -26,6 +26,15 @@ public interface ISubjectTypeService extends IService<SubjectType> { ...@@ -26,6 +26,15 @@ public interface ISubjectTypeService extends IService<SubjectType> {
List<Node> enableList(Integer category); List<Node> enableList(Integer category);
/** /**
* 可用的专题分类列表-研究中心
*
* @param username 创建人
* @author lkg
* @date 2024/4/29
*/
List<Node> researchCenterEnableList(String username);
/**
* 获取分类下的所有节点id集合 * 获取分类下的所有节点id集合
* *
* @param typeId 分类id * @param typeId 分类id
......
...@@ -39,6 +39,15 @@ public interface SubjectService extends IService<Subject> { ...@@ -39,6 +39,15 @@ public interface SubjectService extends IService<Subject> {
Page<SubjectPage> researchCenterPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize); Page<SubjectPage> researchCenterPageList(SubjectCondition subjectCondition, Integer pageNo, Integer pageSize);
/** /**
* 获取专题详情(包含样例文章信息)
*
* @param subjectId 专题id
* @author lkg
* @date 2025/1/8
*/
SubjectSampleFileInfoVO queryInfo(String subjectId);
/**
* 新增专题 * 新增专题
* *
* @param subjectPage 参数 * @param subjectPage 参数
......
...@@ -153,6 +153,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl ...@@ -153,6 +153,11 @@ public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, Subject> impl
} }
@Override @Override
public SubjectSampleFileInfoVO queryInfo(String subjectId) {
return baseMapper.queryInfo(subjectId);
}
@Override
@Transactional @Transactional
public Subject saveMain(SubjectPage subjectPage) { public Subject saveMain(SubjectPage subjectPage) {
Subject subject = new Subject(); Subject subject = new Subject();
......
...@@ -38,6 +38,11 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje ...@@ -38,6 +38,11 @@ public class SubjectTypeServiceImpl extends ServiceImpl<SubjectTypeMapper, Subje
} }
@Override @Override
public List<Node> researchCenterEnableList(String username) {
return baseMapper.enableList(1, username);
}
@Override
public List<String> belowIdList(String typeId,Integer category) { public List<String> belowIdList(String typeId,Integer category) {
List<Node> nodes = this.enableList(category); List<Node> nodes = this.enableList(category);
return TreeUtil.belowList(nodes, typeId, true); return TreeUtil.belowList(nodes, typeId, true);
......
package com.zzsn.event.service.impl; package com.zzsn.event.service.impl;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzsn.event.entity.SysDictItem; import com.zzsn.event.entity.SysDictItem;
import com.zzsn.event.mapper.SysDictItemMapper; import com.zzsn.event.mapper.SysDictItemMapper;
...@@ -17,6 +18,7 @@ import java.util.List; ...@@ -17,6 +18,7 @@ import java.util.List;
* @since 2018-12-28 * @since 2018-12-28
*/ */
@Service @Service
@DS("multi-datasource2")
public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService { public class SysDictItemServiceImpl extends ServiceImpl<SysDictItemMapper, SysDictItem> implements SysDictItemService {
@Override @Override
......
package com.zzsn.event.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.zzsn.event.entity.SubjectSampleFile;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
import java.util.List;
/**
* 专题详情信息(包含样例文章)
*
* @author lkg
* @date 2025/1/8
*/
@Data
public class SubjectSampleFileInfoVO {
/**专题名称*/
private String subjectName;
/**专题描述*/
private String remark;
/**开始时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date timeEnable;
/**结束时间*/
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern="yyyy-MM-dd")
private Date timeDisable;
/**是否公开(0-未公开;1-已公开)*/
private Integer facePublic;
/**数据来源(0-平台数据;1-全网搜)*/
private Integer dataSource;
/**划分专题库*/
private String library;
/**专题分类名称*/
private String subjectTypeName;
/**专题下的样例文章*/
private List<SubjectSampleFile> sampleFileList;
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论