mitao
2025-01-17 afa0dbb4f54e7244835dd67ec33c3e545f122f71
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package com.ruoyi.system.service.impl.config;
 
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.bean.BeanUtils;
import com.ruoyi.system.api.domain.dto.MgtBaseGetDto;
import com.ruoyi.system.domain.dto.MgtPopEditDto;
import com.ruoyi.system.domain.pojo.config.Pop;
import com.ruoyi.system.domain.vo.AppPopVo;
import com.ruoyi.system.domain.vo.MgtPopGetVo;
import com.ruoyi.system.domain.vo.MgtPopPageVo;
import com.ruoyi.system.mapper.config.PopMapper;
import com.ruoyi.system.service.config.PopService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
 
import javax.annotation.Resource;
import java.text.ParseException;
import java.util.Date;
import java.util.List;
 
/**
 * <p>
 * 弹窗 服务实现类
 * </p>
 *
 * @author jqs
 * @since 2023-04-25
 */
@Service
public class PopServiceImpl extends ServiceImpl<PopMapper, Pop> implements PopService {
 
    @Resource
    private PopMapper popMapper;
 
    /**
     * @description  平台分页获取弹窗广告
     * @author  jqs
     * @date    2023/6/7 10:08
     * @param page
     * @return  List<MgtPopPageVo>
     */
    @Override
    public List<MgtPopPageVo> pageMgtPop(Page page){
        return popMapper.pageMgtPop(page);
    }
 
    /**
     * @description 平台修改弹窗广告
     * @author  jqs
     * @date    2023/6/7 10:20
     * @param mgtPopEditDto
     * @return  void
     */
    @Override
    public void editMgtPop(MgtPopEditDto mgtPopEditDto){
        Pop pop;
        // 如果管理弹窗ID不为空,则获取该管理弹窗
        if (mgtPopEditDto.getPopId() != null) {
            pop = this.getById(mgtPopEditDto.getPopId());
        } else {
            // 否则,创建新的管理弹窗
            pop = new Pop();
            pop.setDelFlag(0);
        }
        // 将管理弹窗编辑DTO的属性复制到管理弹窗中
        BeanUtils.copyProperties(mgtPopEditDto, pop);
        // 设置创建时间和创建者ID
        pop.setCreateTime(new Date());
        pop.setCreateUserId(mgtPopEditDto.getPopId());
        try {
            pop.setShowStartTime(DateUtils.parseDate(mgtPopEditDto.getShowStartTime(),"yyyy-MM-dd"));
            pop.setShowEndTime(DateUtils.parseDate(mgtPopEditDto.getShowEndTime(),"yyyy-MM-dd"));
        } catch (ParseException e) {
            throw new RuntimeException(e);
        }
        // 保存或更新管理弹窗
        this.saveOrUpdate(pop);
    }
 
    /**
     * @description  平台获取弹窗编辑信息
     * @author  jqs
     * @date    2023/6/7 10:30
     * @param popId
     * @return  MgtPopGetVo
     */
    @Override
    public MgtPopGetVo getMgtPop(Long popId){
        Pop pop = this.getById(popId);
        if(pop.getTargetType()==1){
            pop.setJumpType(null);
            pop.setJumpId(null);
            pop.setLinkType(null);
        }else if(pop.getTargetType()==2){
            if(pop.getLinkType()==1){
                pop.setJumpType(null);
                pop.setJumpId(null);
            }else{
                pop.setLinkUrl(null);
            }
        }else if(pop.getTargetType()==3){
            pop.setLinkUrl(null);
            pop.setLinkType(null);
            pop.setJumpType(null);
            pop.setJumpId(null);
        }
        MgtPopGetVo mgtPopGetVo = new MgtPopGetVo();
        BeanUtils.copyProperties(pop, mgtPopGetVo);
        return mgtPopGetVo;
    }
 
    /**
     * @description  平台删除弹窗
     * @author  jqs
     * @date    2023/6/7 10:35
     * @param mgtBaseGetDto
     * @return  void
     */
    @Override
    public void deleteMgtPop(MgtBaseGetDto mgtBaseGetDto){
        Pop pop = this.getById(Long.valueOf(mgtBaseGetDto.getId()));
        pop.setDelFlag(1);
        this.saveOrUpdate(pop);
    }
 
    /**
     * @description  获取首页弹窗
     * @author  jqs
     * @date    2023/7/20 17:19
     * @param
     * @return  AppPopVo
     */
    @Override
    public AppPopVo getAppPop(){
        return popMapper.getAppPop();
    }
}