浏览代码

* 新需求

顾绍勇 5 年前
父节点
当前提交
e9f892a458

+ 7
- 5
src/main/java/com/huiju/estateagents/sample/controller/TaH5SampleController.java 查看文件

27
  * @since 2020-03-18
27
  * @since 2020-03-18
28
  */
28
  */
29
 @RestController
29
 @RestController
30
-@RequestMapping("/")
30
+@RequestMapping("/api")
31
 public class TaH5SampleController extends BaseController {
31
 public class TaH5SampleController extends BaseController {
32
 
32
 
33
     private final Logger logger = LoggerFactory.getLogger(TaH5SampleController.class);
33
     private final Logger logger = LoggerFactory.getLogger(TaH5SampleController.class);
42
      * @param pageSize
42
      * @param pageSize
43
      * @return
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
         ResponseBean responseBean = new ResponseBean();
49
         ResponseBean responseBean = new ResponseBean();
49
         try {
50
         try {
50
             //使用分页插件
51
             //使用分页插件
51
 		    IPage<TaH5Sample> pg = new Page<>(pageNum, pageSize);
52
 		    IPage<TaH5Sample> pg = new Page<>(pageNum, pageSize);
52
             QueryWrapper<TaH5Sample> queryWrapper = new QueryWrapper<>();
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
             IPage<TaH5Sample> result = iTaH5SampleService.page(pg, queryWrapper);
57
             IPage<TaH5Sample> result = iTaH5SampleService.page(pg, queryWrapper);
56
             responseBean.addSuccess(result);
58
             responseBean.addSuccess(result);

+ 53
- 45
src/main/java/com/huiju/estateagents/sample/controller/TaNoticeController.java 查看文件

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

+ 10
- 1
src/main/java/com/huiju/estateagents/sample/entity/TaNotice.java 查看文件

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

+ 21
- 0
src/main/java/com/huiju/estateagents/sample/mapper/TaNoticeMapper.java 查看文件

1
 package com.huiju.estateagents.sample.mapper;
1
 package com.huiju.estateagents.sample.mapper;
2
 
2
 
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
4
 import com.huiju.estateagents.sample.entity.TaNotice;
5
 import com.huiju.estateagents.sample.entity.TaNotice;
5
 import org.apache.ibatis.annotations.Mapper;
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
  * <p>
13
  * <p>
13
  * @since 2020-03-18
18
  * @since 2020-03-18
14
  */
19
  */
15
 @Mapper
20
 @Mapper
21
+@Component
16
 public interface TaNoticeMapper extends BaseMapper<TaNotice> {
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
 package com.huiju.estateagents.sample.service;
1
 package com.huiju.estateagents.sample.service;
2
 
2
 
3
 import com.baomidou.mybatisplus.extension.service.IService;
3
 import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.huiju.estateagents.base.ResponseBean;
4
 import com.huiju.estateagents.sample.entity.TaNotice;
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
  * <p>
11
  * <p>
13
  */
17
  */
14
 public interface ITaNoticeService extends IService<TaNotice> {
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
 package com.huiju.estateagents.sample.service.impl;
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
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
+import com.huiju.estateagents.base.ResponseBean;
8
+import com.huiju.estateagents.common.CommConstant;
4
 import com.huiju.estateagents.sample.entity.TaNotice;
9
 import com.huiju.estateagents.sample.entity.TaNotice;
5
 import com.huiju.estateagents.sample.mapper.TaNoticeMapper;
10
 import com.huiju.estateagents.sample.mapper.TaNoticeMapper;
6
 import com.huiju.estateagents.sample.service.ITaNoticeService;
11
 import com.huiju.estateagents.sample.service.ITaNoticeService;
12
+import lombok.extern.slf4j.Slf4j;
13
+import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.stereotype.Service;
14
 import org.springframework.stereotype.Service;
8
 
15
 
16
+import java.util.ArrayList;
17
+import java.util.List;
18
+
9
 /**
19
 /**
10
  * <p>
20
  * <p>
11
  * 开屏通知  服务实现类
21
  * 开屏通知  服务实现类
14
  * @author fxf
24
  * @author fxf
15
  * @since 2020-03-18
25
  * @since 2020-03-18
16
  */
26
  */
27
+@Slf4j
17
 @Service
28
 @Service
18
 public class TaNoticeServiceImpl extends ServiceImpl<TaNoticeMapper, TaNotice> implements ITaNoticeService {
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
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
 <mapper namespace="com.huiju.estateagents.sample.mapper.TaNoticeMapper">
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
 </mapper>
29
 </mapper>