dingxin 6 years ago
parent
commit
1de4a31a60

+ 37
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/BuildingDynamicController.java View File

@@ -10,9 +10,17 @@ import io.swagger.annotations.ApiImplicitParam;
10 10
 import io.swagger.annotations.ApiImplicitParams;
11 11
 import io.swagger.annotations.ApiOperation;
12 12
 import org.springframework.beans.factory.annotation.Autowired;
13
+import org.springframework.beans.factory.annotation.Value;
14
+import org.springframework.beans.propertyeditors.CustomDateEditor;
15
+import org.springframework.web.bind.ServletRequestDataBinder;
13 16
 import org.springframework.web.bind.annotation.*;
14 17
 
18
+import javax.servlet.http.HttpServletRequest;
15 19
 import javax.servlet.http.HttpSession;
20
+import java.text.DateFormat;
21
+import java.text.SimpleDateFormat;
22
+import java.util.Date;
23
+import java.util.HashMap;
16 24
 
17 25
 /**
18 26
  * <p>
@@ -30,6 +38,13 @@ public class BuildingDynamicController extends BaseController {
30 38
     @Autowired
31 39
     private IBuildingDynamicService iBuildingDynamicService;
32 40
 
41
+    @InitBinder
42
+    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
43
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
44
+        CustomDateEditor editor = new CustomDateEditor(df, true);//true表示允许为空,false反之
45
+        binder.registerCustomEditor(Date.class, editor);
46
+    }
47
+
33 48
     @ApiOperation(value = "项目动态管理列表", notes = "项目动态管理列表")
34 49
     @ApiImplicitParams({
35 50
             @ApiImplicitParam(paramType = "Query",dataType = "Integer",name = "pageNum",value = "分页第几页" ),
@@ -74,4 +89,26 @@ public class BuildingDynamicController extends BaseController {
74 89
         return responseBean;
75 90
     }
76 91
 
92
+    @RequestMapping(value = "/buildingDynamic/add" ,method =RequestMethod.PUT)
93
+    @ApiOperation(value = "动态管理添加",notes="动态管理添加")
94
+    @ApiImplicitParams({
95
+            @ApiImplicitParam(paramType = "Query",dataTypeClass = String.class,name = "buildingId",value = "楼盘id" ),
96
+            @ApiImplicitParam(paramType = "Query",dataTypeClass = String.class,name = "imgUrl",value = "首页图片" ),
97
+            @ApiImplicitParam(paramType = "Query",dataTypeClass = String.class,name = "title",value = "标题" ),
98
+            @ApiImplicitParam(paramType = "Query",dataTypeClass = String.class,name = "desc",value = "描述" ),
99
+            @ApiImplicitParam(paramType = "Query",dataTypeClass = String.class,name = "url",value = "url" ),
100
+            @ApiImplicitParam(paramType = "Query",dataType = "Date",name = "publishDate",value = "publishDate" )
101
+    })
102
+    public  ResponseBean buildingDynamicAdd(@RequestParam(required = false) String buildingId,
103
+                                         @RequestParam(required = false) String imgUrl,
104
+                                         @RequestParam(required = false) String title,
105
+                                         @RequestParam(required = false) String desc,
106
+                                         @RequestParam(required = false) String url,
107
+                                         @RequestParam(value = "publishDate",required = false) Date publishDate){
108
+        HashMap<String,Object> map= new HashMap<>();
109
+        map.put("buildingId",buildingId);map.put("imgUrl",imgUrl);map.put("title",title);map.put("desc",desc);map.put("url",url);map.put("publishDate",publishDate);
110
+         ResponseBean responseBean= iBuildingDynamicService.buildingDynamicAdd(map);
111
+         return responseBean;
112
+    }
113
+
77 114
 }

+ 8
- 0
whole-estate/src/main/java/com/example/wholeestate/service/IBuildingDynamicService.java View File

@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
4 4
 import com.example.wholeestate.common.resp.ResponseBean;
5 5
 import com.example.wholeestate.model.BuildingDynamic;
6 6
 
7
+import java.util.HashMap;
8
+
7 9
 /**
8 10
  * <p>
9 11
  * 项目动态表 服务类
@@ -40,4 +42,10 @@ public interface IBuildingDynamicService extends IService<BuildingDynamic> {
40 42
      */
41 43
     ResponseBean getWxBuildingDynamiceInfo(String dynamicId);
42 44
 
45
+    /**
46
+     * 动态管理添加
47
+     * @param map
48
+     * @return
49
+     */
50
+    ResponseBean buildingDynamicAdd(HashMap map);
43 51
 }

+ 35
- 0
whole-estate/src/main/java/com/example/wholeestate/service/impl/BuildingDynamicServiceImpl.java View File

@@ -8,14 +8,22 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8 8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9 9
 import com.example.wholeestate.common.base.BaseController;
10 10
 import com.example.wholeestate.common.resp.ResponseBean;
11
+import com.example.wholeestate.common.uuid.IdGen;
11 12
 import com.example.wholeestate.dao.BuildingDynamicMapper;
12 13
 import com.example.wholeestate.dao.BuildingMapper;
13 14
 import com.example.wholeestate.model.Building;
14 15
 import com.example.wholeestate.model.BuildingDynamic;
15 16
 import com.example.wholeestate.service.IBuildingDynamicService;
16 17
 import org.springframework.beans.factory.annotation.Autowired;
18
+import org.springframework.beans.propertyeditors.CustomDateEditor;
17 19
 import org.springframework.stereotype.Service;
20
+import org.springframework.web.bind.ServletRequestDataBinder;
18 21
 
22
+import javax.servlet.http.HttpServletRequest;
23
+import java.text.DateFormat;
24
+import java.text.SimpleDateFormat;
25
+import java.time.LocalDateTime;
26
+import java.util.Date;
19 27
 import java.util.HashMap;
20 28
 import java.util.List;
21 29
 
@@ -36,6 +44,12 @@ public class BuildingDynamicServiceImpl extends ServiceImpl<BuildingDynamicMappe
36 44
     @Autowired
37 45
     private BuildingMapper buildingMapper;
38 46
 
47
+    private IdGen idGen = IdGen.get();
48
+    protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception {
49
+        DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
50
+        CustomDateEditor editor = new CustomDateEditor(df, true);//true表示允许为空,false反之
51
+        binder.registerCustomEditor(Date.class, editor);
52
+    }
39 53
     @Override
40 54
     public ResponseBean iBuildingDynamicList(Integer pageNum,Integer pageSize) {
41 55
         ResponseBean response= new ResponseBean();
@@ -97,4 +111,25 @@ public class BuildingDynamicServiceImpl extends ServiceImpl<BuildingDynamicMappe
97 111
         responseBean.addSuccess(buildingDynamic);
98 112
         return responseBean;
99 113
     }
114
+
115
+    @Override
116
+    public ResponseBean buildingDynamicAdd(HashMap map) {
117
+        ResponseBean responseBean= new ResponseBean<>();
118
+        BuildingDynamic buildingDynamic= new BuildingDynamic();
119
+        Date  f = new Date();
120
+        new SimpleDateFormat("yyyy-MM-dd").format(f);
121
+        buildingDynamic.setDynamicId(idGen.nextId()+"")
122
+                .setBuildingId(map.get("buildingId")+"")
123
+                .setBuildingId(map.get("buildingId")+"")
124
+                .setImgUrl((String) map.get("imgUrl"))
125
+                .setDesc(map.get("desc")+"")
126
+                .setUrl(map.get("url")+"")
127
+                .setTitle(map.get("title")+"")
128
+                .setPublishDate(LocalDateTime.parse(map.get("publishDate")+""))
129
+                .setStatus(-1)
130
+                .setCreateDate(LocalDateTime.now());
131
+        buildingDynamicMapper.insert(buildingDynamic);
132
+        responseBean.addSuccess("成功");
133
+        return responseBean;
134
+    }
100 135
 }