52 lines
1.8 KiB
Java
52 lines
1.8 KiB
Java
package com.muyu.system.service.impl;
|
||
|
||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||
import com.muyu.common.core.domain.Result;
|
||
import com.muyu.common.security.utils.SecurityUtils;
|
||
import com.muyu.common.system.domain.LoginUser;
|
||
import com.muyu.system.domain.Connector;
|
||
import com.muyu.system.domain.ConnectorUser;
|
||
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
|
||
* @Project:cloud-system
|
||
* @name:BuyServiceImpl
|
||
* @Date:2024/9/1 14:40
|
||
* 购买接口
|
||
*/
|
||
@Service
|
||
public class BuyServiceImpl extends ServiceImpl<BuyMapper, Connector> implements BuyService {
|
||
@Resource
|
||
private BuyMapper buyMapper;
|
||
@Override
|
||
public Result doBuyInterface(ConnectorUser connectorUser) {
|
||
// //获取当前用户名
|
||
// String username = SecurityUtils.getUsername();
|
||
//获取当前用户ID
|
||
Long userId = SecurityUtils.getUserId();
|
||
// //获取当前的用户信息
|
||
// LoginUser loginUser = SecurityUtils.getLoginUser();
|
||
connectorUser.setUserId(userId);
|
||
Integer i = buyMapper.doBuyInterface(connectorUser);
|
||
if (i>0){
|
||
return Result.success(i,"购买成功");
|
||
}
|
||
ConnectorUser connectorUser1 = buyMapper.selectConnectorUser(connectorUser);
|
||
if (connectorUser1==null){
|
||
Integer i1 = buyMapper.addConnectorUser(connectorUser);
|
||
if (i1>0){
|
||
buyMapper.doBuyInterface(connectorUser);
|
||
return Result.success(i,"购买成功");
|
||
}
|
||
}
|
||
return Result.error("购买失败");
|
||
}
|
||
}
|