101captain
2022-01-05 7d4d5f6000f09cf7e1b5e94e7873208b00315c61
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
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;
 
/**
 * (McsGame)表服务实现类
 *
 * @author makejava
 * @since 2021-12-28 14:37:09
 */
@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("删除失败,请重新尝试");
    }
}