Ver código fonte

Merge branch 'master' of http://git.ycjcjy.com/zhiyuxing/estateagents

傅行帆 5 anos atrás
pai
commit
b0b1931000
35 arquivos alterados com 1665 adições e 137 exclusões
  1. 36
    0
      pom.xml
  2. 137
    0
      src/main/java/com/huiju/estateagents/common/BeanTools.java
  3. 20
    2
      src/main/java/com/huiju/estateagents/common/CommConstant.java
  4. 72
    0
      src/main/java/com/huiju/estateagents/common/StringConverter.java
  5. 149
    0
      src/main/java/com/huiju/estateagents/controller/ExtendContentController.java
  6. 19
    0
      src/main/java/com/huiju/estateagents/controller/IndexController.java
  7. 25
    4
      src/main/java/com/huiju/estateagents/controller/TaBuildingDynamicController.java
  8. 44
    58
      src/main/java/com/huiju/estateagents/controller/TaNewsController.java
  9. 10
    59
      src/main/java/com/huiju/estateagents/controller/TaNewsTypeController.java
  10. 55
    0
      src/main/java/com/huiju/estateagents/controller/TaSaveController.java
  11. 90
    0
      src/main/java/com/huiju/estateagents/entity/ExtendContent.java
  12. 59
    0
      src/main/java/com/huiju/estateagents/entity/TaActivityDynamicEnlist.java
  13. 39
    0
      src/main/java/com/huiju/estateagents/entity/TaBuildingDynamic.java
  14. 9
    1
      src/main/java/com/huiju/estateagents/entity/TaNews.java
  15. 76
    0
      src/main/java/com/huiju/estateagents/entity/TaSave.java
  16. 17
    0
      src/main/java/com/huiju/estateagents/exception/EstaException.java
  17. 65
    0
      src/main/java/com/huiju/estateagents/exception/ExceptionHandleAdice.java
  18. 18
    0
      src/main/java/com/huiju/estateagents/mapper/ExtendContentMapper.java
  19. 18
    0
      src/main/java/com/huiju/estateagents/mapper/TaActivityDynamicEnlistMapper.java
  20. 10
    0
      src/main/java/com/huiju/estateagents/mapper/TaBuildingDynamicMapper.java
  21. 11
    0
      src/main/java/com/huiju/estateagents/mapper/TaNewsMapper.java
  22. 18
    0
      src/main/java/com/huiju/estateagents/mapper/TaSaveMapper.java
  23. 16
    0
      src/main/java/com/huiju/estateagents/service/IExtendContentService.java
  24. 10
    2
      src/main/java/com/huiju/estateagents/service/ITaBuildingDynamicService.java
  25. 54
    0
      src/main/java/com/huiju/estateagents/service/ITaNewsService.java
  26. 39
    0
      src/main/java/com/huiju/estateagents/service/ITaNewsTypeService.java
  27. 22
    0
      src/main/java/com/huiju/estateagents/service/ITaSaveService.java
  28. 20
    0
      src/main/java/com/huiju/estateagents/service/impl/ExtendContentServiceImpl.java
  29. 68
    10
      src/main/java/com/huiju/estateagents/service/impl/TaBuildingDynamicServiceImpl.java
  30. 31
    1
      src/main/java/com/huiju/estateagents/service/impl/TaFavorServiceImpl.java
  31. 164
    0
      src/main/java/com/huiju/estateagents/service/impl/TaNewsServiceImpl.java
  32. 100
    0
      src/main/java/com/huiju/estateagents/service/impl/TaNewsTypeServiceImpl.java
  33. 134
    0
      src/main/java/com/huiju/estateagents/service/impl/TaSaveServiceImpl.java
  34. 5
    0
      src/main/resources/mapper/ExtendContentMapper.xml
  35. 5
    0
      src/main/resources/mapper/TaActivityDynamicEnlistMapper.xml

+ 36
- 0
pom.xml Ver arquivo

@@ -91,6 +91,42 @@
91 91
 			<artifactId>dom4j</artifactId>
92 92
 			<version>2.1.1</version>
93 93
 		</dependency>
94
+		<dependency>
95
+			<groupId>org.jodd</groupId>
96
+			<artifactId>jodd-bean</artifactId>
97
+			<version>3.7.1</version>
98
+		</dependency>
99
+		<dependency>
100
+			<groupId>commons-collections</groupId>
101
+			<artifactId>commons-collections</artifactId>
102
+			<version>3.2.1</version>
103
+		</dependency>
104
+		<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
105
+		<dependency>
106
+			<groupId>commons-io</groupId>
107
+			<artifactId>commons-io</artifactId>
108
+			<version>1.4</version>
109
+		</dependency>
110
+		<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
111
+		<dependency>
112
+			<groupId>org.apache.commons</groupId>
113
+			<artifactId>commons-lang3</artifactId>
114
+			<version>3.8.1</version>
115
+		</dependency>
116
+
117
+		<!-- https://mvnrepository.com/artifact/commons-lang/commons-lang -->
118
+		<dependency>
119
+			<groupId>commons-lang</groupId>
120
+			<artifactId>commons-lang</artifactId>
121
+			<version>2.6</version>
122
+		</dependency>
123
+
124
+		<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
125
+		<dependency>
126
+			<groupId>com.google.guava</groupId>
127
+			<artifactId>guava</artifactId>
128
+			<version>26.0-jre</version>
129
+		</dependency>
94 130
 	</dependencies>
95 131
 
96 132
 	<profiles>

+ 137
- 0
src/main/java/com/huiju/estateagents/common/BeanTools.java Ver arquivo

@@ -0,0 +1,137 @@
1
+package com.huiju.estateagents.common;
2
+
3
+import jodd.bean.BeanCopy;
4
+import jodd.typeconverter.TypeConverterManager;
5
+import org.apache.commons.collections.BeanMap;
6
+import org.springframework.beans.BeanUtils;
7
+import org.springframework.beans.BeanWrapper;
8
+import org.springframework.beans.BeanWrapperImpl;
9
+
10
+import java.beans.PropertyDescriptor;
11
+import java.lang.reflect.Method;
12
+import java.util.*;
13
+
14
+@SuppressWarnings("deprecation")
15
+public final class BeanTools {
16
+
17
+    private static Map<String, Object> toBeanMethodMap = new HashMap<String, Object>();
18
+
19
+    /**
20
+     * <pre>
21
+     * 功能:实现BEAN的属性对拷
22
+     * 创建人:JokenWang
23
+     * </pre>
24
+     *
25
+     * @param fromBean        待转换的源bean
26
+     * @param toBeanClassName 转换成目标bean的名称 形如:ItemSeries.class.getName()
27
+     * @return 目标BEAN类
28
+     */
29
+    public static <T> T convertBean(Object fromBean, Class<T> toBeanClassName) {
30
+        T toBean = null;
31
+        try {
32
+            toBean = getBeanInstance(toBeanClassName.getName());
33
+            return convertBean(fromBean, toBean);
34
+        } catch (Exception e) {
35
+            e.printStackTrace();
36
+        }
37
+        return toBean;
38
+    }
39
+
40
+    private static <T> T convertBean(Object fromBean, T toBean) {
41
+        TypeConverterManager.register(String.class, new StringConverter());
42
+        BeanCopy.beans(fromBean, toBean).copy();
43
+        return toBean;
44
+    }
45
+
46
+    public static Method getDeclaredMethod(Object object, String methodName, Class<?>... parameterTypes) {
47
+        Method method;
48
+        for (Class<?> clazz = object.getClass(); clazz != Object.class; clazz = clazz.getSuperclass()) {
49
+            try {
50
+                method = clazz.getDeclaredMethod(methodName, parameterTypes);
51
+                return method;
52
+            } catch (Exception ignored) {
53
+
54
+            }
55
+        }
56
+        return null;
57
+    }
58
+
59
+    @SuppressWarnings("unchecked")
60
+    public static <T> T getBeanInstance(String clazzName)
61
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException {
62
+
63
+        return (T) Class.forName(clazzName).newInstance();
64
+    }
65
+
66
+    public static Map<String, Object> toBeanMethodMap(String toBean)
67
+            throws InstantiationException, IllegalAccessException, ClassNotFoundException {
68
+
69
+        Class<?> toBeanClazz = getBeanInstance(toBean).getClass();
70
+        Method[] toBeanMethods = toBeanClazz.getDeclaredMethods();
71
+        if (!toBeanClazz.isInstance(Object.class))// 非超类Object
72
+        {
73
+            for (Method method : toBeanMethods) {
74
+                String methodName = method.getName();
75
+                toBeanMethodMap.put(methodName, method);
76
+            }
77
+
78
+            Class<?> toBeanSuperclazz = toBeanClazz.getSuperclass();// 获取父类
79
+            toBeanMethodMap(toBeanSuperclazz.getName());
80
+        }
81
+
82
+        return toBeanMethodMap;
83
+    }
84
+
85
+    public static Map<String, Object> toMap(Object object) {
86
+        Map<String, Object> map = new HashMap<String, Object>();
87
+
88
+        if (object == null) {
89
+            return map;
90
+        }
91
+
92
+        BeanMap beanMap;
93
+        beanMap = new BeanMap(object);
94
+        @SuppressWarnings("unchecked")
95
+        Iterator<String> it = beanMap.keyIterator();
96
+        while (it.hasNext()) {
97
+            String name = it.next();
98
+            Object value = beanMap.get(name);
99
+            // 转换时会将类名也转换成属性,此处去掉
100
+            if (value != null && !name.equals("class")) {
101
+                map.put(name, value);
102
+            }
103
+        }
104
+
105
+        return map;
106
+    }
107
+
108
+    public static Map<String, Object> toMap(Object... objs) {
109
+        Map<String, Object> map = new HashMap<>();
110
+        for (Object object : objs) {
111
+            if (object != null) {
112
+                map.putAll(toMap(object));
113
+            }
114
+        }
115
+        return map;
116
+    }
117
+
118
+    public static String[] getNullPropertyNames (Object source) {
119
+        final BeanWrapper src = new BeanWrapperImpl(source);
120
+        PropertyDescriptor[] pds = src.getPropertyDescriptors();
121
+
122
+        Set<String> emptyNames = new HashSet<String>();
123
+        for(PropertyDescriptor pd : pds) {
124
+            Object srcValue = src.getPropertyValue(pd.getName());
125
+            if (srcValue == null) {
126
+                emptyNames.add(pd.getName());
127
+            }
128
+        }
129
+        String[] result = new String[emptyNames.size()];
130
+        return emptyNames.toArray(result);
131
+    }
132
+
133
+    public static void copyProperties(Object src, Object target) {
134
+        BeanUtils.copyProperties(src, target, getNullPropertyNames(src));
135
+    }
136
+
137
+}

+ 20
- 2
src/main/java/com/huiju/estateagents/common/CommConstant.java Ver arquivo

@@ -43,11 +43,22 @@ public class CommConstant {
43 43
      */
44 44
     public final static String FAVOR_CONSULTANT = "consultant";
45 45
 
46
+    /**
47
+     * 点赞资讯
48
+     */
49
+    public final static String FAVOR_NEWS = "news";
50
+
46 51
     /**
47 52
      * 点赞项目
48 53
      */
49 54
     public final static String FAVOR_PROJECT = "project";
50
-    
55
+
56
+    /**
57
+     * 活动点赞
58
+     */
59
+    public final static String FAVOR_ACTIVITY = "activity";
60
+
61
+
51 62
     /**
52 63
      * 兑换商品
53 64
      */
@@ -68,15 +79,22 @@ public class CommConstant {
68 79
      */
69 80
     public final static String POINTS_AUTHORIZE = "authorize";
70 81
 
82
+
71 83
     /**
72 84
      * 小程序默认首页
73 85
      */
74 86
     public final static String MINIAPP_INDEX = "/index/index";
75 87
 
76 88
     public final static String MINIAPP_DEFAULT_AVATAR = "https://estateagents.oss-cn-shanghai.aliyuncs.com/miniapp/upload/images/default_avatar.jpg";
77
-    
89
+
90
+
78 91
     /**
79 92
      * 未领取
80 93
      */
81 94
     public static final Integer STATUS_UNACCALIMED = 0;
95
+
96
+
97
+
98
+
99
+
82 100
 }

+ 72
- 0
src/main/java/com/huiju/estateagents/common/StringConverter.java Ver arquivo

@@ -0,0 +1,72 @@
1
+package com.huiju.estateagents.common;
2
+
3
+import jodd.typeconverter.TypeConversionException;
4
+import jodd.typeconverter.TypeConverter;
5
+import jodd.util.ArraysUtil;
6
+
7
+import java.sql.Clob;
8
+import java.sql.SQLException;
9
+import java.util.Date;
10
+
11
+public class StringConverter implements TypeConverter<String> {
12
+
13
+    public String convert(Object value) {
14
+        if (value == null) {
15
+            return null;
16
+        }
17
+
18
+        if (value instanceof CharSequence) { // for speed
19
+            return value.toString();
20
+        }
21
+        Class<?> type = value.getClass();
22
+        if (type == Class.class) {
23
+            return ((Class<?>) value).getName();
24
+        }
25
+        if (type.isArray()) {
26
+            if (type == char[].class) {
27
+                char[] charArray = (char[]) value;
28
+                return new String(charArray);
29
+            }
30
+            if (type == int[].class) {
31
+                return ArraysUtil.toString((int[]) value);
32
+            }
33
+            if (type == long[].class) {
34
+                return ArraysUtil.toString((long[]) value);
35
+            }
36
+            if (type == byte[].class) {
37
+                return ArraysUtil.toString((byte[]) value);
38
+            }
39
+            if (type == float[].class) {
40
+                return ArraysUtil.toString((float[]) value);
41
+            }
42
+            if (type == double[].class) {
43
+                return ArraysUtil.toString((double[]) value);
44
+            }
45
+            if (type == short[].class) {
46
+                return ArraysUtil.toString((short[]) value);
47
+            }
48
+            if (type == boolean[].class) {
49
+                return ArraysUtil.toString((boolean[]) value);
50
+            }
51
+            return ArraysUtil.toString((Object[]) value);
52
+        }
53
+        if (value instanceof Clob) {
54
+            Clob clob = (Clob) value;
55
+            try {
56
+                long length = clob.length();
57
+                if (length > Integer.MAX_VALUE) {
58
+                    throw new TypeConversionException("Clob is too big.");
59
+                }
60
+                return clob.getSubString(1, (int) length);
61
+            } catch (SQLException sex) {
62
+                throw new TypeConversionException(value, sex);
63
+            }
64
+        }
65
+        if (value instanceof Date) {
66
+            java.text.DateFormat format1 = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
67
+            return format1.format(value);
68
+        }
69
+
70
+        return value.toString();
71
+    }
72
+}

+ 149
- 0
src/main/java/com/huiju/estateagents/controller/ExtendContentController.java Ver arquivo

@@ -0,0 +1,149 @@
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.entity.ExtendContent;
9
+import com.huiju.estateagents.service.IExtendContentService;
10
+import org.slf4j.Logger;
11
+import org.slf4j.LoggerFactory;
12
+import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.web.bind.annotation.PathVariable;
14
+import org.springframework.web.bind.annotation.RequestBody;
15
+import org.springframework.web.bind.annotation.RequestMapping;
16
+import org.springframework.web.bind.annotation.RequestMethod;
17
+import org.springframework.web.bind.annotation.RequestParam;
18
+import org.springframework.web.bind.annotation.ResponseBody;
19
+import org.springframework.web.bind.annotation.RestController;
20
+
21
+/**
22
+ * <p>
23
+    * 辅助内容表  前端控制器
24
+    * </p>
25
+ *
26
+ * @author jobob
27
+ * @since 2019-07-25
28
+ */
29
+@RestController
30
+@RequestMapping("/api")
31
+public class ExtendContentController extends BaseController {
32
+
33
+    private final Logger logger = LoggerFactory.getLogger(ExtendContentController.class);
34
+
35
+    @Autowired
36
+    public IExtendContentService iExtendContentService;
37
+
38
+
39
+    /**
40
+     * 分页查询列表
41
+     * @param pageNum
42
+     * @param pageSize
43
+     * @return
44
+     */
45
+    @RequestMapping(value="/extendContent",method= RequestMethod.GET)
46
+    public ResponseBean extendContentList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
+                                          @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
48
+        ResponseBean responseBean = new ResponseBean();
49
+        try {
50
+            //使用分页插件
51
+		    IPage<ExtendContent> pg = new Page<>(pageNum, pageSize);
52
+            QueryWrapper<ExtendContent> queryWrapper = new QueryWrapper<>();
53
+            queryWrapper.orderByDesc("create_date");
54
+
55
+            IPage<ExtendContent> result = iExtendContentService.page(pg, queryWrapper);
56
+            responseBean.addSuccess(result);
57
+        }catch (Exception e){
58
+            e.printStackTrace();
59
+            logger.error("extendContentList -=- {}",e.toString());
60
+            responseBean.addError(e.getMessage());
61
+        }
62
+        return responseBean;
63
+    }
64
+
65
+    /**
66
+     * 保存对象
67
+     * @param extendContent 实体对象
68
+     * @return
69
+     */
70
+    @RequestMapping(value="/extendContent",method= RequestMethod.POST)
71
+    public ResponseBean extendContentAdd(@RequestBody ExtendContent extendContent){
72
+        ResponseBean responseBean = new ResponseBean();
73
+        try {
74
+            if (iExtendContentService.save(extendContent)){
75
+                responseBean.addSuccess(extendContent);
76
+            }else {
77
+                responseBean.addError("fail");
78
+            }
79
+        }catch (Exception e){
80
+            e.printStackTrace();
81
+            logger.error("extendContentAdd -=- {}",e.toString());
82
+            responseBean.addError(e.getMessage());
83
+        }
84
+        return responseBean;
85
+    }
86
+
87
+    /**
88
+     * 根据id删除对象
89
+     * @param id  实体ID
90
+     */
91
+    @ResponseBody
92
+    @RequestMapping(value="/extendContent/{id}", method= RequestMethod.DELETE)
93
+    public ResponseBean extendContentDelete(@PathVariable Integer id){
94
+        ResponseBean responseBean = new ResponseBean();
95
+        try {
96
+            if(iExtendContentService.removeById(id)){
97
+                responseBean.addSuccess("success");
98
+            }else {
99
+                responseBean.addError("fail");
100
+            }
101
+        }catch (Exception e){
102
+            e.printStackTrace();
103
+            logger.error("extendContentDelete -=- {}",e.toString());
104
+            responseBean.addError(e.getMessage());
105
+        }
106
+        return responseBean;
107
+    }
108
+
109
+    /**
110
+     * 修改对象
111
+     * @param id  实体ID
112
+     * @param extendContent 实体对象
113
+     * @return
114
+     */
115
+    @RequestMapping(value="/extendContent/{id}",method= RequestMethod.PUT)
116
+    public ResponseBean extendContentUpdate(@PathVariable Integer id,
117
+                                        @RequestBody ExtendContent extendContent){
118
+        ResponseBean responseBean = new ResponseBean();
119
+        try {
120
+            if (iExtendContentService.updateById(extendContent)){
121
+                responseBean.addSuccess(extendContent);
122
+            }else {
123
+                responseBean.addError("fail");
124
+            }
125
+        }catch (Exception e){
126
+            e.printStackTrace();
127
+            logger.error("extendContentUpdate -=- {}",e.toString());
128
+            responseBean.addError(e.getMessage());
129
+        }
130
+        return responseBean;
131
+    }
132
+
133
+    /**
134
+     * 根据id查询对象
135
+     * @param id  实体ID
136
+     */
137
+    @RequestMapping(value="/extendContent/{id}",method= RequestMethod.GET)
138
+    public ResponseBean extendContentGet(@PathVariable Integer id){
139
+        ResponseBean responseBean = new ResponseBean();
140
+        try {
141
+            responseBean.addSuccess(iExtendContentService.getById(id));
142
+        }catch (Exception e){
143
+            e.printStackTrace();
144
+            logger.error("extendContentDelete -=- {}",e.toString());
145
+            responseBean.addError(e.getMessage());
146
+        }
147
+        return responseBean;
148
+    }
149
+}

+ 19
- 0
src/main/java/com/huiju/estateagents/controller/IndexController.java Ver arquivo

@@ -0,0 +1,19 @@
1
+package com.huiju.estateagents.controller;
2
+
3
+import org.springframework.web.bind.annotation.RequestMapping;
4
+import org.springframework.web.bind.annotation.RestController;
5
+
6
+/**
7
+ * 微信首页
8
+ */
9
+@RestController
10
+@RequestMapping("/api")
11
+public class IndexController {
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+}

+ 25
- 4
src/main/java/com/huiju/estateagents/controller/TaBuildingDynamicController.java Ver arquivo

@@ -5,7 +5,9 @@ import com.alibaba.fastjson.JSONObject;
5 5
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
6 6
 import com.huiju.estateagents.base.BaseController;
7 7
 import com.huiju.estateagents.base.ResponseBean;
8
+import com.huiju.estateagents.common.JWTUtils;
8 9
 import com.huiju.estateagents.entity.TaBuildingDynamic;
10
+import com.huiju.estateagents.mapper.TaActivityDynamicEnlistMapper;
9 11
 import com.huiju.estateagents.service.ITaBuildingDynamicService;
10 12
 import org.springframework.beans.factory.annotation.Autowired;
11 13
 import org.springframework.beans.propertyeditors.CustomDateEditor;
@@ -14,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
14 16
 
15 17
 import javax.servlet.http.HttpServletRequest;
16 18
 import javax.servlet.http.HttpSession;
19
+import javax.swing.*;
17 20
 import java.text.DateFormat;
18 21
 import java.text.SimpleDateFormat;
19 22
 import java.time.LocalDateTime;
@@ -58,17 +61,35 @@ public class TaBuildingDynamicController extends BaseController {
58 61
     }
59 62
 
60 63
     @RequestMapping(value = "/wx/buildingDynamiceList", method = RequestMethod.GET)
61
-    public ResponseBean wxBuildingDynamiceList(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize, HttpSession session){
62
-        ResponseBean  responseBean = iBuildingDynamicService.getWxBuildingDynamiceList(pageNum,pageSize);
64
+    public ResponseBean wxBuildingDynamiceList(@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum,
65
+                                               @RequestParam(value = "pageSize",defaultValue = "10")Integer pageSize,
66
+                                               HttpServletRequest request){
67
+        String openid = JWTUtils.getSubject(request);
68
+        /* buildingId 正在设计中*/
69
+        Integer buildingId = null;
70
+        ResponseBean  responseBean = iBuildingDynamicService.getWxBuildingDynamiceList(pageNum,pageSize,buildingId);
63 71
         return responseBean;
64 72
     }
65 73
 
66 74
     @RequestMapping(value = "/wx/buildingDynamiceInfo/{dynamicId}", method = RequestMethod.GET)
67
-    public ResponseBean iBuildingDynamicInfo(@PathVariable(value = "dynamicId") String dynamicId, HttpSession session){
68
-        ResponseBean  responseBean = iBuildingDynamicService.getWxBuildingDynamiceInfo(dynamicId);
75
+    public ResponseBean iBuildingDynamicInfo(@PathVariable(value = "dynamicId") String dynamicId,
76
+                                             @RequestParam("buildingId")Integer buildingId){
77
+        ResponseBean  responseBean = iBuildingDynamicService.getWxBuildingDynamiceInfo(dynamicId,buildingId);
69 78
         return responseBean;
70 79
     }
71 80
 
81
+    @RequestMapping(value = "/wx/activityDynamicEnlistAdd", method = RequestMethod.POST)
82
+
83
+    public ResponseBean taActivityDynamicEnlist(@RequestParam("dynamicId")Integer dynamicId,
84
+                                                @RequestParam("phone")String phone,
85
+                                                @RequestParam("name")String name,
86
+                                                HttpServletRequest request){
87
+        String openid = JWTUtils.getSubject(request);
88
+        ResponseBean  responseBean = iBuildingDynamicService.taActivityDynamicEnlistAdd(dynamicId,phone,name);
89
+        return responseBean;
90
+    }
91
+
92
+
72 93
     @RequestMapping(value = "/admin/buildingDynamic/add" ,method =RequestMethod.POST)
73 94
     public  ResponseBean buildingDynamicAdd(@RequestBody String parameter){
74 95
         ResponseBean responseBean = new ResponseBean();

+ 44
- 58
src/main/java/com/huiju/estateagents/controller/TaNewsController.java Ver arquivo

@@ -44,21 +44,25 @@ public class TaNewsController extends BaseController {
44 44
      */
45 45
     @RequestMapping(value="/taNews",method= RequestMethod.GET)
46 46
     public ResponseBean taNewsList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
-                                   @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
48
-        ResponseBean responseBean = new ResponseBean();
49
-        try {
50
-            //使用分页插件
51
-		    IPage<TaNews> pg = new Page<>(pageNum, pageSize);
52
-            QueryWrapper<TaNews> queryWrapper = new QueryWrapper<>();
53
-            queryWrapper.orderByDesc("create_date");
47
+                                   @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
48
+                                   @RequestParam(value = "buildingId") Integer buildingId,
49
+                                   @RequestParam(value = "orgId") Integer orgId,
50
+                                   @RequestParam(value = "newsTypeId") Integer newsTypeId,
51
+                                   @RequestParam(value = "newsStatus") Integer newsStatus){
52
+        ResponseBean responseBean = iTaNewsService.getList(pageNum, pageSize, buildingId, orgId, newsTypeId, newsStatus);
53
+        return responseBean;
54
+    }
54 55
 
55
-            IPage<TaNews> result = iTaNewsService.page(pg, queryWrapper);
56
-            responseBean.addSuccess(result);
57
-        }catch (Exception e){
58
-            e.printStackTrace();
59
-            logger.error("taNewsList -=- {}",e.toString());
60
-            responseBean.addError(e.getMessage());
61
-        }
56
+    /**
57
+     * 微信 分页查询列表
58
+     * @param pageNum
59
+     * @param pageSize
60
+     * @return
61
+     */
62
+    @RequestMapping(value="/wx/taNews",method= RequestMethod.GET)
63
+    public ResponseBean wxTaNewsList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
64
+                                   @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
65
+        ResponseBean responseBean = iTaNewsService.getList(pageNum, pageSize, null, null, null, null);
62 66
         return responseBean;
63 67
     }
64 68
 
@@ -69,18 +73,7 @@ public class TaNewsController extends BaseController {
69 73
      */
70 74
     @RequestMapping(value="/taNews",method= RequestMethod.POST)
71 75
     public ResponseBean taNewsAdd(@RequestBody TaNews taNews){
72
-        ResponseBean responseBean = new ResponseBean();
73
-        try {
74
-            if (iTaNewsService.save(taNews)){
75
-                responseBean.addSuccess(taNews);
76
-            }else {
77
-                responseBean.addError("fail");
78
-            }
79
-        }catch (Exception e){
80
-            e.printStackTrace();
81
-            logger.error("taNewsAdd -=- {}",e.toString());
82
-            responseBean.addError(e.getMessage());
83
-        }
76
+        ResponseBean responseBean = iTaNewsService.addTaNews(taNews);
84 77
         return responseBean;
85 78
     }
86 79
 
@@ -91,18 +84,7 @@ public class TaNewsController extends BaseController {
91 84
     @ResponseBody
92 85
     @RequestMapping(value="/taNews/{id}", method= RequestMethod.DELETE)
93 86
     public ResponseBean taNewsDelete(@PathVariable Integer id){
94
-        ResponseBean responseBean = new ResponseBean();
95
-        try {
96
-            if(iTaNewsService.removeById(id)){
97
-                responseBean.addSuccess("success");
98
-            }else {
99
-                responseBean.addError("fail");
100
-            }
101
-        }catch (Exception e){
102
-            e.printStackTrace();
103
-            logger.error("taNewsDelete -=- {}",e.toString());
104
-            responseBean.addError(e.getMessage());
105
-        }
87
+        ResponseBean responseBean = iTaNewsService.deleteTaNews(id);
106 88
         return responseBean;
107 89
     }
108 90
 
@@ -115,18 +97,8 @@ public class TaNewsController extends BaseController {
115 97
     @RequestMapping(value="/taNews/{id}",method= RequestMethod.PUT)
116 98
     public ResponseBean taNewsUpdate(@PathVariable Integer id,
117 99
                                         @RequestBody TaNews taNews){
118
-        ResponseBean responseBean = new ResponseBean();
119
-        try {
120
-            if (iTaNewsService.updateById(taNews)){
121
-                responseBean.addSuccess(taNews);
122
-            }else {
123
-                responseBean.addError("fail");
124
-            }
125
-        }catch (Exception e){
126
-            e.printStackTrace();
127
-            logger.error("taNewsUpdate -=- {}",e.toString());
128
-            responseBean.addError(e.getMessage());
129
-        }
100
+        taNews.setNewsId(id);
101
+        ResponseBean responseBean = iTaNewsService.updateTaNews(taNews);
130 102
         return responseBean;
131 103
     }
132 104
 
@@ -136,14 +108,28 @@ public class TaNewsController extends BaseController {
136 108
      */
137 109
     @RequestMapping(value="/taNews/{id}",method= RequestMethod.GET)
138 110
     public ResponseBean taNewsGet(@PathVariable Integer id){
139
-        ResponseBean responseBean = new ResponseBean();
140
-        try {
141
-            responseBean.addSuccess(iTaNewsService.getById(id));
142
-        }catch (Exception e){
143
-            e.printStackTrace();
144
-            logger.error("taNewsDelete -=- {}",e.toString());
145
-            responseBean.addError(e.getMessage());
146
-        }
111
+        ResponseBean responseBean = iTaNewsService.getTaNewsById(id);
112
+        return responseBean;
113
+    }
114
+
115
+    /**
116
+     * 微信 根据id查询对象
117
+     * @param id  实体ID
118
+     */
119
+    @RequestMapping(value="/wx/taNews/{id}",method= RequestMethod.GET)
120
+    public ResponseBean wxTaNewsGet(@PathVariable Integer id){
121
+        ResponseBean responseBean = iTaNewsService.getWxTaNewsById(id);
122
+        return responseBean;
123
+    }
124
+
125
+    /**
126
+     * 微信 资讯阅读量+1
127
+     * @param id
128
+     * @return
129
+     */
130
+    @RequestMapping(value = "/wx/taNews/pvNum/{id}", method = RequestMethod.PUT)
131
+    public ResponseBean wxTaPvNum(@PathVariable Integer id) {
132
+        ResponseBean responseBean = iTaNewsService.wxTaPvNum(id);
147 133
         return responseBean;
148 134
     }
149 135
 }

+ 10
- 59
src/main/java/com/huiju/estateagents/controller/TaNewsTypeController.java Ver arquivo

@@ -44,21 +44,10 @@ public class TaNewsTypeController extends BaseController {
44 44
      */
45 45
     @RequestMapping(value="/taNewsType",method= RequestMethod.GET)
46 46
     public ResponseBean taNewsTypeList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
47
-                                       @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize){
48
-        ResponseBean responseBean = new ResponseBean();
49
-        try {
50
-            //使用分页插件
51
-		    IPage<TaNewsType> pg = new Page<>(pageNum, pageSize);
52
-            QueryWrapper<TaNewsType> queryWrapper = new QueryWrapper<>();
53
-            queryWrapper.orderByDesc("create_date");
54
-
55
-            IPage<TaNewsType> result = iTaNewsTypeService.page(pg, queryWrapper);
56
-            responseBean.addSuccess(result);
57
-        }catch (Exception e){
58
-            e.printStackTrace();
59
-            logger.error("taNewsTypeList -=- {}",e.toString());
60
-            responseBean.addError(e.getMessage());
61
-        }
47
+                                       @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
48
+                                       @RequestParam(value = "buildingId", required = false) Integer buildingId,
49
+                                       @RequestParam(value = "orgId", required = false) Integer orgId){
50
+        ResponseBean responseBean = iTaNewsTypeService.getList(pageNum, pageSize, buildingId, orgId);
62 51
         return responseBean;
63 52
     }
64 53
 
@@ -69,18 +58,7 @@ public class TaNewsTypeController extends BaseController {
69 58
      */
70 59
     @RequestMapping(value="/taNewsType",method= RequestMethod.POST)
71 60
     public ResponseBean taNewsTypeAdd(@RequestBody TaNewsType taNewsType){
72
-        ResponseBean responseBean = new ResponseBean();
73
-        try {
74
-            if (iTaNewsTypeService.save(taNewsType)){
75
-                responseBean.addSuccess(taNewsType);
76
-            }else {
77
-                responseBean.addError("fail");
78
-            }
79
-        }catch (Exception e){
80
-            e.printStackTrace();
81
-            logger.error("taNewsTypeAdd -=- {}",e.toString());
82
-            responseBean.addError(e.getMessage());
83
-        }
61
+        ResponseBean responseBean = iTaNewsTypeService.addTaNewsType(taNewsType);
84 62
         return responseBean;
85 63
     }
86 64
 
@@ -91,18 +69,7 @@ public class TaNewsTypeController extends BaseController {
91 69
     @ResponseBody
92 70
     @RequestMapping(value="/taNewsType/{id}", method= RequestMethod.DELETE)
93 71
     public ResponseBean taNewsTypeDelete(@PathVariable Integer id){
94
-        ResponseBean responseBean = new ResponseBean();
95
-        try {
96
-            if(iTaNewsTypeService.removeById(id)){
97
-                responseBean.addSuccess("success");
98
-            }else {
99
-                responseBean.addError("fail");
100
-            }
101
-        }catch (Exception e){
102
-            e.printStackTrace();
103
-            logger.error("taNewsTypeDelete -=- {}",e.toString());
104
-            responseBean.addError(e.getMessage());
105
-        }
72
+        ResponseBean responseBean = iTaNewsTypeService.deleteTaNewsType(id);
106 73
         return responseBean;
107 74
     }
108 75
 
@@ -115,18 +82,8 @@ public class TaNewsTypeController extends BaseController {
115 82
     @RequestMapping(value="/taNewsType/{id}",method= RequestMethod.PUT)
116 83
     public ResponseBean taNewsTypeUpdate(@PathVariable Integer id,
117 84
                                         @RequestBody TaNewsType taNewsType){
118
-        ResponseBean responseBean = new ResponseBean();
119
-        try {
120
-            if (iTaNewsTypeService.updateById(taNewsType)){
121
-                responseBean.addSuccess(taNewsType);
122
-            }else {
123
-                responseBean.addError("fail");
124
-            }
125
-        }catch (Exception e){
126
-            e.printStackTrace();
127
-            logger.error("taNewsTypeUpdate -=- {}",e.toString());
128
-            responseBean.addError(e.getMessage());
129
-        }
85
+        taNewsType.setNewsTypeId(id);
86
+        ResponseBean responseBean = iTaNewsTypeService.updateTaNewsType(taNewsType);
130 87
         return responseBean;
131 88
     }
132 89
 
@@ -136,14 +93,8 @@ public class TaNewsTypeController extends BaseController {
136 93
      */
137 94
     @RequestMapping(value="/taNewsType/{id}",method= RequestMethod.GET)
138 95
     public ResponseBean taNewsTypeGet(@PathVariable Integer id){
139
-        ResponseBean responseBean = new ResponseBean();
140
-        try {
141
-            responseBean.addSuccess(iTaNewsTypeService.getById(id));
142
-        }catch (Exception e){
143
-            e.printStackTrace();
144
-            logger.error("taNewsTypeDelete -=- {}",e.toString());
145
-            responseBean.addError(e.getMessage());
146
-        }
96
+        ResponseBean responseBean = iTaNewsTypeService.getTaNewsTypeById(id);
147 97
         return responseBean;
148 98
     }
99
+
149 100
 }

+ 55
- 0
src/main/java/com/huiju/estateagents/controller/TaSaveController.java Ver arquivo

@@ -0,0 +1,55 @@
1
+package com.huiju.estateagents.controller;
2
+
3
+
4
+import com.huiju.estateagents.base.BaseController;
5
+import com.huiju.estateagents.base.ResponseBean;
6
+import com.huiju.estateagents.common.JWTUtils;
7
+import com.huiju.estateagents.service.ITaSaveService;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.web.bind.annotation.*;
10
+
11
+import javax.servlet.http.HttpServletRequest;
12
+
13
+/**
14
+ * <p>
15
+ * 收藏表  前端控制器
16
+ * </p>
17
+ *
18
+ * @author jobob
19
+ * @since 2019-07-25
20
+ */
21
+@RestController
22
+@RequestMapping("/api")
23
+public class TaSaveController extends BaseController {
24
+
25
+    @Autowired
26
+    private ITaSaveService iTaSaveService;
27
+
28
+    /**
29
+     * 点赞
30
+     * @param typeOf
31
+     * @param id
32
+     * @param request
33
+     * @return
34
+     */
35
+    @PostMapping("/wx/{typeOf}/save/{id}")
36
+    public ResponseBean giveFavor(@PathVariable String typeOf, @PathVariable String id, HttpServletRequest request) {
37
+        String openid = JWTUtils.getSubject(request);
38
+
39
+        return iTaSaveService.postLike(openid, typeOf, id);
40
+    }
41
+
42
+    /**
43
+     * 取消赞
44
+     * @param typeOf
45
+     * @param id
46
+     * @param request
47
+     * @return
48
+     */
49
+    @DeleteMapping("/wx/{typeOf}/save/{id}")
50
+    public ResponseBean cancelFavor(@PathVariable String typeOf, @PathVariable String id, HttpServletRequest request) {
51
+        String openid = JWTUtils.getSubject(request);
52
+        return iTaSaveService.cancelLike(openid, typeOf, id);
53
+    }
54
+
55
+}

+ 90
- 0
src/main/java/com/huiju/estateagents/entity/ExtendContent.java Ver arquivo

@@ -0,0 +1,90 @@
1
+package com.huiju.estateagents.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.TableName;
4
+import com.baomidou.mybatisplus.annotation.IdType;
5
+import com.baomidou.mybatisplus.annotation.TableId;
6
+import java.time.LocalDateTime;
7
+import java.io.Serializable;
8
+import lombok.Data;
9
+import lombok.EqualsAndHashCode;
10
+import lombok.experimental.Accessors;
11
+
12
+/**
13
+ * <p>
14
+ * 辅助内容表 
15
+ * </p>
16
+ *
17
+ * @author jobob
18
+ * @since 2019-07-25
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+@TableName("ta_extend_content")
24
+public class ExtendContent implements Serializable {
25
+
26
+    private static final long serialVersionUID = 1L;
27
+
28
+    /**
29
+     * 内容ID
30
+     */
31
+    @TableId(value = "content_id", type = IdType.AUTO)
32
+    private Integer contentId;
33
+
34
+    /**
35
+     * 打开方式
36
+     */
37
+    private String showType;
38
+
39
+    /**
40
+     * 发布位置
41
+     */
42
+    private String showPosition;
43
+
44
+    /**
45
+     * 类型
46
+     */
47
+    private String contentType;
48
+
49
+    /**
50
+     * 链接ID
51
+     */
52
+    private String targetId;
53
+
54
+    /**
55
+     * 图片
56
+     */
57
+    private String image;
58
+
59
+    /**
60
+     * 自定义内容
61
+     */
62
+    private String content;
63
+
64
+    /**
65
+     * 内容标题
66
+     */
67
+    private String title;
68
+
69
+    /**
70
+     * 创建时间
71
+     */
72
+    private LocalDateTime createDate;
73
+
74
+    /**
75
+     * 状态
76
+     */
77
+    private Integer status;
78
+
79
+    /**
80
+     * 公司id
81
+     */
82
+    private Integer orgId;
83
+
84
+    /**
85
+     * 楼盘id
86
+     */
87
+    private String buildingId;
88
+
89
+
90
+}

+ 59
- 0
src/main/java/com/huiju/estateagents/entity/TaActivityDynamicEnlist.java Ver arquivo

@@ -0,0 +1,59 @@
1
+package com.huiju.estateagents.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import lombok.Data;
6
+import lombok.EqualsAndHashCode;
7
+import lombok.experimental.Accessors;
8
+
9
+import java.io.Serializable;
10
+import java.time.LocalDateTime;
11
+
12
+/**
13
+ * <p>
14
+ * 点赞表
15
+ * </p>
16
+ *
17
+ * @author jobob
18
+ * @since 2019-05-10
19
+ */
20
+@Data
21
+@EqualsAndHashCode(callSuper = false)
22
+@Accessors(chain = true)
23
+public class TaActivityDynamicEnlist implements Serializable {
24
+
25
+    private static final long serialVersionUID = 1L;
26
+
27
+    /**
28
+     * 报名ID
29
+     */
30
+    @TableId(value = "favor_id", type = IdType.AUTO)
31
+    private Integer enlist_id;
32
+
33
+    /**
34
+     * 活动ID
35
+     */
36
+    private String dynamic_id;
37
+
38
+    /**
39
+     * 姓名
40
+     */
41
+    private String name;
42
+
43
+    /**
44
+     * 楼盘id
45
+     */
46
+    private String building_id;
47
+
48
+    /**
49
+     * 创建时间
50
+     */
51
+    private LocalDateTime createDate;
52
+
53
+    /**
54
+     * 手机号
55
+     */
56
+    private String phone;
57
+
58
+
59
+}

+ 39
- 0
src/main/java/com/huiju/estateagents/entity/TaBuildingDynamic.java Ver arquivo

@@ -81,4 +81,43 @@ public class TaBuildingDynamic implements Serializable {
81 81
     @TableField(exist = false)
82 82
     private TaBuilding building;
83 83
 
84
+    /**
85
+     * 活动总开关判断活动是否能开始报名_1:可以,0:不可以
86
+     */
87
+    private  String isEnlist;
88
+
89
+    /**
90
+     * 活动开始时间
91
+     */
92
+    private LocalDateTime startDate;
93
+
94
+    /**
95
+     * 活动结束时间
96
+     */
97
+    private  LocalDateTime endDate;
98
+
99
+    /**
100
+     *  报名开始时间
101
+     */
102
+    private  LocalDateTime enlistStart;
103
+
104
+    /**
105
+     * 报名结束时间
106
+     */
107
+    private  LocalDateTime enlistEnd;
108
+
109
+    /**
110
+     * 活动的当前状态1:进行中,2:未开始,3:结束
111
+     */
112
+    @TableField(exist = false)
113
+    private  Integer activityCondition;
114
+
115
+    /**
116
+     * 报名总数
117
+     */
118
+    @TableField(exist = false)
119
+    private  int count;
120
+
121
+
122
+
84 123
 }

+ 9
- 1
src/main/java/com/huiju/estateagents/entity/TaNews.java Ver arquivo

@@ -1,5 +1,8 @@
1 1
 package com.huiju.estateagents.entity;
2 2
 
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableField;
5
+import com.baomidou.mybatisplus.annotation.TableId;
3 6
 import lombok.Data;
4 7
 import lombok.EqualsAndHashCode;
5 8
 import lombok.experimental.Accessors;
@@ -25,6 +28,7 @@ public class TaNews implements Serializable {
25 28
     /**
26 29
      * 咨询ID
27 30
      */
31
+    @TableId(value = "news_id", type = IdType.AUTO)
28 32
     private Integer newsId;
29 33
 
30 34
     /**
@@ -77,5 +81,9 @@ public class TaNews implements Serializable {
77 81
      */
78 82
     private LocalDateTime createDate;
79 83
 
80
-
84
+    /**
85
+     * 类型
86
+     */
87
+    @TableField(exist = false)
88
+    private TaNewsType newsType;
81 89
 }

+ 76
- 0
src/main/java/com/huiju/estateagents/entity/TaSave.java Ver arquivo

@@ -0,0 +1,76 @@
1
+package com.huiju.estateagents.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import com.baomidou.mybatisplus.annotation.TableName;
6
+import lombok.Data;
7
+import lombok.EqualsAndHashCode;
8
+import lombok.experimental.Accessors;
9
+
10
+import java.io.Serializable;
11
+import java.time.LocalDateTime;
12
+
13
+/**
14
+ * <p>
15
+ * 收藏表 
16
+ * </p>
17
+ *
18
+ * @author jobob
19
+ * @since 2019-07-25
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@TableName("ta_save")
25
+public class TaSave implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    /**
30
+     * 收藏ID
31
+     */
32
+    @TableId(value = "save_id", type = IdType.AUTO)
33
+    private Integer saveId;
34
+
35
+    /**
36
+     * 收藏人ID
37
+     */
38
+    private String personId;
39
+
40
+    /**
41
+     * 名称
42
+     */
43
+    private String nameOrnick;
44
+
45
+    /**
46
+     * 头像
47
+     */
48
+    private String photoOravatar;
49
+
50
+    /**
51
+     * 被收藏对象
52
+     */
53
+    private String savedTarget;
54
+
55
+    /**
56
+     * 收藏类型
57
+     */
58
+    private String tagertType;
59
+
60
+    /**
61
+     * 创建时间
62
+     */
63
+    private LocalDateTime createDate;
64
+
65
+    /**
66
+     * 公司id
67
+     */
68
+    private Integer orgId;
69
+
70
+    /**
71
+     * 楼盘id
72
+     */
73
+    private String buildingId;
74
+
75
+
76
+}

+ 17
- 0
src/main/java/com/huiju/estateagents/exception/EstaException.java Ver arquivo

@@ -0,0 +1,17 @@
1
+package com.huiju.estateagents.exception;
2
+
3
+
4
+/**
5
+ * @author weiximei
6
+ */
7
+public class EstaException extends RuntimeException {
8
+
9
+
10
+    public EstaException(String msg, Throwable t) {
11
+        super(msg, t);
12
+    }
13
+
14
+    public EstaException(String msg) {
15
+        super(msg);
16
+    }
17
+}

+ 65
- 0
src/main/java/com/huiju/estateagents/exception/ExceptionHandleAdice.java Ver arquivo

@@ -0,0 +1,65 @@
1
+package com.huiju.estateagents.exception;
2
+
3
+import com.huiju.estateagents.base.ResponseBean;
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.validation.ObjectError;
6
+import org.springframework.web.bind.MethodArgumentNotValidException;
7
+import org.springframework.web.bind.annotation.ControllerAdvice;
8
+import org.springframework.web.bind.annotation.ExceptionHandler;
9
+import org.springframework.web.bind.annotation.ResponseBody;
10
+
11
+import java.util.List;
12
+
13
+/**
14
+ * 统一异常出口
15
+ * @author weiximei
16
+ */
17
+@ControllerAdvice
18
+@ResponseBody
19
+@Slf4j
20
+public class ExceptionHandleAdice {
21
+
22
+
23
+    @ExceptionHandler(Exception.class)
24
+    public ResponseBean handleException(Exception e){
25
+        log.error(e.getMessage(),e);
26
+        ResponseBean response = new ResponseBean();
27
+        response.addError("系统异常,请稍后重试!");
28
+        return response;
29
+    }
30
+
31
+    @ExceptionHandler(RuntimeException.class)
32
+    public ResponseBean handleException(RuntimeException e){
33
+        log.error(e.getMessage(),e);
34
+        ResponseBean response = new ResponseBean();
35
+        response.addError(e.getMessage());
36
+        return response;
37
+    }
38
+
39
+
40
+    @ExceptionHandler(EstaException.class)
41
+    public ResponseBean handleException(EstaException e) {
42
+        log.error(e.getMessage(),e);
43
+        ResponseBean response = new ResponseBean();
44
+        response.addError(e.getMessage());
45
+        return response;
46
+    }
47
+
48
+
49
+    @ExceptionHandler(MethodArgumentNotValidException.class)
50
+    public ResponseBean handlelllewgalParamException(MethodArgumentNotValidException e){
51
+        ResponseBean response = new ResponseBean();
52
+
53
+        List<ObjectError> errors  =e.getBindingResult().getAllErrors();
54
+        String message = "参数不合法";
55
+        if (errors.size() >0) {
56
+            message = errors.get(0).getDefaultMessage();
57
+        }
58
+
59
+        response.addError(message);
60
+
61
+        return response;
62
+    }
63
+
64
+
65
+}

+ 18
- 0
src/main/java/com/huiju/estateagents/mapper/ExtendContentMapper.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.huiju.estateagents.entity.ExtendContent;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 辅助内容表  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-07-25
14
+ */
15
+@Mapper
16
+public interface ExtendContentMapper extends BaseMapper<ExtendContent> {
17
+
18
+}

+ 18
- 0
src/main/java/com/huiju/estateagents/mapper/TaActivityDynamicEnlistMapper.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.huiju.estateagents.entity.TaActivityDynamicEnlist;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 楼盘户型对应图片表 Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-05-10
14
+ */
15
+@Mapper
16
+public interface TaActivityDynamicEnlistMapper extends BaseMapper<TaActivityDynamicEnlist> {
17
+
18
+}

+ 10
- 0
src/main/java/com/huiju/estateagents/mapper/TaBuildingDynamicMapper.java Ver arquivo

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.huiju.estateagents.entity.TaBuildingDynamic;
7 7
 import org.apache.ibatis.annotations.Mapper;
8 8
 import org.apache.ibatis.annotations.Param;
9
+import org.apache.ibatis.annotations.Update;
9 10
 
10 11
 /**
11 12
  * <p>
@@ -43,4 +44,13 @@ public interface TaBuildingDynamicMapper extends BaseMapper<TaBuildingDynamic> {
43 44
      * @param buildingDynamic
44 45
      */
45 46
     void buildingDynamicUpdate(TaBuildingDynamic buildingDynamic);
47
+
48
+    /**
49
+     * 某个字段值 +1
50
+     * @param newsId
51
+     * @param field
52
+     * @param increment
53
+     */
54
+    @Update("UPDATE ta_building_dynamic  SET ${field} = IFNULL(${field}, 0) + #{increment}  WHERE dynamic_id = #{newsId}")
55
+    void setFieldNum(@Param("newsId") String newsId, @Param("field") String field, @Param("increment") int increment);
46 56
 }

+ 11
- 0
src/main/java/com/huiju/estateagents/mapper/TaNewsMapper.java Ver arquivo

@@ -3,6 +3,8 @@ package com.huiju.estateagents.mapper;
3 3
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4 4
 import com.huiju.estateagents.entity.TaNews;
5 5
 import org.apache.ibatis.annotations.Mapper;
6
+import org.apache.ibatis.annotations.Param;
7
+import org.apache.ibatis.annotations.Update;
6 8
 
7 9
 /**
8 10
  * <p>
@@ -15,4 +17,13 @@ import org.apache.ibatis.annotations.Mapper;
15 17
 @Mapper
16 18
 public interface TaNewsMapper extends BaseMapper<TaNews> {
17 19
 
20
+    /**
21
+     * 某个字段值 +1
22
+     * @param newsId
23
+     * @param field
24
+     * @param increment
25
+     */
26
+    @Update("UPDATE ta_news  SET ${field} = IFNULL(${field}, 0) + #{increment}  WHERE news_id = #{newsId}")
27
+    void setFieldNum(@Param("newsId") String newsId, @Param("field") String field, @Param("increment") int increment);
28
+
18 29
 }

+ 18
- 0
src/main/java/com/huiju/estateagents/mapper/TaSaveMapper.java Ver arquivo

@@ -0,0 +1,18 @@
1
+package com.huiju.estateagents.mapper;
2
+
3
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
4
+import com.huiju.estateagents.entity.TaSave;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 收藏表  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-07-25
14
+ */
15
+@Mapper
16
+public interface TaSaveMapper extends BaseMapper<TaSave> {
17
+
18
+}

+ 16
- 0
src/main/java/com/huiju/estateagents/service/IExtendContentService.java Ver arquivo

@@ -0,0 +1,16 @@
1
+package com.huiju.estateagents.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.huiju.estateagents.entity.ExtendContent;
5
+
6
+/**
7
+ * <p>
8
+ * 辅助内容表  服务类
9
+ * </p>
10
+ *
11
+ * @author jobob
12
+ * @since 2019-07-25
13
+ */
14
+public interface IExtendContentService extends IService<ExtendContent> {
15
+
16
+}

+ 10
- 2
src/main/java/com/huiju/estateagents/service/ITaBuildingDynamicService.java Ver arquivo

@@ -33,14 +33,14 @@ public interface ITaBuildingDynamicService extends IService<TaBuildingDynamic> {
33 33
      * 微信小程序 项目动态管理列表
34 34
      * @return
35 35
      */
36
-    ResponseBean getWxBuildingDynamiceList(Integer pageNum, Integer pageSize);
36
+    ResponseBean getWxBuildingDynamiceList(Integer pageNum, Integer pageSize,Integer buildingId);
37 37
 
38 38
     /**
39 39
      * 微信小程序 项目详情
40 40
      * @param dynamicId
41 41
      * @return
42 42
      */
43
-    ResponseBean getWxBuildingDynamiceInfo(String dynamicId);
43
+    ResponseBean getWxBuildingDynamiceInfo(String dynamicId,Integer buildingId);
44 44
 
45 45
     /**
46 46
      * 动态管理添加
@@ -63,4 +63,12 @@ public interface ITaBuildingDynamicService extends IService<TaBuildingDynamic> {
63 63
      */
64 64
     ResponseBean buildingDynamicUpdate(HashMap<Object, Object> map);
65 65
 
66
+    /**
67
+     * 报名活动
68
+     * @param dynamicId
69
+     * @param phone
70
+     * @param name
71
+     * @return
72
+     */
73
+    ResponseBean taActivityDynamicEnlistAdd(Integer dynamicId, String phone, String name);
66 74
 }

+ 54
- 0
src/main/java/com/huiju/estateagents/service/ITaNewsService.java Ver arquivo

@@ -1,6 +1,8 @@
1 1
 package com.huiju.estateagents.service;
2 2
 
3
+import com.baomidou.mybatisplus.core.metadata.IPage;
3 4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.huiju.estateagents.base.ResponseBean;
4 6
 import com.huiju.estateagents.entity.TaNews;
5 7
 
6 8
 /**
@@ -13,4 +15,56 @@ import com.huiju.estateagents.entity.TaNews;
13 15
  */
14 16
 public interface ITaNewsService extends IService<TaNews> {
15 17
 
18
+    /**
19
+     * 查询资讯列表
20
+     * @param pageNum
21
+     * @param pageSize
22
+     * @param buildingId
23
+     * @param orgId
24
+     * @param newsTypeId
25
+     * @return
26
+     */
27
+    ResponseBean getList(Integer pageNum, Integer pageSize, Integer buildingId, Integer orgId, Integer newsTypeId, Integer newsStatus);
28
+
29
+    /**
30
+     * 根据Id查询资讯数据
31
+     * @param newsId
32
+     * @return
33
+     */
34
+    ResponseBean getTaNewsById(Integer newsId);
35
+
36
+    /**
37
+     * 修改资讯数据
38
+     * @param taNews
39
+     * @return
40
+     */
41
+    ResponseBean updateTaNews(TaNews taNews);
42
+
43
+    /**
44
+     * add资讯数据
45
+     * @param taNews
46
+     * @return
47
+     */
48
+    ResponseBean addTaNews(TaNews taNews);
49
+
50
+    /**
51
+     * 删除资讯
52
+     * @param newsId
53
+     * @return
54
+     */
55
+    ResponseBean deleteTaNews(Integer newsId);
56
+
57
+    /**
58
+     * 微信 根据Id查询资讯数据
59
+     * @param newsId
60
+     * @return
61
+     */
62
+    ResponseBean getWxTaNewsById(Integer newsId);
63
+
64
+    /**
65
+     * 微信 阅读量 +1
66
+     * @param id
67
+     * @return
68
+     */
69
+    ResponseBean wxTaPvNum(Integer id);
16 70
 }

+ 39
- 0
src/main/java/com/huiju/estateagents/service/ITaNewsTypeService.java Ver arquivo

@@ -1,6 +1,7 @@
1 1
 package com.huiju.estateagents.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.entity.TaNewsType;
5 6
 
6 7
 /**
@@ -13,4 +14,42 @@ import com.huiju.estateagents.entity.TaNewsType;
13 14
  */
14 15
 public interface ITaNewsTypeService extends IService<TaNewsType> {
15 16
 
17
+    /**
18
+     * 查询资讯类型列表
19
+     * @param pageNum
20
+     * @param pageSize
21
+     * @param buildingId
22
+     * @param orgId
23
+     * @return
24
+     */
25
+    ResponseBean getList(Integer pageNum, Integer pageSize, Integer buildingId, Integer orgId);
26
+
27
+    /**
28
+     * 根据Id查询资讯类型数据
29
+     * @param newsTypeId
30
+     * @return
31
+     */
32
+    ResponseBean getTaNewsTypeById(Integer newsTypeId);
33
+
34
+    /**
35
+     * 修改资讯类型数据
36
+     * @param taNewsType
37
+     * @return
38
+     */
39
+    ResponseBean updateTaNewsType(TaNewsType taNewsType);
40
+
41
+    /**
42
+     * add资讯类型数据
43
+     * @param taNewsType
44
+     * @return
45
+     */
46
+    ResponseBean addTaNewsType(TaNewsType taNewsType);
47
+
48
+    /**
49
+     * 删除资讯类型
50
+     * @param newsTypeId
51
+     * @return
52
+     */
53
+    ResponseBean deleteTaNewsType(Integer newsTypeId);
54
+
16 55
 }

+ 22
- 0
src/main/java/com/huiju/estateagents/service/ITaSaveService.java Ver arquivo

@@ -0,0 +1,22 @@
1
+package com.huiju.estateagents.service;
2
+
3
+import com.baomidou.mybatisplus.extension.service.IService;
4
+import com.huiju.estateagents.base.ResponseBean;
5
+import com.huiju.estateagents.entity.TaSave;
6
+
7
+/**
8
+ * <p>
9
+ * 收藏表  服务类
10
+ * </p>
11
+ *
12
+ * @author jobob
13
+ * @since 2019-07-25
14
+ */
15
+public interface ITaSaveService extends IService<TaSave> {
16
+
17
+
18
+    ResponseBean postLike(String openid, String typeOf, String like);
19
+
20
+    ResponseBean cancelLike(String openid, String typeOf, String like);
21
+
22
+}

+ 20
- 0
src/main/java/com/huiju/estateagents/service/impl/ExtendContentServiceImpl.java Ver arquivo

@@ -0,0 +1,20 @@
1
+package com.huiju.estateagents.service.impl;
2
+
3
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
4
+import com.huiju.estateagents.entity.ExtendContent;
5
+import com.huiju.estateagents.mapper.ExtendContentMapper;
6
+import com.huiju.estateagents.service.IExtendContentService;
7
+import org.springframework.stereotype.Service;
8
+
9
+/**
10
+ * <p>
11
+ * 辅助内容表  服务实现类
12
+ * </p>
13
+ *
14
+ * @author jobob
15
+ * @since 2019-07-25
16
+ */
17
+@Service
18
+public class ExtendContentServiceImpl extends ServiceImpl<ExtendContentMapper, ExtendContent> implements IExtendContentService {
19
+
20
+}

+ 68
- 10
src/main/java/com/huiju/estateagents/service/impl/TaBuildingDynamicServiceImpl.java Ver arquivo

@@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
6 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8 8
 import com.huiju.estateagents.base.ResponseBean;
9
+import com.huiju.estateagents.entity.TaActivityDynamicEnlist;
9 10
 import com.huiju.estateagents.entity.TaBuilding;
10 11
 import com.huiju.estateagents.entity.TaBuildingDynamic;
12
+import com.huiju.estateagents.mapper.TaActivityDynamicEnlistMapper;
11 13
 import com.huiju.estateagents.mapper.TaBuildingDynamicMapper;
12 14
 import com.huiju.estateagents.mapper.TaBuildingMapper;
13 15
 import com.huiju.estateagents.service.ITaBuildingDynamicService;
@@ -22,6 +24,7 @@ import java.text.SimpleDateFormat;
22 24
 import java.time.Instant;
23 25
 import java.time.LocalDateTime;
24 26
 import java.time.ZoneId;
27
+import java.time.ZoneOffset;
25 28
 import java.util.Date;
26 29
 import java.util.HashMap;
27 30
 import java.util.List;
@@ -43,6 +46,11 @@ public class TaBuildingDynamicServiceImpl extends ServiceImpl<TaBuildingDynamicM
43 46
     @Autowired
44 47
     private TaBuildingMapper buildingMapper;
45 48
 
49
+
50
+    @Autowired
51
+    private TaActivityDynamicEnlistMapper taActivityDynamicEnlistMapper;
52
+
53
+
46 54
     protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
47 55
         DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
48 56
         CustomDateEditor editor = new CustomDateEditor(df, true);//true表示允许为空,false反之
@@ -72,30 +80,43 @@ public class TaBuildingDynamicServiceImpl extends ServiceImpl<TaBuildingDynamicM
72 80
     }
73 81
 
74 82
     @Override
75
-    public ResponseBean getWxBuildingDynamiceList(Integer pageNum, Integer pageSize) {
83
+    public ResponseBean getWxBuildingDynamiceList(Integer pageNum, Integer pageSize,Integer buildingId) {
76 84
         Page<TaBuildingDynamic> page = new Page<>();
77 85
         page.setCurrent(pageNum);
78 86
         page.setSize(pageSize);
79 87
         QueryWrapper<TaBuildingDynamic> buildingDynamicQueryWrapper = new QueryWrapper<>();
88
+        buildingDynamicQueryWrapper.eq("building_id", buildingId);
80 89
         buildingDynamicQueryWrapper.eq("status", "1");
81 90
         buildingDynamicQueryWrapper.orderByDesc("create_date");
82 91
         IPage<TaBuildingDynamic> buildingDynamicIPage = buildingDynamicMapper.selectPage(page, buildingDynamicQueryWrapper);
83 92
         List<TaBuildingDynamic> records = buildingDynamicIPage.getRecords();
84
-        records.forEach(e -> {
85
-            QueryWrapper<TaBuilding> buildingQueryWrapper = new QueryWrapper<>();
86
-            buildingQueryWrapper.eq("building_id", e.getBuildingId());
87
-            TaBuilding building = buildingMapper.selectOne(buildingQueryWrapper);
88
-            e.setBuilding(building);
89
-        });
90
-
91
-        return ResponseBean.success(buildingDynamicIPage);
93
+        // 判断换当前列表活动状态—1:进行中(展示活动报名截止时间),2:未开始(展示活动报名时间),3:结束(不展示)
94
+        for (TaBuildingDynamic taBuildingDynamic:records){
95
+            // 获取当前时间状态
96
+            taBuildingDynamic= timeCondition(taBuildingDynamic);
97
+        }
98
+        HashMap<String, Object> map = new HashMap<>();
99
+        map.put("list", records);
100
+        map.put("total", buildingDynamicIPage.getTotal());
101
+        map.put("pageNum", buildingDynamicIPage.getCurrent());
102
+        map.put("pageSize", buildingDynamicIPage.getSize());
103
+        return ResponseBean.success(map);
92 104
     }
93 105
 
94 106
     @Override
95
-    public ResponseBean getWxBuildingDynamiceInfo(String dynamicId) {
107
+    public ResponseBean getWxBuildingDynamiceInfo(String dynamicId,Integer buildingId) {
96 108
         QueryWrapper<TaBuildingDynamic> buildingDynamicQueryWrapper = new QueryWrapper<>();
97 109
         buildingDynamicQueryWrapper.eq("dynamic_id", dynamicId);
110
+        buildingDynamicQueryWrapper.eq("status",1);
98 111
         TaBuildingDynamic buildingDynamic = buildingDynamicMapper.selectOne(buildingDynamicQueryWrapper);
112
+        // 获取报名总数
113
+        QueryWrapper<TaActivityDynamicEnlist> taActivityDynamicEnlist = new QueryWrapper<>();
114
+        taActivityDynamicEnlist.eq("dynamic_id", dynamicId);
115
+        taActivityDynamicEnlist.eq("building_id",buildingId);
116
+        int applyCount= taActivityDynamicEnlistMapper.selectCount(taActivityDynamicEnlist);
117
+        buildingDynamic.setCount(applyCount);
118
+        // 获取当前时间状态
119
+        buildingDynamic = timeCondition(buildingDynamic);
99 120
         return ResponseBean.success(buildingDynamic);
100 121
     }
101 122
 
@@ -155,5 +176,42 @@ public class TaBuildingDynamicServiceImpl extends ServiceImpl<TaBuildingDynamicM
155 176
         return ResponseBean.success("成功");
156 177
     }
157 178
 
179
+    @Override
180
+    public ResponseBean taActivityDynamicEnlistAdd(Integer dynamicId, String phone, String name) {
181
+        // 查询当前活动属于哪个楼盘
182
+        TaBuildingDynamic taBuildingDynamic= buildingDynamicMapper.iBuildingDynamicSelectId(dynamicId+"");
183
+
184
+        TaActivityDynamicEnlist taActivityDynamicEnlist= new TaActivityDynamicEnlist();
185
+        taActivityDynamicEnlist.setCreateDate(LocalDateTime.now())
186
+                               .setDynamic_id(dynamicId+"")
187
+                               .setPhone(phone).setName(name)
188
+                               .setBuilding_id(taBuildingDynamic.getDynamicId());
189
+        taActivityDynamicEnlistMapper.insert(taActivityDynamicEnlist);
190
+        return ResponseBean.success("成功");
191
+    }
158 192
 
193
+    // 根据报名开始时间和结束时间判断当前图标状态
194
+    private  TaBuildingDynamic  timeCondition(TaBuildingDynamic taBuildingDynamic){
195
+        Long currentTime = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
196
+        if (null == taBuildingDynamic.getEnlistEnd () && null == taBuildingDynamic.getEnlistStart()){
197
+            return  taBuildingDynamic;
198
+        }
199
+        // 报名截止时间
200
+        Long enlistEnd = taBuildingDynamic.getEnlistEnd ().toInstant(ZoneOffset.of("+8")).toEpochMilli();
201
+        // 报名开始时间
202
+        Long enlistStart = taBuildingDynamic.getEnlistStart().toInstant(ZoneOffset.of("+8")).toEpochMilli();
203
+        // (1:进行中)当前时间小于报名截止时间,并且报名状态为1
204
+        if ("1".equals(taBuildingDynamic.getIsEnlist()) && currentTime <= enlistEnd ) {
205
+            taBuildingDynamic.setActivityCondition(1);
206
+        }
207
+        //(2:未开始)当前时间是否小于报名时间,并且报名状态为1
208
+        if (!"1".equals(taBuildingDynamic.getIsEnlist()) && currentTime <= enlistStart){
209
+            taBuildingDynamic.setActivityCondition(2);
210
+        }
211
+        //(3:结束)当前时间大于报名结束时间,并且报名状态为1
212
+        if ("1".equals(taBuildingDynamic.getIsEnlist()) && currentTime >= enlistEnd){
213
+            taBuildingDynamic.setActivityCondition(3);
214
+        }
215
+        return taBuildingDynamic;
216
+    }
159 217
 }

+ 31
- 1
src/main/java/com/huiju/estateagents/service/impl/TaFavorServiceImpl.java Ver arquivo

@@ -3,9 +3,12 @@ package com.huiju.estateagents.service.impl;
3 3
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4 4
 import com.huiju.estateagents.base.ResponseBean;
5 5
 import com.huiju.estateagents.common.CommConstant;
6
+import com.huiju.estateagents.entity.TaBuildingDynamic;
6 7
 import com.huiju.estateagents.entity.TaFavor;
7 8
 import com.huiju.estateagents.entity.TaPerson;
9
+import com.huiju.estateagents.mapper.TaBuildingDynamicMapper;
8 10
 import com.huiju.estateagents.mapper.TaFavorMapper;
11
+import com.huiju.estateagents.mapper.TaNewsMapper;
9 12
 import com.huiju.estateagents.mapper.TaPersonMapper;
10 13
 import com.huiju.estateagents.service.ITaFavorService;
11 14
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -34,6 +37,12 @@ public class TaFavorServiceImpl extends ServiceImpl<TaFavorMapper, TaFavor> impl
34 37
     @Autowired
35 38
     TaFavorMapper taFavorMapper;
36 39
 
40
+    @Autowired
41
+    private TaNewsMapper taNewsMapper;
42
+
43
+    @Autowired
44
+    private TaBuildingDynamicMapper taBuildingDynamicMapper;
45
+
37 46
     @Override
38 47
     public ResponseBean postLike(String openid, String typeOf, String like) {
39 48
         List<TaPerson> persons = getPersonsByOpenId(openid);
@@ -73,6 +82,16 @@ public class TaFavorServiceImpl extends ServiceImpl<TaFavorMapper, TaFavor> impl
73 82
             taPersonMapper.setFieldIncrement(like,"like_num", 1);
74 83
         }
75 84
 
85
+        // 如果是资讯点赞, 则 +1
86
+        if(typeOf.equals(CommConstant.FAVOR_NEWS)) {
87
+            taNewsMapper.setFieldNum(like, "favor_num", 1);
88
+        }
89
+
90
+        // 如果是活动点赞, 则 +1
91
+        if(typeOf.equals(CommConstant.FAVOR_ACTIVITY)) {
92
+            taBuildingDynamicMapper.setFieldNum(like, "favor_num", 1);
93
+        }
94
+
76 95
         return ResponseBean.success("");
77 96
     }
78 97
 
@@ -102,10 +121,21 @@ public class TaFavorServiceImpl extends ServiceImpl<TaFavorMapper, TaFavor> impl
102 121
         taFavorMapper.deleteByMap(condition);
103 122
 
104 123
         // 如果是点赞置业, 则人员点赞 - 1
105
-        if (typeOf == CommConstant.FAVOR_CONSULTANT) {
124
+        if (typeOf.equals(CommConstant.FAVOR_CONSULTANT)) {
106 125
             taPersonMapper.setFieldIncrement(taPerson.getPersonId(),"like_num", -1);
107 126
         }
108 127
 
128
+        // 如果是收藏资讯, 则 - 1
129
+        if (typeOf.equals(CommConstant.FAVOR_NEWS)) {
130
+            taNewsMapper.setFieldNum(taPerson.getPersonId(),"favor_num", -1);
131
+        }
132
+
133
+
134
+        // 如果是活动点赞, 则 -1
135
+        if(typeOf.equals(CommConstant.FAVOR_ACTIVITY)) {
136
+            taBuildingDynamicMapper.setFieldNum(like, "favor_num", 1);
137
+        }
138
+
109 139
         return ResponseBean.success("");
110 140
     }
111 141
 

+ 164
- 0
src/main/java/com/huiju/estateagents/service/impl/TaNewsServiceImpl.java Ver arquivo

@@ -1,11 +1,32 @@
1 1
 package com.huiju.estateagents.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.BeanTools;
9
+import com.huiju.estateagents.common.CommConstant;
10
+import com.huiju.estateagents.entity.TaBuilding;
11
+import com.huiju.estateagents.entity.TaFavor;
4 12
 import com.huiju.estateagents.entity.TaNews;
13
+import com.huiju.estateagents.entity.TaNewsType;
14
+import com.huiju.estateagents.exception.EstaException;
15
+import com.huiju.estateagents.mapper.TaFavorMapper;
5 16
 import com.huiju.estateagents.mapper.TaNewsMapper;
17
+import com.huiju.estateagents.service.ITaBuildingService;
18
+import com.huiju.estateagents.service.ITaFavorService;
6 19
 import com.huiju.estateagents.service.ITaNewsService;
20
+import com.huiju.estateagents.service.ITaNewsTypeService;
21
+import org.springframework.beans.BeanUtils;
22
+import org.springframework.beans.factory.annotation.Autowired;
7 23
 import org.springframework.stereotype.Service;
8 24
 
25
+import java.time.LocalDateTime;
26
+import java.util.HashMap;
27
+import java.util.List;
28
+import java.util.Map;
29
+
9 30
 /**
10 31
  * <p>
11 32
  * 资讯表  服务实现类
@@ -17,4 +38,147 @@ import org.springframework.stereotype.Service;
17 38
 @Service
18 39
 public class TaNewsServiceImpl extends ServiceImpl<TaNewsMapper, TaNews> implements ITaNewsService {
19 40
 
41
+    @Autowired
42
+    private ITaNewsTypeService iTaNewsTypeService;
43
+
44
+    @Autowired
45
+    private ITaBuildingService iTaBuildingService;
46
+
47
+    @Autowired
48
+    private TaFavorMapper taFavorMapper;
49
+
50
+    @Autowired
51
+    private TaNewsMapper taNewsMapper;
52
+
53
+
54
+    @Override
55
+    public ResponseBean getList(Integer pageNum, Integer pageSize, Integer buildingId, Integer orgId, Integer newsTypeId, Integer newsStatus) {
56
+        ResponseBean responseBean = new ResponseBean();
57
+
58
+        IPage<TaNews> page = new Page<>();
59
+        page.setCurrent(pageNum);
60
+        page.setSize(pageSize);
61
+
62
+        QueryWrapper<TaNews> taNewsQueryWrapper = new QueryWrapper<>();
63
+        taNewsQueryWrapper.eq(buildingId != null,"building_id", buildingId);
64
+        taNewsQueryWrapper.eq(orgId != null,"org_id", orgId);
65
+        taNewsQueryWrapper.eq(newsTypeId != null,"news_type_id", newsTypeId);
66
+        taNewsQueryWrapper.eq(newsStatus != null, "news_status", newsStatus);
67
+        taNewsQueryWrapper.eq("status", 1);
68
+        taNewsQueryWrapper.orderByDesc("create_date");
69
+        IPage<TaNews> taNewsIPage = this.page(page, taNewsQueryWrapper);
70
+
71
+        List<TaNews> records = taNewsIPage.getRecords();
72
+        records.forEach(e -> {
73
+            TaNewsType newsType = iTaNewsTypeService.getById(e.getNewsTypeId());
74
+            e.setNewsType(newsType);
75
+        });
76
+
77
+        responseBean.addSuccess(taNewsIPage);
78
+        return responseBean;
79
+    }
80
+
81
+    @Override
82
+    public ResponseBean getTaNewsById(Integer newsId) {
83
+        ResponseBean responseBean = new ResponseBean();
84
+        if (null == newsId) {
85
+            responseBean.addError("编号不能为空!");
86
+        }
87
+        responseBean.addSuccess(this.getById(newsId));
88
+        return  responseBean;
89
+    }
90
+
91
+    @Override
92
+    public ResponseBean updateTaNews(TaNews taNews) {
93
+        ResponseBean responseBean = new ResponseBean();
94
+        TaNews oldNews = this.getById(taNews.getNewsId());
95
+        if (null == oldNews) {
96
+            responseBean.addError("资讯不存在!");
97
+            return responseBean;
98
+        }
99
+
100
+        //-- 校验 公司,楼盘,资讯类型
101
+        check(taNews);
102
+
103
+        BeanTools.copyProperties(taNews, oldNews);
104
+        responseBean.addSuccess(this.updateById(oldNews));
105
+        return responseBean;
106
+    }
107
+
108
+    @Override
109
+    public ResponseBean addTaNews(TaNews taNews) {
110
+        ResponseBean responseBean = new ResponseBean();
111
+        check(taNews);
112
+
113
+        taNews.setCreateDate(LocalDateTime.now());
114
+        taNews.setStatus(1);
115
+        this.save(taNews);
116
+        responseBean.addSuccess(taNews);
117
+        return responseBean;
118
+    }
119
+
120
+    private void check(TaNews taNews) {
121
+        //-- 校验 公司,楼盘,资讯类型
122
+        // TODO 公司校验没有写 taNews.getOrgId()
123
+
124
+        TaBuilding taBuilding = iTaBuildingService.getById(taNews.getBuildingId());
125
+        if (null == taBuilding) {
126
+            throw new EstaException("楼盘不存在!");
127
+        }
128
+        TaNewsType taNewsType = iTaNewsTypeService.getById(taNews.getNewsTypeId());
129
+        if (null == taNewsType) {
130
+            throw new EstaException("资讯类型不存在!");
131
+        }
132
+    }
133
+
134
+    @Override
135
+    public ResponseBean deleteTaNews(Integer newsId) {
136
+        ResponseBean responseBean = getTaNewsById(newsId);
137
+        if (1 == responseBean.getCode()) {
138
+            return responseBean;
139
+        }
140
+        TaNews taNews = (TaNews) responseBean.getData();
141
+        if (null == taNews) {
142
+            responseBean.addError("数据不存!");
143
+        }
144
+
145
+        // 修改状态
146
+        taNews.setStatus(0);
147
+        this.updateById(taNews);
148
+
149
+        responseBean.addSuccess(taNews);
150
+        return responseBean;
151
+    }
152
+
153
+    @Override
154
+    public ResponseBean getWxTaNewsById(Integer newsId) {
155
+        ResponseBean responseBean = getTaNewsById(newsId);
156
+        if (1 == responseBean.getCode()) {
157
+            return responseBean;
158
+        }
159
+        TaNews taNews = (TaNews) responseBean.getData();
160
+        if (null == taNews) {
161
+            responseBean.addError("数据不存!");
162
+        }
163
+
164
+        responseBean.addSuccess(taNews);
165
+        return responseBean;
166
+    }
167
+
168
+    @Override
169
+    public ResponseBean wxTaPvNum(Integer id) {
170
+        ResponseBean responseBean = getTaNewsById(id);
171
+        if (1 == responseBean.getCode()) {
172
+            return responseBean;
173
+        }
174
+        TaNews taNews = (TaNews) responseBean.getData();
175
+        if (null == taNews) {
176
+            responseBean.addError("数据不存!");
177
+        }
178
+
179
+        taNewsMapper.setFieldNum(id + "", "pv_num", 1);
180
+
181
+        responseBean.addSuccess((Object)"");
182
+        return responseBean;
183
+    }
20 184
 }

+ 100
- 0
src/main/java/com/huiju/estateagents/service/impl/TaNewsTypeServiceImpl.java Ver arquivo

@@ -1,11 +1,22 @@
1 1
 package com.huiju.estateagents.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.BeanTools;
9
+import com.huiju.estateagents.entity.TaBuilding;
4 10
 import com.huiju.estateagents.entity.TaNewsType;
11
+import com.huiju.estateagents.exception.EstaException;
5 12
 import com.huiju.estateagents.mapper.TaNewsTypeMapper;
13
+import com.huiju.estateagents.service.ITaBuildingService;
6 14
 import com.huiju.estateagents.service.ITaNewsTypeService;
15
+import org.springframework.beans.factory.annotation.Autowired;
7 16
 import org.springframework.stereotype.Service;
8 17
 
18
+import java.time.LocalDateTime;
19
+
9 20
 /**
10 21
  * <p>
11 22
  * 资讯类型表  服务实现类
@@ -17,4 +28,93 @@ import org.springframework.stereotype.Service;
17 28
 @Service
18 29
 public class TaNewsTypeServiceImpl extends ServiceImpl<TaNewsTypeMapper, TaNewsType> implements ITaNewsTypeService {
19 30
 
31
+    @Autowired
32
+    private ITaBuildingService iTaBuildingService;
33
+
34
+
35
+    @Override
36
+    public ResponseBean getList(Integer pageNum, Integer pageSize, Integer buildingId, Integer orgId) {
37
+        ResponseBean responseBean = new ResponseBean();
38
+        IPage<TaNewsType> page = new Page<>();
39
+        page.setCurrent(pageNum);
40
+        page.setSize(pageSize);
41
+
42
+        QueryWrapper<TaNewsType> taNewsQueryWrapper = new QueryWrapper<>();
43
+        taNewsQueryWrapper.eq(buildingId != null,"building_id", buildingId);
44
+        taNewsQueryWrapper.eq(orgId != null,"org_id", orgId);
45
+        taNewsQueryWrapper.eq("status", 1);
46
+        taNewsQueryWrapper.orderByDesc("create_date");
47
+        IPage<TaNewsType> typeIPage = this.page(page, taNewsQueryWrapper);
48
+
49
+        responseBean.addSuccess(typeIPage);
50
+        return responseBean;
51
+    }
52
+
53
+    @Override
54
+    public ResponseBean getTaNewsTypeById(Integer newsTypeId) {
55
+        ResponseBean responseBean = new ResponseBean();
56
+        if (null == newsTypeId) {
57
+            responseBean.addError("资讯类型编号不存在!");
58
+        }
59
+        responseBean.addSuccess(this.getById(newsTypeId));
60
+        return responseBean;
61
+    }
62
+
63
+    @Override
64
+    public ResponseBean updateTaNewsType(TaNewsType taNewsType) {
65
+        ResponseBean responseBean =  new ResponseBean();
66
+        TaNewsType oldTaNewsType = this.getById(taNewsType.getNewsTypeId());
67
+        if (null == oldTaNewsType) {
68
+            responseBean.addError("资讯类型不存在!");
69
+            return responseBean;
70
+        }
71
+
72
+        //-- 校验 公司,楼盘
73
+        // TODO 没有校验公司  taNewsType.getOrgId();
74
+        check(taNewsType);
75
+
76
+        BeanTools.copyProperties(taNewsType, oldTaNewsType);
77
+        this.updateById(oldTaNewsType);
78
+        return responseBean;
79
+    }
80
+
81
+    @Override
82
+    public ResponseBean addTaNewsType(TaNewsType taNewsType) {
83
+        ResponseBean responseBean = new ResponseBean();
84
+
85
+        //-- 校验 公司,楼盘
86
+        check(taNewsType);
87
+
88
+        taNewsType.setCreateDate(LocalDateTime.now());
89
+        this.save(taNewsType);
90
+        responseBean.addSuccess(taNewsType);
91
+        return responseBean;
92
+    }
93
+
94
+    private void check(TaNewsType taNewsType) {
95
+        TaBuilding taBuilding = iTaBuildingService.getById(taNewsType.getBuildingId());
96
+        if (null == taBuilding) {
97
+            throw new EstaException("楼盘不存在!");
98
+        }
99
+    }
100
+
101
+    @Override
102
+    public ResponseBean deleteTaNewsType(Integer newsTypeId) {
103
+        ResponseBean responseBean = getTaNewsTypeById(newsTypeId);
104
+        if (1 == responseBean.getCode()) {
105
+            return responseBean;
106
+        }
107
+        TaNewsType taNewsType = (TaNewsType) responseBean.getData();
108
+        if (null == taNewsType) {
109
+            responseBean.addError("数据不存!");
110
+        }
111
+
112
+        // 修改状态
113
+        taNewsType.setStatus(0);
114
+        this.updateById(taNewsType);
115
+
116
+        responseBean.addSuccess(taNewsType);
117
+        return responseBean;
118
+    }
119
+
20 120
 }

+ 134
- 0
src/main/java/com/huiju/estateagents/service/impl/TaSaveServiceImpl.java Ver arquivo

@@ -0,0 +1,134 @@
1
+package com.huiju.estateagents.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
5
+import com.huiju.estateagents.base.ResponseBean;
6
+import com.huiju.estateagents.common.CommConstant;
7
+import com.huiju.estateagents.entity.TaPerson;
8
+import com.huiju.estateagents.entity.TaSave;
9
+import com.huiju.estateagents.mapper.TaBuildingDynamicMapper;
10
+import com.huiju.estateagents.mapper.TaNewsMapper;
11
+import com.huiju.estateagents.mapper.TaPersonMapper;
12
+import com.huiju.estateagents.mapper.TaSaveMapper;
13
+import com.huiju.estateagents.service.ITaSaveService;
14
+import org.springframework.beans.factory.annotation.Autowired;
15
+import org.springframework.stereotype.Service;
16
+
17
+import java.time.LocalDateTime;
18
+import java.util.HashMap;
19
+import java.util.List;
20
+import java.util.Map;
21
+
22
+/**
23
+ * <p>
24
+ * 收藏表  服务实现类
25
+ * </p>
26
+ *
27
+ * @author jobob
28
+ * @since 2019-07-25
29
+ */
30
+@Service
31
+public class TaSaveServiceImpl extends ServiceImpl<TaSaveMapper, TaSave> implements ITaSaveService {
32
+
33
+
34
+    @Autowired
35
+    TaPersonMapper taPersonMapper;
36
+
37
+    @Autowired
38
+    private TaSaveMapper taSaveMapper;
39
+
40
+    @Autowired
41
+    private TaNewsMapper taNewsMapper;
42
+
43
+    @Autowired
44
+    private TaBuildingDynamicMapper taBuildingDynamicMapper;
45
+
46
+    @Override
47
+    public ResponseBean postLike(String openid, String typeOf, String like) {
48
+        List<TaPerson> persons = getPersonsByOpenId(openid);
49
+        if (null == persons || persons.size() != 1) {
50
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
51
+        }
52
+
53
+        TaPerson taPerson = persons.get(0);
54
+
55
+        // 是否被赞过
56
+        QueryWrapper<TaSave> queryWrapper = new QueryWrapper<>();
57
+        queryWrapper.eq("person_id", taPerson.getPersonId());
58
+        queryWrapper.eq("saved_target", like);
59
+        queryWrapper.eq("tagert_type", typeOf);
60
+        List<TaSave> saves = taSaveMapper.selectList(queryWrapper);
61
+        if (null != saves && saves.size() > 0) {
62
+//            return ResponseBean.error("请不需要重复收藏", ResponseBean.ERROR_UNAVAILABLE);
63
+            return ResponseBean.success("");
64
+        }
65
+
66
+        // 写入收藏
67
+        TaSave taSave = new TaSave();
68
+        taSave.setSavedTarget(like);
69
+        taSave.setCreateDate(LocalDateTime.now());
70
+        taSave.setNameOrnick(taPerson.getNickname());
71
+        taSave.setPersonId(taPerson.getPersonId());
72
+        taSave.setPhotoOravatar(taPerson.getAvatarurl());
73
+        taSave.setTagertType(typeOf);
74
+
75
+        int row = taSaveMapper.insert(taSave);
76
+        if (row < 1) {
77
+            return ResponseBean.error("收藏失败", ResponseBean.ERROR_UNAVAILABLE);
78
+        }
79
+
80
+        // 如果是资讯收藏, 则 +1
81
+        if(typeOf.equals(CommConstant.FAVOR_NEWS)) {
82
+            taNewsMapper.setFieldNum(like, "save_num", 1);
83
+        }
84
+
85
+        // 如果是活动收藏, 则 +1
86
+        if(typeOf.equals(CommConstant.FAVOR_ACTIVITY)) {
87
+            taBuildingDynamicMapper.setFieldNum(like, "save_num", 1);
88
+        }
89
+
90
+        return ResponseBean.success("");
91
+    }
92
+
93
+    @Override
94
+    public ResponseBean cancelLike(String openid, String typeOf, String like) {
95
+        List<TaPerson> persons = getPersonsByOpenId(openid);
96
+        if (null == persons || persons.size() != 1) {
97
+            return ResponseBean.error("验证当前人员信息失败", ResponseBean.ERROR_UNAVAILABLE);
98
+        }
99
+
100
+        TaPerson taPerson = persons.get(0);
101
+
102
+        // 是否被赞过
103
+        QueryWrapper<TaSave> queryWrapper = new QueryWrapper<>();
104
+        queryWrapper.eq("person_id", taPerson.getPersonId());
105
+        queryWrapper.eq("saved_target", like);
106
+        queryWrapper.eq("tagert_type", typeOf);
107
+        List<TaSave> saves = taSaveMapper.selectList(queryWrapper);
108
+        if (null == saves || saves.size() == 0) {
109
+            return ResponseBean.success("");
110
+        }
111
+
112
+        Map<String, Object> condition = new HashMap<>();
113
+        condition.put("person_id", taPerson.getPersonId());
114
+        condition.put("saved_target", like);
115
+        condition.put("tagert_type", typeOf);
116
+        taSaveMapper.deleteByMap(condition);
117
+
118
+        // 如果是收藏资讯, 则 - 1
119
+        if (typeOf.equals(CommConstant.FAVOR_NEWS)) {
120
+            taNewsMapper.setFieldNum(taPerson.getPersonId(),"save_num", -1);
121
+        }
122
+
123
+        // 如果是活动收藏, 则 - 1
124
+        if(typeOf.equals(CommConstant.FAVOR_ACTIVITY)) {
125
+            taBuildingDynamicMapper.setFieldNum(like, "save_num", -1);
126
+        }
127
+
128
+        return ResponseBean.success("");
129
+    }
130
+
131
+    List<TaPerson> getPersonsByOpenId(String openid) {
132
+        return taPersonMapper.getPersonByOpenId(openid);
133
+    }
134
+}

+ 5
- 0
src/main/resources/mapper/ExtendContentMapper.xml Ver arquivo

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
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.mapper.ExtendContentMapper">
4
+
5
+</mapper>

+ 5
- 0
src/main/resources/mapper/TaActivityDynamicEnlistMapper.xml Ver arquivo

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
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.mapper.TaActivityDynamicEnlistMapper">
4
+
5
+</mapper>