From f67fbb638013ee1b8f5c639afdfa9372c696eae9 Mon Sep 17 00:00:00 2001 From: chaiyapeng <3535863041@qq.com> Date: Sun, 1 Sep 2024 15:20:18 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=AD=E4=B9=B0=E8=A7=A3=E5=86=B3=E6=A1=86?= =?UTF-8?q?=E6=9E=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/muyu/system/controller/BuyInterface.java | 13 +++++++++++++ .../java/com/muyu/system/mapper/BuyMapper.java | 1 + .../java/com/muyu/system/service/BuyService.java | 2 ++ .../muyu/system/service/impl/BuyServiceImpl.java | 14 ++++++++++++++ src/main/resources/mapper/system/BuyMapper.xml | 11 +++++++++++ 5 files changed, 41 insertions(+) create mode 100644 src/main/resources/mapper/system/BuyMapper.xml diff --git a/src/main/java/com/muyu/system/controller/BuyInterface.java b/src/main/java/com/muyu/system/controller/BuyInterface.java index f056379..ff9f8e5 100644 --- a/src/main/java/com/muyu/system/controller/BuyInterface.java +++ b/src/main/java/com/muyu/system/controller/BuyInterface.java @@ -1,6 +1,12 @@ package com.muyu.system.controller; +import com.muyu.common.core.domain.Result; +import com.muyu.system.domain.Connector; +import com.muyu.system.service.BuyService; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @@ -15,4 +21,11 @@ import org.springframework.web.bind.annotation.RestController; @RequestMapping("/buy") @Tag(name = "BuyMapper", description = "购买接口") public class BuyInterface { + @Autowired + private BuyService buyService; + + @PostMapping("/doBuyInterface") + public Result doBuyInterface(@RequestBody Connector connector){ + return buyService.doBuyInterface(connector); + } } diff --git a/src/main/java/com/muyu/system/mapper/BuyMapper.java b/src/main/java/com/muyu/system/mapper/BuyMapper.java index 1035cc5..2ad0812 100644 --- a/src/main/java/com/muyu/system/mapper/BuyMapper.java +++ b/src/main/java/com/muyu/system/mapper/BuyMapper.java @@ -12,4 +12,5 @@ import com.muyu.system.domain.Connector; * 购买接口 */ public interface BuyMapper extends BaseMapper { + Integer doBuyInterface(Connector connector); } diff --git a/src/main/java/com/muyu/system/service/BuyService.java b/src/main/java/com/muyu/system/service/BuyService.java index e4943cb..623aa76 100644 --- a/src/main/java/com/muyu/system/service/BuyService.java +++ b/src/main/java/com/muyu/system/service/BuyService.java @@ -1,6 +1,7 @@ package com.muyu.system.service; import com.baomidou.mybatisplus.extension.service.IService; +import com.muyu.common.core.domain.Result; import com.muyu.system.domain.Connector; /** @@ -12,4 +13,5 @@ import com.muyu.system.domain.Connector; * 购买接口 */ public interface BuyService extends IService { + Result doBuyInterface(Connector connector); } diff --git a/src/main/java/com/muyu/system/service/impl/BuyServiceImpl.java b/src/main/java/com/muyu/system/service/impl/BuyServiceImpl.java index 9a1a8e5..0364938 100644 --- a/src/main/java/com/muyu/system/service/impl/BuyServiceImpl.java +++ b/src/main/java/com/muyu/system/service/impl/BuyServiceImpl.java @@ -1,11 +1,15 @@ package com.muyu.system.service.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.muyu.common.core.domain.Result; import com.muyu.system.domain.Connector; import com.muyu.system.mapper.BuyMapper; import com.muyu.system.service.BuyService; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + /** * @Author:chaiyapeng * @Package:com.muyu.system.service.impl @@ -16,4 +20,14 @@ import org.springframework.stereotype.Service; */ @Service public class BuyServiceImpl extends ServiceImpl implements BuyService { + @Resource + private BuyMapper buyMapper; + @Override + public Result doBuyInterface(Connector connector) { + Integer i = buyMapper.doBuyInterface(connector); + if (i>0){ + return Result.success(i,"购买成功"); + } + return Result.error("购买失败"); + } } diff --git a/src/main/resources/mapper/system/BuyMapper.xml b/src/main/resources/mapper/system/BuyMapper.xml new file mode 100644 index 0000000..1faea4b --- /dev/null +++ b/src/main/resources/mapper/system/BuyMapper.xml @@ -0,0 +1,11 @@ + + + + + + + update connector set connector_frequency=connector_frequency+#{connectorFrequency},connector_residue_degree=connector_residue_degree+#{connectorFrequency} where connector_id=#{connectorId} + +