swq 2 months ago
parent
commit
3d8e63d1b1

+ 38 - 0
src/main/java/com/gydx/controller/RulesController.java

@@ -0,0 +1,38 @@
+package com.gydx.controller;
+
+
+import com.gydx.service.RulesServiceFace;
+import com.gydx.vo.Rules;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("rules")
+public class RulesController {
+
+    @Autowired
+    RulesServiceFace rulesService;
+
+    @RequestMapping("addrules")
+    public void addRules(Rules rules){
+        rulesService.addRules(rules);
+    }
+
+    @RequestMapping("updateRules")
+    public void updateRules(Rules rules){
+        rulesService.updateRules(rules);
+    }
+
+    @RequestMapping("deleteRules")
+    public void deleteRules(Rules rules){
+        rulesService.deleteRules(rules);
+    }
+
+    @RequestMapping("queryRules")
+    public List<Rules> queryRules(Rules rules){
+        return rulesService.queryRules(rules);
+    }
+}

+ 50 - 0
src/main/java/com/gydx/controller/SuppliersController.java

@@ -0,0 +1,50 @@
+package com.gydx.controller;
+
+
+import com.gydx.service.SuppliersServiceFace;
+import com.gydx.vo.Suppliers;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.CrossOrigin;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@CrossOrigin(origins = "http://localhost:8081")  // 允许来自前端的跨域请求
+@RestController
+@RequestMapping("/suppliers")
+public class SuppliersController {
+    @Autowired
+    SuppliersServiceFace suppliersServiceFace;
+
+
+    @RequestMapping("addsuppliers")
+    public void addSuppliers(@RequestBody Suppliers suppliers) {
+        suppliers.setDepartment_status(true);
+        System.out.println(suppliers);
+        suppliersServiceFace.addSuppliers(suppliers);
+        suppliers.setDepartment_status(true);
+    }
+
+
+
+    @RequestMapping("deletesuppliers")
+    public void deleteSuppliers(Suppliers suppliers) {
+        suppliersServiceFace.deleteSuppliers(suppliers);
+    }
+
+    @RequestMapping("updatesuppliers")
+    public void updateSuppliers(Suppliers suppliers) {
+        suppliersServiceFace.updateSuppliers(suppliers);
+    }
+
+    @RequestMapping("querysuppliers")
+    public List<Suppliers> querySuppliers(Suppliers suppliers) {
+        return suppliersServiceFace.querySuppliers(suppliers);
+    }
+    @RequestMapping("querySuppliersName")
+    public List<Suppliers> querySuppliersName(Suppliers suppliers) {
+        return suppliersServiceFace.querySuppliersName(suppliers);
+    }
+}

+ 16 - 0
src/main/java/com/gydx/mapper/RulesFace.java

@@ -0,0 +1,16 @@
+package com.gydx.mapper;
+
+import com.gydx.vo.Rules;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+@Mapper
+public interface RulesFace {
+
+    public void addRules(Rules rules);
+    public void updateRules(Rules rules);
+    public void deleteRules(Rules rules);
+    public List<Rules> queryRules(Rules rules);
+
+}

+ 16 - 0
src/main/java/com/gydx/mapper/SuppliersFace.java

@@ -0,0 +1,16 @@
+package com.gydx.mapper;
+
+
+import com.gydx.vo.Suppliers;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+@Mapper
+public interface SuppliersFace {
+
+    public void addSuppliers(Suppliers suppliers);
+    public void deleteSuppliers(Suppliers suppliers);
+    public void updateSuppliers(Suppliers suppliers);
+    public List<Suppliers> querySuppliers(Suppliers suppliers);
+    public List<Suppliers> querySuppliersName(Suppliers suppliers);
+}

+ 12 - 0
src/main/java/com/gydx/service/RulesServiceFace.java

@@ -0,0 +1,12 @@
+package com.gydx.service;
+
+import com.gydx.vo.Rules;
+
+import java.util.List;
+
+public interface RulesServiceFace {
+    public void addRules(Rules rules);
+    public void updateRules(Rules rules);
+    public void deleteRules(Rules rules);
+    public List<Rules> queryRules(Rules rules);
+}

+ 35 - 0
src/main/java/com/gydx/service/RulesServiceImpl.java

@@ -0,0 +1,35 @@
+package com.gydx.service;
+
+import com.gydx.mapper.RulesFace;
+import com.gydx.vo.Rules;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+@Service
+public class RulesServiceImpl implements RulesServiceFace{
+
+    @Autowired
+    RulesFace rulesFace;
+    @Override
+    public void addRules(Rules rules) {
+        rulesFace.addRules(rules);
+    }
+
+    @Override
+    public void updateRules(Rules rules) {
+        rulesFace.updateRules(rules);
+    }
+
+    @Override
+    public void deleteRules(Rules rules) {
+        rulesFace.deleteRules(rules);
+    }
+
+    @Override
+    public List<Rules> queryRules(Rules rules) {
+        return rulesFace.queryRules(rules);
+    }
+}

+ 13 - 0
src/main/java/com/gydx/service/SuppliersServiceFace.java

@@ -0,0 +1,13 @@
+package com.gydx.service;
+
+import com.gydx.vo.Suppliers;
+
+import java.util.List;
+
+public interface SuppliersServiceFace {
+    public void addSuppliers(Suppliers suppliers);
+    public void deleteSuppliers(Suppliers suppliers);
+    public void updateSuppliers(Suppliers suppliers);
+    public List<Suppliers> querySuppliers(Suppliers suppliers);
+    public List<Suppliers> querySuppliersName(Suppliers suppliers);
+}

+ 40 - 0
src/main/java/com/gydx/service/SuppliersServiceImpl.java

@@ -0,0 +1,40 @@
+package com.gydx.service;
+
+import com.gydx.mapper.SuppliersFace;
+import com.gydx.vo.Suppliers;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.Collections;
+import java.util.List;
+
+@Service
+public class SuppliersServiceImpl implements SuppliersServiceFace{
+
+    @Autowired
+    SuppliersFace suppliersFace;
+    @Override
+    public void addSuppliers(Suppliers suppliers) {
+        suppliersFace.addSuppliers(suppliers);
+    }
+
+    @Override
+    public void deleteSuppliers(Suppliers suppliers) {
+        suppliersFace.deleteSuppliers(suppliers);
+    }
+
+    @Override
+    public void updateSuppliers(Suppliers suppliers) {
+        suppliersFace.updateSuppliers(suppliers);
+    }
+
+    @Override
+    public List<Suppliers> querySuppliers(Suppliers suppliers) {
+        return suppliersFace.querySuppliers(suppliers);
+    }
+
+    @Override
+    public List<Suppliers> querySuppliersName(Suppliers suppliers) {
+        return suppliersFace.querySuppliersName(suppliers);
+    }
+}

+ 22 - 0
src/main/resources/mapper/Rules.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.gydx.mapper.RulesFace">
+    <parameterMap id="pm" type="com.gydx.vo.Rules"></parameterMap>
+    <resultMap id="rm" type="com.gydx.vo.Rules"></resultMap>
+    
+    <select id="queryRules" resultMap="rm" parameterMap="pm">
+        select name,rounds,duration_minutes,interval_minutes from Rules
+    </select>
+
+    <insert id="addRules" parameterMap="pm">
+        insert into Rules (name,rounds,duration_minutes,interval_minutes) values (#{name},#{rounds},#{duration_minutes},#{interval_minutes})
+    </insert>
+
+    <update id="updateRules" parameterMap="pm">
+        update Rules set name = #{name},rounds = #{rounds},duration_minutes = #{duration_minutes},interval_minutes = #{interval_minutes} where id = #{id}
+    </update>
+
+    <delete id="deleteRules" parameterMap="pm">
+        delete from Rules where id = #{id}
+    </delete>
+</mapper>

+ 28 - 0
src/main/resources/mapper/suppliers.xml

@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.gydx.mapper.SuppliersFace">
+    
+    <parameterMap id="pm" type="com.gydx.vo.Suppliers"></parameterMap>
+    <resultMap id="rm" type="com.gydx.vo.Suppliers"></resultMap>
+
+    <select id="querySuppliersName" resultMap="rm" parameterMap="pm">
+        select id,name,phone,department_status from Suppliers where name LIKE CONCAT('%',#{name},'%') or phone = #{phone}
+    </select>
+    
+    <select id="querySuppliers" resultMap="rm" parameterMap="pm">
+        select id,name,phone,department_status from Suppliers
+    </select>
+
+    <insert id="addSuppliers" parameterMap="pm">
+        insert into Suppliers (name,phone,department_status) values (#{name},#{phone},#{department_status})
+    </insert>
+
+    <delete id="deleteSuppliers" parameterMap="pm">
+        delete from Suppliers where id = #{id}
+    </delete>
+
+    <update id="updateSuppliers" parameterMap="pm">
+        update Suppliers set name = #{name},phone = #{phone},account = #{account},password = #{password} where id = #{id}
+    </update>
+    
+</mapper>