Explorar o código

企业藏品上下架

licailing %!s(int64=4) %!d(string=hai) anos
pai
achega
e8f9b71e25

+ 10 - 1
src/main/java/com/izouma/nineth/web/CollectionController.java

@@ -64,7 +64,7 @@ public class CollectionController extends BaseController {
     @PostMapping("/create")
     public Collection create(@RequestBody CollectionInfoDTO record) {
         Collection collection = new Collection();
-        BeanUtils.copyProperties(record,collection);
+        BeanUtils.copyProperties(record, collection);
         collection = collectionService.create(collection);
         CollectionPrivilege collectionPrivilege = new CollectionPrivilege();
         BeanUtils.copyProperties(record, collectionPrivilege);
@@ -199,5 +199,14 @@ public class CollectionController extends BaseController {
         cacheService.clearRecommend();
         return "ok";
     }
+
+    @PreAuthorize("hasAnyRole('ADMIN','COMPANY')")
+    @PostMapping("/onShelf")
+    public void onShelf(Long id, boolean onShelf, boolean salable) {
+        Collection collection = collectionRepo.findById(id).orElseThrow(new BusinessException("藏品不存在"));
+        collection.setOnShelf(onShelf);
+        collection.setSalable(salable);
+        collectionRepo.save(collection);
+    }
 }
 

+ 2 - 1
src/main/java/com/izouma/nineth/web/CouponController.java

@@ -12,6 +12,7 @@ import com.izouma.nineth.utils.excel.ExcelUtils;
 import lombok.AllArgsConstructor;
 import org.apache.commons.collections.CollectionUtils;
 import org.springframework.data.domain.Page;
+import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
@@ -27,7 +28,7 @@ public class CouponController extends BaseController {
     private CouponRepo     couponRepo;
     private CollectionRepo collectionRepo;
 
-    //@PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasRole('ADMIN')")
     @PostMapping("/save")
     public Coupon save(@RequestBody Coupon record) {
         if (record.getId() != null) {

+ 5 - 1
src/main/vue/src/views/company/CompanyCollectionShelf.vue

@@ -377,7 +377,11 @@ export default {
 
             this.saving = true;
             this.$http
-                .post('/collection/save', data, { body: 'json' })
+                .post('/collection/onShelf', {
+                    id: data.id,
+                    onShelf: data.onShelf,
+                    salable: data.salable,
+                })
                 .then(res => {
                     this.saving = false;
                     this.$message.success('成功');