You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

103 lines
3.3 KiB

package com.example.demo.controller.bean;
import com.example.demo.domain.vo.bean.BeanRecharge;
import com.example.demo.domain.vo.bean.BeanRechargeInfo;
import com.example.demo.domain.vo.bean.GoldBean;
import com.example.demo.domain.vo.coin.Page;
import com.example.demo.domain.vo.coin.Result;
import com.example.demo.service.bean.BeanRechargeService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
/**
* @program: gold-java
* @ClassName BeanRechrageController
* @description:
* @author: Double
* @create: 2025−07-29 16:46
* @Version 1.0
**/
@RestController
@RequestMapping("/beanRecharge")
@RequiredArgsConstructor
@Slf4j
@CrossOrigin
public class BeanRechargeController {
@Autowired
private BeanRechargeService beanRechargeService;
//添加金豆
@PostMapping("/add")
public Result add(@RequestBody BeanRecharge recharge) {
try {
return beanRechargeService.add(recharge);
} catch (Exception e) {
return Result.error("添加失败");
}
}
//系统充值
@PostMapping("/selectBySystem")
public Result selectBySystem(@RequestBody Page page) {
try {
if (ObjectUtils.isEmpty(page.getPageNum())) {
return Result.error("页码数为空!");
}
if (ObjectUtils.isEmpty(page.getPageSize())) {
return Result.error("页大小为空!");
} else {
return Result.success(beanRechargeService.selectBySystem(page.getPageNum(), page.getPageSize(), page.getBeanRechargeInfo()));
}
} catch (Exception e) {
e.printStackTrace();
return Result.error("请检查筛选数据的格式");
}
}
//系统金豆统计
@PostMapping("/statsSystemBean")
public Result statsSystemBean(@RequestBody BeanRechargeInfo beanRechargeInfo) {
try {
GoldBean goldBean = beanRechargeService.statsSystemBean(beanRechargeInfo);
return Result.success(goldBean);
} catch (Exception e) {
return Result.error("请检查数据的格式");
}
}
//线上充值
@PostMapping("/selectByOnline")
public Result selectByOnline(@RequestBody Page page) {
try {
if (ObjectUtils.isEmpty(page.getPageNum())) {
return Result.error("页码数为空!");
}
if (ObjectUtils.isEmpty(page.getPageSize())) {
return Result.error("页大小为空!");
} else {
return Result.success(beanRechargeService.selectByOnline(page.getPageNum(), page.getPageSize(), page.getBeanRechargeInfo()));
}
} catch (Exception e) {
e.printStackTrace();
return Result.error("请检查筛选数据的格式");
}
}
//线上金豆统计
@PostMapping("/statsOnlineBean")
public Result statsOnlineBean(@RequestBody BeanRechargeInfo beanRechargeInfo) {
try {
GoldBean goldBean = beanRechargeService.statsOnlineBean(beanRechargeInfo);
return Result.success(goldBean);
} catch (Exception e) {
return Result.error("请检查数据的格式");
}
}
}