|
|
@@ -1,10 +1,19 @@
|
|
|
package cn.reghao.dfs.store.rpc;
|
|
|
|
|
|
+import cn.reghao.dfs.store.db.mapper.AudioFileMapper;
|
|
|
+import cn.reghao.dfs.store.db.mapper.FileMetaMapper;
|
|
|
+import cn.reghao.dfs.store.db.mapper.ImageFileMapper;
|
|
|
+import cn.reghao.dfs.store.db.mapper.VideoUrlMapper;
|
|
|
+import cn.reghao.dfs.store.model.po.AudioFile;
|
|
|
+import cn.reghao.dfs.store.model.po.ImageFile;
|
|
|
+import cn.reghao.dfs.store.model.po.VideoUrl;
|
|
|
import cn.reghao.oss.api.constant.ObjectACL;
|
|
|
import cn.reghao.oss.api.iface.PermissionService;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @author reghao
|
|
|
* @date 2023-06-02 10:07:42
|
|
|
@@ -12,25 +21,70 @@ import org.springframework.stereotype.Service;
|
|
|
@DubboService
|
|
|
@Service
|
|
|
public class PermissionServiceImpl implements PermissionService {
|
|
|
+ private final ImageFileMapper imageFileMapper;
|
|
|
+ private final AudioFileMapper audioFileMapper;
|
|
|
+ private final VideoUrlMapper videoUrlMapper;
|
|
|
+ private final FileMetaMapper fileMetaMapper;
|
|
|
+
|
|
|
+ public PermissionServiceImpl(ImageFileMapper imageFileMapper, AudioFileMapper audioFileMapper,
|
|
|
+ VideoUrlMapper videoUrlMapper, FileMetaMapper fileMetaMapper) {
|
|
|
+ this.imageFileMapper = imageFileMapper;
|
|
|
+ this.audioFileMapper = audioFileMapper;
|
|
|
+ this.videoUrlMapper = videoUrlMapper;
|
|
|
+ this.fileMetaMapper = fileMetaMapper;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public void setDirPermission(String prefix, int acl) {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void getDirPermission(String prefix) {
|
|
|
for (ObjectACL acl : ObjectACL.values()) {
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void setObjectPermission(String objectName, int acl) {
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setImagePermission(String imageFileId, int acl) {
|
|
|
+ fileMetaMapper.updateSetAcl(imageFileId, acl);
|
|
|
+
|
|
|
+ ImageFile imageFile = imageFileMapper.findByImageFileId(imageFileId);
|
|
|
+ String jpegObjectId = imageFile.getJpegObjectId();
|
|
|
+ fileMetaMapper.updateSetAcl(jpegObjectId, acl);
|
|
|
+
|
|
|
+ String webpObjectId = imageFile.getWebpObjectId();
|
|
|
+ if (webpObjectId != null) {
|
|
|
+ fileMetaMapper.updateSetAcl(webpObjectId, acl);
|
|
|
+ }
|
|
|
+
|
|
|
+ String thumbnailObjectId = imageFile.getThumbnailObjectId();
|
|
|
+ if (thumbnailObjectId != null) {
|
|
|
+ fileMetaMapper.updateSetAcl(thumbnailObjectId, acl);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setAudioPermission(String audioFileId, int acl) {
|
|
|
+ fileMetaMapper.updateSetAcl(audioFileId, acl);
|
|
|
|
|
|
+ AudioFile audioFile = audioFileMapper.findByAudioFileId(audioFileId);
|
|
|
+ String objectId = audioFile.getObjectId();
|
|
|
+ fileMetaMapper.updateSetAcl(objectId, acl);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setVideoPermission(String videoFileId, int acl) {
|
|
|
+ fileMetaMapper.updateSetAcl(videoFileId, acl);
|
|
|
+
|
|
|
+ List<VideoUrl> list = videoUrlMapper.findByVideoFileId(videoFileId);
|
|
|
+ for (VideoUrl videoUrl : list) {
|
|
|
+ String objectId = videoUrl.getObjectId();
|
|
|
+ fileMetaMapper.updateSetAcl(objectId, acl);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void getObjectPermission(String objectName) {
|
|
|
-
|
|
|
}
|
|
|
}
|