Merge remote-tracking branch 'origin/master'

This commit is contained in:
2025-04-23 15:44:56 +08:00
9 changed files with 64 additions and 11 deletions
@@ -71,7 +71,8 @@ public class FilesController {
if(StringUtils.isNotBlank(model.getFilename())){
filename = model.getFilename();
}
GridFSInputFile gridFSInputFile = fileDao.saveToGridFs(file.getInputStream(), filename, contentType);
String type = model.getType();
GridFSInputFile gridFSInputFile = fileDao.saveToGridFs(file.getInputStream(), filename, contentType, type);
UniversalDto dto = UniversalDto.newDto();
if(OpenConfig.getConfig().isProductionEnvironment()){
dto.append("link", "http://static.fangjia.com/stc/files/" + gridFSInputFile.get("_id").toString());
@@ -780,6 +780,7 @@ public class WeiXinEvaluationController {
dataMap.put("fjw", averageStatistics.getFangjiaPrice());
dataMap.put("soufang", averageStatistics.getSoufangEsfPrice());
dataMap.put("anjuke", averageStatistics.getAnjukeEsfPrice());
dataMap.put("beike", averageStatistics.getBeikeEsfPrice());
}
}
jsonMmodel.setJsonModel(dataMap);
@@ -7,6 +7,10 @@ public class FilesModel extends FangjiaApiModel {
private MultipartFile file;
private String contentType;
private String filename;
/**
* ÎļþÀàÐÍ
*/
private String type;
public MultipartFile getFile() {
return file;
@@ -31,4 +35,12 @@ public class FilesModel extends FangjiaApiModel {
public void setFilename(String filename) {
this.filename = filename;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
}
@@ -8,6 +8,7 @@ import com.mongodb.gridfs.GridFS;
import com.mongodb.gridfs.GridFSDBFile;
import com.mongodb.gridfs.GridFSInputFile;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.bson.types.ObjectId;
import java.io.InputStream;
@@ -70,6 +71,18 @@ public class FileDao {
return fsInputFile;
}
public GridFSInputFile saveToGridFs(InputStream inputStream, String filename, String contentType, String type){
GridFSInputFile fsInputFile = gridFs.createFile(inputStream, filename);
fsInputFile.put("contentType", contentType);
if (StringUtils.isNotBlank(type)){
fsInputFile.put("t", type);
} else {
fsInputFile.put("t", "default");
}
fsInputFile.save();
return fsInputFile;
}
public GridFSDBFile findByIdInGridFS(String id){
return gridFs.findOne(new ObjectId(id));
}