浏览代码

农村合作社 添加控制器 修改逻辑删除

wangzhe 1 年之前
父节点
当前提交
56ff9fc0e4

+ 105 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/controller/CooperativeController.java

@@ -0,0 +1,105 @@
+package com.ruoyi.web.controller.controller;
+
+import java.util.List;
+import javax.servlet.http.HttpServletResponse;
+
+import com.sooka.jnb.cooperative.domain.Cooperative;
+import com.sooka.jnb.cooperative.service.ICooperativeService;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import com.ruoyi.common.annotation.Log;
+import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.common.core.page.TableDataInfo;
+
+/**
+ * 供销合作社Controller
+ * 
+ * @author ruoyi
+ * @date 2024-03-01
+ */
+@RestController
+@RequestMapping("/system/cooperative")
+public class CooperativeController extends BaseController
+{
+    @Autowired
+    private ICooperativeService cooperativeService;
+
+    /**
+     * 查询供销合作社列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:cooperative:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(Cooperative cooperative)
+    {
+        startPage();
+        List<Cooperative> list = cooperativeService.selectCooperativeList(cooperative);
+        return getDataTable(list);
+    }
+
+    /**
+     * 导出供销合作社列表
+     */
+    @PreAuthorize("@ss.hasPermi('system:cooperative:export')")
+    @Log(title = "供销合作社", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, Cooperative cooperative)
+    {
+        List<Cooperative> list = cooperativeService.selectCooperativeList(cooperative);
+        ExcelUtil<Cooperative> util = new ExcelUtil<Cooperative>(Cooperative.class);
+        util.exportExcel(response, list, "供销合作社数据");
+    }
+
+    /**
+     * 获取供销合作社详细信息
+     */
+    @PreAuthorize("@ss.hasPermi('system:cooperative:query')")
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(cooperativeService.selectCooperativeById(id));
+    }
+
+    /**
+     * 新增供销合作社
+     */
+    @PreAuthorize("@ss.hasPermi('system:cooperative:add')")
+    @Log(title = "供销合作社", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody Cooperative cooperative)
+    {
+        return toAjax(cooperativeService.insertCooperative(cooperative));
+    }
+
+    /**
+     * 修改供销合作社
+     */
+    @PreAuthorize("@ss.hasPermi('system:cooperative:edit')")
+    @Log(title = "供销合作社", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody Cooperative cooperative)
+    {
+        return toAjax(cooperativeService.updateCooperative(cooperative));
+    }
+
+    /**
+     * 删除供销合作社
+     */
+    @PreAuthorize("@ss.hasPermi('system:cooperative:remove')")
+    @Log(title = "供销合作社", businessType = BusinessType.DELETE)
+	@DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids)
+    {
+        return toAjax(cooperativeService.deleteCooperativeByIds(ids));
+    }
+}

+ 4 - 3
sooka-jnb/src/main/resources/mapper/cooperative/CooperativeMapper.xml

@@ -26,7 +26,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectCooperativeList" parameterType="com.sooka.jnb.cooperative.domain.Cooperative" resultMap="CooperativeResult">
         <include refid="selectCooperativeVo"/>
-        <where>  
+        <where>
+            del_flag = '0'
             <if test="version != null  and version != ''"> and version = #{version}</if>
             <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
             <if test="address != null  and address != ''"> and address like concat('%', #{address}, '%')</if>
@@ -93,11 +94,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteCooperativeById" parameterType="java.lang.Long">
-        delete from jnb_supply_and_marketing_cooperative where id = #{id}
+        update jnb_supply_and_marketing_cooperative set del_flag = '2' where id = #{id}
     </delete>
 
     <delete id="deleteCooperativeByIds" parameterType="java.lang.String">
-        delete from jnb_supply_and_marketing_cooperative where id in 
+        update jnb_supply_and_marketing_cooperative set del_flag = '2' where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>