|
|
@@ -2,9 +2,7 @@ package com.miekir.shibei.controller.api;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.miekir.shibei.bean.*;
|
|
|
-import com.miekir.shibei.bean.db.GoodsBean;
|
|
|
-import com.miekir.shibei.bean.db.SystemBean;
|
|
|
-import com.miekir.shibei.bean.db.User;
|
|
|
+import com.miekir.shibei.bean.db.*;
|
|
|
import com.miekir.shibei.repository.FavRepository;
|
|
|
import com.miekir.shibei.repository.GoodsRepository;
|
|
|
import com.miekir.shibei.repository.SystemRepository;
|
|
|
@@ -115,7 +113,62 @@ public class GoodsController {
|
|
|
return JSON.toJSONString(responseResult);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ // 删除插图
|
|
|
+ Set<String> contentImageList = dbGoodsBean.contentImageUrlList;
|
|
|
+ if (contentImageList != null && contentImageList.size() > 0) {
|
|
|
+ for (String imgUrl : contentImageList) {
|
|
|
+ String fileUrl = imgUrl;
|
|
|
+ if (fileUrl.startsWith("auto/")) {
|
|
|
+ fileUrl = fileUrl.substring("auto/".length());
|
|
|
+ }
|
|
|
+
|
|
|
+ File file = new File(FileTool.TARGET_DIR_AUTO_IMAGES, fileUrl);
|
|
|
+ if (file.exists()) {
|
|
|
+ try {
|
|
|
+ file.delete();
|
|
|
+ } catch (Exception imgException) {
|
|
|
+ imgException.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除torrent
|
|
|
+ Set<MagnetBean> magnetBeanList = dbGoodsBean.magnetBeanList;
|
|
|
+ if (magnetBeanList != null && magnetBeanList.size() > 0) {
|
|
|
+ for (MagnetBean magnetBean : magnetBeanList) {
|
|
|
+ String torrentUrl = magnetBean.url;
|
|
|
+ if (!TextUtils.isEmpty(torrentUrl)) {
|
|
|
+ if (torrentUrl.startsWith("torrent/")) {
|
|
|
+ torrentUrl = torrentUrl.substring("torrent/".length());
|
|
|
+ }
|
|
|
+
|
|
|
+ File file = new File(FileTool.TARGET_DIR_AUTO_TORRENT, torrentUrl);
|
|
|
+ if (file.exists()) {
|
|
|
+ try {
|
|
|
+ file.delete();
|
|
|
+ } catch (Exception imgException) {
|
|
|
+ imgException.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 删除收藏
|
|
|
+ try {
|
|
|
+ List<FavBean> favBeanList = favRepository.findFavListByGoodsId(dbGoodsBean.id);
|
|
|
+ if (favBeanList != null && favBeanList.size() > 0) {
|
|
|
+ favRepository.delete(favBeanList);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
try {
|
|
|
+ // 这里数据库一对多关系的多会被删除,但自己手动插入的和本地文件还是需要自己处理
|
|
|
goodsRepository.delete(dbGoodsBean);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|