Browse Source

藏品查询、删除实现

aozhentao 2 years ago
parent
commit
605709caff

+ 26 - 10
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/PoCollectionController.java

@@ -5,6 +5,7 @@ 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.common.utils.poi.ExcelUtil;
 import com.ruoyi.system.domain.PoCollection;
 import com.ruoyi.system.service.IPoCollectionService;
 import io.swagger.annotations.ApiOperation;
@@ -13,6 +14,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 
 /**
@@ -29,25 +31,36 @@ public class PoCollectionController extends BaseController {
     /**
      * 获取藏品列表
      */
+    @PreAuthorize("@ss.hasPermi('system:collection:list')")
     @GetMapping("/list")
-    public TableDataInfo list(PoCollection collection) {
-        return new TableDataInfo();
+    public TableDataInfo list(PoCollection poCollection)
+    {
+        startPage();
+        List<PoCollection> list = collectionService.selectPoCollectionList(poCollection);
+        return getDataTable(list);
     }
 
     /**
      * 获取藏品列表
      */
-    @GetMapping("/export")
-    public AjaxResult export(PoCollection collection) {
-        return AjaxResult.success();
+    @PreAuthorize("@ss.hasPermi('system:collection:export')")
+    @Log(title = "获取藏品列表", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, PoCollection poCollection)
+    {
+        List<PoCollection> list = collectionService.selectPoCollectionList(poCollection);
+        ExcelUtil<PoCollection> util = new ExcelUtil<PoCollection>(PoCollection.class);
+        util.exportExcel(response, list, "藏品数据");
     }
 
     /**
      * 根据藏品编号获取详细信息
      */
+    @PreAuthorize("@ss.hasPermi('system:collection:query')")
     @GetMapping(value = "/{collectionId}")
-    public AjaxResult getInfo(@PathVariable("collectionId") Long collectionId) {
-        return success();
+    public AjaxResult getInfo(@PathVariable("collectionId") Long collectionId)
+    {
+        return success(collectionService.selectCollectionById(collectionId));
     }
 
     /**
@@ -58,7 +71,7 @@ public class PoCollectionController extends BaseController {
     @ApiOperation("添加藏品")
     @PostMapping
     public AjaxResult add(@Validated @RequestBody PoCollection collection) {
-        List<PoCollection> collectionList = collectionService.selectCollections(collection);
+        List<PoCollection> collectionList = collectionService.selectPoCollectionList(collection);
         if (collectionList != null && !collectionList.isEmpty())
             return error("重复的藏品");
         return toAjax(collectionService.insertCollection(collection));
@@ -84,8 +97,11 @@ public class PoCollectionController extends BaseController {
     /**
      * 删除藏品
      */
+    @PreAuthorize("@ss.hasPermi('system:collection:remove')")
+    @Log(title = "删除藏品", businessType = BusinessType.DELETE)
     @DeleteMapping("/{collectionIds}")
-    public AjaxResult remove(@PathVariable Long[] collectionIds) {
-        return AjaxResult.success();
+    public AjaxResult remove(@PathVariable Long[] collectionIds)
+    {
+        return toAjax(collectionService.deletePoCollectionByCollectionIds(collectionIds));
     }
 }

+ 19 - 10
ruoyi-system/src/main/java/com/ruoyi/system/mapper/PoCollectionMapper.java

@@ -13,20 +13,29 @@ import java.util.List;
 @Mapper
 public interface PoCollectionMapper {
     /**
-     * 查询藏品信息
+     * 查询多个藏品信息
      *
-     * @param collectionId 藏品ID
+     * @param collectionIdList 藏品ID
      * @return 藏品信息
      */
-    PoCollection selectPoCollectionById(Long collectionId);
+     List<PoCollection> selectCollectionById(Long[] collectionIdList);
 
     /**
      * 查询藏品列表
      *
-     * @param collections 藏品信息
+     * @param poCollection 藏品信息
      * @return 藏品集合
      */
-    List<PoCollection> selectPoCollectionList(PoCollection collections);
+    List<PoCollection> selectPoCollectionList(PoCollection poCollection);
+
+    /**
+     * 查询单个藏品信息
+     *
+     * @param collectionId 藏品ID
+     * @return 藏品信息
+     */
+    PoCollection selectCollectionById(Long collectionId);
+
 
     /**
      * 新增藏品
@@ -45,18 +54,18 @@ public interface PoCollectionMapper {
     int updatePoCollection(PoCollection collections);
 
     /**
-     * 批量删除藏品
+     * 删除藏品
      *
-     * @param collectionsId 藏品ID
+     * @param collectionId 藏品ID
      * @return 结果
      */
-    int deletePoCollectionById(Long collectionsId);
+    public int deletePoCollectionByCollectionId(Long collectionId);
 
     /**
      * 批量删除藏品信息
      *
-     * @param collectionsIds 需要删除的藏品ID
+     * @param collectionIds 需要删除的藏品ID
      * @return 结果
      */
-    int deletePoCollectionByIds(Long[] collectionsIds);
+    public int deletePoCollectionByCollectionIds(Long[] collectionIds);
 }

+ 29 - 23
ruoyi-system/src/main/java/com/ruoyi/system/service/IPoCollectionService.java

@@ -9,12 +9,29 @@ import java.util.List;
  */
 public interface IPoCollectionService {
     /**
-     * 根据Id查询
+     * 查询藏品
      *
-     * @param collectionIdList 要查询的藏品ID
-     * @return 藏品ID对应的藏品
+     * @param collectionIdList
+     * @return
+     */
+    public List<PoCollection> selectPoCollectionByCollectionIds(Long[] collectionIdList);
+
+
+    /**
+     * 获取藏品详细内容
+     *
+     * @param collectionId 藏品ID
+     * @return 藏品信息
+     */
+    PoCollection selectCollectionById(Long collectionId);
+
+    /**
+     * 查询藏品列表
+     *
+     * @param poCollection
+     * @return
      */
-    public List<PoCollection> selectCollectionByCollectionId(Long[] collectionIdList);
+    public List<PoCollection> selectPoCollectionList(PoCollection poCollection);
 
     /**
      * 增加
@@ -33,35 +50,24 @@ public interface IPoCollectionService {
     public int updateCollection(PoCollection collection);
 
     /**
-     * 批量删除
+     * 批量删除藏品
      *
      * @param collectionIds
      * @return
      */
-    int deleteCollectionByIds(Long[] collectionIds);
+    public int deletePoCollectionByCollectionIds(Long[] collectionIds);
 
     /**
-     * 删除
+     * 删除藏品
      *
      * @param collectionId
-     * @return
+     * @return 结果
      */
-    int deleteCollectionById(Long collectionId);
+    public int deletePoCollectionByCollectionId(Long collectionId);
+
+
+
 
-    /**
-     * 获取符合要求的藏品
-     *
-     * @param collection 搜索的藏品信息
-     * @return 符合要求的藏品,默认为全部藏品
-     */
-    List<PoCollection> selectCollections(PoCollection collection);
 
-    /**
-     * 获取藏品详细内容
-     *
-     * @param collectionId 藏品ID
-     * @return 藏品信息
-     */
-    PoCollection selectCollectionById(Long collectionId);
 }
 

+ 26 - 20
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/PoCollectionServiceImpl.java

@@ -14,27 +14,30 @@ public class PoCollectionServiceImpl implements IPoCollectionService {
     PoCollectionMapper poCollectionMapper;
 
     /**
-     * 根据Id查询
+     * 查询藏品
      *
-     * @param collectionIdList 要查询的藏品ID表
-     * @return 藏品ID对应的藏品
+     * @param collectionIdList
+     * @return
      */
     @Override
-    public List<PoCollection> selectCollectionByCollectionId(Long[] collectionIdList) {
+    public List<PoCollection> selectPoCollectionByCollectionIds(Long[] collectionIdList)
+    {
         return null;
     }
 
     /**
-     * 获取符合要求的藏品
+     * 查询藏品列表
      *
-     * @param collection 搜索的藏品信息
-     * @return 符合要求的藏品,默认为全部藏品
+     * @param poCollection
+     * @return
      */
     @Override
-    public List<PoCollection> selectCollections(PoCollection collection) {
-        return null;
+    public List<PoCollection> selectPoCollectionList(PoCollection poCollection)
+    {
+        return poCollectionMapper.selectPoCollectionList(poCollection);
     }
 
+
     /**
      * 获取藏品详细内容
      *
@@ -43,9 +46,10 @@ public class PoCollectionServiceImpl implements IPoCollectionService {
      */
     @Override
     public PoCollection selectCollectionById(Long collectionId) {
-        return null;
+        return poCollectionMapper.selectCollectionById(collectionId);
     }
 
+
     /**
      * 增加
      *
@@ -72,24 +76,26 @@ public class PoCollectionServiceImpl implements IPoCollectionService {
     }
 
     /**
-     * 批量删除
+     * 批量删除藏品
      *
-     * @param collectionIds 藏品ID
-     * @return 操作状态
+     * @param collectionIds 需要删除的藏品主键
+     * @return
      */
     @Override
-    public int deleteCollectionByIds(Long[] collectionIds) {
-        return 0;
+    public int deletePoCollectionByCollectionIds(Long[] collectionIds)
+    {
+        return poCollectionMapper.deletePoCollectionByCollectionIds(collectionIds);
     }
 
     /**
-     * 单个删除
+     * 删除藏品
      *
-     * @param collectionId 藏品ID
-     * @return 操作状态
+     * @param collectionId
+     * @return
      */
     @Override
-    public int deleteCollectionById(Long collectionId) {
-        return 0;
+    public int deletePoCollectionByCollectionId(Long collectionId)
+    {
+        return poCollectionMapper.deletePoCollectionByCollectionId(collectionId);
     }
 }

+ 16 - 32
ruoyi-system/src/main/resources/mapper/system/PoCollectionMapper.xml

@@ -46,7 +46,7 @@
         from po_collection
     </sql>
 
-    <select id="selectPoCollectionById" parameterType="Long" resultMap="PoCollectionResult">
+    <select id="selectCollectionById" parameterType="Long" resultMap="PoCollectionResult">
         <include refid="selectPoCollectionVo"/>
         where collection_id = #{collectionId}
     </select>
@@ -54,30 +54,18 @@
     <select id="selectPoCollectionList" parameterType="PoCollection" resultMap="PoCollectionResult">
         <include refid="selectPoCollectionVo"/>
         <where>
-            <if test="collectionTitle != null and collectionTitle != ''">
-                AND collection_title like concat('%', #{collectionTitle}, '%')
-            </if>
-            <if test="createBy != null and createBy != ''">
-                AND create_by like concat('%', #{createBy}, '%')
-            </if>
-            <if test="publisherName != null and publisherName != ''">
-                AND publisher_name like concat('%', #{publisherName}, '%')
-            </if>
-            <if test="delFlag != null and delFlag != ''">
-                AND del_flag like concat('%', #{delFlag}, '%')
-            </if>
-            <if test="collectionType != null and collectionType != ''">
-                AND collection_type like concat('%', #{collectionType}, '%')
-            </if>
-            <if test="grouding != null and grouding != ''">
-                AND grounding like concat('%', #{grounding}, '%')
-            </if>
-            <if test="cochain != null and cochain != ''">
-                AND cochain like concat('%', #{cochain}, '%')
-            </if>
-            <if test="tetherId != null and tetherId != ''">
-                AND tether_id like concat('%', #{tetherId}, '%')
-            </if>
+            <if test="collectionTitle != null  and collectionTitle != ''"> and collection_title = #{collectionTitle}</if>
+            <if test="status != null  and status != ''"> and status = #{status}</if>
+            <if test="collectionType != null "> and collection_type = #{collectionType}</if>
+            <if test="total != null "> and total = #{total}</if>
+            <if test="image != null  and image != ''"> and image = #{image}</if>
+            <if test="formwork != null  and formwork != ''"> and formwork = #{formwork}</if>
+            <if test="price != null "> and price = #{price}</if>
+            <if test="publisherName != null "> and publisher_name like concat('%', #{publisherName}, '%')</if>
+            <if test="story != null  and story != ''"> and story = #{story}</if>
+            <if test="grounding != null "> and grounding = #{grounding}</if>
+            <if test="cochain != null "> and cochain = #{cochain}</if>
+            <if test="tetherId != null "> and tether_id = #{tetherId}</if>
         </where>
     </select>
 
@@ -135,19 +123,15 @@
         where collection_id = #{collectionId}
     </update>
 
-    <delete id="deletePoCollectionById" parameterType="Long">
-        delete
-        from po_collection
-        where collection_id = #{collectionId}
-          and cochain != 0
+    <delete id="deletePoCollectionByCollectionId" parameterType="Long">
+        delete from po_collection where collection_id = #{collectionId}
     </delete>
 
-    <delete id="deletePoCollectionByIds" parameterType="Long">
+    <delete id="deletePoCollectionByCollectionIds" parameterType="String">
         delete from po_collection where collection_id in
         <foreach item="collectionId" collection="array" open="(" separator="," close=")">
             #{collectionId}
         </foreach>
-        and cochain != 0
     </delete>
 
 </mapper>