|
@@ -1,137 +0,0 @@
|
|
|
-package com.zanxiang.game.module.manage.service.impl;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.zanxiang.game.module.base.pojo.enums.GameCategoryEnum;
|
|
|
-import com.zanxiang.game.module.manage.pojo.dto.GameCategoryDTO;
|
|
|
-import com.zanxiang.game.module.manage.pojo.dto.GameDTO;
|
|
|
-import com.zanxiang.game.module.manage.pojo.params.GamePictureParam;
|
|
|
-import com.zanxiang.game.module.manage.pojo.vo.GamePictureVO;
|
|
|
-import com.zanxiang.game.module.manage.service.IGameCategoryService;
|
|
|
-import com.zanxiang.game.module.manage.service.IGamePictureService;
|
|
|
-import com.zanxiang.game.module.manage.service.IGameService;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.Game;
|
|
|
-import com.zanxiang.game.module.mybatis.entity.GamePicture;
|
|
|
-import com.zanxiang.game.module.mybatis.mapper.GamePictureMapper;
|
|
|
-import com.zanxiang.module.util.bean.BeanUtil;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
-
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.Objects;
|
|
|
-
|
|
|
-/**
|
|
|
- * @author : lingfeng
|
|
|
- * @time : 2022-07-12
|
|
|
- * @description : 游戏图片
|
|
|
- */
|
|
|
-@Slf4j
|
|
|
-@Service
|
|
|
-public class GamePictureServiceImpl extends ServiceImpl<GamePictureMapper, GamePicture> implements IGamePictureService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IGameService gameService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private IGameCategoryService gameCategoryService;
|
|
|
-
|
|
|
- @Override
|
|
|
- public GamePictureVO getByGameId(Long gameId) {
|
|
|
- GamePicture gamePicture = super.getOne(new LambdaQueryWrapper<GamePicture>().eq(GamePicture::getGameId, gameId));
|
|
|
- if (gamePicture == null) {
|
|
|
- gamePicture = GamePicture.builder().gameId(gameId).build();
|
|
|
- }
|
|
|
- GamePictureVO gamePictureVO = BeanUtil.copy(gamePicture, GamePictureVO.class);
|
|
|
- GameDTO gameDTO = gameService.getById(gameId);
|
|
|
- gamePictureVO.setNeedAuth(gameDTO.getNeedAuth());
|
|
|
- gamePictureVO.setDownloadCount(gameDTO.getDownloadCount());
|
|
|
- return gamePictureVO;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Boolean addOrUpdate(GamePictureParam param) {
|
|
|
- GameDTO gameDTO = gameService.getById(param.getGameId());
|
|
|
- GameCategoryDTO gameCategoryDTO = gameCategoryService.getById(gameDTO.getCategory());
|
|
|
- //微信小游戏更新
|
|
|
- if (Objects.equals(gameCategoryDTO.getKey(), GameCategoryEnum.CATEGORY_WX_APPLET.getKey())) {
|
|
|
- return this.appletGameAddOrUpdate(param);
|
|
|
- }
|
|
|
- //h5游戏更新
|
|
|
- if (Objects.equals(gameCategoryDTO.getKey(), GameCategoryEnum.CATEGORY_DY_APPLET.getKey())) {
|
|
|
- return this.h5GameAddOrUpdate(param);
|
|
|
- }
|
|
|
- return Boolean.FALSE;
|
|
|
- }
|
|
|
-
|
|
|
- @Transactional(rollbackFor = {RuntimeException.class, Exception.class})
|
|
|
- public Boolean h5GameAddOrUpdate(GamePictureParam param) {
|
|
|
- Long gameId = param.getGameId();
|
|
|
- GamePicture gamePicture = super.getOne(new LambdaQueryWrapper<GamePicture>().eq(GamePicture::getGameId, gameId));
|
|
|
- if (gamePicture == null) {
|
|
|
- gamePicture = GamePicture.builder()
|
|
|
- .gameId(gameId)
|
|
|
- .avatarImg(param.getAvatarImg())
|
|
|
-// .gamePictureImg(param.getGamePictureImg())
|
|
|
-// .loginBackGroundImg(param.getLoginBackGroundImg())
|
|
|
- .createTime(LocalDateTime.now())
|
|
|
- .updateTime(LocalDateTime.now())
|
|
|
- .build();
|
|
|
- } else {
|
|
|
- gamePicture.setAvatarImg(param.getAvatarImg());
|
|
|
-// gamePicture.setGamePictureImg(param.getGamePictureImg());
|
|
|
-// gamePicture.setLoginBackGroundImg(param.getLoginBackGroundImg());
|
|
|
- gamePicture.setUpdateTime(LocalDateTime.now());
|
|
|
- }
|
|
|
- //游戏图片信息更新
|
|
|
- super.saveOrUpdate(gamePicture);
|
|
|
- //游戏信息更新
|
|
|
- if (param.getNeedAuth() != null || param.getDownloadCount() != null) {
|
|
|
- gameService.update(new LambdaUpdateWrapper<Game>()
|
|
|
- .set(Game::getUpdateTime, LocalDateTime.now())
|
|
|
- .eq(Game::getId, gameId));
|
|
|
- }
|
|
|
- return Boolean.TRUE;
|
|
|
- }
|
|
|
-
|
|
|
- private Boolean appletGameAddOrUpdate(GamePictureParam param) {
|
|
|
- Long gameId = param.getGameId();
|
|
|
- GamePicture gamePicture = super.getOne(new LambdaQueryWrapper<GamePicture>().eq(GamePicture::getGameId, gameId));
|
|
|
- if (gamePicture == null) {
|
|
|
- gamePicture = GamePicture.builder()
|
|
|
- .gameId(gameId)
|
|
|
- .avatarImg(param.getAvatarImg())
|
|
|
- .appletImg(param.getAppletImg())
|
|
|
-// .cardTitle(param.getCardTitle())
|
|
|
-// .cardUrl(param.getCardUrl())
|
|
|
-// .cardImg(param.getCardImg())
|
|
|
-// .isOpenInlet(param.getIsOpenInlet())
|
|
|
-// .inletImg(param.getInletImg())
|
|
|
-// .findImg(param.getFindImg())
|
|
|
-// .recommendImg(param.getRecommendImg())
|
|
|
-// .tryPayImg(param.getTryPayImg())
|
|
|
-// .shareImgName(param.getShareImgName())
|
|
|
-// .shareImg(param.getShareImg())
|
|
|
- .createTime(LocalDateTime.now())
|
|
|
- .updateTime(LocalDateTime.now())
|
|
|
- .build();
|
|
|
- } else {
|
|
|
- gamePicture.setAvatarImg(param.getAvatarImg());
|
|
|
- gamePicture.setAppletImg(param.getAppletImg());
|
|
|
-// gamePicture.setCardTitle(param.getCardTitle());
|
|
|
-// gamePicture.setCardUrl(param.getCardUrl());
|
|
|
-// gamePicture.setCardImg(param.getCardImg());
|
|
|
-// gamePicture.setIsOpenInlet(param.getIsOpenInlet());
|
|
|
-// gamePicture.setInletImg(param.getInletImg());
|
|
|
-// gamePicture.setFindImg(param.getFindImg());
|
|
|
-// gamePicture.setRecommendImg(param.getRecommendImg());
|
|
|
-// gamePicture.setTryPayImg(param.getTryPayImg());
|
|
|
-// gamePicture.setShareImgName(param.getShareImgName());
|
|
|
- gamePicture.setShareImg(param.getShareImg());
|
|
|
- gamePicture.setUpdateTime(LocalDateTime.now());
|
|
|
- }
|
|
|
- return super.saveOrUpdate(gamePicture);
|
|
|
- }
|
|
|
-}
|