|
@@ -1,9 +1,13 @@
|
1
|
1
|
package com.ylcm.sys.service.impl;
|
2
|
2
|
|
3
|
3
|
import com.ylcm.sys.domain.AdMedia;
|
|
4
|
+import com.ylcm.sys.domain.AdSpecial;
|
|
5
|
+import com.ylcm.sys.domain.AdTheatre;
|
4
|
6
|
import com.ylcm.sys.excel.model.AdMediaImportDTO;
|
5
|
7
|
import com.ylcm.sys.exception.BaseException;
|
6
|
8
|
import com.ylcm.sys.mapper.AdMediaMapper;
|
|
9
|
+import com.ylcm.sys.mapper.AdSpecialMapper;
|
|
10
|
+import com.ylcm.sys.mapper.AdTheatreMapper;
|
7
|
11
|
import com.ylcm.sys.service.AdMediaService;
|
8
|
12
|
|
9
|
13
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -15,6 +19,8 @@ import org.apache.commons.lang.StringUtils;
|
15
|
19
|
import org.springframework.stereotype.Service;
|
16
|
20
|
import org.springframework.transaction.annotation.Transactional;
|
17
|
21
|
|
|
22
|
+import javax.annotation.Resource;
|
|
23
|
+
|
18
|
24
|
/**
|
19
|
25
|
* <p>
|
20
|
26
|
* 媒体管理表 服务实现类
|
|
@@ -26,6 +32,12 @@ import org.springframework.transaction.annotation.Transactional;
|
26
|
32
|
@Service
|
27
|
33
|
public class AdMediaServiceImpl extends ServiceImpl<AdMediaMapper, AdMedia> implements AdMediaService {
|
28
|
34
|
|
|
35
|
+ @Resource
|
|
36
|
+ private AdSpecialMapper adSpecialMapper;
|
|
37
|
+
|
|
38
|
+ @Resource
|
|
39
|
+ private AdTheatreMapper adTheatreMapper;
|
|
40
|
+
|
29
|
41
|
@Override
|
30
|
42
|
public AdMedia getByName(String name) {
|
31
|
43
|
LambdaQueryWrapper<AdMedia> queryWrapper = new LambdaQueryWrapper<AdMedia>().eq(AdMedia::getName, name);
|
|
@@ -55,4 +67,22 @@ public class AdMediaServiceImpl extends ServiceImpl<AdMediaMapper, AdMedia> impl
|
55
|
67
|
}
|
56
|
68
|
return baseMapper.selectCount(queryWrapper);
|
57
|
69
|
}
|
|
70
|
+
|
|
71
|
+ @Override
|
|
72
|
+ public String deleteById(Integer id) {
|
|
73
|
+ AdMedia adMedia = baseMapper.selectById(id);
|
|
74
|
+
|
|
75
|
+ AdSpecial adSpecial = adSpecialMapper.selectOne(
|
|
76
|
+ new LambdaQueryWrapper<AdSpecial>().eq(AdSpecial::getMediaName, adMedia.getName()).last("limit 1"));
|
|
77
|
+ if (adSpecial == null) {
|
|
78
|
+ return "该媒体在专题中使用不能删除";
|
|
79
|
+ }
|
|
80
|
+ AdTheatre adTheatre = adTheatreMapper.selectOne(
|
|
81
|
+ new LambdaQueryWrapper<AdTheatre>().eq(AdTheatre::getMediaName, adMedia.getName()).last("limit 1"));
|
|
82
|
+ if (adTheatre != null) {
|
|
83
|
+ return "该媒体在剧场中使用不能删除";
|
|
84
|
+ }
|
|
85
|
+ baseMapper.deleteById(id);
|
|
86
|
+ return null;
|
|
87
|
+ }
|
58
|
88
|
}
|