Commit f787fe20 authored by 周健威's avatar 周健威

添加代码

parent 0c1814a8
package com.upyuns.platform.rs.website.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.github.wxiaoqi.security.common.vo.PageParam;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class DataTempcacheDTO extends PageParam {
private Integer source;
private String name;
private String upTimeStartStr;
private String upTimeEndStr;
}
...@@ -175,4 +175,10 @@ public class DataTempcache implements Serializable { ...@@ -175,4 +175,10 @@ public class DataTempcache implements Serializable {
@ApiModelProperty(value = "文件服务器路径") @ApiModelProperty(value = "文件服务器路径")
private String filepath; private String filepath;
@ApiModelProperty(value = "描述")
private String descr;
@ApiModelProperty(value = "标签信息")
private String labelinfo;
} }
package com.upyuns.platform.rs.website.biz; package com.upyuns.platform.rs.website.biz;
import com.upyuns.platform.rs.website.dto.DataTempcacheDTO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.upyuns.platform.rs.website.entity.DataTempcache; import com.upyuns.platform.rs.website.entity.DataTempcache;
import com.upyuns.platform.rs.website.mapper.DataTempcacheMapper; import com.upyuns.platform.rs.website.mapper.DataTempcacheMapper;
import com.github.wxiaoqi.security.common.biz.BaseBiz; import com.github.wxiaoqi.security.common.biz.BaseBiz;
import java.util.List;
/** /**
* 数据临时缓存库 * 数据临时缓存库
* *
...@@ -15,4 +18,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz; ...@@ -15,4 +18,7 @@ import com.github.wxiaoqi.security.common.biz.BaseBiz;
*/ */
@Service @Service
public class DataTempcacheBiz extends BaseBiz<DataTempcacheMapper,DataTempcache> { public class DataTempcacheBiz extends BaseBiz<DataTempcacheMapper,DataTempcache> {
public List<DataTempcache> pageList(DataTempcacheDTO dto){
return mapper.pageList(dto);
}
} }
\ No newline at end of file
...@@ -9,11 +9,15 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse; ...@@ -9,11 +9,15 @@ import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.rest.BaseController; import com.github.wxiaoqi.security.common.rest.BaseController;
import com.github.wxiaoqi.security.common.util.process.ResultCode; import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.util.process.SystemConfig; import com.github.wxiaoqi.security.common.util.process.SystemConfig;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.upyuns.platform.rs.gtdata.GtDataRestClient; import com.upyuns.platform.rs.gtdata.GtDataRestClient;
import com.upyuns.platform.rs.gtdata.GtFileInfo; import com.upyuns.platform.rs.gtdata.GtFileInfo;
import com.upyuns.platform.rs.website.biz.DataTempcacheBiz; import com.upyuns.platform.rs.website.biz.DataTempcacheBiz;
import com.upyuns.platform.rs.website.dto.DataTempcacheDTO;
import com.upyuns.platform.rs.website.dto.GainDataDTO;
import com.upyuns.platform.rs.website.entity.DataTempcache; import com.upyuns.platform.rs.website.entity.DataTempcache;
import com.upyuns.platform.rs.website.entity.FileData; import com.upyuns.platform.rs.website.entity.FileData;
import com.upyuns.platform.rs.website.entity.GainData;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
...@@ -21,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody; ...@@ -21,6 +25,7 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import tk.mybatis.mapper.entity.Example;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -44,5 +49,98 @@ public class AdminDataTempcacheController extends BaseController<DataTempcacheBi ...@@ -44,5 +49,98 @@ public class AdminDataTempcacheController extends BaseController<DataTempcacheBi
private String xx_url ; private String xx_url ;
//BaseController.baseLogicPages //BaseController.baseLogicPages
//BaseController.del
@RequestMapping(value = "/getPageList",method = RequestMethod.GET)
public ObjectRestResponse<List<GainData>> getPageList(DataTempcacheDTO dto) {
PageDataVO pageDataVO = PageDataVO.pageInfo(dto.getPage(), dto.getLimit(), ()->baseBiz.pageList(dto));
return ObjectRestResponse.succ(pageDataVO);
}
@ApiModelProperty("添加修改文件")
@RequestMapping(value = "/app/unauth/saveDataTempcache",method = RequestMethod.POST)
@IgnoreUserToken
public ObjectRestResponse<FileData> saveDataTempcache(@RequestBody DataTempcache dataTempcache) {
if(null != dataTempcache.getUptype()) {
if(DataTempcache.UPTYPE_GTDATA == dataTempcache.getUptype()) {
// //gtdtat 获取数据
Map<String, Object> responseMap = gtDataRestClient.list(dataTempcache.getGtdataPath());
if(null != responseMap && null != responseMap.get("HttpStatusCode") && null != responseMap.get("files") && 200 == (Integer) responseMap.get("HttpStatusCode")) {
List<GtFileInfo> gtFileInfos = Convert.toList(GtFileInfo.class, responseMap.get("files"));
GtFileInfo gtFileInfo = gtFileInfos.get(0);
String filename = gtFileInfo.getFilename();
String filesize = gtFileInfo.getSize();
String filetype = filename.substring(filename.lastIndexOf("."));
long fileSize = Long.valueOf(filesize);
// double fileSizeInKB = (double) fileSize / 1024; // 转换为 KB
double fileSizeInMB = (double) fileSize / (1024 * 1024); // 转换为 MB
double roundedFileSizeInMB = Math.round(fileSizeInMB * 100.0) / 100.0; // 保留两位小数
String fileSizeString = String.format("%.2f MB", roundedFileSizeInMB);
dataTempcache.setHasGtdata(SYS_TRUE);
dataTempcache.setFilename(filename);
dataTempcache.setFiletype(filetype);
dataTempcache.setFilesize(fileSizeString);
}else {
return ObjectRestResponse.createFailedResult(ResultCode.FAILED_CODE, "分布式路径不对");
}
}else if(DataTempcache.UPTYPE_URL == dataTempcache.getUptype()) {
//提前插入
if(null == dataTempcache.getId()) {
baseBiz.insertSelective(dataTempcache);
}
String realPath = tempcachePath+"/"+dataTempcache.getId();
String serverPath = baseUploadPath + realPath;
//创建目录
if(!FileUtil.exist(serverPath)) {
FileUtil.mkdir(serverPath);
}
String fileName = StrUtil.subAfter(dataTempcache.getUpurl(), "/", true);
//然后获取这个文件名的后缀
String suffix = StrUtil.subAfter(fileName, ".", true);
if(StrUtil.isBlank(dataTempcache.getFilename())) {
dataTempcache.setFilename(fileName);
}
if(StrUtil.isBlank(dataTempcache.getFiletype())) {
dataTempcache.setFiletype("." + suffix);
}
//下载文件
Long size = HttpUtil.downloadFile(dataTempcache.getUpurl(), FileUtil.file(serverPath + "/" + dataTempcache.getFilename()));
double fileSizeInMB = (double) size / (1024 * 1024); // 转换为 MB
double roundedFileSizeInMB = Math.round(fileSizeInMB * 100.0) / 100.0; // 保留两位小数
String fileSizeString = String.format("%.2f MB", roundedFileSizeInMB);
dataTempcache.setFilesize(fileSizeString);
dataTempcache.setFilepath(serverPath + "/" + dataTempcache.getFilename());
dataTempcache.setFileurl(xx_url+ SystemConfig.XXMP_URL + realPath + "/" + dataTempcache.getFilename());
}
}
if (dataTempcache.getId()!=null){
baseBiz.updateSelectiveById(dataTempcache);
}else {
dataTempcache.setIsDel(0);
baseBiz.insertSelective(dataTempcache);
}
return ObjectRestResponse.succ();
}
public static void main(String[] args) {
String url = "http://example.com/path/to/file.jpg";
// 假设URL的最后一个部分是文件名,我们可以先获取这个部分
String fileName = StrUtil.subAfter(url, "/", true);
System.out.println("URL路径的文件后缀是:" + fileName);
// 然后获取这个文件名的后缀
String suffix = StrUtil.subAfter(fileName, ".", true);
System.out.println("URL路径的文件后缀是:" + suffix);
}
} }
\ No newline at end of file
package com.upyuns.platform.rs.website.mapper; package com.upyuns.platform.rs.website.mapper;
import com.upyuns.platform.rs.website.dto.DataTempcacheDTO;
import com.upyuns.platform.rs.website.entity.DataTempcache; import com.upyuns.platform.rs.website.entity.DataTempcache;
import tk.mybatis.mapper.common.Mapper; import tk.mybatis.mapper.common.Mapper;
import java.util.List;
/** /**
* 数据临时缓存库 * 数据临时缓存库
* *
...@@ -11,5 +14,5 @@ import tk.mybatis.mapper.common.Mapper; ...@@ -11,5 +14,5 @@ import tk.mybatis.mapper.common.Mapper;
* @date 2024-08-14 14:52:35 * @date 2024-08-14 14:52:35
*/ */
public interface DataTempcacheMapper extends Mapper<DataTempcache> { public interface DataTempcacheMapper extends Mapper<DataTempcache> {
public List<DataTempcache> pageList(DataTempcacheDTO dataTempcacheDTO);
} }
...@@ -2,5 +2,24 @@ ...@@ -2,5 +2,24 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.upyuns.platform.rs.website.mapper.DataTempcacheMapper"> <mapper namespace="com.upyuns.platform.rs.website.mapper.DataTempcacheMapper">
<select id="pageList" resultType="com.upyuns.platform.rs.website.entity.DataTempcache">
select *
from data_tempcache
<where>
is_del = 0
<if test="name != null">
and name = #{name}
</if>
<if test="source != null">
and source = #{source}
</if>
<if test="upTimeStartStr != null ">
and up_time &gt;= #{upTimeStartStr}
</if>
<if test="upTimeEndStr != null ">
and up_time &lt;= #{upTimeEndStr}
</if>
</where>
order by up_time desc
</select>
</mapper> </mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment