|
@@ -8,13 +8,16 @@ import com.caimei365.manager.entity.caimei.page.NewPageTopAdvertisementImage;
|
|
|
import com.caimei365.manager.entity.caimei.page.NewPageZone;
|
|
|
import com.caimei365.manager.entity.caimei.page.NewPageZoneImage;
|
|
|
import com.caimei365.manager.entity.caimei.product.Product;
|
|
|
+import com.caimei365.manager.service.RedisService;
|
|
|
import com.caimei365.manager.service.caimei.page.NewPageZoneService;
|
|
|
+import com.caimei365.manager.utils.GenerateUtils;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -22,6 +25,8 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
|
|
|
+ @Resource
|
|
|
+ private RedisService redisService;
|
|
|
@Autowired
|
|
|
private NewPageZoneDao zoneDao;
|
|
|
|
|
@@ -43,7 +48,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
} else {
|
|
|
zoneDao.updateZone(pageZone);
|
|
|
}
|
|
|
- // 修改
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -53,6 +58,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
zoneDao.delZone(id);
|
|
|
zoneDao.delProducts(id);
|
|
|
zoneDao.delImages(id);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -60,6 +66,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson updateEnabledStatus(Integer id, Integer status, Integer type) {
|
|
|
zoneDao.updateEnabledStatus(id, status, type);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -67,6 +74,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson updateSort(Integer id, Integer sort) {
|
|
|
zoneDao.updateSort(id, sort);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -91,6 +99,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
list.add(Integer.parseInt(ids));
|
|
|
}
|
|
|
zoneDao.delZoneProduct(id, list);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -107,6 +116,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
list.add(Integer.parseInt(ids));
|
|
|
}
|
|
|
zoneDao.addZoneProduct(id, list);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -114,6 +124,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson updateProductSort(Integer id, Integer productId, Integer sort) {
|
|
|
zoneDao.updateProductSort(id, productId, sort);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -134,7 +145,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
} else {
|
|
|
zoneDao.updateZoneImage(pageZoneImage);
|
|
|
}
|
|
|
- // 修改
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -142,6 +153,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson delZoneImage(Integer imageId) {
|
|
|
zoneDao.delImageById(imageId);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -149,6 +161,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson updateImageSort(Integer imageId, Integer sort) {
|
|
|
zoneDao.updateImageSort(imageId, sort);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -156,6 +169,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson updateImageStatus(Integer imageId, Integer status, Integer type) {
|
|
|
zoneDao.updateImageStatus(imageId, status, type);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -185,6 +199,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
list.add(Integer.parseInt(ids));
|
|
|
}
|
|
|
zoneDao.addRecommendProduct(list);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -201,6 +216,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
list.add(Integer.parseInt(ids));
|
|
|
}
|
|
|
zoneDao.recommendDel(list);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -208,6 +224,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson recommendSort(Integer productId, Integer sort) {
|
|
|
zoneDao.recommendSort(productId, sort);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -227,6 +244,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
} else {
|
|
|
zoneDao.updateAdvertisement(image);
|
|
|
}
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -234,6 +252,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson advertisementSort(Integer id, Integer sort) {
|
|
|
zoneDao.advertisementSort(id, sort);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -241,6 +260,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson advertisementDel(Integer id) {
|
|
|
zoneDao.advertisementDel(id);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -252,6 +272,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
return ResponseJson.success(page);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public ResponseJson saveTopAdvertisement(NewPageTopAdvertisementImage image) {
|
|
|
if (null == image.getId()) {
|
|
@@ -259,6 +280,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
} else {
|
|
|
zoneDao.updateTopAdvertisement(image);
|
|
|
}
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -266,6 +288,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson topAdvertisementDel(Integer id) {
|
|
|
zoneDao.delTopAdvertisement(id);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -273,6 +296,7 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
@Override
|
|
|
public ResponseJson updateTopStatus(Integer id, Integer status, Integer type) {
|
|
|
zoneDao.updateTopStatus(id, status, type);
|
|
|
+ cleanRedisCache();
|
|
|
return ResponseJson.success();
|
|
|
}
|
|
|
|
|
@@ -285,4 +309,11 @@ public class NewPageZoneServiceImpl implements NewPageZoneService {
|
|
|
public ResponseJson<NewPageTopAdvertisementImage> topAdvertisementForm(Integer id) {
|
|
|
return ResponseJson.success(zoneDao.getTopAdvertisementForm(id));
|
|
|
}
|
|
|
+
|
|
|
+ public void cleanRedisCache() {
|
|
|
+ //首页缓存
|
|
|
+ redisService.removePattern("getHomeCommodityData*");
|
|
|
+ // 重新生成静态首页
|
|
|
+ GenerateUtils.generateHome();
|
|
|
+ }
|
|
|
}
|