|
@@ -0,0 +1,149 @@
|
|
1
|
+package com.huiju.estateagents.property.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.common.CommConstant;
|
|
9
|
+import io.swagger.annotations.Api;
|
|
10
|
+import io.swagger.annotations.ApiOperation;
|
|
11
|
+import io.swagger.annotations.ApiParam;
|
|
12
|
+import org.slf4j.Logger;
|
|
13
|
+import org.slf4j.LoggerFactory;
|
|
14
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
15
|
+import org.springframework.web.bind.annotation.PathVariable;
|
|
16
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
17
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
18
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
19
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
20
|
+import com.huiju.estateagents.property.service.ITpRepairTypeService;
|
|
21
|
+import com.huiju.estateagents.property.entity.TpRepairType;
|
|
22
|
+import org.springframework.web.bind.annotation.RestController;
|
|
23
|
+
|
|
24
|
+import javax.servlet.http.HttpServletRequest;
|
|
25
|
+import java.time.LocalDateTime;
|
|
26
|
+
|
|
27
|
+/**
|
|
28
|
+ * <p>
|
|
29
|
+ * 工单报修分类表 前端控制器
|
|
30
|
+ * </p>
|
|
31
|
+ *
|
|
32
|
+ * @author yansen
|
|
33
|
+ * @since 2020-12-17
|
|
34
|
+ */
|
|
35
|
+
|
|
36
|
+@Api(tags = "工单报修分类表 ")
|
|
37
|
+@RestController
|
|
38
|
+@RequestMapping("/api")
|
|
39
|
+public class TpRepairTypeController extends BaseController {
|
|
40
|
+
|
|
41
|
+ private final Logger logger = LoggerFactory.getLogger(TpRepairTypeController.class);
|
|
42
|
+
|
|
43
|
+ @Autowired
|
|
44
|
+ public ITpRepairTypeService iTpRepairTypeService;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+ /**
|
|
48
|
+ * 分页查询列表
|
|
49
|
+ * @param pageNum
|
|
50
|
+ * @param pageSize
|
|
51
|
+ * @return
|
|
52
|
+ */
|
|
53
|
+ @RequestMapping(value="/{client}/tpRepairType",method= RequestMethod.GET)
|
|
54
|
+ @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
|
55
|
+ public ResponseBean tpRepairTypeList(@ApiParam(value = "客户端", allowableValues = "wx,admin") @PathVariable String client,
|
|
56
|
+ @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
|
57
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
58
|
+ HttpServletRequest request) throws Exception{
|
|
59
|
+
|
|
60
|
+ Integer orgId = getOrgId(request);
|
|
61
|
+
|
|
62
|
+ IPage<TpRepairType> pg = new Page<>(pageNum, pageSize);
|
|
63
|
+ QueryWrapper<TpRepairType> queryWrapper = new QueryWrapper<>();
|
|
64
|
+ queryWrapper.eq("org_id", orgId);
|
|
65
|
+ queryWrapper.eq("wx".equals(client),"status", CommConstant.STATUS_NORMAL);
|
|
66
|
+ queryWrapper.gt("admin".equals(client),"status", CommConstant.STATUS_DELETE);
|
|
67
|
+ queryWrapper.orderByDesc("sort_num");
|
|
68
|
+ queryWrapper.orderByDesc("create_time");
|
|
69
|
+
|
|
70
|
+ IPage<TpRepairType> result = iTpRepairTypeService.page(pg, queryWrapper);
|
|
71
|
+ return ResponseBean.success(result);
|
|
72
|
+ }
|
|
73
|
+
|
|
74
|
+ /**
|
|
75
|
+ * 保存对象
|
|
76
|
+ * @param tpRepairType 实体对象
|
|
77
|
+ * @return
|
|
78
|
+ */
|
|
79
|
+ @RequestMapping(value="/admin/tpRepairType",method= RequestMethod.POST)
|
|
80
|
+ @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
|
81
|
+ public ResponseBean tpRepairTypeAdd(@ApiParam("保存内容") @RequestBody TpRepairType tpRepairType,
|
|
82
|
+ HttpServletRequest request) throws Exception{
|
|
83
|
+ Integer orgId = getOrgId(request);
|
|
84
|
+
|
|
85
|
+ tpRepairType.setOrgId(orgId);
|
|
86
|
+ if (null == tpRepairType.getStatus()) {
|
|
87
|
+ tpRepairType.setStatus(CommConstant.STATUS_NORMAL);
|
|
88
|
+ }
|
|
89
|
+ tpRepairType.setCreatedTime(LocalDateTime.now());
|
|
90
|
+
|
|
91
|
+ if (iTpRepairTypeService.save(tpRepairType)){
|
|
92
|
+ return ResponseBean.success(tpRepairType);
|
|
93
|
+ }else {
|
|
94
|
+ return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
95
|
+ }
|
|
96
|
+ }
|
|
97
|
+
|
|
98
|
+ /**
|
|
99
|
+ * 根据id删除对象
|
|
100
|
+ * @param id 实体ID
|
|
101
|
+ */
|
|
102
|
+ @RequestMapping(value="/admin/tpRepairType/{id}", method= RequestMethod.DELETE)
|
|
103
|
+ @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
|
104
|
+ public ResponseBean tpRepairTypeDelete(@ApiParam("对象ID") @PathVariable Integer id,
|
|
105
|
+ HttpServletRequest request) throws Exception{
|
|
106
|
+ TpRepairType tpRepairType = iTpRepairTypeService.getById(id);
|
|
107
|
+ return tpRepairTypeUpdate(tpRepairType.getTypeId(), tpRepairType, request);
|
|
108
|
+ }
|
|
109
|
+
|
|
110
|
+ /**
|
|
111
|
+ * 修改对象
|
|
112
|
+ * @param id 实体ID
|
|
113
|
+ * @param tpRepairType 实体对象
|
|
114
|
+ * @return
|
|
115
|
+ */
|
|
116
|
+ @RequestMapping(value="/admin/tpRepairType/{id}",method= RequestMethod.PUT)
|
|
117
|
+ @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
118
|
+ public ResponseBean tpRepairTypeUpdate(@ApiParam("对象ID") @PathVariable Integer id,
|
|
119
|
+ @ApiParam("更新内容") @RequestBody TpRepairType tpRepairType,
|
|
120
|
+ HttpServletRequest request) throws Exception{
|
|
121
|
+ if (null == tpRepairType || tpRepairType.getStatus().equals(CommConstant.STATUS_DELETE) || !tpRepairType.getTypeId().equals(id) || !tpRepairType.getOrgId().equals(getOrgId(request))) {
|
|
122
|
+ return ResponseBean.error("当前数据不存在", ResponseBean.ERROR_UNAVAILABLE);
|
|
123
|
+ }
|
|
124
|
+
|
|
125
|
+ tpRepairType.setUpdatedTime(LocalDateTime.now());
|
|
126
|
+
|
|
127
|
+ if (iTpRepairTypeService.updateById(tpRepairType)){
|
|
128
|
+ return ResponseBean.success(iTpRepairTypeService.getById(id));
|
|
129
|
+ }else {
|
|
130
|
+ return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
|
131
|
+ }
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ /**
|
|
135
|
+ * 根据id查询对象
|
|
136
|
+ * @param id 实体ID
|
|
137
|
+ */
|
|
138
|
+ @RequestMapping(value="/admin/tpRepairType/{id}",method= RequestMethod.GET)
|
|
139
|
+ @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
140
|
+ public ResponseBean tpRepairTypeGet(@ApiParam("对象ID") @PathVariable Integer id,
|
|
141
|
+ HttpServletRequest request) throws Exception{
|
|
142
|
+ TpRepairType tpRepairType = iTpRepairTypeService.getById(id);
|
|
143
|
+ if (null == tpRepairType || tpRepairType.getStatus().equals(CommConstant.STATUS_DELETE) || !tpRepairType.getOrgId().equals(getOrgId(request))) {
|
|
144
|
+ return ResponseBean.error("当前数据不存在", ResponseBean.ERROR_UNAVAILABLE);
|
|
145
|
+ }
|
|
146
|
+
|
|
147
|
+ return ResponseBean.success(tpRepairType);
|
|
148
|
+ }
|
|
149
|
+}
|