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