Compare commits
2 Commits
a5e68f197d
...
3963d64781
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3963d64781 | ||
|
|
4fa0d501d4 |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -3,6 +3,8 @@ target/
|
|||||||
.mvn/wrapper/maven-wrapper.jar
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
!**/src/main/**/target/
|
!**/src/main/**/target/
|
||||||
!**/src/test/**/target/
|
!**/src/test/**/target/
|
||||||
|
/media/
|
||||||
|
|
||||||
|
|
||||||
### STS ###
|
### STS ###
|
||||||
.apt_generated
|
.apt_generated
|
||||||
|
|||||||
BIN
media/img/test.jpg
Normal file
BIN
media/img/test.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 301 KiB |
BIN
media/video/testVideo.mp4
Normal file
BIN
media/video/testVideo.mp4
Normal file
Binary file not shown.
@@ -2,8 +2,10 @@ package com.bicloud.controller;
|
|||||||
|
|
||||||
import com.bicloud.common.result.PageResult;
|
import com.bicloud.common.result.PageResult;
|
||||||
import com.bicloud.common.result.Result;
|
import com.bicloud.common.result.Result;
|
||||||
|
import com.bicloud.pojo.dto.LiteratureCreateDto;
|
||||||
import com.bicloud.pojo.dto.LiteratureDto;
|
import com.bicloud.pojo.dto.LiteratureDto;
|
||||||
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
||||||
|
import com.bicloud.pojo.vo.LiteratureListVo;
|
||||||
import com.bicloud.service.LiteratureService;
|
import com.bicloud.service.LiteratureService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@@ -24,16 +26,9 @@ public class LiteratureController {
|
|||||||
// 新增文献数据
|
// 新增文献数据
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
@Operation(summary = "新增文献")
|
@Operation(summary = "新增文献")
|
||||||
public Result<String> addLiterature(@RequestBody LiteratureDto literatureDTO) {
|
public Result<String> addLiterature(@RequestBody LiteratureCreateDto dto) {
|
||||||
try {
|
literatureService.addLiterature(dto);
|
||||||
literatureService.addLiterature(literatureDTO);
|
|
||||||
// 成功:返回200码
|
|
||||||
return Result.success("新增文献成功");
|
return Result.success("新增文献成功");
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
// 失败:返回500码、自定义失败提示
|
|
||||||
return Result.error("新增文献失败:" + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除文献
|
// 删除文献
|
||||||
@@ -50,11 +45,10 @@ public class LiteratureController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//分页查询
|
//分页查询
|
||||||
@GetMapping("/page")
|
|
||||||
@Operation(summary = "分页查询文献")
|
@Operation(summary = "分页查询文献")
|
||||||
public Result<PageResult<LiteratureDto>> page(LiteraturePageQueryDto queryDTO) {
|
@GetMapping("/page")
|
||||||
log.info("传入参数为:"+queryDTO);
|
public Result<PageResult<LiteratureListVo>> page(LiteraturePageQueryDto queryDTO) {
|
||||||
PageResult<LiteratureDto> result = literatureService.pageQuery(queryDTO);
|
PageResult<LiteratureListVo> result = literatureService.pageQuery(queryDTO);
|
||||||
return Result.success(result);
|
return Result.success(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,25 +1,20 @@
|
|||||||
package com.bicloud.mapper;
|
package com.bicloud.mapper;
|
||||||
|
|
||||||
|
import com.bicloud.pojo.dto.LiteratureCreateDto;
|
||||||
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
||||||
import com.bicloud.pojo.entity.LiteratureInfo;
|
import com.bicloud.pojo.vo.LiteratureListVo;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import org.apache.ibatis.annotations.Delete;
|
|
||||||
import org.apache.ibatis.annotations.Insert;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
|
||||||
@Mapper
|
@Mapper
|
||||||
public interface LiteratureMapper {
|
public interface LiteratureMapper {
|
||||||
|
|
||||||
// 插入文献数据
|
// 新增:插入 biology_document_info
|
||||||
@Insert("INSERT INTO literature_info(year, article_title, journal_name, impact_factor, sample_source, literature_type,literature_url) " +
|
int insertDocument(LiteratureCreateDto dto);
|
||||||
"VALUES(#{year}, #{articleTitle}, #{journalName}, #{impactFactor}, #{sampleSource}, #{literatureType},#{literatureUrl})")
|
|
||||||
int insertLiterature(LiteratureInfo literatureInfo);
|
|
||||||
|
|
||||||
|
// 删除:软删除 removed=1
|
||||||
|
int softDeleteById(Long id);
|
||||||
|
|
||||||
// 根据文献ID删除数据
|
// 分页查询:返回列表VO(PageHelper自动分页)
|
||||||
@Delete("DELETE FROM literature_info WHERE id = #{id}")
|
Page<LiteratureListVo> pageQuery(LiteraturePageQueryDto queryDTO);
|
||||||
void deleteLiteratureById(Long id);
|
|
||||||
|
|
||||||
Page<LiteratureInfo> pageQuery(LiteraturePageQueryDto queryDTO);
|
|
||||||
}
|
}
|
||||||
|
|||||||
31
src/main/java/com/bicloud/pojo/dto/LiteratureCreateDto.java
Normal file
31
src/main/java/com/bicloud/pojo/dto/LiteratureCreateDto.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.bicloud.pojo.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增文献(写入 biology_document_info)的入参
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LiteratureCreateDto {
|
||||||
|
|
||||||
|
private Integer docType; // 对应 biology_document_info.doc_type(类型ID)
|
||||||
|
private String docLabel; // 对应 doc_label(目前是varchar,先按原样存)
|
||||||
|
private String docTitle; // 标题
|
||||||
|
private String docIcon; // 封面
|
||||||
|
private String docDesp; // 简介/摘要
|
||||||
|
private String docInfo; // 正文/富文本
|
||||||
|
|
||||||
|
private Integer docCollect; // 收藏/热度(可空)
|
||||||
|
private Integer position; // 排序权重(可空)
|
||||||
|
|
||||||
|
private String author; // 作者
|
||||||
|
private String publication; // 期刊
|
||||||
|
private String impactFactor; // IF(新库是varchar)
|
||||||
|
private LocalDateTime publishTime; // 发表时间
|
||||||
|
private String techniques; // 样品来源/技术(你页面“样品来源”先映射这里)
|
||||||
|
|
||||||
|
private Integer status; // 状态(可空)
|
||||||
|
private Integer ifContent; // 是否有内容(可空)
|
||||||
|
}
|
||||||
@@ -4,15 +4,23 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表页筛选 + 分页参数
|
||||||
|
*/
|
||||||
@Data
|
@Data
|
||||||
public class LiteraturePageQueryDto {
|
public class LiteraturePageQueryDto {
|
||||||
|
|
||||||
private Integer page;
|
private Integer page;
|
||||||
private Integer pageSize;
|
private Integer pageSize;
|
||||||
private String articleTitle;
|
|
||||||
private Integer year;
|
private Integer year; // YEAR(publish_time)
|
||||||
private String journalName;
|
private String docTitle; // 文章标题(模糊)
|
||||||
private String literatureType;
|
private String publication; // 期刊名称(模糊)
|
||||||
private String sampleSource;
|
private String techniques; // 样品来源(模糊)
|
||||||
private BigDecimal impactFactorMin;
|
private Integer docType; // 文献分类(类型ID,下拉建议传这个)
|
||||||
private BigDecimal impactFactorMax;
|
|
||||||
|
private String keyword; // 关键字搜索(可选:对标题/期刊/作者/简介做模糊)
|
||||||
|
|
||||||
|
private BigDecimal impactFactorMin; // IF最小值
|
||||||
|
private BigDecimal impactFactorMax; // IF最大值
|
||||||
}
|
}
|
||||||
18
src/main/java/com/bicloud/pojo/vo/LiteratureListVo.java
Normal file
18
src/main/java/com/bicloud/pojo/vo/LiteratureListVo.java
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package com.bicloud.pojo.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表页返回对象
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class LiteratureListVo {
|
||||||
|
|
||||||
|
private Long id; // 隐藏id(用于操作)
|
||||||
|
private Integer year; // 年份:由 YEAR(publish_time) 计算得到
|
||||||
|
private String docTitle; // 文章标题
|
||||||
|
private String publication; // 期刊
|
||||||
|
private String impactFactor; // IF(varchar原样返回,避免精度/格式问题)
|
||||||
|
private String techniques; // 样品来源(先用 techniques)
|
||||||
|
private String typeName; // 文献分类名(来自 biology_document_type.name)
|
||||||
|
}
|
||||||
@@ -1,17 +1,18 @@
|
|||||||
package com.bicloud.service;
|
package com.bicloud.service;
|
||||||
|
|
||||||
import com.bicloud.common.result.PageResult;
|
import com.bicloud.common.result.PageResult;
|
||||||
import com.bicloud.pojo.dto.LiteratureDto;
|
import com.bicloud.pojo.dto.LiteratureCreateDto;
|
||||||
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
||||||
|
import com.bicloud.pojo.vo.LiteratureListVo;
|
||||||
|
|
||||||
public interface LiteratureService {
|
public interface LiteratureService {
|
||||||
// 新增文献
|
|
||||||
void addLiterature(LiteratureDto literatureDTO);
|
|
||||||
|
|
||||||
// 删除文献
|
// 新增文献(写入 biology_document_info)
|
||||||
|
void addLiterature(LiteratureCreateDto dto);
|
||||||
|
|
||||||
|
// 删除文献(软删除:removed=1)
|
||||||
void deleteLiterature(Long id);
|
void deleteLiterature(Long id);
|
||||||
|
|
||||||
// 文献分页查询
|
// 分页查询(返回列表VO)
|
||||||
PageResult<LiteratureDto> pageQuery(LiteraturePageQueryDto queryDTO);
|
PageResult<LiteratureListVo> pageQuery(LiteraturePageQueryDto queryDTO);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,71 +1,48 @@
|
|||||||
package com.bicloud.service.impl;
|
package com.bicloud.service.impl;
|
||||||
|
|
||||||
|
import com.bicloud.common.result.PageResult;
|
||||||
|
import com.bicloud.mapper.LiteratureMapper;
|
||||||
|
import com.bicloud.pojo.dto.LiteratureCreateDto;
|
||||||
|
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
||||||
|
import com.bicloud.pojo.vo.LiteratureListVo;
|
||||||
|
import com.bicloud.service.LiteratureService;
|
||||||
import com.github.pagehelper.Page;
|
import com.github.pagehelper.Page;
|
||||||
import com.github.pagehelper.PageHelper;
|
import com.github.pagehelper.PageHelper;
|
||||||
import com.bicloud.common.result.PageResult;
|
|
||||||
import com.bicloud.pojo.dto.LiteratureDto;
|
|
||||||
import com.bicloud.pojo.dto.LiteraturePageQueryDto;
|
|
||||||
import com.bicloud.pojo.entity.LiteratureInfo;
|
|
||||||
import com.bicloud.mapper.LiteratureMapper;
|
|
||||||
import com.bicloud.service.LiteratureService;
|
|
||||||
import org.springframework.beans.BeanUtils; // Spring工具类,用于对象属性拷贝
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class LiteratureServiceImpl implements LiteratureService {
|
public class LiteratureServiceImpl implements LiteratureService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private LiteratureMapper literatureMapper;
|
private LiteratureMapper literatureMapper;
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增文献
|
|
||||||
* @param literatureDTO
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void addLiterature(LiteratureDto literatureDTO) {
|
public void addLiterature(LiteratureCreateDto dto) {
|
||||||
// 把DTO转成Entity
|
// 新库:直接写入 biology_document_info(SQL 在 XML)
|
||||||
LiteratureInfo literatureInfo = new LiteratureInfo();
|
literatureMapper.insertDocument(dto);
|
||||||
BeanUtils.copyProperties(literatureDTO, literatureInfo); // 自动拷贝同名属性
|
|
||||||
|
|
||||||
// 调用Mapper插入数据库
|
|
||||||
literatureMapper.insertLiterature(literatureInfo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除文献
|
|
||||||
* @param id
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteLiterature(Long id) {
|
public void deleteLiterature(Long id) {
|
||||||
literatureMapper.deleteLiteratureById(id);
|
// 新库:软删除 removed=1
|
||||||
|
literatureMapper.softDeleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 文献分页查询
|
|
||||||
* @param queryDTO
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<LiteratureDto> pageQuery(LiteraturePageQueryDto queryDTO) {
|
public PageResult<LiteratureListVo> pageQuery(LiteraturePageQueryDto queryDTO) {
|
||||||
|
|
||||||
// 1) PageHelper 开始分页
|
// 1) 兜底默认值,避免空指针/非法分页参数
|
||||||
PageHelper.startPage(queryDTO.getPage(), queryDTO.getPageSize());
|
int page = (queryDTO.getPage() == null || queryDTO.getPage() < 1) ? 1 : queryDTO.getPage();
|
||||||
|
int pageSize = (queryDTO.getPageSize() == null || queryDTO.getPageSize() < 1) ? 10 : queryDTO.getPageSize();
|
||||||
|
|
||||||
// 2) 执行 mapper 查询(会被 PageHelper 自动加 limit)
|
// 2) PageHelper 开始分页
|
||||||
Page<LiteratureInfo> page = literatureMapper.pageQuery(queryDTO);
|
PageHelper.startPage(page, pageSize);
|
||||||
|
|
||||||
// 3) 取 total + records
|
// 3) 执行 mapper 查询(PageHelper 自动分页 + 自动 count)
|
||||||
long total = page.getTotal();
|
Page<LiteratureListVo> p = literatureMapper.pageQuery(queryDTO);
|
||||||
List<LiteratureDto> records = page.getResult().stream().map(info -> {
|
|
||||||
LiteratureDto dto = new LiteratureDto();
|
|
||||||
BeanUtils.copyProperties(info, dto);
|
|
||||||
return dto;
|
|
||||||
}).collect(Collectors.toList());
|
|
||||||
|
|
||||||
return new PageResult<>(total, records);
|
// 4) 取 total + records
|
||||||
|
return new PageResult<>(p.getTotal(), p.getResult());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,41 +3,93 @@
|
|||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<mapper namespace="com.bicloud.mapper.LiteratureMapper">
|
<mapper namespace="com.bicloud.mapper.LiteratureMapper">
|
||||||
|
|
||||||
<select id="pageQuery" resultType="com.bicloud.pojo.entity.LiteratureInfo">
|
<!-- 新增文献:写入 biology_document_info -->
|
||||||
select *
|
<insert id="insertDocument" parameterType="com.bicloud.pojo.dto.LiteratureCreateDto" useGeneratedKeys="true" keyProperty="id">
|
||||||
from literature_info
|
INSERT INTO biology_document_info
|
||||||
<where>
|
(doc_type, doc_label, doc_title, doc_icon, doc_desp, doc_info,
|
||||||
|
doc_collect, position, author, publication, impact_factor,
|
||||||
|
publish_time, techniques, addtime, updtime, status, if_content, removed)
|
||||||
|
VALUES
|
||||||
|
(#{docType}, #{docLabel}, #{docTitle}, #{docIcon}, #{docDesp}, #{docInfo},
|
||||||
|
#{docCollect}, #{position}, #{author}, #{publication}, #{impactFactor},
|
||||||
|
#{publishTime}, #{techniques}, NOW(), NOW(), #{status}, #{ifContent}, 0)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 软删除:removed=1 -->
|
||||||
|
<update id="softDeleteById" parameterType="long">
|
||||||
|
UPDATE biology_document_info
|
||||||
|
SET removed = 1, updtime = NOW()
|
||||||
|
WHERE id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 分页查询:列表页7字段 + id
|
||||||
|
说明:
|
||||||
|
1) YEAR 取 publish_time
|
||||||
|
2) 文献分类名来自 biology_document_type.name(join)
|
||||||
|
3) IF范围:impact_factor 是varchar,先用 REGEXP 过滤“纯数字/小数”,再 CAST 比较
|
||||||
|
-->
|
||||||
|
<select id="pageQuery" resultType="com.bicloud.pojo.vo.LiteratureListVo">
|
||||||
|
SELECT
|
||||||
|
d.id,
|
||||||
|
YEAR(d.publish_time) AS year,
|
||||||
|
d.doc_title AS docTitle,
|
||||||
|
d.publication AS publication,
|
||||||
|
d.impact_factor AS impactFactor,
|
||||||
|
d.techniques AS techniques,
|
||||||
|
t.name AS typeName
|
||||||
|
FROM biology_document_info d
|
||||||
|
LEFT JOIN biology_document_type t
|
||||||
|
ON t.id = d.doc_type
|
||||||
|
WHERE d.removed = 0
|
||||||
|
|
||||||
<if test="year != null">
|
<if test="year != null">
|
||||||
and year = #{year}
|
AND d.publish_time IS NOT NULL
|
||||||
|
AND YEAR(d.publish_time) = #{year}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="articleTitle != null and articleTitle != ''">
|
<if test="docTitle != null and docTitle != ''">
|
||||||
and article_title like concat('%', #{articleTitle}, '%')
|
AND d.doc_title LIKE CONCAT('%', #{docTitle}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="journalName != null and journalName != ''">
|
<if test="publication != null and publication != ''">
|
||||||
and journal_name like concat('%', #{journalName}, '%')
|
AND d.publication LIKE CONCAT('%', #{publication}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="literatureType != null and literatureType != ''">
|
<if test="techniques != null and techniques != ''">
|
||||||
and literature_type like concat('%', #{literatureType}, '%')
|
AND d.techniques LIKE CONCAT('%', #{techniques}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
<if test="sampleSource != null and sampleSource != ''">
|
<if test="docType != null">
|
||||||
and sample_source like concat('%', #{sampleSource}, '%')
|
AND d.doc_type = #{docType}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
<!-- 关键字:可按需扩大范围(这里覆盖标题/期刊/作者/简介) -->
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
AND (
|
||||||
|
d.doc_title LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
OR d.publication LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
OR d.author LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
OR d.doc_desp LIKE CONCAT('%', #{keyword}, '%')
|
||||||
|
)
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- IF 下限:仅对可转换为数值的 IF 参与比较 -->
|
||||||
<if test="impactFactorMin != null">
|
<if test="impactFactorMin != null">
|
||||||
and impact_factor >= #{impactFactorMin}
|
AND d.impact_factor IS NOT NULL
|
||||||
|
AND d.impact_factor != ''
|
||||||
|
AND d.impact_factor REGEXP '^[0-9]+(\\\\.[0-9]+)?$'
|
||||||
|
AND CAST(d.impact_factor AS DECIMAL(10, 3)) >= #{impactFactorMin}
|
||||||
</if>
|
</if>
|
||||||
|
|
||||||
|
<!-- IF 上限 -->
|
||||||
<if test="impactFactorMax != null">
|
<if test="impactFactorMax != null">
|
||||||
and impact_factor <= #{impactFactorMax}
|
AND d.impact_factor IS NOT NULL
|
||||||
|
AND d.impact_factor != ''
|
||||||
|
AND d.impact_factor REGEXP '^[0-9]+(\\\\.[0-9]+)?$'
|
||||||
|
AND CAST(d.impact_factor AS DECIMAL(10, 3)) <= #{impactFactorMax}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
|
||||||
order by id desc
|
ORDER BY d.id DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user