Commit 6da8849e by 吕明尚

小程序增加奖品列表,转盘游戏返回对象增加奖品列表

parent 0950b7ac
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.R;
import share.system.domain.vo.PrizeVo;
import share.system.service.PrizeService;
import java.util.List;
/**
* 奖品Controller
*
* @author wuwenlong
* @date 2024-11-12
*/
@RestController
@RequestMapping("/prize")
public class PrizeController extends BaseController {
@Autowired
private PrizeService prizeService;
/**
* 查询奖品列表
*/
@GetMapping("/list")
public R<List<PrizeVo>> list(PrizeVo prize) {
List<PrizeVo> list = prizeService.selectPrizeList(prize);
return R.ok(list);
}
}
......@@ -5,10 +5,11 @@ import org.springframework.web.bind.annotation.*;
import share.common.annotation.Log;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.common.core.domain.R;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.WheelGame;
import share.system.domain.vo.WheelGameVo;
import share.system.service.WheelGameService;
import javax.servlet.http.HttpServletResponse;
......@@ -29,11 +30,10 @@ public class WheelGameController extends BaseController {
/**
* 查询转盘游戏列表
*/
@GetMapping("/list")
public TableDataInfo list(WheelGame wheelGame) {
startPage();
List<WheelGame> list = wheelGameService.selectWheelGameList(wheelGame);
return getDataTable(list);
@GetMapping("/query")
public R<List<WheelGameVo>> query(WheelGame wheelGame) {
List<WheelGameVo> list = wheelGameService.query(wheelGame);
return R.ok(list);
}
/**
......
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.Prize;
import share.system.domain.WheelGame;
import java.util.List;
@Data
public class WheelGameVo extends WheelGame {
private List<Prize> prizeList;
}
......@@ -3,6 +3,7 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.Prize;
import share.system.domain.WheelGame;
import share.system.domain.vo.WheelGameVo;
import java.util.List;
......@@ -29,6 +30,8 @@ public interface WheelGameService extends IService<WheelGame> {
*/
public List<WheelGame> selectWheelGameList(WheelGame wheelGame);
public List<WheelGameVo> query(WheelGame wheelGame);
/**
* 新增转盘游戏
*
......
......@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.RandomUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -17,6 +18,7 @@ import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
import share.common.utils.DateUtils;
import share.system.domain.*;
import share.system.domain.vo.WheelGameVo;
import share.system.mapper.WheelGameMapper;
import share.system.service.*;
......@@ -73,6 +75,17 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
return wheelGameMapper.selectWheelGameList(wheelGame);
}
@Override
public List<WheelGameVo> query(WheelGame wheelGame) {
List<WheelGame> wheelGames = wheelGameMapper.selectWheelGameList(wheelGame);
List<WheelGameVo> wheelGameVos = convertDoListToVoList(wheelGames);
List<Prize> list = prizeService.list();
wheelGameVos.stream().forEach(item -> {
item.setPrizeList(list.stream().filter(prize -> prize.getGameId().equals(item.getId())).collect(Collectors.toList()));
});
return wheelGameVos;
}
/**
* 新增转盘游戏
*
......@@ -319,4 +332,16 @@ public class WheelGameServiceImpl extends ServiceImpl<WheelGameMapper, WheelGame
redisUtil.unLock(Constants.LOTTERY_LOCK_KEY + gameId, keyValue, 2);
}
}
public List<WheelGameVo> convertDoListToVoList(List<WheelGame> gameList) {
List<WheelGameVo> voList = new ArrayList<>();
if (CollectionUtils.isNotEmpty(gameList)) {
gameList.stream().forEach(o -> {
WheelGameVo vo = new WheelGameVo();
BeanUtils.copyProperties(o, vo);
voList.add(vo);
});
}
return voList;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment