购买解决框架
parent
0aed87c444
commit
f67fbb6380
|
@ -1,6 +1,12 @@
|
||||||
package com.muyu.system.controller;
|
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 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.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@ -15,4 +21,11 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
@RequestMapping("/buy")
|
@RequestMapping("/buy")
|
||||||
@Tag(name = "BuyMapper", description = "购买接口")
|
@Tag(name = "BuyMapper", description = "购买接口")
|
||||||
public class BuyInterface {
|
public class BuyInterface {
|
||||||
|
@Autowired
|
||||||
|
private BuyService buyService;
|
||||||
|
|
||||||
|
@PostMapping("/doBuyInterface")
|
||||||
|
public Result doBuyInterface(@RequestBody Connector connector){
|
||||||
|
return buyService.doBuyInterface(connector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,4 +12,5 @@ import com.muyu.system.domain.Connector;
|
||||||
* 购买接口
|
* 购买接口
|
||||||
*/
|
*/
|
||||||
public interface BuyMapper extends BaseMapper<Connector> {
|
public interface BuyMapper extends BaseMapper<Connector> {
|
||||||
|
Integer doBuyInterface(Connector connector);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.muyu.system.service;
|
package com.muyu.system.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.system.domain.Connector;
|
import com.muyu.system.domain.Connector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,4 +13,5 @@ import com.muyu.system.domain.Connector;
|
||||||
* 购买接口
|
* 购买接口
|
||||||
*/
|
*/
|
||||||
public interface BuyService extends IService<Connector> {
|
public interface BuyService extends IService<Connector> {
|
||||||
|
Result doBuyInterface(Connector connector);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,15 @@
|
||||||
package com.muyu.system.service.impl;
|
package com.muyu.system.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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.domain.Connector;
|
||||||
import com.muyu.system.mapper.BuyMapper;
|
import com.muyu.system.mapper.BuyMapper;
|
||||||
import com.muyu.system.service.BuyService;
|
import com.muyu.system.service.BuyService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:chaiyapeng
|
* @Author:chaiyapeng
|
||||||
* @Package:com.muyu.system.service.impl
|
* @Package:com.muyu.system.service.impl
|
||||||
|
@ -16,4 +20,14 @@ import org.springframework.stereotype.Service;
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class BuyServiceImpl extends ServiceImpl<BuyMapper, Connector> implements BuyService {
|
public class BuyServiceImpl extends ServiceImpl<BuyMapper, Connector> 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("购买失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
<?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.muyu.system.mapper.BuyMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<update id="doBuyInterface">
|
||||||
|
update connector set connector_frequency=connector_frequency+#{connectorFrequency},connector_residue_degree=connector_residue_degree+#{connectorFrequency} where connector_id=#{connectorId}
|
||||||
|
</update>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue