master
parent
402616bd4f
commit
96b82f0d3f
|
@ -2,6 +2,7 @@ package com.muyu.system.controller;
|
||||||
|
|
||||||
import com.muyu.common.core.domain.Result;
|
import com.muyu.common.core.domain.Result;
|
||||||
import com.muyu.system.domain.Connector;
|
import com.muyu.system.domain.Connector;
|
||||||
|
import com.muyu.system.domain.ConnectorUser;
|
||||||
import com.muyu.system.service.BuyService;
|
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.beans.factory.annotation.Autowired;
|
||||||
|
@ -24,8 +25,13 @@ public class BuyInterface {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BuyService buyService;
|
private BuyService buyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 购买API接口
|
||||||
|
* @param connectorUser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@PostMapping("/doBuyInterface")
|
@PostMapping("/doBuyInterface")
|
||||||
public Result doBuyInterface(@RequestBody Connector connector){
|
public Result doBuyInterface(@RequestBody ConnectorUser connectorUser){
|
||||||
return buyService.doBuyInterface(connector);
|
return buyService.doBuyInterface(connectorUser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,42 @@
|
||||||
|
package com.muyu.system.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:chaiyapeng
|
||||||
|
* @Package:com.muyu.system.domain
|
||||||
|
* @Project:cloud-system
|
||||||
|
* @name:ConnectorUser
|
||||||
|
* @Date:2024/9/2 10:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ConnectorUser {
|
||||||
|
/**
|
||||||
|
* id
|
||||||
|
*/
|
||||||
|
private Integer connectorUserId;
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Integer userId;
|
||||||
|
/**
|
||||||
|
* 接口id
|
||||||
|
*/
|
||||||
|
private Integer connectorId;
|
||||||
|
/**
|
||||||
|
* 剩余次数
|
||||||
|
*/
|
||||||
|
private Integer connectorResidueDegree;
|
||||||
|
/**
|
||||||
|
* 购买次数
|
||||||
|
*/
|
||||||
|
private Integer connectorFrequency;
|
||||||
|
/**
|
||||||
|
* 接口名称
|
||||||
|
*/
|
||||||
|
private String connectorName;
|
||||||
|
/**
|
||||||
|
* 用户名称
|
||||||
|
*/
|
||||||
|
private String userName;
|
||||||
|
}
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.system.domain.Connector;
|
import com.muyu.system.domain.Connector;
|
||||||
|
import com.muyu.system.domain.ConnectorUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:chaiyapeng
|
* @Author:chaiyapeng
|
||||||
|
@ -12,5 +13,5 @@ import com.muyu.system.domain.Connector;
|
||||||
* 购买接口
|
* 购买接口
|
||||||
*/
|
*/
|
||||||
public interface BuyMapper extends BaseMapper<Connector> {
|
public interface BuyMapper extends BaseMapper<Connector> {
|
||||||
Integer doBuyInterface(Connector connector);
|
Integer doBuyInterface(ConnectorUser connectorUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.common.core.domain.Result;
|
||||||
import com.muyu.system.domain.Connector;
|
import com.muyu.system.domain.Connector;
|
||||||
|
import com.muyu.system.domain.ConnectorUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:chaiyapeng
|
* @Author:chaiyapeng
|
||||||
|
@ -13,5 +14,5 @@ import com.muyu.system.domain.Connector;
|
||||||
* 购买接口
|
* 购买接口
|
||||||
*/
|
*/
|
||||||
public interface BuyService extends IService<Connector> {
|
public interface BuyService extends IService<Connector> {
|
||||||
Result doBuyInterface(Connector connector);
|
Result doBuyInterface(ConnectorUser connectorUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ 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.common.core.domain.Result;
|
||||||
import com.muyu.system.domain.Connector;
|
import com.muyu.system.domain.Connector;
|
||||||
|
import com.muyu.system.domain.ConnectorUser;
|
||||||
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.beans.factory.annotation.Autowired;
|
||||||
|
@ -23,8 +24,9 @@ public class BuyServiceImpl extends ServiceImpl<BuyMapper, Connector> implements
|
||||||
@Resource
|
@Resource
|
||||||
private BuyMapper buyMapper;
|
private BuyMapper buyMapper;
|
||||||
@Override
|
@Override
|
||||||
public Result doBuyInterface(Connector connector) {
|
public Result doBuyInterface(ConnectorUser connectorUserr) {
|
||||||
Integer i = buyMapper.doBuyInterface(connector);
|
|
||||||
|
Integer i = buyMapper.doBuyInterface(connectorUserr);
|
||||||
if (i>0){
|
if (i>0){
|
||||||
return Result.success(i,"购买成功");
|
return Result.success(i,"购买成功");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,6 @@
|
||||||
|
|
||||||
|
|
||||||
<update id="doBuyInterface">
|
<update id="doBuyInterface">
|
||||||
update connector set connector_residue_degree=connector_residue_degree+#{connectorFrequency},connector_frequency=connector_frequency+#{connectorFrequency} where connector_id=#{connectorId}
|
update connector_user set connector_residue_degree=connector_residue_degree+#{connectorFrequency},connector_frequency=connector_frequency+#{connectorFrequency} where connector_user_id=#{connector_user_id}
|
||||||
</update>
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue