|
@@ -1,17 +1,26 @@
|
1
|
1
|
package com.huiju.estateagents.service.impl;
|
2
|
2
|
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
3
|
4
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
5
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
4
|
6
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
7
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
8
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
9
|
+import com.huiju.estateagents.base.ResponseBean;
|
7
|
10
|
import com.huiju.estateagents.common.CommConstant;
|
|
11
|
+import com.huiju.estateagents.common.StringUtils;
|
|
12
|
+import com.huiju.estateagents.entity.TaMiniappOrgIcon;
|
8
|
13
|
import com.huiju.estateagents.entity.TaMiniappTheme;
|
9
|
14
|
import com.huiju.estateagents.mapper.TaMiniappIconMapper;
|
|
15
|
+import com.huiju.estateagents.mapper.TaMiniappOrgIconMapper;
|
10
|
16
|
import com.huiju.estateagents.mapper.TaMiniappThemeMapper;
|
11
|
17
|
import com.huiju.estateagents.service.ITaMiniappThemeService;
|
12
|
18
|
import org.springframework.beans.factory.annotation.Autowired;
|
13
|
19
|
import org.springframework.stereotype.Service;
|
14
|
20
|
|
|
21
|
+import java.time.LocalDateTime;
|
|
22
|
+import java.util.List;
|
|
23
|
+
|
15
|
24
|
|
16
|
25
|
@Service
|
17
|
26
|
public class TaMiniappThemeServiceImpl extends ServiceImpl<TaMiniappThemeMapper, TaMiniappTheme> implements ITaMiniappThemeService {
|
|
@@ -21,6 +30,9 @@ public class TaMiniappThemeServiceImpl extends ServiceImpl<TaMiniappThemeMapper,
|
21
|
30
|
@Autowired
|
22
|
31
|
TaMiniappIconMapper taMiniappIconMapper;
|
23
|
32
|
|
|
33
|
+ @Autowired
|
|
34
|
+ TaMiniappOrgIconMapper taMiniappOrgIconMapper;
|
|
35
|
+
|
24
|
36
|
@Override
|
25
|
37
|
public IPage<TaMiniappTheme> getThemeList(Integer orgId, Boolean includeNotUsed, Integer pageNum, Integer pageSize) {
|
26
|
38
|
QueryWrapper<TaMiniappTheme> queryTheme = new QueryWrapper<>();
|
|
@@ -41,4 +53,129 @@ public class TaMiniappThemeServiceImpl extends ServiceImpl<TaMiniappThemeMapper,
|
41
|
53
|
|
42
|
54
|
return result;
|
43
|
55
|
}
|
|
56
|
+
|
|
57
|
+ @Override
|
|
58
|
+ public ResponseBean editTheme(TaMiniappTheme taMiniappTheme) {
|
|
59
|
+ if (taMiniappTheme == null) {
|
|
60
|
+ return ResponseBean.error("没有需要保存的内容", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ if (StringUtils.isEmpty(taMiniappTheme.getThemeTitle())) {
|
|
64
|
+ return ResponseBean.error("主题名称不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
65
|
+ }
|
|
66
|
+
|
|
67
|
+ if (StringUtils.isEmpty(taMiniappTheme.getNaviFrontColor()) || StringUtils.isEmpty(taMiniappTheme.getNaviBackColor())) {
|
|
68
|
+ return ResponseBean.error("导航栏前景或者背景色不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
69
|
+ }
|
|
70
|
+
|
|
71
|
+ if (StringUtils.isEmpty(taMiniappTheme.getTabbarFrontColor()) || StringUtils.isEmpty(taMiniappTheme.getTabbarBackColor())) {
|
|
72
|
+ return ResponseBean.error("TabBar前景或者背景色不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ if (StringUtils.isEmpty(taMiniappTheme.getTabbarSelectColor())) {
|
|
76
|
+ return ResponseBean.error("TabBar选择色不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
77
|
+ }
|
|
78
|
+
|
|
79
|
+ if (taMiniappTheme.getStatus() == null) {
|
|
80
|
+ taMiniappTheme.setStatus(CommConstant.STATUS_NORMAL);
|
|
81
|
+ }
|
|
82
|
+
|
|
83
|
+ Integer themeId = taMiniappTheme.getThemeId();
|
|
84
|
+ if (themeId != null && themeId > 0) {
|
|
85
|
+ // 先删除所有图标
|
|
86
|
+ QueryWrapper<TaMiniappOrgIcon> wrapper = new QueryWrapper<>();
|
|
87
|
+ wrapper.eq("org_id", taMiniappTheme.getOrgId());
|
|
88
|
+ wrapper.eq("theme_id", themeId);
|
|
89
|
+
|
|
90
|
+ taMiniappOrgIconMapper.delete(wrapper);
|
|
91
|
+ }
|
|
92
|
+
|
|
93
|
+ // 先主表
|
|
94
|
+ if (themeId != null && themeId > 0) {
|
|
95
|
+ if (!this.updateById(taMiniappTheme)) {
|
|
96
|
+ return ResponseBean.error("更新主题内容失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
97
|
+ }
|
|
98
|
+ } else {
|
|
99
|
+ if (!this.save(taMiniappTheme)) {
|
|
100
|
+ return ResponseBean.error("保存主题内容失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
101
|
+ }
|
|
102
|
+ }
|
|
103
|
+
|
|
104
|
+ // 再子表
|
|
105
|
+ List<TaMiniappOrgIcon> iconList = taMiniappTheme.getIconList();
|
|
106
|
+ Integer orgId = taMiniappTheme.getOrgId();
|
|
107
|
+ if (iconList != null) {
|
|
108
|
+ Integer size = iconList.size();
|
|
109
|
+ LocalDateTime now = LocalDateTime.now();
|
|
110
|
+ Integer successd = 0;
|
|
111
|
+
|
|
112
|
+ for (int i = size - 1; i >= 0; i --) {
|
|
113
|
+ TaMiniappOrgIcon icon = iconList.get(i);
|
|
114
|
+ icon.setOrgId(orgId);
|
|
115
|
+ icon.setThemeId(themeId);
|
|
116
|
+ icon.setStatus(CommConstant.STATUS_NORMAL);
|
|
117
|
+ icon.setSort(i + 1);
|
|
118
|
+ icon.setCreateDate(now);
|
|
119
|
+ icon.setUpdateDate(now);
|
|
120
|
+ successd += taMiniappOrgIconMapper.insert(icon);
|
|
121
|
+ }
|
|
122
|
+
|
|
123
|
+ if (!size.equals(successd)) {
|
|
124
|
+ return ResponseBean.error("保存主题图标内容失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
125
|
+ }
|
|
126
|
+ }
|
|
127
|
+
|
|
128
|
+ return ResponseBean.success(taMiniappTheme);
|
|
129
|
+ }
|
|
130
|
+
|
|
131
|
+ @Override
|
|
132
|
+ public ResponseBean deleteTheme(TaMiniappTheme taMiniappTheme) {
|
|
133
|
+ LocalDateTime now = LocalDateTime.now();
|
|
134
|
+
|
|
135
|
+ // 先处理子表
|
|
136
|
+ TaMiniappOrgIcon icon = new TaMiniappOrgIcon();
|
|
137
|
+ icon.setStatus(CommConstant.STATUS_DELETE);
|
|
138
|
+ icon.setUpdateDate(now);
|
|
139
|
+ icon.setOrgId(taMiniappTheme.getOrgId());
|
|
140
|
+ icon.setThemeId(taMiniappTheme.getThemeId());
|
|
141
|
+
|
|
142
|
+ UpdateWrapper<TaMiniappOrgIcon> wrapper = new UpdateWrapper<>();
|
|
143
|
+ wrapper.set("status", CommConstant.STATUS_DELETE);
|
|
144
|
+ wrapper.set("update_date", LocalDateTime.now());
|
|
145
|
+ wrapper.eq("org_id", taMiniappTheme.getOrgId());
|
|
146
|
+ wrapper.eq("theme_id", taMiniappTheme.getThemeId());
|
|
147
|
+
|
|
148
|
+ taMiniappOrgIconMapper.update(icon, wrapper);
|
|
149
|
+
|
|
150
|
+ // 再处理主表
|
|
151
|
+ taMiniappTheme.setStatus(CommConstant.STATUS_DELETE);
|
|
152
|
+ taMiniappTheme.setModifyDate(now);
|
|
153
|
+// taMiniappTheme.setModifyUser();
|
|
154
|
+
|
|
155
|
+ if (this.updateById(taMiniappTheme)) {
|
|
156
|
+ return ResponseBean.success("");
|
|
157
|
+ } else {
|
|
158
|
+ return ResponseBean.error("删除主题内容失败", ResponseBean.ERROR_UNAVAILABLE);
|
|
159
|
+ }
|
|
160
|
+ }
|
|
161
|
+
|
|
162
|
+ @Override
|
|
163
|
+ public TaMiniappTheme getProfileById(Integer id) {
|
|
164
|
+ if (id == null || id < 1) return null;
|
|
165
|
+
|
|
166
|
+ TaMiniappTheme taMiniappTheme = this.getById(id);
|
|
167
|
+ if (taMiniappTheme.getStatus().equals(CommConstant.STATUS_DELETE)) {
|
|
168
|
+ return null;
|
|
169
|
+ }
|
|
170
|
+
|
|
171
|
+ QueryWrapper<TaMiniappOrgIcon> queryWrapper = new QueryWrapper<>();
|
|
172
|
+ queryWrapper.eq("org_id", taMiniappTheme.getOrgId());
|
|
173
|
+ queryWrapper.eq("theme_id", taMiniappTheme.getThemeId());
|
|
174
|
+ queryWrapper.eq("status", CommConstant.STATUS_NORMAL);
|
|
175
|
+ queryWrapper.orderByDesc("sort");
|
|
176
|
+
|
|
177
|
+ taMiniappTheme.setIconList(taMiniappOrgIconMapper.selectList(queryWrapper));
|
|
178
|
+
|
|
179
|
+ return taMiniappTheme;
|
|
180
|
+ }
|
44
|
181
|
}
|