From 12c595079a76967023895b701bd918b85adca5e5 Mon Sep 17 00:00:00 2001 From: puhanshu <a9236326> Date: 星期四, 30 十二月 2021 18:06:36 +0800 Subject: [PATCH] 微商业街-12/30代码提交 --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java | 102 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 101 insertions(+), 1 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java index 5e600fd..3c5a6a7 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/McsGameServiceImpl.java @@ -1,10 +1,20 @@ package com.panzhihua.service_community.service.impl; +import static java.util.Objects.isNull; + +import org.springframework.stereotype.Service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.panzhihua.common.model.dtos.community.microCommercialStreet.PageMcsGameDTO; +import com.panzhihua.common.model.dtos.community.microCommercialStreet.SetPopularForGameDTO; +import com.panzhihua.common.model.dtos.community.microCommercialStreet.SetShelfForGameDTO; +import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.microCommercialStreet.McsGameVO; import com.panzhihua.service_community.dao.McsGameDAO; import com.panzhihua.service_community.entity.McsGame; import com.panzhihua.service_community.service.McsGameService; -import org.springframework.stereotype.Service; /** * (McsGame)表服务实现类 @@ -15,4 +25,94 @@ @Service("mcsGameService") public class McsGameServiceImpl extends ServiceImpl<McsGameDAO, McsGame> implements McsGameService { + /** + * 分页查询戳戳游戏 + * @param pageMcsGameDTO + * @return + */ + @Override + public R pageMcsGame(PageMcsGameDTO pageMcsGameDTO) { + Page page = new Page<>(); + page.setSize(pageMcsGameDTO.getPageSize()); + page.setCurrent(pageMcsGameDTO.getPageNum()); + IPage<McsGameVO> mcsGames = this.baseMapper.pageMcsGame(page, pageMcsGameDTO); + return R.ok(mcsGames); + } + + /** + * 设为/取消游戏热门 + * @param setPopularForGameDTO + * @return + */ + @Override + public R setPopularForGame(SetPopularForGameDTO setPopularForGameDTO) { + McsGame mcsGame = this.baseMapper.selectById(setPopularForGameDTO.getGameId()); + if (isNull(mcsGame)) { + return R.fail("修改数据不存在"); + } + Integer type = setPopularForGameDTO.getType(); + if (type.equals(1)) { + //设为热门 + mcsGame.setIsPopular(true); + } else if (type.equals(2)) { + //取消热门 + mcsGame.setIsPopular(false); + } else { + return R.fail("未知错误"); + } + int num = this.baseMapper.updateById(mcsGame); + if (num > 0) { + return R.ok(); + } + return R.fail("修改失败,请重新尝试"); + } + + /** + * 上架/下架戳戳游戏 + * @param setShelfForGameDTO + * @return + */ + @Override + public R setShelfForGame(SetShelfForGameDTO setShelfForGameDTO) { + McsGame mcsGame = this.baseMapper.selectById(setShelfForGameDTO.getGameId()); + if (isNull(mcsGame)) { + return R.fail("修改数据不存在"); + } + Integer type = setShelfForGameDTO.getType(); + if (type.equals(1)) { + //上架 + mcsGame.setStatus(2); + } else if (type.equals(2)) { + //下架 + mcsGame.setStatus(3); + } else { + return R.fail("未知错误"); + } + int num = this.baseMapper.updateById(mcsGame); + if (num > 0) { + return R.ok(); + } + return R.fail("修改失败,请重新尝试"); + } + + /** + * 删除戳戳游戏 + * @param gameId + * @param userId + * @return + */ + @Override + public R deleteMcsGame(Long gameId, Long userId) { + McsGame mcsGame = this.baseMapper.selectById(gameId); + if (isNull(mcsGame)) { + return R.fail("修改数据不存在"); + } + mcsGame.setIsDel(true); + mcsGame.setUpdatedBy(userId); + int num = this.baseMapper.updateById(mcsGame); + if (num > 0) { + return R.ok(); + } + return R.fail("删除失败,请重新尝试"); + } } -- Gitblit v1.7.1