소스 검색

* 新需求

顾绍勇 5 년 전
부모
커밋
e9f892a458

+ 7
- 5
src/main/java/com/huiju/estateagents/sample/controller/TaH5SampleController.java 파일 보기

@@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
27 27
  * @since 2020-03-18
28 28
  */
29 29
 @RestController
30
-@RequestMapping("/")
30
+@RequestMapping("/api")
31 31
 public class TaH5SampleController extends BaseController {
32 32
 
33 33
     private final Logger logger = LoggerFactory.getLogger(TaH5SampleController.class);
@@ -42,15 +42,17 @@ public class TaH5SampleController extends BaseController {
42 42
      * @param pageSize
43 43
      * @return
44 44
      */
45
-    @RequestMapping(value="/taH5Sample",method= RequestMethod.GET)
46
-    public ResponseBean taH5SampleList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
-                                       @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
45
+    @RequestMapping(value="/admin/taH5Sample",method= RequestMethod.GET)
46
+    public ResponseBean ListH5SampleByCondition(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
+                                       @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
48
+                                       String sampleName){
48 49
         ResponseBean responseBean = new ResponseBean();
49 50
         try {
50 51
             //使用分页插件
51 52
 		    IPage<TaH5Sample> pg = new Page<>(pageNum, pageSize);
52 53
             QueryWrapper<TaH5Sample> queryWrapper = new QueryWrapper<>();
53
-            queryWrapper.orderByDesc("create_date");
54
+            queryWrapper.like("sample_name",sampleName);
55
+            queryWrapper.orderByDesc("order_no","create_date");
54 56
 
55 57
             IPage<TaH5Sample> result = iTaH5SampleService.page(pg, queryWrapper);
56 58
             responseBean.addSuccess(result);

+ 53
- 45
src/main/java/com/huiju/estateagents/sample/controller/TaNoticeController.java 파일 보기

@@ -1,5 +1,6 @@
1 1
 package com.huiju.estateagents.sample.controller;
2 2
 
3
+import com.alibaba.fastjson.JSONObject;
3 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 5
 import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -18,16 +19,19 @@ import org.springframework.web.bind.annotation.RequestParam;
18 19
 import org.springframework.web.bind.annotation.ResponseBody;
19 20
 import org.springframework.web.bind.annotation.RestController;
20 21
 
22
+import javax.servlet.http.HttpServletRequest;
23
+import java.util.List;
24
+
21 25
 /**
22 26
  * <p>
23
-    * 开屏通知  前端控制器
24
-    * </p>
27
+ * 开屏通知  前端控制器
28
+ * </p>
25 29
  *
26 30
  * @author fxf
27 31
  * @since 2020-03-18
28 32
  */
29 33
 @RestController
30
-@RequestMapping("/")
34
+@RequestMapping("/api")
31 35
 public class TaNoticeController extends BaseController {
32 36
 
33 37
     private final Logger logger = LoggerFactory.getLogger(TaNoticeController.class);
@@ -37,26 +41,29 @@ public class TaNoticeController extends BaseController {
37 41
 
38 42
 
39 43
     /**
40
-     * 分页查询列表
44
+     * 条件查询通知列表
45
+     *
41 46
      * @param pageNum
42 47
      * @param pageSize
48
+     * @param title
49
+     * @param targetType
50
+     * @param targetName
51
+     * @param status
52
+     * @param type       类型
43 53
      * @return
44 54
      */
45
-    @RequestMapping(value="/taNotice",method= RequestMethod.GET)
46
-    public ResponseBean taNoticeList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
-                                     @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
55
+    @RequestMapping(value = "/admin/listNoticeByCondition", method = RequestMethod.GET)
56
+    public ResponseBean listNoticeByCondition(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
57
+                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
58
+                                              String title, String targetType, String targetName, Integer status,
59
+                                              String type) {
48 60
         ResponseBean responseBean = new ResponseBean();
49 61
         try {
50
-            //使用分页插件
51
-		    IPage<TaNotice> pg = new Page<>(pageNum, pageSize);
52
-            QueryWrapper<TaNotice> queryWrapper = new QueryWrapper<>();
53
-            queryWrapper.orderByDesc("create_date");
54
-
55
-            IPage<TaNotice> result = iTaNoticeService.page(pg, queryWrapper);
56
-            responseBean.addSuccess(result);
57
-        }catch (Exception e){
62
+            responseBean = iTaNoticeService.listNoticeByCondition(pageNum, pageSize, title, targetType, targetName, status, type);
63
+            logger.info("TaNoticeController.listNoticeByCondition 返回结果:" + JSONObject.toJSONString(responseBean));
64
+        } catch (Exception e) {
58 65
             e.printStackTrace();
59
-            logger.error("taNoticeList -=- {}",e.toString());
66
+            logger.error("taNoticeList -=- {}", e.toString());
60 67
             responseBean.addError(e.getMessage());
61 68
         }
62 69
         return responseBean;
@@ -64,43 +71,42 @@ public class TaNoticeController extends BaseController {
64 71
 
65 72
     /**
66 73
      * 保存对象
74
+     *
67 75
      * @param taNotice 实体对象
68 76
      * @return
69 77
      */
70
-    @RequestMapping(value="/taNotice",method= RequestMethod.POST)
71
-    public ResponseBean taNoticeAdd(@RequestBody TaNotice taNotice){
78
+    @RequestMapping(value = "/admin/taNotice", method = RequestMethod.POST)
79
+    public ResponseBean taNoticeAdd(@RequestBody TaNotice taNotice) {
72 80
         ResponseBean responseBean = new ResponseBean();
73 81
         try {
74
-            if (iTaNoticeService.save(taNotice)){
82
+            if (iTaNoticeService.save(taNotice)) {
75 83
                 responseBean.addSuccess(taNotice);
76
-            }else {
84
+            } else {
77 85
                 responseBean.addError("fail");
78 86
             }
79
-        }catch (Exception e){
87
+        } catch (Exception e) {
80 88
             e.printStackTrace();
81
-            logger.error("taNoticeAdd -=- {}",e.toString());
89
+            logger.error("taNoticeAdd -=- {}", e.toString());
82 90
             responseBean.addError(e.getMessage());
83 91
         }
84 92
         return responseBean;
85 93
     }
86 94
 
87 95
     /**
88
-     * 根据id删除对象
89
-     * @param id  实体ID
96
+     * 批量删除开屏通知
97
+     *
98
+     * @param taNoticeList
90 99
      */
91 100
     @ResponseBody
92
-    @RequestMapping(value="/taNotice/{id}", method= RequestMethod.DELETE)
93
-    public ResponseBean taNoticeDelete(@PathVariable Integer id){
101
+    @RequestMapping(value = "/admin/taNotice/batchDelete/{id}", method = RequestMethod.DELETE)
102
+    public ResponseBean batchDelete(List<TaNotice> taNoticeList) {
94 103
         ResponseBean responseBean = new ResponseBean();
95 104
         try {
96
-            if(iTaNoticeService.removeById(id)){
97
-                responseBean.addSuccess("success");
98
-            }else {
99
-                responseBean.addError("fail");
100
-            }
101
-        }catch (Exception e){
105
+            responseBean = iTaNoticeService.batchDelete(taNoticeList);
106
+            logger.info("TaNoticeController.taNoticeDelete 返回结果:" + JSONObject.toJSONString(responseBean));
107
+        } catch (Exception e) {
102 108
             e.printStackTrace();
103
-            logger.error("taNoticeDelete -=- {}",e.toString());
109
+            logger.error("taNoticeDelete -=- {}", e.toString());
104 110
             responseBean.addError(e.getMessage());
105 111
         }
106 112
         return responseBean;
@@ -108,23 +114,24 @@ public class TaNoticeController extends BaseController {
108 114
 
109 115
     /**
110 116
      * 修改对象
111
-     * @param id  实体ID
117
+     *
118
+     * @param id       实体ID
112 119
      * @param taNotice 实体对象
113 120
      * @return
114 121
      */
115
-    @RequestMapping(value="/taNotice/{id}",method= RequestMethod.PUT)
122
+    @RequestMapping(value = "/admin/taNotice/{id}", method = RequestMethod.PUT)
116 123
     public ResponseBean taNoticeUpdate(@PathVariable Integer id,
117
-                                        @RequestBody TaNotice taNotice){
124
+                                       @RequestBody TaNotice taNotice) {
118 125
         ResponseBean responseBean = new ResponseBean();
119 126
         try {
120
-            if (iTaNoticeService.updateById(taNotice)){
127
+            if (iTaNoticeService.updateById(taNotice)) {
121 128
                 responseBean.addSuccess(taNotice);
122
-            }else {
129
+            } else {
123 130
                 responseBean.addError("fail");
124 131
             }
125
-        }catch (Exception e){
132
+        } catch (Exception e) {
126 133
             e.printStackTrace();
127
-            logger.error("taNoticeUpdate -=- {}",e.toString());
134
+            logger.error("taNoticeUpdate -=- {}", e.toString());
128 135
             responseBean.addError(e.getMessage());
129 136
         }
130 137
         return responseBean;
@@ -132,16 +139,17 @@ public class TaNoticeController extends BaseController {
132 139
 
133 140
     /**
134 141
      * 根据id查询对象
135
-     * @param id  实体ID
142
+     *
143
+     * @param id 实体ID
136 144
      */
137
-    @RequestMapping(value="/taNotice/{id}",method= RequestMethod.GET)
138
-    public ResponseBean taNoticeGet(@PathVariable Integer id){
145
+    @RequestMapping(value = "/taNotice/{id}", method = RequestMethod.GET)
146
+    public ResponseBean taNoticeGet(@PathVariable Integer id) {
139 147
         ResponseBean responseBean = new ResponseBean();
140 148
         try {
141 149
             responseBean.addSuccess(iTaNoticeService.getById(id));
142
-        }catch (Exception e){
150
+        } catch (Exception e) {
143 151
             e.printStackTrace();
144
-            logger.error("taNoticeDelete -=- {}",e.toString());
152
+            logger.error("taNoticeDelete -=- {}", e.toString());
145 153
             responseBean.addError(e.getMessage());
146 154
         }
147 155
         return responseBean;

+ 10
- 1
src/main/java/com/huiju/estateagents/sample/entity/TaNotice.java 파일 보기

@@ -1,16 +1,19 @@
1 1
 package com.huiju.estateagents.sample.entity;
2 2
 
3 3
 import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
4 5
 import com.baomidou.mybatisplus.annotation.TableId;
6
+
5 7
 import java.time.LocalDateTime;
6 8
 import java.io.Serializable;
9
+
7 10
 import lombok.Data;
8 11
 import lombok.EqualsAndHashCode;
9 12
 import lombok.experimental.Accessors;
10 13
 
11 14
 /**
12 15
  * <p>
13
- * 开屏通知 
16
+ * 开屏通知
14 17
  * </p>
15 18
  *
16 19
  * @author fxf
@@ -49,6 +52,12 @@ public class TaNotice implements Serializable {
49 52
      */
50 53
     private Integer targetId;
51 54
 
55
+    /**
56
+     * 关联业务名
57
+     */
58
+    @TableField(exist = false)
59
+    private String targetName;
60
+
52 61
     /**
53 62
      * 状态 -1删除0是未发布1是已发布
54 63
      */

+ 21
- 0
src/main/java/com/huiju/estateagents/sample/mapper/TaNoticeMapper.java 파일 보기

@@ -1,8 +1,13 @@
1 1
 package com.huiju.estateagents.sample.mapper;
2 2
 
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
4 5
 import com.huiju.estateagents.sample.entity.TaNotice;
5 6
 import org.apache.ibatis.annotations.Mapper;
7
+import org.apache.ibatis.annotations.Param;
8
+import org.springframework.stereotype.Component;
9
+
10
+import java.util.List;
6 11
 
7 12
 /**
8 13
  * <p>
@@ -13,6 +18,22 @@ import org.apache.ibatis.annotations.Mapper;
13 18
  * @since 2020-03-18
14 19
  */
15 20
 @Mapper
21
+@Component
16 22
 public interface TaNoticeMapper extends BaseMapper<TaNotice> {
17 23
 
24
+    /**
25
+     * 条件查询开屏通知
26
+     *
27
+     * @param pg
28
+     * @param title
29
+     * @param targetType
30
+     * @param targetName
31
+     * @param status
32
+     * @return
33
+     */
34
+    IPage<TaNotice> listNoticeByCondition(IPage<TaNotice> pg, @Param("title") String title,
35
+                                          @Param("targetType") String targetType,
36
+                                          @Param("targetName") String targetName,
37
+                                          @Param("status") Integer status,
38
+                                          @Param("type") String type);
18 39
 }

+ 26
- 0
src/main/java/com/huiju/estateagents/sample/service/ITaNoticeService.java 파일 보기

@@ -1,7 +1,11 @@
1 1
 package com.huiju.estateagents.sample.service;
2 2
 
3 3
 import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.huiju.estateagents.base.ResponseBean;
4 5
 import com.huiju.estateagents.sample.entity.TaNotice;
6
+import org.apache.ibatis.annotations.Param;
7
+
8
+import java.util.List;
5 9
 
6 10
 /**
7 11
  * <p>
@@ -13,4 +17,26 @@ import com.huiju.estateagents.sample.entity.TaNotice;
13 17
  */
14 18
 public interface ITaNoticeService extends IService<TaNotice> {
15 19
 
20
+    /**
21
+     * 条件查询开屏通知列表
22
+     *
23
+     * @param pageNum
24
+     * @param pageSize
25
+     * @param title
26
+     * @param targetType
27
+     * @param targetName
28
+     * @param status
29
+     * @param type
30
+     * @return
31
+     */
32
+    ResponseBean listNoticeByCondition(Integer pageNum, Integer pageSize, String title, String targetType, String targetName,
33
+                                       Integer status, String type);
34
+
35
+    /**
36
+     * 批量删除
37
+     *
38
+     * @param taNoticeList
39
+     * @return
40
+     */
41
+    ResponseBean batchDelete(List<TaNotice> taNoticeList);
16 42
 }

+ 44
- 0
src/main/java/com/huiju/estateagents/sample/service/impl/TaNoticeServiceImpl.java 파일 보기

@@ -1,11 +1,21 @@
1 1
 package com.huiju.estateagents.sample.service.impl;
2 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;
3 6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.huiju.estateagents.base.ResponseBean;
8
+import com.huiju.estateagents.common.CommConstant;
4 9
 import com.huiju.estateagents.sample.entity.TaNotice;
5 10
 import com.huiju.estateagents.sample.mapper.TaNoticeMapper;
6 11
 import com.huiju.estateagents.sample.service.ITaNoticeService;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.springframework.beans.factory.annotation.Autowired;
7 14
 import org.springframework.stereotype.Service;
8 15
 
16
+import java.util.ArrayList;
17
+import java.util.List;
18
+
9 19
 /**
10 20
  * <p>
11 21
  * 开屏通知  服务实现类
@@ -14,7 +24,41 @@ import org.springframework.stereotype.Service;
14 24
  * @author fxf
15 25
  * @since 2020-03-18
16 26
  */
27
+@Slf4j
17 28
 @Service
18 29
 public class TaNoticeServiceImpl extends ServiceImpl<TaNoticeMapper, TaNotice> implements ITaNoticeService {
19 30
 
31
+    @Autowired
32
+    private TaNoticeMapper taNoticeMapper;
33
+
34
+    @Override
35
+    public ResponseBean listNoticeByCondition(Integer pageNum, Integer pageSize, String title, String targetType, String targetName, Integer status, String type) {
36
+        log.info("TaNoticeServiceImpl.listNoticeByCondition 接收参数:pageNum:{},pageSize:{},title:{},targetType:{},targetName:{},status:{},type:{}",
37
+                pageNum, pageSize, title, targetType, targetName, status, type);
38
+
39
+        ResponseBean responseBean = new ResponseBean();
40
+
41
+        //使用分页插件
42
+        IPage<TaNotice> pg = new Page<>(pageNum, pageSize);
43
+        pg = taNoticeMapper.listNoticeByCondition(pg, title, targetType, targetName, status, type);
44
+        responseBean.addSuccess(pg);
45
+        return responseBean;
46
+    }
47
+
48
+    @Override
49
+    public ResponseBean batchDelete(List<TaNotice> taNoticeList) {
50
+        ResponseBean responseBean = new ResponseBean();
51
+
52
+        List<TaNotice> updateList = new ArrayList<>();
53
+        TaNotice newNotice;
54
+        for (TaNotice taNotice : taNoticeList) {
55
+            newNotice = new TaNotice();
56
+            newNotice.setNoticeId(taNotice.getNoticeId());
57
+            newNotice.setStatus(CommConstant.STATUS_DELETE);
58
+            updateList.add(newNotice);
59
+        }
60
+
61
+        responseBean.addSuccess(updateBatchById(updateList));
62
+        return responseBean;
63
+    }
20 64
 }

+ 24
- 0
src/main/resources/mapper/sample/TaNoticeMapper.xml 파일 보기

@@ -2,4 +2,28 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.huiju.estateagents.sample.mapper.TaNoticeMapper">
4 4
 
5
+    <select id="listNoticeByCondition" resultType="com.huiju.estateagents.sample.entity.TaNotice">
6
+        SELECT
7
+            t.*,
8
+            t2.sample_name targetName
9
+        FROM
10
+            ta_notice t
11
+            LEFT JOIN ta_h5_sample t2 ON t.target_id = t2.sample_id
12
+        <where>
13
+            <if test="title != null and title != ''">
14
+                t.title like CONCAT('%',#{title}, '%')
15
+            </if>
16
+            <if test="targetName != null and targetName != ''">
17
+                AND t2.sample_name like CONCAT('%',#{targetName}, '%')
18
+            </if>
19
+            <if test="targetType != null and targetType != ''">
20
+                AND t.target_type = #{targetType}
21
+            </if>
22
+            <if test="status != null">
23
+                AND t.`status` = #{status}
24
+            </if>
25
+        </where>
26
+        ORDER BY
27
+            t.order_no DESC,t.create_date DESC
28
+    </select>
5 29
 </mapper>