Skip to content

Commit

Permalink
feat: 附件添加移动功能
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyudong committed Jul 31, 2023
1 parent 506ec89 commit 098d3e9
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.simple.keen.attachment.model.dto.AttachmentFolderAndInfoDTO;
import com.simple.keen.attachment.model.dto.AttachmentInfoDTO;
import com.simple.keen.attachment.model.dto.AttachmentInfoSummaryDTO;
import com.simple.keen.attachment.model.entity.AttachmentInfo;
import com.simple.keen.attachment.model.query.AttachmentFolderAndInfoQuery;
import com.simple.keen.attachment.model.query.AttachmentQuery;
import com.simple.keen.attachment.model.vo.AttachmentInfoSummaryVO;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
Expand Down Expand Up @@ -35,6 +32,7 @@ public interface AttachmentInfoMapper extends BaseMapper<AttachmentInfo> {
+ "and pid =#{parentId} "
+ "</otherwise>"
+ "</choose>"
+ "<if test=\"includeFile\">"
+ "union ALL "
+ "select "
+ "id, "
Expand All @@ -55,28 +53,11 @@ public interface AttachmentInfoMapper extends BaseMapper<AttachmentInfo> {
+ "and folder_id = #{parentId} "
+ "</otherwise>"
+ "</choose>"
+ "</if>"
+ ") a left join t_user b on a.create_user_id = b.id "
+ "order by isFolder desc, create_time desc"
+ "</script>")
List<AttachmentFolderAndInfoDTO> selectAttachmentFolderAndInfoList(
AttachmentFolderAndInfoQuery folderQuery);

@Select("<script> "
+ "select * from ("
+ "select "
+ "a.*, b.nickname 'fromName', c.nickname 'toName' "
+ "from "
+ "t_message_chat a "
+ "left join t_user b on a.from_id = b.id "
+ "left join t_user c on a.to_id = c.id "
+ ")a"
+ "<where>"
+ "<if test=\"fromName != null and fromName != ''\">"
+ "and fromName like concat('%', #{fromName}, '%') "
+ "</if>"
+ "</where>"
+ "</script>")
List<AttachmentInfoDTO> selectAttachmentList(AttachmentQuery attachmentQuery);
List<AttachmentFolderAndInfoDTO> selectAttachmentList(AttachmentFolderAndInfoQuery folderQuery);

@Select("<script> "
+ "select count(*) as itemCount, sum(attachment_size) as storageSize "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,14 @@ public class AttachmentFolderAndInfoQuery extends PageQuery {
*/
private Integer parentId;

/**
* 文件的文件夹id
*/
private Integer folderId;

/**
* 是否包含文件
*/
private boolean includeFile;

}
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,16 @@ public class AttachmentInfoServiceImpl extends

private final IAttachmentStorageService attachmentStorageService;

private static final String DEFAULT_ORDER_BY = " isFolder desc, order_num desc,create_time desc";
private static final String DEFAULT_ORDER_BY = " isFolder desc, order_num desc, create_time desc";

@Override
public PageSerializable<AttachmentFolderAndInfoVO> pageAttachmentFolderAndInfo(
AttachmentFolderAndInfoQuery folderQuery) {
PageHelperUtils.startPage(folderQuery, DEFAULT_ORDER_BY);
List<AttachmentFolderAndInfoDTO> attachmentFolderDTOS = baseMapper.selectAttachmentFolderAndInfoList(
List<AttachmentFolderAndInfoDTO> attachmentFolderDTOS = baseMapper.selectAttachmentList(
folderQuery);
attachmentFolderDTOS.forEach(item -> {
item.setSize(formatAttachmentSize(item.getAttachmentSize()));
});
attachmentFolderDTOS.forEach(
item -> item.setSize(formatAttachmentSize(item.getAttachmentSize())));

return PageHelperUtils.convertPageDto2Vo(attachmentFolderDTOS,
AttachmentFolderMapping.INSTANCE::toAttachmentFolderVOList);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void run(int port) {
ChannelFuture f = b.bind(port).sync();
f.addListener(future -> {
if (future.isSuccess()) {
log.info("Netty server started in port(s): {} success!", port);
log.info("Netty server started on port(s): {} success!", port);
}
});
// 等待服务器 socket 关闭 。
Expand Down

0 comments on commit 098d3e9

Please sign in to comment.