|
@@ -122,16 +122,28 @@ public class ResourceService {
|
122
|
122
|
}
|
123
|
123
|
|
124
|
124
|
public void deleteModel(Integer modelId) {
|
|
125
|
+ ModelInfo modelInfo = infoRepository.findById(modelId).get();
|
125
|
126
|
infoRepository.deleteById(modelId);
|
|
127
|
+ aliOSSUtils.deleteModel(modelInfo.getOriginalPath());
|
126
|
128
|
}
|
127
|
129
|
|
128
|
130
|
@Transactional
|
129
|
131
|
public void deleteCategory(List<Integer> categoryId) {
|
|
132
|
+ deleteOssFiles(categoryId);
|
130
|
133
|
categoryRepository.deleteAllByIdInBatch(categoryId);
|
131
|
134
|
// 更新用户资源刷新状态
|
132
|
135
|
userInfoRepository.updateRefreshStatus();
|
133
|
136
|
}
|
134
|
137
|
|
|
138
|
+ /**
|
|
139
|
+ * 删除oss文件
|
|
140
|
+ *
|
|
141
|
+ * @param categoryId
|
|
142
|
+ */
|
|
143
|
+ private void deleteOssFiles(List<Integer> categoryId) {
|
|
144
|
+ infoRepository.findByCategoryIdIn(categoryId).forEach(modelInfo -> aliOSSUtils.deleteModel(modelInfo.getOriginalPath()));
|
|
145
|
+ }
|
|
146
|
+
|
135
|
147
|
public List<Map<String, Object>> resourceCategory(String userCode) {
|
136
|
148
|
return categoryRepository.queryWithUserCode(userCode);
|
137
|
149
|
}
|