yby 2 months ago
parent
commit
b80fa694e8

+ 19 - 0
src/main/java/org/ajnb/controller/SuppliersController.java

@@ -3,9 +3,13 @@ package org.ajnb.controller;
 import org.ajnb.service.SuppliersService;
 import org.ajnb.vo.SuppliersVO;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.ResponseBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
+
 @RestController
 @RequestMapping("Suppliers")
 public class SuppliersController {
@@ -17,4 +21,19 @@ public class SuppliersController {
     public void addSuppliers(SuppliersVO suppliersVO){
         suppliersService.addSuppliers(suppliersVO);
     }
+
+    @RequestMapping("querySuppliers")
+    public List<SuppliersVO> querySuppliers(SuppliersVO suppliersVO){
+        return suppliersService.querySuppliers(suppliersVO);
+    }
+
+    @RequestMapping("updateSuppliers")
+    public void updateSuppliers(SuppliersVO suppliersVO){
+        suppliersService.updateSuppliers(suppliersVO);
+    }
+
+    @RequestMapping("deleteSuppliers")
+    public void deleteSuppliers(SuppliersVO suppliersVO){
+        suppliersService.deleteSuppliers(suppliersVO);
+    }
 }

+ 5 - 0
src/main/java/org/ajnb/mapper/SuppliersMapper.java

@@ -3,8 +3,13 @@ package org.ajnb.mapper;
 import org.ajnb.vo.SuppliersVO;
 import org.apache.ibatis.annotations.Mapper;
 
+import java.util.List;
+
 @Mapper
 public interface SuppliersMapper {
 
     public void addSuppliers(SuppliersVO suppliersVO);
+    public List<SuppliersVO> querySuppliers(SuppliersVO suppliersVO);
+    public void updateSuppliers(SuppliersVO suppliersVO);
+    public void deleteSuppliers(SuppliersVO suppliersVO);
 }

+ 5 - 0
src/main/java/org/ajnb/service/SuppliersService.java

@@ -2,6 +2,11 @@ package org.ajnb.service;
 
 import org.ajnb.vo.SuppliersVO;
 
+import java.util.List;
+
 public interface SuppliersService {
     public void addSuppliers(SuppliersVO suppliersVO);
+    public List<SuppliersVO> querySuppliers(SuppliersVO suppliersVO);
+    public void updateSuppliers(SuppliersVO suppliersVO);
+    public void deleteSuppliers(SuppliersVO suppliersVO);
 }

+ 17 - 0
src/main/java/org/ajnb/service/SuppliersServiceImpl.java

@@ -5,6 +5,8 @@ import org.ajnb.vo.SuppliersVO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.List;
+
 @Service
 public class SuppliersServiceImpl implements SuppliersService {
 
@@ -15,4 +17,19 @@ public class SuppliersServiceImpl implements SuppliersService {
     public void addSuppliers(SuppliersVO suppliersVO) {
         suppliersMapper.addSuppliers(suppliersVO);
     }
+
+    @Override
+    public List<SuppliersVO> querySuppliers(SuppliersVO suppliersVO) {
+        return suppliersMapper.querySuppliers(suppliersVO);
+    }
+
+    @Override
+    public void updateSuppliers(SuppliersVO suppliersVO) {
+        suppliersMapper.updateSuppliers(suppliersVO);
+    }
+
+    @Override
+    public void deleteSuppliers(SuppliersVO suppliersVO) {
+        suppliersMapper.deleteSuppliers(suppliersVO);
+    }
 }

+ 17 - 0
src/main/resources/mapper/Suppliers.xml

@@ -8,7 +8,24 @@
     <parameterMap id="pm" type="org.ajnb.vo.SuppliersVO"></parameterMap>
     <resultMap id="rm" type="org.ajnb.vo.SuppliersVO"></resultMap>
 
+<!--    添加供应商-->
     <insert id="addSuppliers" parameterMap="pm">
         INSERT INTO Suppliers(name,phone,department_status) VALUES (#{name},#{phone},#{department_status})
     </insert>
+
+<!--    查询供应商-->
+    <select id="querySuppliers" resultMap="rm" parameterMap="pm">
+        SELECT * FROM Suppliers WHERE name LIKE CONCAT('%',#{name},'%') OR phone = #{phone}
+    </select>
+
+<!--    用户管理修改供应商-->
+    <update id="updateSuppliers" parameterMap="pm">
+        UPDATE Suppliers
+        SET name = #{name}, phone = #{phone}, account = #{account}, password = #{password}
+        WHERE id = #{id};
+    </update>
+<!--    删除供应商-->
+    <delete id="deleteSuppliers" parameterMap="pm">
+        DELETE FROM Suppliers WHERE id = #{id}
+    </delete>
 </mapper>