|
@@ -0,0 +1,153 @@
|
|
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.TaBuildingDynamicType;
|
|
9
|
+import com.huiju.estateagents.service.ITaBuildingDynamicTypeService;
|
|
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.*;
|
|
14
|
+
|
|
15
|
+import javax.servlet.http.HttpServletRequest;
|
|
16
|
+import java.time.LocalDateTime;
|
|
17
|
+
|
|
18
|
+/**
|
|
19
|
+ * <p>
|
|
20
|
+ * 活动类型表 前端控制器
|
|
21
|
+ * </p>
|
|
22
|
+ *
|
|
23
|
+ * @author jobob
|
|
24
|
+ * @since 2020-11-28
|
|
25
|
+ */
|
|
26
|
+@RestController
|
|
27
|
+@RequestMapping("/api")
|
|
28
|
+public class TaBuildingDynamicTypeController extends BaseController {
|
|
29
|
+
|
|
30
|
+ private final Logger logger = LoggerFactory.getLogger(TaBuildingDynamicTypeController.class);
|
|
31
|
+
|
|
32
|
+ @Autowired
|
|
33
|
+ public ITaBuildingDynamicTypeService iTaBuildingDynamicTypeService;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+ /**
|
|
37
|
+ * 分页查询列表
|
|
38
|
+ * @param pageNum
|
|
39
|
+ * @param pageSize
|
|
40
|
+ * @return
|
|
41
|
+ */
|
|
42
|
+ @RequestMapping(value="/admin/taBuildingDynamicType",method= RequestMethod.GET)
|
|
43
|
+ public ResponseBean taBuildingDynamicTypeList(@RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
44
|
+ @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,HttpServletRequest request){
|
|
45
|
+ ResponseBean responseBean = new ResponseBean();
|
|
46
|
+ try {
|
|
47
|
+ Integer orgId = getOrgId(request);
|
|
48
|
+ //使用分页插件
|
|
49
|
+ IPage<TaBuildingDynamicType> pg = new Page<>(pageNum, pageSize);
|
|
50
|
+ QueryWrapper<TaBuildingDynamicType> queryWrapper = new QueryWrapper<>();
|
|
51
|
+ queryWrapper.eq(orgId != null,"org_id", orgId);
|
|
52
|
+ queryWrapper.eq("status", 1);
|
|
53
|
+ queryWrapper.orderByDesc("create_date");
|
|
54
|
+
|
|
55
|
+ IPage<TaBuildingDynamicType> result = iTaBuildingDynamicTypeService.page(pg, queryWrapper);
|
|
56
|
+ responseBean.addSuccess(result);
|
|
57
|
+ }catch (Exception e){
|
|
58
|
+ e.printStackTrace();
|
|
59
|
+ logger.error("taBuildingDynamicTypeList -=- {}",e.toString());
|
|
60
|
+ responseBean.addError(e.getMessage());
|
|
61
|
+ }
|
|
62
|
+ return responseBean;
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ /**
|
|
66
|
+ * 保存对象
|
|
67
|
+ * @param taBuildingDynamicType 实体对象
|
|
68
|
+ * @return
|
|
69
|
+ */
|
|
70
|
+ @RequestMapping(value="/admin/taBuildingDynamicType",method= RequestMethod.POST)
|
|
71
|
+ public ResponseBean taBuildingDynamicTypeAdd(@RequestBody TaBuildingDynamicType taBuildingDynamicType, HttpServletRequest request){
|
|
72
|
+ ResponseBean responseBean = new ResponseBean();
|
|
73
|
+ try {
|
|
74
|
+ taBuildingDynamicType.setCreateDate(LocalDateTime.now());
|
|
75
|
+ taBuildingDynamicType.setStatus(1);
|
|
76
|
+ taBuildingDynamicType.setOrgId(getOrgId(request));
|
|
77
|
+ if (iTaBuildingDynamicTypeService.save(taBuildingDynamicType)){
|
|
78
|
+ responseBean.addSuccess(taBuildingDynamicType);
|
|
79
|
+ }else {
|
|
80
|
+ responseBean.addError("fail");
|
|
81
|
+ }
|
|
82
|
+ }catch (Exception e){
|
|
83
|
+ e.printStackTrace();
|
|
84
|
+ logger.error("taBuildingDynamicTypeAdd -=- {}",e.toString());
|
|
85
|
+ responseBean.addError(e.getMessage());
|
|
86
|
+ }
|
|
87
|
+ return responseBean;
|
|
88
|
+ }
|
|
89
|
+
|
|
90
|
+ /**
|
|
91
|
+ * 根据id删除对象
|
|
92
|
+ * @param id 实体ID
|
|
93
|
+ */
|
|
94
|
+ @ResponseBody
|
|
95
|
+ @RequestMapping(value="/admin/taBuildingDynamicType/{id}", method= RequestMethod.DELETE)
|
|
96
|
+ public ResponseBean taBuildingDynamicTypeDelete(@PathVariable Integer id){
|
|
97
|
+ ResponseBean responseBean = new ResponseBean();
|
|
98
|
+ try {
|
|
99
|
+ if(iTaBuildingDynamicTypeService.removeById(id)){
|
|
100
|
+ responseBean.addSuccess("success");
|
|
101
|
+ }else {
|
|
102
|
+ responseBean.addError("fail");
|
|
103
|
+ }
|
|
104
|
+ }catch (Exception e){
|
|
105
|
+ e.printStackTrace();
|
|
106
|
+ logger.error("taBuildingDynamicTypeDelete -=- {}",e.toString());
|
|
107
|
+ responseBean.addError(e.getMessage());
|
|
108
|
+ }
|
|
109
|
+ return responseBean;
|
|
110
|
+ }
|
|
111
|
+
|
|
112
|
+ /**
|
|
113
|
+ * 修改对象
|
|
114
|
+ * @param id 实体ID
|
|
115
|
+ * @param taBuildingDynamicType 实体对象
|
|
116
|
+ * @return
|
|
117
|
+ */
|
|
118
|
+ @RequestMapping(value="/admin/taBuildingDynamicType/{id}",method= RequestMethod.PUT)
|
|
119
|
+ public ResponseBean taBuildingDynamicTypeUpdate(@PathVariable Integer id,
|
|
120
|
+ @RequestBody TaBuildingDynamicType taBuildingDynamicType){
|
|
121
|
+ ResponseBean responseBean = new ResponseBean();
|
|
122
|
+ try {
|
|
123
|
+ taBuildingDynamicType.setDynamicTypeId(id);
|
|
124
|
+ if (iTaBuildingDynamicTypeService.updateById(taBuildingDynamicType)){
|
|
125
|
+ responseBean.addSuccess(taBuildingDynamicType);
|
|
126
|
+ }else {
|
|
127
|
+ responseBean.addError("fail");
|
|
128
|
+ }
|
|
129
|
+ }catch (Exception e){
|
|
130
|
+ e.printStackTrace();
|
|
131
|
+ logger.error("taBuildingDynamicTypeUpdate -=- {}",e.toString());
|
|
132
|
+ responseBean.addError(e.getMessage());
|
|
133
|
+ }
|
|
134
|
+ return responseBean;
|
|
135
|
+ }
|
|
136
|
+
|
|
137
|
+ /**
|
|
138
|
+ * 根据id查询对象
|
|
139
|
+ * @param id 实体ID
|
|
140
|
+ */
|
|
141
|
+ @RequestMapping(value="/admin/taBuildingDynamicType/{id}",method= RequestMethod.GET)
|
|
142
|
+ public ResponseBean taBuildingDynamicTypeGet(@PathVariable Integer id){
|
|
143
|
+ ResponseBean responseBean = new ResponseBean();
|
|
144
|
+ try {
|
|
145
|
+ responseBean.addSuccess(iTaBuildingDynamicTypeService.getById(id));
|
|
146
|
+ }catch (Exception e){
|
|
147
|
+ e.printStackTrace();
|
|
148
|
+ logger.error("taBuildingDynamicTypeDelete -=- {}",e.toString());
|
|
149
|
+ responseBean.addError(e.getMessage());
|
|
150
|
+ }
|
|
151
|
+ return responseBean;
|
|
152
|
+ }
|
|
153
|
+}
|