| | |
| | | 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)表服务实现类 |
| | |
| | | @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("删除失败,请重新尝试"); |
| | | } |
| | | } |