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} + +