Kaynağa Gözat

藏品Controller层藏品增改功能实现

Signed-off-by: hamjin <335908093@qq.com>
hamjin 2 yıl önce
ebeveyn
işleme
7ae9f6bee4

+ 91 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoCollectionController.java

@@ -0,0 +1,91 @@
+package com.ruoyi.web.controller.system;
+
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.system.domain.PoCollection;
+import com.ruoyi.system.service.IPoCollectionService;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 藏品 信息操作处理
+ *
+ * @author ruoyi
+ */
+@RestController
+@RequestMapping("/collections")
+public class PoCollectionController extends BaseController {
+    @Autowired
+    private IPoCollectionService collectionService;
+
+    /**
+     * 获取藏品列表
+     */
+    @GetMapping("/list")
+    public TableDataInfo list(PoCollection collection) {
+        return new TableDataInfo();
+    }
+
+    /**
+     * 获取藏品列表
+     */
+    @GetMapping("/export")
+    public AjaxResult export(PoCollection collection) {
+        return AjaxResult.success();
+    }
+
+    /**
+     * 根据藏品编号获取详细信息
+     */
+    @GetMapping(value = "/{collectionId}")
+    public AjaxResult getInfo(@PathVariable("collectionId") Long collectionId) {
+        return success();
+    }
+
+    /**
+     * 新增藏品
+     */
+    @PreAuthorize("@ss.hasPermi('collection:add')")
+    @Log(title = "藏品", businessType = BusinessType.INSERT)
+    @ApiOperation("添加藏品")
+    @PostMapping
+    public AjaxResult add(@Validated @RequestBody PoCollection collection) {
+        List<PoCollection> collectionList = collectionService.selectCollections(collection);
+        if (collectionList != null && !collectionList.isEmpty())
+            return error("重复的藏品");
+        return toAjax(collectionService.insertCollection(collection));
+    }
+
+    /**
+     * 修改藏品
+     */
+    @PreAuthorize("@ss.hasPermi('collection:edit')")
+    @Log(title = "藏品", businessType = BusinessType.UPDATE)
+    @ApiOperation("编辑藏品")
+    @PutMapping
+    public AjaxResult edit(@Validated @RequestBody PoCollection collection) {
+        PoCollection collection1 = collectionService.selectCollectionById(collection.getCollectionId());
+        if (collection1 == null)
+            return error("要修改的藏品不存在");
+        if (collection1.getCochain() == 0)
+            return error("要修改的藏品已上链");
+        collection.setUpdateBy(getUsername());
+        return toAjax(collectionService.updateCollection(collection));
+    }
+
+    /**
+     * 删除藏品
+     */
+    @DeleteMapping("/{collectionIds}")
+    public AjaxResult remove(@PathVariable Long[] collectionIds) {
+        return AjaxResult.success();
+    }
+}