|
|
@@ -1,5 +1,7 @@
|
|
|
package com.gis.service.impl;
|
|
|
|
|
|
+import com.gis.common.util.AliyunOssUtil;
|
|
|
+import com.gis.common.util.FileUtils;
|
|
|
import com.gis.common.util.RandomUtils;
|
|
|
import com.gis.common.util.Result;
|
|
|
import com.gis.domain.dto.SceneInitDto;
|
|
|
@@ -11,8 +13,10 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.transaction.Transactional;
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -28,6 +32,9 @@ public class SceneInitServiceImpl extends IBaseServiceImpl<SceneInitEntity, Stri
|
|
|
@Autowired
|
|
|
private SceneInitMapper entityMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ AliyunOssUtil aliyunOssUtil;
|
|
|
+
|
|
|
@Override
|
|
|
public IBaseMapper<SceneInitEntity, String> getBaseMapper() {
|
|
|
return this.entityMapper;
|
|
|
@@ -63,7 +70,35 @@ public class SceneInitServiceImpl extends IBaseServiceImpl<SceneInitEntity, Stri
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public List<SceneInitDto> voFindByHouseId(String houseId) {
|
|
|
+ return entityMapper.voFindByHouseId(houseId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public void removeByHouseIdAndSceneCode(String houseId, String sceneCode) {
|
|
|
entityMapper.removeByHouseIdAndSceneCode(houseId, sceneCode);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result uploadFixedName(MultipartFile file, String sceneCode) {
|
|
|
+
|
|
|
+ // 检查非法文件上传
|
|
|
+ boolean checkFile = FileUtils.checkFile(file);
|
|
|
+ if (!checkFile) {
|
|
|
+ return Result.failure("上传文件格式有误, 请重新上传");
|
|
|
+ }
|
|
|
+
|
|
|
+ String ossPath = configConstant.ossBasePath + "image/thumb_"+sceneCode+".jpg";
|
|
|
+ try {
|
|
|
+ aliyunOssUtil.upload(file.getBytes(), ossPath);
|
|
|
+ Object ossUrl = configConstant.ossDomain + ossPath;
|
|
|
+ log.info("ossUrl: {}", ossUrl);
|
|
|
+ return Result.success(ossUrl);
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.failure("上传失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|