|
@@ -0,0 +1,177 @@
|
|
1
|
+package com.huiju.estateagents.controller;
|
|
2
|
+
|
|
3
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
4
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
5
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
6
|
+import com.huiju.estateagents.base.BaseController;
|
|
7
|
+import com.huiju.estateagents.base.ResponseBean;
|
|
8
|
+import com.huiju.estateagents.common.CommConstant;
|
|
9
|
+import com.huiju.estateagents.entity.TaCustomImg;
|
|
10
|
+import com.huiju.estateagents.service.ITaCustomImgService;
|
|
11
|
+import org.apache.commons.codec.language.DaitchMokotoffSoundex;
|
|
12
|
+import org.slf4j.Logger;
|
|
13
|
+import org.slf4j.LoggerFactory;
|
|
14
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
+import org.springframework.web.bind.annotation.*;
|
|
16
|
+
|
|
17
|
+import java.time.LocalDateTime;
|
|
18
|
+
|
|
19
|
+/**
|
|
20
|
+ * <p>
|
|
21
|
+ * 前端控制器
|
|
22
|
+ * </p>
|
|
23
|
+ *
|
|
24
|
+ * @author jobob
|
|
25
|
+ * @since 2019-12-17
|
|
26
|
+ */
|
|
27
|
+@RestController
|
|
28
|
+@RequestMapping("/api")
|
|
29
|
+public class TaCustomImgController extends BaseController {
|
|
30
|
+
|
|
31
|
+ private final Logger logger = LoggerFactory.getLogger(TaCustomImgController.class);
|
|
32
|
+
|
|
33
|
+ @Autowired
|
|
34
|
+ public ITaCustomImgService iTaCustomImgService;
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+ /**
|
|
38
|
+ * 分页查询列表
|
|
39
|
+ * @param pageNum
|
|
40
|
+ * @param pageSize
|
|
41
|
+ * @return
|
|
42
|
+ */
|
|
43
|
+ @RequestMapping(value="/admin/taCustomImg",method= RequestMethod.GET)
|
|
44
|
+ public ResponseBean taCustomImgList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
45
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
|
|
46
|
+ ResponseBean responseBean = new ResponseBean();
|
|
47
|
+ try {
|
|
48
|
+ //使用分页插件
|
|
49
|
+ IPage<TaCustomImg> pg = new Page<>(pageNum, pageSize);
|
|
50
|
+ QueryWrapper<TaCustomImg> queryWrapper = new QueryWrapper<>();
|
|
51
|
+ queryWrapper.orderByDesc("create_time");
|
|
52
|
+
|
|
53
|
+ IPage<TaCustomImg> result = iTaCustomImgService.page(pg, queryWrapper);
|
|
54
|
+ responseBean.addSuccess(result);
|
|
55
|
+ }catch (Exception e){
|
|
56
|
+ e.printStackTrace();
|
|
57
|
+ logger.error("taCustomImgList -=- {}",e.toString());
|
|
58
|
+ responseBean.addError(e.getMessage());
|
|
59
|
+ }
|
|
60
|
+ return responseBean;
|
|
61
|
+ }
|
|
62
|
+
|
|
63
|
+ /**
|
|
64
|
+ * 保存对象
|
|
65
|
+ * @param taCustomImg 实体对象
|
|
66
|
+ * @return
|
|
67
|
+ */
|
|
68
|
+ @RequestMapping(value="/admin/taCustomImg",method= RequestMethod.POST)
|
|
69
|
+ public ResponseBean taCustomImgAdd(@RequestBody TaCustomImg taCustomImg){
|
|
70
|
+ ResponseBean responseBean = new ResponseBean();
|
|
71
|
+ taCustomImg.setImgDesc(CommConstant.BANNER_INDEX.equals(taCustomImg.getImgType()) ? "小程序首页分享配图" : "小程序首页推荐客户入口配图");
|
|
72
|
+ try {
|
|
73
|
+ taCustomImg.setCreateTime(LocalDateTime.now());
|
|
74
|
+ taCustomImg.setUpdateTime(LocalDateTime.now());
|
|
75
|
+ boolean countFlag = iTaCustomImgService.countCustomImg(taCustomImg);
|
|
76
|
+ if (!countFlag){
|
|
77
|
+ responseBean.addError("您已新增首页分享或推荐客户图,请勿重复添加");
|
|
78
|
+ return responseBean;
|
|
79
|
+ }
|
|
80
|
+
|
|
81
|
+ if (iTaCustomImgService.save(taCustomImg)){
|
|
82
|
+ responseBean.addSuccess(taCustomImg);
|
|
83
|
+ }else {
|
|
84
|
+ responseBean.addError("fail");
|
|
85
|
+ }
|
|
86
|
+ }catch (Exception e){
|
|
87
|
+ e.printStackTrace();
|
|
88
|
+ logger.error("taCustomImgAdd -=- {}",e.toString());
|
|
89
|
+ responseBean.addError(e.getMessage());
|
|
90
|
+ }
|
|
91
|
+ return responseBean;
|
|
92
|
+ }
|
|
93
|
+
|
|
94
|
+ /**
|
|
95
|
+ * 根据id删除对象
|
|
96
|
+ * @param id 实体ID
|
|
97
|
+ */
|
|
98
|
+ @ResponseBody
|
|
99
|
+ @RequestMapping(value="/admin/taCustomImg/{id}", method= RequestMethod.DELETE)
|
|
100
|
+ public ResponseBean taCustomImgDelete(@PathVariable Integer id){
|
|
101
|
+ ResponseBean responseBean = new ResponseBean();
|
|
102
|
+ try {
|
|
103
|
+ if(iTaCustomImgService.removeById(id)){
|
|
104
|
+ responseBean.addSuccess("success");
|
|
105
|
+ }else {
|
|
106
|
+ responseBean.addError("fail");
|
|
107
|
+ }
|
|
108
|
+ }catch (Exception e){
|
|
109
|
+ e.printStackTrace();
|
|
110
|
+ logger.error("taCustomImgDelete -=- {}",e.toString());
|
|
111
|
+ responseBean.addError(e.getMessage());
|
|
112
|
+ }
|
|
113
|
+ return responseBean;
|
|
114
|
+ }
|
|
115
|
+
|
|
116
|
+ /**
|
|
117
|
+ * 修改对象
|
|
118
|
+ * @param id 实体ID
|
|
119
|
+ * @param taCustomImg 实体对象
|
|
120
|
+ * @return
|
|
121
|
+ */
|
|
122
|
+ @RequestMapping(value="/admin/taCustomImg/{id}",method= RequestMethod.PUT)
|
|
123
|
+ public ResponseBean taCustomImgUpdate(@PathVariable Integer id,
|
|
124
|
+ @RequestBody TaCustomImg taCustomImg){
|
|
125
|
+ ResponseBean responseBean = new ResponseBean();
|
|
126
|
+ try {
|
|
127
|
+ taCustomImg.setUpdateTime(LocalDateTime.now());
|
|
128
|
+ if (iTaCustomImgService.updateById(taCustomImg)){
|
|
129
|
+ responseBean.addSuccess(taCustomImg);
|
|
130
|
+ }else {
|
|
131
|
+ responseBean.addError("fail");
|
|
132
|
+ }
|
|
133
|
+ }catch (Exception e){
|
|
134
|
+ e.printStackTrace();
|
|
135
|
+ logger.error("taCustomImgUpdate -=- {}",e.toString());
|
|
136
|
+ responseBean.addError(e.getMessage());
|
|
137
|
+ }
|
|
138
|
+ return responseBean;
|
|
139
|
+ }
|
|
140
|
+
|
|
141
|
+ /**
|
|
142
|
+ * 根据id查询对象
|
|
143
|
+ * @param id 实体ID
|
|
144
|
+ */
|
|
145
|
+ @RequestMapping(value="/admin/taCustomImg/{id}",method= RequestMethod.GET)
|
|
146
|
+ public ResponseBean taCustomImgGet(@PathVariable Integer id){
|
|
147
|
+ ResponseBean responseBean = new ResponseBean();
|
|
148
|
+ try {
|
|
149
|
+ responseBean.addSuccess(iTaCustomImgService.getById(id));
|
|
150
|
+ }catch (Exception e){
|
|
151
|
+ e.printStackTrace();
|
|
152
|
+ logger.error("taCustomImgDelete -=- {}",e.toString());
|
|
153
|
+ responseBean.addError(e.getMessage());
|
|
154
|
+ }
|
|
155
|
+ return responseBean;
|
|
156
|
+ }
|
|
157
|
+
|
|
158
|
+ /**
|
|
159
|
+ * 微信接口获取首页分享或推荐客户图
|
|
160
|
+ * @param imgType
|
|
161
|
+ */
|
|
162
|
+ @RequestMapping(value="/wx/taCustomImg",method= RequestMethod.GET)
|
|
163
|
+ public ResponseBean taCustomImgGet(@RequestParam(value ="imgType") String imgType){
|
|
164
|
+ ResponseBean responseBean = new ResponseBean();
|
|
165
|
+ try {
|
|
166
|
+ QueryWrapper<TaCustomImg> queryWrapper = new QueryWrapper<>();
|
|
167
|
+ queryWrapper.eq("img_type", imgType);
|
|
168
|
+ TaCustomImg taCustomImg = iTaCustomImgService.getOne(queryWrapper);
|
|
169
|
+ responseBean.addSuccess(taCustomImg);
|
|
170
|
+ }catch (Exception e){
|
|
171
|
+ e.printStackTrace();
|
|
172
|
+ logger.error(" taCustomImgGet-=- {}",e.toString());
|
|
173
|
+ responseBean.addError(e.getMessage());
|
|
174
|
+ }
|
|
175
|
+ return responseBean;
|
|
176
|
+ }
|
|
177
|
+}
|