|
|
@@ -1,15 +1,15 @@
|
|
|
package com.izouma.nineth.web;
|
|
|
|
|
|
import com.izouma.nineth.domain.Banner;
|
|
|
-import com.izouma.nineth.service.BannerService;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.BannerRepo;
|
|
|
+import com.izouma.nineth.service.BannerService;
|
|
|
+import com.izouma.nineth.service.CacheService;
|
|
|
import com.izouma.nineth.utils.ObjUtils;
|
|
|
import com.izouma.nineth.utils.excel.ExcelUtils;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
|
-import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
@@ -22,6 +22,7 @@ import java.util.List;
|
|
|
public class BannerController extends BaseController {
|
|
|
private BannerService bannerService;
|
|
|
private BannerRepo bannerRepo;
|
|
|
+ private CacheService cacheService;
|
|
|
|
|
|
//@PreAuthorize("hasRole('ADMIN')")
|
|
|
@PostMapping("/save")
|
|
|
@@ -29,9 +30,13 @@ public class BannerController extends BaseController {
|
|
|
if (record.getId() != null) {
|
|
|
Banner orig = bannerRepo.findById(record.getId()).orElseThrow(new BusinessException("无记录"));
|
|
|
ObjUtils.merge(orig, record);
|
|
|
- return bannerRepo.save(orig);
|
|
|
+ orig = bannerRepo.save(orig);
|
|
|
+ cacheService.clearBannerList();
|
|
|
+ return orig;
|
|
|
}
|
|
|
- return bannerRepo.save(record);
|
|
|
+ record = bannerRepo.save(record);
|
|
|
+ cacheService.clearBannerList();
|
|
|
+ return record;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -39,7 +44,7 @@ public class BannerController extends BaseController {
|
|
|
@PostMapping("/all")
|
|
|
public Page<Banner> all(@RequestBody PageQuery pageQuery) {
|
|
|
pageQuery.getQuery().put("del", false);
|
|
|
- return bannerService.all(pageQuery);
|
|
|
+ return bannerService.all(pageQuery).toPage();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/get/{id}")
|
|
|
@@ -50,6 +55,7 @@ public class BannerController extends BaseController {
|
|
|
@PostMapping("/del/{id}")
|
|
|
public void del(@PathVariable Long id) {
|
|
|
bannerRepo.softDelete(id);
|
|
|
+ cacheService.clearBannerList();
|
|
|
}
|
|
|
|
|
|
@GetMapping("/excel")
|